changeset 203:719475ad0923 iiif_diva

more work on new diva.js in imageServer
author casties
date Fri, 05 Jul 2019 16:05:57 +0200
parents 81f761f9c015
children 964846688a95
files src/main/webapp/imageServer/displayDigi.jsp src/main/webapp/imageServer/resources/css/diva.min.css src/main/webapp/imageServer/resources/js/.DS_Store src/main/webapp/imageServer/resources/js/diva.css src/main/webapp/imageServer/resources/js/diva.css.map src/main/webapp/imageServer/resources/js/diva.js src/main/webapp/imageServer/resources/js/diva.js.map src/main/webapp/imageServer/resources/js/diva.min.js src/main/webapp/imageServer/resources/js/jquery-ui-1.10.4.zip src/main/webapp/imageServer/resources/js/vendor/diva-old.js src/main/webapp/imageServer/resources/js/vendor/diva-old.min.css src/main/webapp/imageServer/resources/js/vendor/diva-old.min.js src/main/webapp/imageServer/resources/js/vendor/jquery-ui-1.10.4.zip
diffstat 13 files changed, 3845 insertions(+), 2726 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/webapp/imageServer/displayDigi.jsp	Mon Jul 01 15:05:05 2019 +0200
+++ b/src/main/webapp/imageServer/displayDigi.jsp	Fri Jul 05 16:05:57 2019 +0200
@@ -15,7 +15,7 @@
 		<link href="resources/css/diva4ismi.css" type="text/css" rel="stylesheet" />
 		
 		<script type="text/javascript" src="resources/js/jquery.min.js"></script>
-		<script type="text/javascript" src="resources/js/diva.min.js"></script>
+		<script type="text/javascript" src="resources/js/diva.js"></script>
 		<script type="text/javascript" src="resources/js/bootstrap.min.js"></script>
 		<script type="text/javascript" src="resources/js/typeahead.js"></script>
 		<script type="text/javascript" src="resources/js/diva4ismi.js"></script>
@@ -182,17 +182,17 @@
 	        }
 	    }			
 		
-		$("#diva-wrapper").diva(
+//		$("#diva-wrapper").diva(
+        window.divaInstance = new Diva('diva-wrapper', 
 		{
-			enableAutoHeight: true,
 	        enableAutoTitle: false,
 	        enableGotoPage: false,
 	        fixedHeightGrid: false,
-	        contained: true,
-	        iipServerURL: divaGlobal.iipServerURL,
-	        digiId: "<%=digiBean.getDigiId()%>",
-	        objectData: divaGlobal.rest_url + "/rest/diva/proxy/json/<%=digiBean.getDigiLabel()%>",
-	        imageDir: "/<%=digiBean.getDigiLabel()%>",
+//	        iipServerURL: divaGlobal.iipServerURL,
+//	        digiId: "<%=digiBean.getDigiId()%>",
+//	        objectData: divaGlobal.rest_url + "/rest/diva/proxy/json/<%=digiBean.getDigiLabel()%>",
+            objectData: "https://ismi-imageserver-cc.mpiwg-berlin.mpg.de/iiif/manifests/<%=digiBean.getDigiLabel()%>.json",
+//	        imageDir: "/<%=digiBean.getDigiLabel()%>",
 			onSetCurrentPage : handlePageSwitch,
 			onDocumentLoaded : handleDocumentLoaded,
 			zoomLevel: 1,
--- a/src/main/webapp/imageServer/resources/css/diva.min.css	Mon Jul 01 15:05:05 2019 +0200
+++ b/src/main/webapp/imageServer/resources/css/diva.min.css	Fri Jul 05 16:05:57 2019 +0200
@@ -1,1 +1,554 @@
-.hidden{display:none}.grab{cursor:url("../img/openhand.cur"),pointer}.grabbing{cursor:url("../img/closedhand.cur"),move !important}.loading{background:url("../img/loading.gif") no-repeat center}.full-width{width:100% !important;max-width:100% !important}.full-height{height:100% !important;max-height:100% !important}.prevent-selection{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.button{cursor:pointer;height:32px;width:32px;background-color:#f1f1f1;background-repeat:no-repeat;background-position:center;border:1px solid #99bbe8}@media screen and (min-device-width:769px){.button:hover{background-color:#fdfdfd}}.diva-title{text-align:center;font-weight:bold;font-size:2em}.diva-tools{margin-top:5px}.diva-tools .diva-tools-left{float:left}.diva-tools .diva-tools-left .diva-slider-label{display:none;padding:8px;float:left}.diva-tools .diva-tools-left .diva-zoom-buttons-label{display:none;padding:8px;float:left}.diva-tools .diva-tools-left .diva-zoom-out-button{display:none;float:left;background-image:url("../img/zoomout.png")}.diva-tools .diva-tools-left .diva-zoom-in-button{display:none;float:left;background-image:url("../img/zoomin.png");margin-left:-1px}.diva-tools .diva-tools-left .diva-grid-out-button{display:none;float:left;background-image:url("../img/zoomout.png")}.diva-tools .diva-tools-left .diva-grid-in-button{display:none;float:left;background-image:url("../img/zoomin.png");margin-left:-1px}.diva-tools .diva-tools-left .diva-buttons-label{display:none;padding:8px;float:left}.diva-tools .diva-tools-left.in-fullscreen{float:left;clear:none}.diva-tools .diva-tools-right{float:right;height:42px}.diva-tools .diva-tools-right .diva-grid-icon{float:right;background-image:url("../img/grid.png")}.diva-tools .diva-tools-right .diva-grid-icon.diva-in-grid{background-image:url("../img/document.png")}.diva-tools .diva-tools-right .diva-download-icon{float:right;background-image:url("../img/download.png")}.diva-link-icon{float:right;background-image:url("../img/link.png")}.diva-tools .diva-tools-right .diva-page-nav{float:left;text-align:right;padding-right:4px;white-space:nowrap;line-height:32px}.diva-tools .diva-tools-right .diva-page-nav .diva-page-label{float:left;padding-top:1px;padding-right:.5em;line-height:32px}.diva-tools .diva-tools-right .diva-page-nav .diva-goto-form{float:right}.diva-tools .diva-tools-right .diva-page-nav .diva-goto-form .diva-input{width:30px;outline:none;margin:0;padding-top:0}.diva-tools.diva-fullscreen-tools{position:fixed;top:0;right:30px;z-index:101;width:230px;height:73px;padding:15px;border:1px solid #ddd;background:#fff;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5)}.diva-tools.diva-fullscreen-tools .diva-buttons-label{margin-top:5px;padding:0;clear:both}.diva-tools.diva-fullscreen-tools .diva-page-nav{float:none;line-height:1em}.diva-tools.diva-fullscreen-tools .diva-page-nav .diva-goto-form{margin-top:9px}.diva-tools.diva-fullscreen-tools .diva-page-nav .diva-page-label{float:none;clear:both;line-height:1em}.diva-outer{clear:both;background:#f1f1f1;border:1px solid #99bbe8;position:relative;min-height:100px;min-width:200px;height:700px;overflow:auto}.diva-outer .diva-inner{position:relative;overflow:hidden;margin:0 auto}.diva-outer .diva-inner .diva-page{-webkit-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);background:url("../img/loading.gif") no-repeat center;position:absolute}.diva-outer .diva-inner .diva-document-page{-webkit-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);background:url("../img/loading.gif") no-repeat center;position:absolute;left:0;right:0}.diva-outer .diva-inner .diva-document-page .diva-page-tools{position:absolute;top:-25px;left:0;height:25px;z-index:3}.diva-outer .diva-inner .diva-document-page .diva-page-tools div{display:inline-block;height:25px;width:25px;cursor:pointer}.diva-outer .diva-inner .diva-page-vertical{margin:0 auto;display:inline-block}.diva-outer .diva-inner .diva-page-horizontal{vertical-align:middle;display:inline-block;top:50%;transform:translate(0, -50%);-webkit-transform:translate(0, -50%);-moz-transform:translate(0, -50%);-ms-transform:translate(0, -50%)}.diva-outer .diva-inner .diva-row{position:absolute;width:100%}.diva-outer .diva-inner.diva-grab{cursor:url("../img/openhand.cur"),pointer}.diva-outer .diva-inner.diva-grabbing{cursor:url("../img/closedhand.cur"),move !important}.diva-outer.diva-fullscreen{width:100% !important;max-width:100% !important;height:100% !important;max-height:100% !important;z-index:100;position:fixed !important;top:0;left:0;margin:0;border:0}.diva-fullscreen-icon{background-image:url("../img/fullscreen.png");border-left:0;float:right}.diva-popup{background:#fff;border:1px solid #99bbe8;padding:.6em;z-index:101;position:absolute;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5)}.diva-link-popup{font-size:10pt}.diva-link-popup input{width:15em}.diva-link-popup input:focus{outline:none}.diva-link-popup.in-fullscreen{top:150px;right:30px}.diva-download-popup{font-size:10pt}.diva-download-popup input{width:15em}.diva-download-popup input:focus{outline:none}.diva-download-popup.in-fullscreen{top:150px;right:30px}.diva-hide-scrollbar{overflow:hidden !important}.diva-relative-position{position:relative}.zoom-slider{position:relative;top:.6em;display:none;float:left}@media (max-width:480px){.zoom-slider{width:100px}}.grid-slider{position:relative;top:.6em;display:none;float:left}@media (max-width:480px){.grid-slider{width:100px}}.diva-throbber{display:none;position:absolute;width:50px;height:50px;background:url("../img/loading.gif") no-repeat center;background-color:#fff;border:1px solid #ddd;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);top:50%;left:50%;margin-left:-25px;margin-top:-25px}.diva-error{position:absolute;width:400px;height:200px;background-color:#fff;border:1px solid #ddd;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);top:50%;left:50%;margin-left:-220px;margin-top:-120px;z-index:120;padding:0 1em}.diva-canvas-icon{background:url('../img/plugins/canvas.png') no-repeat;background-position:left center}.diva-canvas-icon:hover{background-position:-25px center}.diva-canvas-icon.new{background-position:-50px center}.diva-canvas-icon.new:hover{background-position:-75px center}#diva-canvas-backdrop{z-index:105;position:fixed;top:0;left:0;bottom:0;right:0;display:none;background:rgba(50,50,50,0.9)}#diva-canvas-tools{color:#333;position:fixed;top:10px;left:10px;width:230px;z-index:108;background:#fff;padding-bottom:10px;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5)}#diva-canvas-tools .action-buttons{clear:both;margin-bottom:5px;text-align:right}#diva-canvas-tools .action-buttons a{color:#333;text-decoration:none;background:#f1f1f1;padding:5px;border:1px solid #99bbe8}#diva-canvas-tools .action-buttons a:last-child{border-left:0}#diva-canvas-tools .action-buttons a:hover{background:#fdfdfd}#diva-canvas-toolbar{height:16px;padding:10px;padding-bottom:0}#diva-canvas-toolbar div{height:18px;width:18px;background-repeat:no-repeat;cursor:pointer;z-index:109;display:inline-block;margin-right:5px;background-image:url("../img/actions.png")}#diva-canvas-toolbar span{vertical-align:top;float:right}#diva-canvas-toolwindow{position:relative;margin:10px}#diva-canvas-close:hover{background-position:-20px 0}#diva-canvas-minimise{background-position:-40px 0}#diva-canvas-minimise:hover{background-position:-60px 0}#diva-canvas-buttons div{cursor:pointer;background-image:url("../img/plugins/canvas-buttons.png");background-repeat:no-repeat;width:20px;height:20px;padding:5px;display:inline-block}#diva-canvas-buttons div.clicked{background-color:#ddd}#diva-canvas-buttons .contrast{background-position:5px 5px}#diva-canvas-buttons .contrast:hover,#diva-canvas-buttons .contrast.clicked{background-position:5px -25px}#diva-canvas-buttons .brightness{background-position:-25px 5px}#diva-canvas-buttons .brightness:hover,#diva-canvas-buttons .brightness.clicked{background-position:-25px -25px}#diva-canvas-buttons .rotation{background-position:-55px 5px}#diva-canvas-buttons .rotation:hover,#diva-canvas-buttons .rotation.clicked{background-position:-55px -25px}#diva-canvas-buttons .zoom{background-position:-85px 5px}#diva-canvas-buttons .zoom:hover,#diva-canvas-buttons .zoom.clicked{background-position:-85px -25px}#diva-canvas-buttons .red{background-position:-115px 5px}#diva-canvas-buttons .red:hover,#diva-canvas-buttons .red.clicked{background-position:-115px -25px}#diva-canvas-buttons .green{background-position:-145px 5px}#diva-canvas-buttons .green:hover,#diva-canvas-buttons .green.clicked{background-position:-145px -25px}#diva-canvas-buttons .blue{background-position:-175px 5px}#diva-canvas-buttons .blue:hover,#diva-canvas-buttons .blue.clicked{background-position:-175px -25px}#diva-canvas-pane{background:#ddd;padding-bottom:10px}#diva-canvas-pane p{margin-left:10px;padding-top:10px}#diva-canvas-pane p .link{cursor:pointer}#diva-canvas-pane p .link:hover{text-decoration:underline}#diva-canvas-mode{text-transform:capitalize}#diva-canvas-slider{width:188px;margin:0 auto;display:block}#diva-canvas-slider .handle{margin-left:-6px}#diva-canvas-minimap{height:210px;width:210px;cursor:crosshair;margin-bottom:10px;background:#000}#diva-canvas{position:absolute;left:0;right:0;margin:0 auto;z-index:107;cursor:url("../img/openhand.cur"),pointer}#diva-map-viewbox{border:2px solid #99bbe8;position:absolute;top:10px;left:10px;cursor:crosshair;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:none}.overflow-hidden{overflow:hidden !important}#diva-canvas-wrapper{z-index:106;position:absolute;top:0;left:0;bottom:0;right:0;overflow:scroll}.canvas-throbber{z-index:110;position:fixed}.diva-download-icon{background:url('../img/plugins/download.png') no-repeat;background-position:left center}.diva-download-icon:hover{background-position:-25px center}.diva-autoscroll-icon{float:right;border-right:none;background-image:url("../img/plugins/play.png")}.diva-autoscroll-prefs{display:none;margin-right:.6em}.diva-autoscroll-prefs-text{float:left}.diva-autoscroll-prefs-input{float:right;margin-left:.6em}.diva-autoscroll-pps{width:5em}
\ No newline at end of file
+.diva-wrapper {
+  min-height: 95vh;
+  width: 100%;
+  flex-grow: 1; }
+  .diva-wrapper.diva-wrapper-flexbox {
+    display: flex;
+    flex-direction: column; }
+  .diva-wrapper > *:not(.diva-outer) {
+    flex-shrink: 0; }
+
+.diva-title {
+  text-align: center;
+  font-weight: bold;
+  font-size: 1.3em;
+  max-width: 50em;
+  margin: 0 auto; }
+
+.diva-button, .diva-input {
+  box-sizing: border-box;
+  outline: none;
+  border-radius: 0;
+  font: inherit;
+  vertical-align: middle; }
+  .diva-button::-moz-focus-inner, .diva-input::-moz-focus-inner {
+    padding: 0; }
+
+.diva-button {
+  display: inline-block;
+  cursor: pointer;
+  height: 34px;
+  width: 34px;
+  line-height: 34px;
+  -webkit-appearance: none;
+  padding: 3px;
+  background-color: #F1F1F1;
+  background-repeat: no-repeat;
+  background-position: center;
+  border: 1px solid #AAA; }
+  .diva-button:hover, .diva-button:focus {
+    background-color: #FDFDFD; }
+  .diva-button.diva-button-text {
+    width: auto;
+    padding: 0 0.5em; }
+
+.diva-input {
+  height: 34px;
+  border: 1px solid #AAA;
+  padding: 0 0.5em; }
+  .diva-input:focus {
+    border-color: #919191; }
+
+.diva-label {
+  margin: 0 1em;
+  line-height: 34px;
+  vertical-align: top;
+  white-space: nowrap;
+  text-overflow: ellipsis; }
+
+.diva-tools-left, .diva-tools-right {
+  margin-bottom: 1em; }
+
+.diva-tools-left {
+  float: left;
+  user-select: none; }
+
+.diva-zoom-in-button, .diva-grid-in-button {
+  margin-left: -1px; }
+
+.diva-tools-right {
+  float: right; }
+  .diva-tools-right .diva-button {
+    margin-left: -1px;
+    user-select: none; }
+
+.diva-page-nav {
+  white-space: nowrap;
+  margin-right: 1em; }
+
+.diva-goto-form {
+  display: inline-block;
+  position: relative; }
+
+.diva-goto-page-input {
+  width: 5em; }
+
+.diva-input-suggestions {
+  display: none;
+  box-sizing: border-box;
+  position: absolute;
+  width: 100%;
+  background-color: white;
+  border: solid 1px #aaa;
+  border-top: none;
+  z-index: 1; }
+
+.diva-input-suggestion {
+  box-sizing: border-box;
+  width: 100%;
+  margin-top: 3px;
+  padding: 2px;
+  padding-left: 5px;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  cursor: pointer; }
+
+.diva-input-suggestion.active, .diva-input-suggestion:hover {
+  background-color: #dfefff; }
+
+.diva-view-menu {
+  display: inline-block;
+  position: relative; }
+
+.diva-view-options {
+  position: absolute;
+  top: 34px;
+  z-index: 1;
+  display: none;
+  box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1); }
+
+.diva-view-options .diva-button {
+  margin-top: -1px;
+  display: block; }
+
+.diva-zoom-label, .diva-grid-label, .diva-page-label {
+  display: inline-block; }
+
+.diva-fullscreen-tools {
+  position: fixed;
+  top: 15px;
+  right: 30px;
+  z-index: 101;
+  padding: 15px;
+  border: 1px solid #DDD;
+  background: #FFF;
+  transition: opacity 0.5s;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  /* prevent variable number of digits in labels from resizing .diva-fullscreen-tools */ }
+  .diva-fullscreen-tools .diva-tools-left, .diva-fullscreen-tools .diva-tools-right {
+    margin-bottom: 0; }
+  .diva-fullscreen-tools .diva-tools-right {
+    margin-left: 2em; }
+  .diva-fullscreen-tools .diva-label, .diva-fullscreen-tools .diva-page-label {
+    margin: 0; }
+  .diva-fullscreen-tools .diva-zoom-label, .diva-fullscreen-tools .diva-grid-label, .diva-fullscreen-tools .diva-page-label {
+    width: 8em;
+    display: block; }
+  .diva-fullscreen-tools .diva-page-nav {
+    margin-right: 0; }
+
+.diva-outer {
+  display: flex;
+  clear: both;
+  background: #F1F1F1;
+  border: 1px solid #AAA;
+  position: relative;
+  overflow: hidden;
+  min-height: 100px;
+  min-width: 200px;
+  flex-grow: 1; }
+
+.diva-viewer-canvas {
+  position: absolute;
+  top: 0;
+  left: 0; }
+
+.diva-viewport {
+  position: absolute;
+  top: 0;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  overflow: auto; }
+
+.diva-inner {
+  cursor: move;
+  /* fallback if grab cursor is unsupported */
+  cursor: grab;
+  cursor: -moz-grab;
+  cursor: -webkit-grab;
+  position: relative;
+  overflow: hidden;
+  margin: 0 auto; }
+  .diva-inner.diva-grabbing {
+    cursor: grabbing;
+    cursor: -moz-grabbing;
+    cursor: -webkit-grabbing; }
+
+.diva-page {
+  box-shadow: 7px 7px 6px -6px rgba(0, 0, 0, 0.3);
+  position: absolute;
+  background-color: #FDFDFD; }
+
+.diva-page-tools-wrapper {
+  position: absolute;
+  z-index: 3; }
+
+.diva-page-tools {
+  position: relative;
+  top: -27px;
+  height: 20px; }
+  .diva-page-tools div {
+    display: inline-block;
+    height: 20px;
+    width: 20px;
+    cursor: pointer;
+    padding: 3px; }
+    .diva-page-tools div svg:hover .diva-pagetool-icon {
+      fill: #006ebc; }
+
+.diva-page-labels-wrapper {
+  position: absolute;
+  z-index: 3; }
+
+.diva-page-labels {
+  position: relative;
+  top: -20px;
+  height: 20px;
+  font-size: 0.8em; }
+
+.diva-fullscreen {
+  width: 100% !important;
+  max-width: 100% !important;
+  height: 100% !important;
+  max-height: 100% !important;
+  z-index: 100;
+  position: fixed !important;
+  top: 0;
+  left: 0;
+  margin: 0;
+  border: 0; }
+
+.diva-popup {
+  background: #FFF;
+  border: 1px solid #AAA;
+  padding: .6em;
+  z-index: 101;
+  position: absolute;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5); }
+
+.diva-link-popup {
+  font-size: 10pt; }
+  .diva-link-popup input {
+    width: 18em; }
+    .diva-link-popup input:focus {
+      outline: none; }
+  .diva-link-popup.in-fullscreen {
+    top: 150px;
+    right: 30px; }
+
+.diva-hide-scrollbar {
+  overflow: hidden !important; }
+
+.diva-slider {
+  position: relative;
+  top: 0.6em;
+  float: left; }
+  @media (max-width: 480px) {
+    .diva-slider {
+      width: 100px; } }
+
+.diva-throbber {
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  width: 40px;
+  height: 40px;
+  margin: auto auto;
+  padding: 20px;
+  background-color: #fff;
+  /*
+   * Spinner positions
+   * 1 2 3
+   * 4 5 6
+   * 7 8 9
+   */ }
+  .diva-throbber .cube {
+    width: 33.33%;
+    height: 33.33%;
+    background-color: #333;
+    float: left;
+    animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; }
+  .diva-throbber .cube1 {
+    animation-delay: 0.2s; }
+  .diva-throbber .cube2 {
+    animation-delay: 0.3s; }
+  .diva-throbber .cube3 {
+    animation-delay: 0.4s; }
+  .diva-throbber .cube4 {
+    animation-delay: 0.1s; }
+  .diva-throbber .cube5 {
+    animation-delay: 0.2s; }
+  .diva-throbber .cube6 {
+    animation-delay: 0.3s; }
+  .diva-throbber .cube7 {
+    animation-delay: 0.0s; }
+  .diva-throbber .cube8 {
+    animation-delay: 0.1s; }
+  .diva-throbber .cube9 {
+    animation-delay: 0.2s; }
+
+@keyframes sk-cubeGridScaleDelay {
+  0%, 70%, 100% {
+    transform: scale3D(1, 1, 1); }
+  35% {
+    transform: scale3D(0, 0, 1); } }
+
+.diva-error {
+  position: absolute;
+  width: 400px;
+  height: 200px;
+  background-color: #fff;
+  border: 1px solid #ddd;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  top: 50%;
+  left: 50%;
+  margin-left: -220px;
+  margin-top: -120px;
+  z-index: 120;
+  padding: 0 1em; }
+
+.diva-error-close {
+  width: 18px;
+  height: 18px;
+  border: none;
+  position: absolute;
+  top: 1em;
+  right: 1em; }
+  .diva-error-close:hover {
+    cursor: hand; }
+
+.diva-modal {
+  position: absolute;
+  width: 32em;
+  max-height: 26em;
+  background-color: #fff;
+  border: 1px solid #ddd;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  z-index: 120;
+  word-wrap: break-word; }
+
+.manipulation-fullscreen {
+  width: 100% !important;
+  max-width: 100% !important;
+  height: 100% !important;
+  max-height: 100% !important;
+  z-index: 100;
+  position: fixed !important;
+  top: 0;
+  left: 0;
+  margin: 0;
+  border: 0;
+  background-color: rgba(0, 0, 0, 0.9);
+  display: flex; }
+
+.manipulation-sidebar {
+  width: 15%;
+  overflow: scroll;
+  text-align: center;
+  padding: 10px; }
+  .manipulation-sidebar .manipulation-sidebar-primary-image,
+  .manipulation-sidebar .manipulation-sidebar-secondary-image {
+    margin: 10px 0;
+    padding-bottom: 10px;
+    border-bottom: 1px solid #fff;
+    color: #fff; }
+
+.manipulation-sidebar-mobile {
+  width: 50%;
+  text-align: center;
+  padding: 10px;
+  display: none; }
+  .manipulation-sidebar-mobile .manipulation-sidebar-primary-image,
+  .manipulation-sidebar-mobile .manipulation-sidebar-secondary-image {
+    margin: 10px 0;
+    padding-bottom: 10px;
+    border-bottom: 1px solid #fff;
+    color: #fff; }
+
+.manipulation-main-area {
+  width: 70%;
+  flex: 1 1 auto;
+  background-color: rgba(255, 255, 255, 0.5);
+  overflow: scroll;
+  text-align: center;
+  cursor: move;
+  /* fallback if grab cursor is unsupported */
+  cursor: grab;
+  cursor: -moz-grab;
+  cursor: -webkit-grab; }
+  .manipulation-main-area.grabbing {
+    cursor: grabbing;
+    cursor: -moz-grabbing;
+    cursor: -webkit-grabbing; }
+  .manipulation-main-area canvas {
+    margin: 0 auto; }
+
+.manipulation-main-area-mobile {
+  width: 100%;
+  background-color: rgba(255, 255, 255, 0.5);
+  overflow: scroll;
+  text-align: center;
+  cursor: move;
+  /* fallback if grab cursor is unsupported */
+  cursor: grab;
+  cursor: -moz-grab;
+  cursor: -webkit-grab; }
+  .manipulation-main-area-mobile.grabbing {
+    cursor: grabbing;
+    cursor: -moz-grabbing;
+    cursor: -webkit-grabbing; }
+  .manipulation-main-area-mobile canvas {
+    margin: 0 auto; }
+
+.manipulation-tools {
+  width: 15%;
+  flex: 1 1 auto;
+  overflow: auto; }
+  .manipulation-tools .manipulation-tools-text {
+    color: #FBF7F6;
+    margin-bottom: 0.7em; }
+
+.manipulation-tools-mobile {
+  width: 50%;
+  flex: 1 1 auto;
+  overflow: auto;
+  display: none; }
+  .manipulation-tools-mobile .manipulation-tools-text {
+    color: #FBF7F6;
+    margin-bottom: 0.7em; }
+
+.burger-menu {
+  position: fixed;
+  top: 0.5em;
+  left: 0.5em;
+  cursor: pointer; }
+  .burger-menu .stripe {
+    width: 2em;
+    height: 0.3em;
+    background-color: #fff5ef;
+    margin: 0.2em 0; }
+
+input[type=range] {
+  -webkit-appearance: none;
+  width: 100%;
+  margin: 4.5px 0; }
+
+input[type=range]:focus {
+  outline: none; }
+
+input[type=range]::-webkit-slider-runnable-track {
+  width: 100%;
+  height: 5px;
+  cursor: pointer;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32);
+  background: rgba(255, 255, 255, 0.66);
+  border-radius: 25px;
+  border: 0px solid rgba(1, 1, 1, 0); }
+
+input[type=range]::-webkit-slider-thumb {
+  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);
+  border: 0.9px solid rgba(0, 0, 30, 0.42);
+  height: 13px;
+  width: 13px;
+  border-radius: 10px;
+  background: #ffffff;
+  cursor: pointer;
+  -webkit-appearance: none;
+  margin-top: -4.5px; }
+
+input[type=range]:focus::-webkit-slider-runnable-track {
+  background: rgba(253, 133, 243, 0.66); }
+
+input[type=range]::-moz-range-track {
+  width: 100%;
+  height: 5px;
+  cursor: pointer;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32);
+  background: rgba(255, 255, 255, 0.66);
+  border-radius: 25px;
+  border: 0px solid rgba(1, 1, 1, 0); }
+
+input[type=range]::-moz-range-thumb {
+  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);
+  border: 0.9px solid rgba(0, 0, 30, 0.42);
+  height: 13px;
+  width: 13px;
+  border-radius: 10px;
+  background: #ffffff;
+  cursor: pointer; }
+
+input[type=range]::-ms-track {
+  width: 100%;
+  height: 4px;
+  cursor: pointer;
+  background: transparent;
+  border-color: transparent;
+  color: transparent; }
+
+input[type=range]::-ms-fill-lower {
+  background: rgba(251, 83, 239, 0.66);
+  border: 0px solid rgba(1, 1, 1, 0);
+  border-radius: 50px;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32); }
+
+input[type=range]::-ms-fill-upper {
+  background: rgba(252, 108, 241, 0.66);
+  border: 0px solid rgba(1, 1, 1, 0);
+  border-radius: 50px;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32); }
+
+input[type=range]::-ms-thumb {
+  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);
+  border: 0.9px solid rgba(0, 0, 30, 0.42);
+  height: 13px;
+  width: 13px;
+  border-radius: 10px;
+  background: #ffffff;
+  cursor: pointer;
+  height: 4px; }
+
+input[type=range]:focus::-ms-fill-lower {
+  background: rgba(252, 108, 241, 0.66); }
+
+input[type=range]:focus::-ms-fill-upper {
+  background: rgba(253, 133, 243, 0.66); }
+
+#metadata-content {
+  overflow-y: auto;
+  max-height: 20em;
+  padding: 2em; }
+
+#metadata-content dl dt {
+  font-weight: bold; }
+
+#metadata-content dl dd {
+  margin-left: 0;
+  margin-bottom: 1em; }
+
+#metadata-title {
+  margin: 0;
+  text-align: center; }
+
+.close-button {
+  position: absolute;
+  right: 1em;
+  top: 1em; }
+
+.close-button:hover {
+  color: tomato; }
+
+
+/*# sourceMappingURL=diva.css.map*/
\ No newline at end of file
Binary file src/main/webapp/imageServer/resources/js/.DS_Store has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/imageServer/resources/js/diva.css	Fri Jul 05 16:05:57 2019 +0200
@@ -0,0 +1,554 @@
+.diva-wrapper {
+  min-height: 95vh;
+  width: 100%;
+  flex-grow: 1; }
+  .diva-wrapper.diva-wrapper-flexbox {
+    display: flex;
+    flex-direction: column; }
+  .diva-wrapper > *:not(.diva-outer) {
+    flex-shrink: 0; }
+
+.diva-title {
+  text-align: center;
+  font-weight: bold;
+  font-size: 1.3em;
+  max-width: 50em;
+  margin: 0 auto; }
+
+.diva-button, .diva-input {
+  box-sizing: border-box;
+  outline: none;
+  border-radius: 0;
+  font: inherit;
+  vertical-align: middle; }
+  .diva-button::-moz-focus-inner, .diva-input::-moz-focus-inner {
+    padding: 0; }
+
+.diva-button {
+  display: inline-block;
+  cursor: pointer;
+  height: 34px;
+  width: 34px;
+  line-height: 34px;
+  -webkit-appearance: none;
+  padding: 3px;
+  background-color: #F1F1F1;
+  background-repeat: no-repeat;
+  background-position: center;
+  border: 1px solid #AAA; }
+  .diva-button:hover, .diva-button:focus {
+    background-color: #FDFDFD; }
+  .diva-button.diva-button-text {
+    width: auto;
+    padding: 0 0.5em; }
+
+.diva-input {
+  height: 34px;
+  border: 1px solid #AAA;
+  padding: 0 0.5em; }
+  .diva-input:focus {
+    border-color: #919191; }
+
+.diva-label {
+  margin: 0 1em;
+  line-height: 34px;
+  vertical-align: top;
+  white-space: nowrap;
+  text-overflow: ellipsis; }
+
+.diva-tools-left, .diva-tools-right {
+  margin-bottom: 1em; }
+
+.diva-tools-left {
+  float: left;
+  user-select: none; }
+
+.diva-zoom-in-button, .diva-grid-in-button {
+  margin-left: -1px; }
+
+.diva-tools-right {
+  float: right; }
+  .diva-tools-right .diva-button {
+    margin-left: -1px;
+    user-select: none; }
+
+.diva-page-nav {
+  white-space: nowrap;
+  margin-right: 1em; }
+
+.diva-goto-form {
+  display: inline-block;
+  position: relative; }
+
+.diva-goto-page-input {
+  width: 5em; }
+
+.diva-input-suggestions {
+  display: none;
+  box-sizing: border-box;
+  position: absolute;
+  width: 100%;
+  background-color: white;
+  border: solid 1px #aaa;
+  border-top: none;
+  z-index: 1; }
+
+.diva-input-suggestion {
+  box-sizing: border-box;
+  width: 100%;
+  margin-top: 3px;
+  padding: 2px;
+  padding-left: 5px;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  cursor: pointer; }
+
+.diva-input-suggestion.active, .diva-input-suggestion:hover {
+  background-color: #dfefff; }
+
+.diva-view-menu {
+  display: inline-block;
+  position: relative; }
+
+.diva-view-options {
+  position: absolute;
+  top: 34px;
+  z-index: 1;
+  display: none;
+  box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1); }
+
+.diva-view-options .diva-button {
+  margin-top: -1px;
+  display: block; }
+
+.diva-zoom-label, .diva-grid-label, .diva-page-label {
+  display: inline-block; }
+
+.diva-fullscreen-tools {
+  position: fixed;
+  top: 15px;
+  right: 30px;
+  z-index: 101;
+  padding: 15px;
+  border: 1px solid #DDD;
+  background: #FFF;
+  transition: opacity 0.5s;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  /* prevent variable number of digits in labels from resizing .diva-fullscreen-tools */ }
+  .diva-fullscreen-tools .diva-tools-left, .diva-fullscreen-tools .diva-tools-right {
+    margin-bottom: 0; }
+  .diva-fullscreen-tools .diva-tools-right {
+    margin-left: 2em; }
+  .diva-fullscreen-tools .diva-label, .diva-fullscreen-tools .diva-page-label {
+    margin: 0; }
+  .diva-fullscreen-tools .diva-zoom-label, .diva-fullscreen-tools .diva-grid-label, .diva-fullscreen-tools .diva-page-label {
+    width: 8em;
+    display: block; }
+  .diva-fullscreen-tools .diva-page-nav {
+    margin-right: 0; }
+
+.diva-outer {
+  display: flex;
+  clear: both;
+  background: #F1F1F1;
+  border: 1px solid #AAA;
+  position: relative;
+  overflow: hidden;
+  min-height: 100px;
+  min-width: 200px;
+  flex-grow: 1; }
+
+.diva-viewer-canvas {
+  position: absolute;
+  top: 0;
+  left: 0; }
+
+.diva-viewport {
+  position: absolute;
+  top: 0;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  overflow: auto; }
+
+.diva-inner {
+  cursor: move;
+  /* fallback if grab cursor is unsupported */
+  cursor: grab;
+  cursor: -moz-grab;
+  cursor: -webkit-grab;
+  position: relative;
+  overflow: hidden;
+  margin: 0 auto; }
+  .diva-inner.diva-grabbing {
+    cursor: grabbing;
+    cursor: -moz-grabbing;
+    cursor: -webkit-grabbing; }
+
+.diva-page {
+  box-shadow: 7px 7px 6px -6px rgba(0, 0, 0, 0.3);
+  position: absolute;
+  background-color: #FDFDFD; }
+
+.diva-page-tools-wrapper {
+  position: absolute;
+  z-index: 3; }
+
+.diva-page-tools {
+  position: relative;
+  top: -27px;
+  height: 20px; }
+  .diva-page-tools div {
+    display: inline-block;
+    height: 20px;
+    width: 20px;
+    cursor: pointer;
+    padding: 3px; }
+    .diva-page-tools div svg:hover .diva-pagetool-icon {
+      fill: #006ebc; }
+
+.diva-page-labels-wrapper {
+  position: absolute;
+  z-index: 3; }
+
+.diva-page-labels {
+  position: relative;
+  top: -20px;
+  height: 20px;
+  font-size: 0.8em; }
+
+.diva-fullscreen {
+  width: 100% !important;
+  max-width: 100% !important;
+  height: 100% !important;
+  max-height: 100% !important;
+  z-index: 100;
+  position: fixed !important;
+  top: 0;
+  left: 0;
+  margin: 0;
+  border: 0; }
+
+.diva-popup {
+  background: #FFF;
+  border: 1px solid #AAA;
+  padding: .6em;
+  z-index: 101;
+  position: absolute;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5); }
+
+.diva-link-popup {
+  font-size: 10pt; }
+  .diva-link-popup input {
+    width: 18em; }
+    .diva-link-popup input:focus {
+      outline: none; }
+  .diva-link-popup.in-fullscreen {
+    top: 150px;
+    right: 30px; }
+
+.diva-hide-scrollbar {
+  overflow: hidden !important; }
+
+.diva-slider {
+  position: relative;
+  top: 0.6em;
+  float: left; }
+  @media (max-width: 480px) {
+    .diva-slider {
+      width: 100px; } }
+
+.diva-throbber {
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  width: 40px;
+  height: 40px;
+  margin: auto auto;
+  padding: 20px;
+  background-color: #fff;
+  /*
+   * Spinner positions
+   * 1 2 3
+   * 4 5 6
+   * 7 8 9
+   */ }
+  .diva-throbber .cube {
+    width: 33.33%;
+    height: 33.33%;
+    background-color: #333;
+    float: left;
+    animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; }
+  .diva-throbber .cube1 {
+    animation-delay: 0.2s; }
+  .diva-throbber .cube2 {
+    animation-delay: 0.3s; }
+  .diva-throbber .cube3 {
+    animation-delay: 0.4s; }
+  .diva-throbber .cube4 {
+    animation-delay: 0.1s; }
+  .diva-throbber .cube5 {
+    animation-delay: 0.2s; }
+  .diva-throbber .cube6 {
+    animation-delay: 0.3s; }
+  .diva-throbber .cube7 {
+    animation-delay: 0.0s; }
+  .diva-throbber .cube8 {
+    animation-delay: 0.1s; }
+  .diva-throbber .cube9 {
+    animation-delay: 0.2s; }
+
+@keyframes sk-cubeGridScaleDelay {
+  0%, 70%, 100% {
+    transform: scale3D(1, 1, 1); }
+  35% {
+    transform: scale3D(0, 0, 1); } }
+
+.diva-error {
+  position: absolute;
+  width: 400px;
+  height: 200px;
+  background-color: #fff;
+  border: 1px solid #ddd;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  top: 50%;
+  left: 50%;
+  margin-left: -220px;
+  margin-top: -120px;
+  z-index: 120;
+  padding: 0 1em; }
+
+.diva-error-close {
+  width: 18px;
+  height: 18px;
+  border: none;
+  position: absolute;
+  top: 1em;
+  right: 1em; }
+  .diva-error-close:hover {
+    cursor: hand; }
+
+.diva-modal {
+  position: absolute;
+  width: 32em;
+  max-height: 26em;
+  background-color: #fff;
+  border: 1px solid #ddd;
+  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  z-index: 120;
+  word-wrap: break-word; }
+
+.manipulation-fullscreen {
+  width: 100% !important;
+  max-width: 100% !important;
+  height: 100% !important;
+  max-height: 100% !important;
+  z-index: 100;
+  position: fixed !important;
+  top: 0;
+  left: 0;
+  margin: 0;
+  border: 0;
+  background-color: rgba(0, 0, 0, 0.9);
+  display: flex; }
+
+.manipulation-sidebar {
+  width: 15%;
+  overflow: scroll;
+  text-align: center;
+  padding: 10px; }
+  .manipulation-sidebar .manipulation-sidebar-primary-image,
+  .manipulation-sidebar .manipulation-sidebar-secondary-image {
+    margin: 10px 0;
+    padding-bottom: 10px;
+    border-bottom: 1px solid #fff;
+    color: #fff; }
+
+.manipulation-sidebar-mobile {
+  width: 50%;
+  text-align: center;
+  padding: 10px;
+  display: none; }
+  .manipulation-sidebar-mobile .manipulation-sidebar-primary-image,
+  .manipulation-sidebar-mobile .manipulation-sidebar-secondary-image {
+    margin: 10px 0;
+    padding-bottom: 10px;
+    border-bottom: 1px solid #fff;
+    color: #fff; }
+
+.manipulation-main-area {
+  width: 70%;
+  flex: 1 1 auto;
+  background-color: rgba(255, 255, 255, 0.5);
+  overflow: scroll;
+  text-align: center;
+  cursor: move;
+  /* fallback if grab cursor is unsupported */
+  cursor: grab;
+  cursor: -moz-grab;
+  cursor: -webkit-grab; }
+  .manipulation-main-area.grabbing {
+    cursor: grabbing;
+    cursor: -moz-grabbing;
+    cursor: -webkit-grabbing; }
+  .manipulation-main-area canvas {
+    margin: 0 auto; }
+
+.manipulation-main-area-mobile {
+  width: 100%;
+  background-color: rgba(255, 255, 255, 0.5);
+  overflow: scroll;
+  text-align: center;
+  cursor: move;
+  /* fallback if grab cursor is unsupported */
+  cursor: grab;
+  cursor: -moz-grab;
+  cursor: -webkit-grab; }
+  .manipulation-main-area-mobile.grabbing {
+    cursor: grabbing;
+    cursor: -moz-grabbing;
+    cursor: -webkit-grabbing; }
+  .manipulation-main-area-mobile canvas {
+    margin: 0 auto; }
+
+.manipulation-tools {
+  width: 15%;
+  flex: 1 1 auto;
+  overflow: auto; }
+  .manipulation-tools .manipulation-tools-text {
+    color: #FBF7F6;
+    margin-bottom: 0.7em; }
+
+.manipulation-tools-mobile {
+  width: 50%;
+  flex: 1 1 auto;
+  overflow: auto;
+  display: none; }
+  .manipulation-tools-mobile .manipulation-tools-text {
+    color: #FBF7F6;
+    margin-bottom: 0.7em; }
+
+.burger-menu {
+  position: fixed;
+  top: 0.5em;
+  left: 0.5em;
+  cursor: pointer; }
+  .burger-menu .stripe {
+    width: 2em;
+    height: 0.3em;
+    background-color: #fff5ef;
+    margin: 0.2em 0; }
+
+input[type=range] {
+  -webkit-appearance: none;
+  width: 100%;
+  margin: 4.5px 0; }
+
+input[type=range]:focus {
+  outline: none; }
+
+input[type=range]::-webkit-slider-runnable-track {
+  width: 100%;
+  height: 5px;
+  cursor: pointer;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32);
+  background: rgba(255, 255, 255, 0.66);
+  border-radius: 25px;
+  border: 0px solid rgba(1, 1, 1, 0); }
+
+input[type=range]::-webkit-slider-thumb {
+  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);
+  border: 0.9px solid rgba(0, 0, 30, 0.42);
+  height: 13px;
+  width: 13px;
+  border-radius: 10px;
+  background: #ffffff;
+  cursor: pointer;
+  -webkit-appearance: none;
+  margin-top: -4.5px; }
+
+input[type=range]:focus::-webkit-slider-runnable-track {
+  background: rgba(253, 133, 243, 0.66); }
+
+input[type=range]::-moz-range-track {
+  width: 100%;
+  height: 5px;
+  cursor: pointer;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32);
+  background: rgba(255, 255, 255, 0.66);
+  border-radius: 25px;
+  border: 0px solid rgba(1, 1, 1, 0); }
+
+input[type=range]::-moz-range-thumb {
+  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);
+  border: 0.9px solid rgba(0, 0, 30, 0.42);
+  height: 13px;
+  width: 13px;
+  border-radius: 10px;
+  background: #ffffff;
+  cursor: pointer; }
+
+input[type=range]::-ms-track {
+  width: 100%;
+  height: 4px;
+  cursor: pointer;
+  background: transparent;
+  border-color: transparent;
+  color: transparent; }
+
+input[type=range]::-ms-fill-lower {
+  background: rgba(251, 83, 239, 0.66);
+  border: 0px solid rgba(1, 1, 1, 0);
+  border-radius: 50px;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32); }
+
+input[type=range]::-ms-fill-upper {
+  background: rgba(252, 108, 241, 0.66);
+  border: 0px solid rgba(1, 1, 1, 0);
+  border-radius: 50px;
+  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32); }
+
+input[type=range]::-ms-thumb {
+  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);
+  border: 0.9px solid rgba(0, 0, 30, 0.42);
+  height: 13px;
+  width: 13px;
+  border-radius: 10px;
+  background: #ffffff;
+  cursor: pointer;
+  height: 4px; }
+
+input[type=range]:focus::-ms-fill-lower {
+  background: rgba(252, 108, 241, 0.66); }
+
+input[type=range]:focus::-ms-fill-upper {
+  background: rgba(253, 133, 243, 0.66); }
+
+#metadata-content {
+  overflow-y: auto;
+  max-height: 20em;
+  padding: 2em; }
+
+#metadata-content dl dt {
+  font-weight: bold; }
+
+#metadata-content dl dd {
+  margin-left: 0;
+  margin-bottom: 1em; }
+
+#metadata-title {
+  margin: 0;
+  text-align: center; }
+
+.close-button {
+  position: absolute;
+  right: 1em;
+  top: 1em; }
+
+.close-button:hover {
+  color: tomato; }
+
+
+/*# sourceMappingURL=diva.css.map*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/imageServer/resources/js/diva.css.map	Fri Jul 05 16:05:57 2019 +0200
@@ -0,0 +1,1 @@
+{"version":3,"file":"diva.css","sources":["webpack:///./source/css/diva.scss"],"sourcesContent":[".diva-wrapper {\n  min-height: 95vh;\n  width: 100%;\n  flex-grow: 1; }\n  .diva-wrapper.diva-wrapper-flexbox {\n    display: flex;\n    flex-direction: column; }\n  .diva-wrapper > *:not(.diva-outer) {\n    flex-shrink: 0; }\n\n.diva-title {\n  text-align: center;\n  font-weight: bold;\n  font-size: 1.3em;\n  max-width: 50em;\n  margin: 0 auto; }\n\n.diva-button, .diva-input {\n  box-sizing: border-box;\n  outline: none;\n  border-radius: 0;\n  font: inherit;\n  vertical-align: middle; }\n  .diva-button::-moz-focus-inner, .diva-input::-moz-focus-inner {\n    padding: 0; }\n\n.diva-button {\n  display: inline-block;\n  cursor: pointer;\n  height: 34px;\n  width: 34px;\n  line-height: 34px;\n  -webkit-appearance: none;\n  padding: 3px;\n  background-color: #F1F1F1;\n  background-repeat: no-repeat;\n  background-position: center;\n  border: 1px solid #AAA; }\n  .diva-button:hover, .diva-button:focus {\n    background-color: #FDFDFD; }\n  .diva-button.diva-button-text {\n    width: auto;\n    padding: 0 0.5em; }\n\n.diva-input {\n  height: 34px;\n  border: 1px solid #AAA;\n  padding: 0 0.5em; }\n  .diva-input:focus {\n    border-color: #919191; }\n\n.diva-label {\n  margin: 0 1em;\n  line-height: 34px;\n  vertical-align: top;\n  white-space: nowrap;\n  text-overflow: ellipsis; }\n\n.diva-tools-left, .diva-tools-right {\n  margin-bottom: 1em; }\n\n.diva-tools-left {\n  float: left;\n  user-select: none; }\n\n.diva-zoom-in-button, .diva-grid-in-button {\n  margin-left: -1px; }\n\n.diva-tools-right {\n  float: right; }\n  .diva-tools-right .diva-button {\n    margin-left: -1px;\n    user-select: none; }\n\n.diva-page-nav {\n  white-space: nowrap;\n  margin-right: 1em; }\n\n.diva-goto-form {\n  display: inline-block;\n  position: relative; }\n\n.diva-goto-page-input {\n  width: 5em; }\n\n.diva-input-suggestions {\n  display: none;\n  box-sizing: border-box;\n  position: absolute;\n  width: 100%;\n  background-color: white;\n  border: solid 1px #aaa;\n  border-top: none;\n  z-index: 1; }\n\n.diva-input-suggestion {\n  box-sizing: border-box;\n  width: 100%;\n  margin-top: 3px;\n  padding: 2px;\n  padding-left: 5px;\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  cursor: pointer; }\n\n.diva-input-suggestion.active, .diva-input-suggestion:hover {\n  background-color: #dfefff; }\n\n.diva-view-menu {\n  display: inline-block;\n  position: relative; }\n\n.diva-view-options {\n  position: absolute;\n  top: 34px;\n  z-index: 1;\n  display: none;\n  box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1); }\n\n.diva-view-options .diva-button {\n  margin-top: -1px;\n  display: block; }\n\n.diva-zoom-label, .diva-grid-label, .diva-page-label {\n  display: inline-block; }\n\n.diva-fullscreen-tools {\n  position: fixed;\n  top: 15px;\n  right: 30px;\n  z-index: 101;\n  padding: 15px;\n  border: 1px solid #DDD;\n  background: #FFF;\n  transition: opacity 0.5s;\n  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);\n  /* prevent variable number of digits in labels from resizing .diva-fullscreen-tools */ }\n  .diva-fullscreen-tools .diva-tools-left, .diva-fullscreen-tools .diva-tools-right {\n    margin-bottom: 0; }\n  .diva-fullscreen-tools .diva-tools-right {\n    margin-left: 2em; }\n  .diva-fullscreen-tools .diva-label, .diva-fullscreen-tools .diva-page-label {\n    margin: 0; }\n  .diva-fullscreen-tools .diva-zoom-label, .diva-fullscreen-tools .diva-grid-label, .diva-fullscreen-tools .diva-page-label {\n    width: 8em;\n    display: block; }\n  .diva-fullscreen-tools .diva-page-nav {\n    margin-right: 0; }\n\n.diva-outer {\n  display: flex;\n  clear: both;\n  background: #F1F1F1;\n  border: 1px solid #AAA;\n  position: relative;\n  overflow: hidden;\n  min-height: 100px;\n  min-width: 200px;\n  flex-grow: 1; }\n\n.diva-viewer-canvas {\n  position: absolute;\n  top: 0;\n  left: 0; }\n\n.diva-viewport {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  right: 0;\n  overflow: auto; }\n\n.diva-inner {\n  cursor: move;\n  /* fallback if grab cursor is unsupported */\n  cursor: grab;\n  cursor: -moz-grab;\n  cursor: -webkit-grab;\n  position: relative;\n  overflow: hidden;\n  margin: 0 auto; }\n  .diva-inner.diva-grabbing {\n    cursor: grabbing;\n    cursor: -moz-grabbing;\n    cursor: -webkit-grabbing; }\n\n.diva-page {\n  box-shadow: 7px 7px 6px -6px rgba(0, 0, 0, 0.3);\n  position: absolute;\n  background-color: #FDFDFD; }\n\n.diva-page-tools-wrapper {\n  position: absolute;\n  z-index: 3; }\n\n.diva-page-tools {\n  position: relative;\n  top: -27px;\n  height: 20px; }\n  .diva-page-tools div {\n    display: inline-block;\n    height: 20px;\n    width: 20px;\n    cursor: pointer;\n    padding: 3px; }\n    .diva-page-tools div svg:hover .diva-pagetool-icon {\n      fill: #006ebc; }\n\n.diva-page-labels-wrapper {\n  position: absolute;\n  z-index: 3; }\n\n.diva-page-labels {\n  position: relative;\n  top: -20px;\n  height: 20px;\n  font-size: 0.8em; }\n\n.diva-fullscreen {\n  width: 100% !important;\n  max-width: 100% !important;\n  height: 100% !important;\n  max-height: 100% !important;\n  z-index: 100;\n  position: fixed !important;\n  top: 0;\n  left: 0;\n  margin: 0;\n  border: 0; }\n\n.diva-popup {\n  background: #FFF;\n  border: 1px solid #AAA;\n  padding: .6em;\n  z-index: 101;\n  position: absolute;\n  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5); }\n\n.diva-link-popup {\n  font-size: 10pt; }\n  .diva-link-popup input {\n    width: 18em; }\n    .diva-link-popup input:focus {\n      outline: none; }\n  .diva-link-popup.in-fullscreen {\n    top: 150px;\n    right: 30px; }\n\n.diva-hide-scrollbar {\n  overflow: hidden !important; }\n\n.diva-slider {\n  position: relative;\n  top: 0.6em;\n  float: left; }\n  @media (max-width: 480px) {\n    .diva-slider {\n      width: 100px; } }\n\n.diva-throbber {\n  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);\n  width: 40px;\n  height: 40px;\n  margin: auto auto;\n  padding: 20px;\n  background-color: #fff;\n  /*\n   * Spinner positions\n   * 1 2 3\n   * 4 5 6\n   * 7 8 9\n   */ }\n  .diva-throbber .cube {\n    width: 33.33%;\n    height: 33.33%;\n    background-color: #333;\n    float: left;\n    animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; }\n  .diva-throbber .cube1 {\n    animation-delay: 0.2s; }\n  .diva-throbber .cube2 {\n    animation-delay: 0.3s; }\n  .diva-throbber .cube3 {\n    animation-delay: 0.4s; }\n  .diva-throbber .cube4 {\n    animation-delay: 0.1s; }\n  .diva-throbber .cube5 {\n    animation-delay: 0.2s; }\n  .diva-throbber .cube6 {\n    animation-delay: 0.3s; }\n  .diva-throbber .cube7 {\n    animation-delay: 0.0s; }\n  .diva-throbber .cube8 {\n    animation-delay: 0.1s; }\n  .diva-throbber .cube9 {\n    animation-delay: 0.2s; }\n\n@keyframes sk-cubeGridScaleDelay {\n  0%, 70%, 100% {\n    transform: scale3D(1, 1, 1); }\n  35% {\n    transform: scale3D(0, 0, 1); } }\n\n.diva-error {\n  position: absolute;\n  width: 400px;\n  height: 200px;\n  background-color: #fff;\n  border: 1px solid #ddd;\n  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);\n  top: 50%;\n  left: 50%;\n  margin-left: -220px;\n  margin-top: -120px;\n  z-index: 120;\n  padding: 0 1em; }\n\n.diva-error-close {\n  width: 18px;\n  height: 18px;\n  border: none;\n  position: absolute;\n  top: 1em;\n  right: 1em; }\n  .diva-error-close:hover {\n    cursor: hand; }\n\n.diva-modal {\n  position: absolute;\n  width: 32em;\n  max-height: 26em;\n  background-color: #fff;\n  border: 1px solid #ddd;\n  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n  z-index: 120;\n  word-wrap: break-word; }\n\n.manipulation-fullscreen {\n  width: 100% !important;\n  max-width: 100% !important;\n  height: 100% !important;\n  max-height: 100% !important;\n  z-index: 100;\n  position: fixed !important;\n  top: 0;\n  left: 0;\n  margin: 0;\n  border: 0;\n  background-color: rgba(0, 0, 0, 0.9);\n  display: flex; }\n\n.manipulation-sidebar {\n  width: 15%;\n  overflow: scroll;\n  text-align: center;\n  padding: 10px; }\n  .manipulation-sidebar .manipulation-sidebar-primary-image,\n  .manipulation-sidebar .manipulation-sidebar-secondary-image {\n    margin: 10px 0;\n    padding-bottom: 10px;\n    border-bottom: 1px solid #fff;\n    color: #fff; }\n\n.manipulation-sidebar-mobile {\n  width: 50%;\n  text-align: center;\n  padding: 10px;\n  display: none; }\n  .manipulation-sidebar-mobile .manipulation-sidebar-primary-image,\n  .manipulation-sidebar-mobile .manipulation-sidebar-secondary-image {\n    margin: 10px 0;\n    padding-bottom: 10px;\n    border-bottom: 1px solid #fff;\n    color: #fff; }\n\n.manipulation-main-area {\n  width: 70%;\n  flex: 1 1 auto;\n  background-color: rgba(255, 255, 255, 0.5);\n  overflow: scroll;\n  text-align: center;\n  cursor: move;\n  /* fallback if grab cursor is unsupported */\n  cursor: grab;\n  cursor: -moz-grab;\n  cursor: -webkit-grab; }\n  .manipulation-main-area.grabbing {\n    cursor: grabbing;\n    cursor: -moz-grabbing;\n    cursor: -webkit-grabbing; }\n  .manipulation-main-area canvas {\n    margin: 0 auto; }\n\n.manipulation-main-area-mobile {\n  width: 100%;\n  background-color: rgba(255, 255, 255, 0.5);\n  overflow: scroll;\n  text-align: center;\n  cursor: move;\n  /* fallback if grab cursor is unsupported */\n  cursor: grab;\n  cursor: -moz-grab;\n  cursor: -webkit-grab; }\n  .manipulation-main-area-mobile.grabbing {\n    cursor: grabbing;\n    cursor: -moz-grabbing;\n    cursor: -webkit-grabbing; }\n  .manipulation-main-area-mobile canvas {\n    margin: 0 auto; }\n\n.manipulation-tools {\n  width: 15%;\n  flex: 1 1 auto;\n  overflow: auto; }\n  .manipulation-tools .manipulation-tools-text {\n    color: #FBF7F6;\n    margin-bottom: 0.7em; }\n\n.manipulation-tools-mobile {\n  width: 50%;\n  flex: 1 1 auto;\n  overflow: auto;\n  display: none; }\n  .manipulation-tools-mobile .manipulation-tools-text {\n    color: #FBF7F6;\n    margin-bottom: 0.7em; }\n\n.burger-menu {\n  position: fixed;\n  top: 0.5em;\n  left: 0.5em;\n  cursor: pointer; }\n  .burger-menu .stripe {\n    width: 2em;\n    height: 0.3em;\n    background-color: #fff5ef;\n    margin: 0.2em 0; }\n\ninput[type=range] {\n  -webkit-appearance: none;\n  width: 100%;\n  margin: 4.5px 0; }\n\ninput[type=range]:focus {\n  outline: none; }\n\ninput[type=range]::-webkit-slider-runnable-track {\n  width: 100%;\n  height: 5px;\n  cursor: pointer;\n  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32);\n  background: rgba(255, 255, 255, 0.66);\n  border-radius: 25px;\n  border: 0px solid rgba(1, 1, 1, 0); }\n\ninput[type=range]::-webkit-slider-thumb {\n  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);\n  border: 0.9px solid rgba(0, 0, 30, 0.42);\n  height: 13px;\n  width: 13px;\n  border-radius: 10px;\n  background: #ffffff;\n  cursor: pointer;\n  -webkit-appearance: none;\n  margin-top: -4.5px; }\n\ninput[type=range]:focus::-webkit-slider-runnable-track {\n  background: rgba(253, 133, 243, 0.66); }\n\ninput[type=range]::-moz-range-track {\n  width: 100%;\n  height: 5px;\n  cursor: pointer;\n  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32);\n  background: rgba(255, 255, 255, 0.66);\n  border-radius: 25px;\n  border: 0px solid rgba(1, 1, 1, 0); }\n\ninput[type=range]::-moz-range-thumb {\n  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);\n  border: 0.9px solid rgba(0, 0, 30, 0.42);\n  height: 13px;\n  width: 13px;\n  border-radius: 10px;\n  background: #ffffff;\n  cursor: pointer; }\n\ninput[type=range]::-ms-track {\n  width: 100%;\n  height: 4px;\n  cursor: pointer;\n  background: transparent;\n  border-color: transparent;\n  color: transparent; }\n\ninput[type=range]::-ms-fill-lower {\n  background: rgba(251, 83, 239, 0.66);\n  border: 0px solid rgba(1, 1, 1, 0);\n  border-radius: 50px;\n  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32); }\n\ninput[type=range]::-ms-fill-upper {\n  background: rgba(252, 108, 241, 0.66);\n  border: 0px solid rgba(1, 1, 1, 0);\n  border-radius: 50px;\n  box-shadow: 0.4px 0.4px 2.4px rgba(0, 0, 0, 0.32), 0px 0px 0.4px rgba(13, 13, 13, 0.32); }\n\ninput[type=range]::-ms-thumb {\n  box-shadow: 1px 1px 6.2px rgba(0, 0, 49, 0.66), 0px 0px 1px rgba(0, 0, 75, 0.66);\n  border: 0.9px solid rgba(0, 0, 30, 0.42);\n  height: 13px;\n  width: 13px;\n  border-radius: 10px;\n  background: #ffffff;\n  cursor: pointer;\n  height: 4px; }\n\ninput[type=range]:focus::-ms-fill-lower {\n  background: rgba(252, 108, 241, 0.66); }\n\ninput[type=range]:focus::-ms-fill-upper {\n  background: rgba(253, 133, 243, 0.66); }\n\n#metadata-content {\n  overflow-y: auto;\n  max-height: 20em;\n  padding: 2em; }\n\n#metadata-content dl dt {\n  font-weight: bold; }\n\n#metadata-content dl dd {\n  margin-left: 0;\n  margin-bottom: 1em; }\n\n#metadata-title {\n  margin: 0;\n  text-align: center; }\n\n.close-button {\n  position: absolute;\n  right: 1em;\n  top: 1em; }\n\n.close-button:hover {\n  color: tomato; }\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;","sourceRoot":""}
\ No newline at end of file
--- a/src/main/webapp/imageServer/resources/js/diva.js	Mon Jul 01 15:05:05 2019 +0200
+++ b/src/main/webapp/imageServer/resources/js/diva.js	Fri Jul 05 16:05:57 2019 +0200
@@ -1,2592 +1,9 @@
-window.divaPlugins = [];
-
-// this pattern was taken from http://www.virgentech.com/blog/2009/10/building-object-oriented-jquery-plugin.html
-(function ($)
-{
-    var Diva = function (element, options)
-    {
-        // These are elements that can be overridden upon instantiation
-        // See https://github.com/DDMAL/diva.js/wiki/Code-documentation for more details
-        var defaults = {
-            adaptivePadding: 0.05, // The ratio of padding to the page dimension
-            blockMobileMove: true, // Prevent moving or scrolling the page on mobile devices
-            contained: false, // Determines the location of the fullscreen icon
-            objectData: '', // URL to the JSON file that provides the object dimension data - *MANDATORY*
-            enableAutoHeight: false, // Automatically adjust height based on the window size
-            enableAutoTitle: true, // Shows the title within a div of id diva-title
-            enableAutoWidth: true, // Automatically adjust width based on the window size
-            enableCanvas: true, // Used for the canvas plugin
-            enableDownload: true, // Used for the download plugin
-            enableFilename: true, // Uses filenames and not page numbers for links (i=bm_001.tif, not p=1)
-            enableFullscreen: true, // Enable or disable fullscreen icon (mode still available)
-            enableGotoPage: true, // A "go to page" jump box
-            enableGridIcon: true, // A grid view of all the pages
-            enableGridSlider: true, // Slider to control the pages per grid row
-            enableKeyScroll: true, // Scrolling using the page up/down keys
-            enableLinkIcon: true, // Controls the visibility of the link icon
-            enableSpaceScroll: false, // Scrolling down by pressing the space key
-            enableToolbar: true, // Enables the toolbar. Note that disabling this means you have to handle all controls yourself.
-            enableZoomSlider: true, // Enable or disable the zoom slider (for zooming in and out)
-            fixedPadding: 10, // Fallback if adaptive padding is set to 0
-            fixedHeightGrid: true, // So each page in grid view has the same height (only widths differ)
-            goDirectlyTo: 0, // Default initial page to show (0-indexed)
-            iipServerURL: '', // The URL to the IIPImage installation, including the `?FIF=` - *MANDATORY*
-            inFullscreen: false, // Set to true to load fullscreen mode initially
-            inGrid: false, // Set to true to load grid view initially
-            imageDir: '', // Image directory, either absolute path or relative to IIP's FILESYSTEM_PREFIX - *MANDATORY*
-            maxPagesPerRow: 8, // Maximum number of pages per row, grid view
-            maxZoomLevel: -1, // Optional; defaults to the max zoom returned in the JSON response
-            minPagesPerRow: 2, // 2 for the spread view. Recommended to leave it
-            minZoomLevel: 0, // Defaults to 0 (the minimum zoom)
-            onDocumentLoaded: null, // Callback function for when the document is fully loaded
-            onModeToggle: null, // Callback for toggling fullscreen mode
-            onViewToggle: null, // Callback for switching between grid and document view
-            onJump: null, // Callback function for jumping to a specific page (using the gotoPage feature)
-            onPageLoad: null, // Callback function for loading pages
-            onPageLoaded: null, // Callback function for after the page has been loaded
-            onReady: null, // Callback function for initial load
-            onScroll: null, // Callback function for scrolling
-            onScrollDown: null, // Callback function for scrolling down, only
-            onScrollUp: null, // Callback function for scrolling up only
-            onSetCurrentPage: null, // Callback function for when the current page is set
-            onZoom: null, // Callback function for zooming in general
-            onZoomIn: null, // Callback function for zooming in only
-            onZoomOut: null, // Callback function for zooming out only
-            pageLoadTimeout: 200, // Number of milliseconds to wait before loading pages
-            pagesPerRow: 5, // The default number of pages per row in grid view
-            rowLoadTimeout: 50, // Number of milliseconds to wait before loading a row
-            throbberTimeout: 100, // Number of milliseconds to wait before showing throbber
-            tileHeight: 256, // The height of each tile, in pixels; usually 256
-            tileWidth: 256, // The width of each tile, in pixels; usually 256
-            toolbarParentSelector: null, // The toolbar parent selector. If null, it defaults to the primary diva element. Must be a jQuery selector (leading '#')
-            viewerHeightPadding: 15, // Vertical padding when resizing the viewer, if enableAutoHeight is set
-            viewerWidthPadding: 30, // Horizontal padding when resizing the viewer, if enableAutoHeight is set
-            viewportMargin: 200, // Pretend tiles +/- 200px away from viewport are in
-            zoomLevel: 2 // The initial zoom level (used to store the current zoom level)
-        };
-
-        // Apply the defaults, or override them with passed-in options.
-        var settings = $.extend({}, defaults, options);
-
-        // Things that cannot be changed because of the way they are used by the script
-        // Many of these are declared with arbitrary values that are changed later on
-        var globals = {
-            allTilesLoaded: [], // A boolean for each page, indicating if all tiles have been loaded
-            averageHeights: [], // The average page height for each zoom level
-            averageWidths: [], // The average page width for each zoom level
-            currentPageIndex: 0, // The current page in the viewport (center-most page)
-            dimAfterZoom: 0, // Used for storing the item dimensions after zooming
-            firstPageLoaded: -1, // The ID of the first page loaded (value set later)
-            firstRowLoaded: -1, // The index of the first row loaded
-            gridPageWidth: 0, // Holds the max width of each row in grid view. Calculated in loadGrid()
-            hashParamSuffix: '', // Used when there are multiple document viewers on a page
-            heightAbovePages: [], // The height above each page at the current zoom level
-            horizontalOffset: 0, // Used in documentScroll for scrolling more precisely
-            horizontalPadding: 0, // Either the fixed padding or adaptive padding
-            ID: null, // The prefix of the IDs of the elements (usually 1-diva-)
-            innerSelector: '', // settings.selector + 'inner', for selecting the .diva-inner element
-            itemTitle: '', // The title of the document
-            lastPageLoaded: -1, // The ID of the last page loaded (value set later)
-            lastRowLoaded: -1, // The index of the last row loaded
-            leftScrollSoFar: 0, // Current scroll from the left edge of the pane
-            loaded: false, // A flag for when everything is loaded and ready to go.
-            maxWidths: [], // The width of the widest page for each zoom level
-            maxRatio: 0, // The max height/width ratio (for grid view)
-            minHeight: 0, // Minimum height of the .diva-outer element, as defined in the CSS
-            minRatio: 0, // The minimum height/width ratio for a page
-            minWidth: 0, // Minimum width of the .diva-outer element, as defined in the CSS
-            mobileWebkit: false, // Checks if the user is on a touch device (iPad/iPod/iPhone/Android)
-            numPages: 0, // Number of pages in the array
-            numRows: 0, // Number of rows
-            oldPagesPerRow: 0, // Holds the previous number of pages per row after it is changed
-            oldZoomLevel: -1, // Holds the previous zoom level after zooming in or out
-            orientationChange: false, // For handling device orientation changes for touch devices
-            originalHeight: 0, // Stores the original height of the .diva-outer element
-            originalWidth: 0, // Stores the original width of the .diva-outer element
-            outerSelector: '', // settings.selector + 'outer', for selecting the .diva-outer element
-            pages: [], // An array containing the data for all the pages
-            pageLeftOffsets: [], // Offset from the left side of the pane to the edge of the page
-            pageTimeouts: [], // Stack to hold the loadPage timeouts
-            pageTools: '', // The string for page tools
-            panelHeight: 0, // Height of the document viewer pane
-            panelWidth: 0, // Width of the document viewer pane
-            plugins: [], // Filled with the enabled plugins from window.divaPlugins
-            previousTopScroll: 0, // Used to determine vertical scroll direction
-            preZoomOffset: null, // Holds the offset prior to zooming when double-clicking
-            realMaxZoom: -1, // To hold the true max zoom level of the document (needed for calculations)
-            resizeTimer: -1, // Holds the ID of the timeout used when resizing the window (for clearing)
-            rowHeight: 0, // Holds the max height of each row in grid view. Calculated in loadGrid()
-            scaleWait: false, // For preventing double-zoom on touch devices (iPad, etc)
-            selector: '', // Uses the generated ID prefix to easily select elements
-            singleClick: false, // Used for catching ctrl+double-click events in Firefox in Mac OS
-            scrollbarWidth: 0, // Set to the actual scrollbar width in init()
-            throbberTimeoutID: -1, // Holds the ID of the throbber loading timeout
-            toolbar: null, // Holds an object with some toolbar-related functions
-            topScrollSoFar: 0, // Holds the number of pixels of vertical scroll
-            totalHeights: [], // The total height of all pages (stacked together) for each zoom level
-            totalHeight: 0, // The total height for the current zoom level (including padding)
-            verticalOffset: 0, // See horizontalOffset
-            verticalPadding: 0, // Either the fixed padding or adaptive padding
-            viewerXOffset: 0, // Distance between left edge of viewer and document left edge
-            viewerYOffset: 0 // Like viewerXOffset but for the top edges
-        };
-
-        $.extend(settings, globals);
-
-        // Executes a callback function with the diva instance set as the context
-        // Can take an unlimited number to arguments to pass to the callback function
-        var self = this;
-
-        var executeCallback = function (callback)
-        {
-            var args, i, length;
-
-            if (typeof callback === "function")
-            {
-                args = [];
-                for (i = 1, length = arguments.length; i < length; i++)
-                {
-                    args.push(arguments[i]);
-                }
-
-                callback.apply(self, args);
-
-                return true;
-            }
-
-            return false;
-        };
-
-        var getPageData = function (pageIndex, attribute)
-        {
-            return settings.pages[pageIndex].d[settings.zoomLevel][attribute];
-        };
-
-        // Returns the page index associated with the given filename; must called after settings settings.pages
-        var getPageIndex = function (filename)
-        {
-            var i,
-                np = settings.numPages;
-
-            for (i = 0; i < np; i++)
-            {
-                if (settings.pages[i].f === filename)
-                {
-                    return i;
-                }
-            }
-
-            return -1;
-        };
-
-        // Checks if a tile is within the viewport horizontally
-        var isHorizontallyInViewport = function (left, right)
-        {
-            var panelWidth = settings.panelWidth;
-            var leftOfViewport = settings.leftScrollSoFar - settings.viewportMargin;
-            var rightOfViewport = leftOfViewport + panelWidth + settings.viewportMargin * 2;
-
-            var leftVisible = left >= leftOfViewport && left <= rightOfViewport;
-            var rightVisible = right >= leftOfViewport && right <= rightOfViewport;
-            var middleVisible = left <= leftOfViewport && right >= rightOfViewport;
-
-            return (leftVisible || middleVisible || rightVisible);
-        };
-
-        // Checks if a page or tile is within the viewport vertically
-        var isVerticallyInViewport = function (top, bottom)
-        {
-            var panelHeight = settings.panelHeight;
-            var topOfViewport = settings.topScrollSoFar - settings.viewportMargin;
-            var bottomOfViewport = topOfViewport + panelHeight + settings.viewportMargin * 2;
-
-            var topVisible = top >= topOfViewport && top <= bottomOfViewport;
-            var middleVisible = top <= topOfViewport && bottom >= bottomOfViewport;
-            var bottomVisible = bottom >= topOfViewport && bottom <= bottomOfViewport;
-
-            return (topVisible || middleVisible || bottomVisible);
-        };
-
-        // Check if a tile is near the viewport and thus should be loaded
-        var isTileVisible = function (pageIndex, tileRow, tileCol)
-        {
-            var tileTop = settings.heightAbovePages[pageIndex] + (tileRow * settings.tileHeight) + settings.verticalPadding;
-            var tileBottom = tileTop + settings.tileHeight;
-            var tileLeft = settings.pageLeftOffsets[pageIndex] + (tileCol * settings.tileWidth);
-            var tileRight = tileLeft + settings.tileWidth;
-
-            return isVerticallyInViewport(tileTop, tileBottom) && isHorizontallyInViewport(tileLeft, tileRight);
-        };
-
-        // Check if a tile has been appended to the DOM
-        var isTileLoaded = function (pageIndex, tileIndex)
-        {
-            return document.getElementById(settings.ID + 'tile-' + pageIndex + '-' + tileIndex) === false;
-        };
-
-        // Check if a page index is valid
-        var isPageValid = function (pageIndex)
-        {
-            return pageIndex >= 0 && pageIndex < settings.numPages;
-        };
-
-        // Check if a page is in or near the viewport and thus should be loaded
-        var isPageVisible = function (pageIndex)
-        {
-            var topOfPage = settings.heightAbovePages[pageIndex];
-            var bottomOfPage = topOfPage + getPageData(pageIndex, 'h') + settings.verticalPadding;
-
-            return isVerticallyInViewport(topOfPage, bottomOfPage);
-        };
-
-        // Check if a page has been appended to the DOM
-        var isPageLoaded = function (pageIndex)
-        {
-            return $(document.getElementById(settings.ID + 'page-' + pageIndex)).length > 0;
-        };
-
-        // Appends the page directly into the document body, or loads the relevant tiles
-        var loadPage = function (pageIndex)
-        {
-            // If the page and all of its tiles have been loaded, exit
-            if (isPageLoaded(pageIndex) && settings.allTilesLoaded[pageIndex])
-            {
-                return;
-            }
-
-            // Load some data for this page
-            var filename = settings.pages[pageIndex].f;
-            var width = getPageData(pageIndex, 'w');
-            var height = getPageData(pageIndex, 'h');
-            var heightFromTop = settings.heightAbovePages[pageIndex] + settings.verticalPadding;
-            var pageSelector = settings.selector + 'page-' + pageIndex;
-            var plugin;
-
-            // If the page has not been loaded yet, append the div to the DOM
-            if (!isPageLoaded(pageIndex))
-            {
-                $(document.getElementById(settings.ID + "inner")).append('<div id="' + settings.ID + 'page-' + pageIndex + '" style="top: ' + heightFromTop + 'px; width: ' + width + 'px; height: ' + height + 'px;" class="diva-document-page" title="Page ' + (pageIndex + 1) + '" data-index="' + pageIndex + '" data-filename="' + filename + '">' + settings.pageTools + '</div>');
-
-                // Call the callback function
-                executeCallback(settings.onPageLoad, pageIndex, filename, pageSelector);
-                Events.publish("PageHasLoaded", [pageIndex, filename, pageSelector]);
-
-                // @TODO: Replace this with a notification.
-                // Execute the callback functions for any of the enabled plugins
-                for (plugin in settings.plugins) {
-                    executeCallback(settings.plugins[plugin].onPageLoad, pageIndex, filename, pageSelector);
-                }
-            }
-
-            // There are still tiles to load, so try to load those (after a delay)
-            settings.pageTimeouts.push(setTimeout(function ()
-            {
-                // If the page is no longer in the viewport, don't load any tiles
-                if (!isPageVisible(pageIndex))
-                {
-                    return;
-                }
-
-                var imdir = settings.imageDir + "/";
-                // Load some more data and initialise some variables
-                var rows = getPageData(pageIndex, 'r');
-                var cols = getPageData(pageIndex, 'c');
-                var maxZoom = settings.pages[pageIndex].m;
-                var baseURL = settings.iipServerURL + "?FIF=" + imdir + filename + '&JTL=';
-                var content = [];
-                var allTilesLoaded = true;
-                var tileIndex = 0;
-                var i;
-
-                // Calculate the width and height of outer tiles (non-standard dimensions)
-                var lastHeight = height - (rows - 1) * settings.tileHeight;
-                var lastWidth = width - (cols - 1) * settings.tileWidth;
-
-                // Declare variables used within the loops
-                var row, col, tileHeight, tileWidth, top, left, displayStyle, zoomLevel, imageURL;
-
-                // Adjust the zoom level based on the max zoom level of the page
-                zoomLevel = settings.zoomLevel + maxZoom - settings.realMaxZoom;
-                baseImageURL = baseURL + zoomLevel + ',';
-
-                // Loop through all the tiles in this page
-                row = 0;
-                while (row < rows)
-                {
-                    col = 0;
-                    while (col < cols)
-                    {
-                        top = row * settings.tileHeight;
-                        left = col * settings.tileWidth;
-
-                        // If the tile is in the last row or column, its dimensions will be different
-                        tileHeight = (row === rows - 1) ? lastHeight : settings.tileHeight;
-                        tileWidth = (col === cols - 1) ? lastWidth : settings.tileWidth;
-
-                        imageURL = baseImageURL + tileIndex;
-
-                        // this check looks to see if the tile is already loaded, and then if
-                        // it isn't, if it should be visible.
-                        if (!isTileLoaded(pageIndex, tileIndex)) {
-                            if (isTileVisible(pageIndex, row, col)) {
-                                content.push('<div id="' + settings.ID + 'tile-' + pageIndex + '-' + tileIndex + '" style="display:inline; position: absolute; top: ' + top + 'px; left: ' + left + 'px; background-image: url(\'' + imageURL + '\'); height: ' + tileHeight + 'px; width: ' + tileWidth + 'px;"></div>');
-                            } else {
-                                // The tile does not need to be loaded - not all have been loaded
-                                allTilesLoaded = false;
-                            }
-                        }
-                        tileIndex++;
-                        col++;
-                    }
-                    row++;
-                }
-
-                settings.allTilesLoaded[pageIndex] = allTilesLoaded;
-                $(document.getElementById(settings.ID + 'page-' + pageIndex)).append(content.join(''));
-
-                executeCallback(settings.onPageLoaded, pageIndex, filename, pageSelector);
-
-            }, settings.pageLoadTimeout));
-        };
-
-        // Delete a page from the DOM; will occur when a page is scrolled out of the viewport
-        var deletePage = function (pageIndex)
-        {
-            $(document.getElementById(settings.ID + 'page-' + pageIndex)).empty().remove();
-        };
-
-        // Check if the bottom of a page is above the top of a viewport (scrolling down)
-        // For when you want to keep looping but don't want to load a specific page
-        var pageAboveViewport = function (pageIndex)
-        {
-            var bottomOfPage = settings.heightAbovePages[pageIndex] + getPageData(pageIndex, 'h') + settings.verticalPadding;
-            var topOfViewport = settings.topScrollSoFar;
-
-            return bottomOfPage < topOfViewport;
-        };
-
-        // Check if the top of a page is below the bottom of a viewport (scrolling up)
-        var pageBelowViewport = function (pageIndex)
-        {
-            var topOfPage = settings.heightAbovePages[pageIndex];
-            var bottomOfViewport = settings.topScrollSoFar + settings.panelHeight;
-
-            return topOfPage > bottomOfViewport;
-        };
-
-        // Called by adjust pages - determine what pages should be visible, and show them
-        var attemptPageShow = function (pageIndex, direction)
-        {
-            if (direction > 0)
-            {
-                // Direction is positive - we're scrolling down
-                if (isPageValid(pageIndex))
-                {
-                    // If the page should be visible, then yes, add it
-                    if (isPageVisible(pageIndex))
-                    {
-                        loadPage(pageIndex);
-
-                        settings.lastPageLoaded = pageIndex;
-
-                        // Recursively call this function until there's nothing to add
-                        attemptPageShow(settings.lastPageLoaded + 1, direction);
-                    }
-                    else if (pageAboveViewport(pageIndex))
-                    {
-                        // If the page is below the viewport. try to load the next one
-                        attemptPageShow(pageIndex + 1, direction);
-                    }
-                }
-            }
-            else
-            {
-                // Direction is negative - we're scrolling up
-                if (isPageValid(pageIndex))
-                {
-                    // If it's near the viewport, yes, add it
-                    if (isPageVisible(pageIndex))
-                    {
-                        loadPage(pageIndex);
-
-                        // Reset the first page loaded to this one
-                        settings.firstPageLoaded = pageIndex;
-
-                        // Recursively call this function until there's nothing to add
-                        attemptPageShow(settings.firstPageLoaded - 1, direction);
-                    }
-                    else if (pageBelowViewport(pageIndex))
-                    {
-                        // Attempt to call this on the next page, do not increment anything
-                        attemptPageShow(pageIndex - 1, direction);
-                    }
-                }
-            }
-        };
-
-        // Called by adjustPages - see what pages need to be hidden, and hide them
-        var attemptPageHide = function (pageIndex, direction)
-        {
-            if (direction > 0)
-            {
-                // Scrolling down - see if this page needs to be deleted from the DOM
-                if (isPageValid(pageIndex) && pageAboveViewport(pageIndex))
-                {
-                    // Yes, delete it, reset the first page loaded
-                    deletePage(pageIndex);
-                    settings.firstPageLoaded = pageIndex + 1;
-
-                    // Try to call this function recursively until there's nothing to delete
-                    attemptPageHide(settings.firstPageLoaded, direction);
-                }
-            }
-            else
-            {
-                // Direction must be negative (not 0 - see adjustPages), we're scrolling up
-                if (isPageValid(pageIndex) && pageBelowViewport(pageIndex))
-                {
-                    // Yes, delete it, reset the last page loaded
-                    deletePage(pageIndex);
-                    settings.lastPageLoaded = pageIndex - 1;
-
-                    // Try to call this function recursively until there's nothing to delete
-                    attemptPageHide(settings.lastPageLoaded, direction);
-                }
-            }
-        };
-
-        // Handles showing and hiding pages when the user scrolls
-        var adjustPages = function (direction)
-        {
-            var i;
-
-            // Direction is negative, so we're scrolling up
-            if (direction < 0)
-            {
-                attemptPageShow(settings.firstPageLoaded, direction);
-                setCurrentPage(-1);
-                attemptPageHide(settings.lastPageLoaded, direction);
-            }
-            else if (direction > 0)
-            {
-                // Direction is positive so we're scrolling down
-                attemptPageShow(settings.lastPageLoaded, direction);
-                setCurrentPage(1);
-                attemptPageHide(settings.firstPageLoaded, direction);
-            }
-            else
-            {
-                // Horizontal scroll, check if we need to reveal any tiles
-                var lpl = settings.lastPageLoaded;
-                for (i = Math.max(settings.firstPageLoaded, 0); i <= lpl; i++)
-                {
-                    if (isPageVisible(i))
-                    {
-                        loadPage(i);
-                    }
-                }
-            }
-
-            executeCallback(settings.onScroll, settings.topScrollSoFar);
-
-            // If we're scrolling down
-            if (direction > 0)
-            {
-                executeCallback(settings.onScrollDown, settings.topScrollSoFar);
-            }
-            else if (direction < 0)
-            {
-                // We're scrolling up
-                executeCallback(settings.onScrollUp, settings.topScrollSoFar);
-            }
-        };
-
-        // Check if a row index is valid
-        var isRowValid = function (rowIndex)
-        {
-            return rowIndex >= 0 && rowIndex < settings.numRows;
-        };
-
-        // Check if a row should be visible in the viewport
-        var isRowVisible = function (rowIndex)
-        {
-            var topOfRow = settings.rowHeight * rowIndex;
-            var bottomOfRow = topOfRow + settings.rowHeight + settings.fixedPadding;
-
-            return isVerticallyInViewport(topOfRow, bottomOfRow);
-        };
-
-        // Check if a row (in grid view) is present in the DOM
-        var isRowLoaded = function (rowIndex)
-        {
-            return $(settings.selector + 'row-' + rowIndex).length > 0;
-        };
-
-        var loadRow = function (rowIndex)
-        {
-            // If the row has already been loaded, don't attempt to load it again
-            if (isRowLoaded(rowIndex))
-            {
-                return;
-            }
-
-            // Load some data for this and initialise some variables
-            var heightFromTop = (settings.rowHeight * rowIndex) + settings.fixedPadding;
-            var content = [];
-
-            // Create the opening tag for the row div
-            content.push('<div class="diva-row" id="' + settings.ID + 'row-' + rowIndex + '" style="height: ' + settings.rowHeight + '; top: ' + heightFromTop + 'px;">');
-
-            // Declare variables used in the loop
-            var i, pageIndex, filename, realWidth, realHeight, pageWidth, pageHeight, leftOffset, imageURL;
-            var imdir = settings.imageDir + "/";
-
-            // Load each page within that row
-            var ppr = settings.pagesPerRow;
-            for (i = 0; i < ppr; i++)
-            {
-                pageIndex = rowIndex * settings.pagesPerRow + i;
-
-                // If this page is the last row, don't try to load a nonexistent page
-                if (!isPageValid(pageIndex))
-                {
-                    break;
-                }
-
-                // Calculate the width, height and horizontal placement of this page
-                filename = settings.pages[pageIndex].f;
-                realWidth = getPageData(pageIndex, 'w');
-                realHeight = getPageData(pageIndex, 'h');
-                pageWidth = (settings.fixedHeightGrid) ? (settings.rowHeight - settings.fixedPadding) * realWidth / realHeight : settings.gridPageWidth;
-                pageHeight = (settings.fixedHeightGrid) ? settings.rowHeight - settings.fixedPadding : pageWidth / realWidth * realHeight;
-                leftOffset = parseInt(i * (settings.fixedPadding + settings.gridPageWidth) + settings.fixedPadding, 10);
-
-                // Make sure they're all integers for nice, round numbers
-                pageWidth = parseInt(pageWidth, 10);
-                pageHeight = parseInt(pageHeight, 10);
-
-                // Center the page if the height is fixed (otherwise, there is no horizontal padding)
-                leftOffset += (settings.fixedHeightGrid) ? (settings.gridPageWidth - pageWidth) / 2 : 0;
-                imageURL = settings.iipServerURL + "?FIF=" + imdir + filename + '&amp;HEI=' + (pageHeight + 2) + '&amp;CVT=JPEG';
-
-                // Append the HTML for this page to the string builder array
-                content.push('<div id="' + settings.ID + 'page-' + pageIndex + '" class="diva-page" style="width: ' + pageWidth + 'px; height: ' + pageHeight + 'px; left: ' + leftOffset + 'px;" title="Page ' + (pageIndex + 1) + '"></div>');
-
-                // Add each image to a queue so that images aren't loaded unnecessarily
-                addPageToQueue(rowIndex, pageIndex, imageURL, pageWidth, pageHeight);
-            }
-
-            // Append this row to the DOM
-            content.push('</div>');
-            $(document.getElementById(settings.ID + "inner")).append(content.join(''));
-        };
-
-        var deleteRow = function (rowIndex)
-        {
-            $(document.getElementById(settings.ID + 'row-' + rowIndex)).empty().remove();
-        };
-
-        // Check if the bottom of a row is above the top of the viewport (scrolling down)
-        var rowAboveViewport = function (rowIndex)
-        {
-            var bottomOfRow = settings.rowHeight * (rowIndex + 1);
-            var topOfViewport = settings.topScrollSoFar;
-
-            return (bottomOfRow < topOfViewport);
-        };
-
-        // Check if the top of a row is below the bottom of the viewport (scrolling up)
-        var rowBelowViewport = function (rowIndex)
-        {
-            var topOfRow = settings.rowHeight * rowIndex;
-            var bottomOfViewport = settings.topScrollSoFar + settings.panelHeight;
-
-            return (topOfRow > bottomOfViewport);
-        };
-
-        // Same thing as attemptPageShow only with rows
-        var attemptRowShow = function (rowIndex, direction)
-        {
-            if (direction > 0)
-            {
-                if (isRowValid(rowIndex))
-                {
-                    if (isRowVisible(rowIndex))
-                    {
-                        loadRow(rowIndex);
-                        settings.lastRowLoaded = rowIndex;
-
-                        attemptRowShow(settings.lastRowLoaded + 1, direction);
-                    }
-                    else if (rowAboveViewport(rowIndex))
-                    {
-                        attemptRowShow(rowIndex + 1, direction);
-                    }
-                }
-            }
-            else
-            {
-                if (isRowValid(rowIndex))
-                {
-                    if (isRowVisible(rowIndex))
-                    {
-                        loadRow(rowIndex);
-                        settings.firstRowLoaded = rowIndex;
-
-                        attemptRowShow(settings.firstRowLoaded - 1, direction);
-                    }
-                    else if (rowBelowViewport(rowIndex))
-                    {
-                        attemptRowShow(rowIndex - 1, direction);
-                    }
-                }
-            }
-        };
-
-        var attemptRowHide = function (rowIndex, direction)
-        {
-            if (direction > 0)
-            {
-                if (isRowValid(rowIndex) && rowAboveViewport(rowIndex))
-                {
-                    deleteRow(rowIndex);
-                    settings.firstRowLoaded++;
-
-                    attemptRowHide(settings.firstRowLoaded, direction);
-                }
-            }
-            else
-            {
-                if (isRowValid(rowIndex) && rowBelowViewport(rowIndex))
-                {
-                    deleteRow(rowIndex);
-                    settings.lastRowLoaded--;
-
-                    attemptRowHide(settings.lastRowLoaded, direction);
-                }
-            }
-        };
-
-        var adjustRows = function (direction)
-        {
-            if (direction < 0)
-            {
-                attemptRowShow(settings.firstRowLoaded, -1);
-                setCurrentRow(-1);
-                attemptRowHide(settings.lastRowLoaded, -1);
-            }
-            else if (direction > 0)
-            {
-                attemptRowShow(settings.lastRowLoaded, 1);
-                setCurrentRow(1);
-                attemptRowHide(settings.firstRowLoaded, 1);
-            }
-
-            executeCallback(settings.onScroll, settings.topScrollSoFar);
-
-            // If we're scrolling down
-            if (direction > 0)
-            {
-                executeCallback(settings.onScrollDown, settings.topScrollSoFar);
-            }
-            else if (direction < 0)
-            {
-                // We're scrolling up
-                executeCallback(settings.onScrollUp, settings.topScrollSoFar);
-            }
-        };
-
-        // Used to delay loading of page images in grid view to prevent unnecessary loads
-        var addPageToQueue = function (rowIndex, pageIndex, imageURL, pageWidth, pageHeight)
-        {
-            settings.pageTimeouts.push(setTimeout(function ()
-            {
-                if (isRowVisible(rowIndex))
-                {
-                    $(settings.selector + 'page-' + pageIndex).html('<img src="' + imageURL + '" style="width: ' + pageWidth + 'px; height: ' + pageHeight + 'px;" />');
-                }
-            }, settings.rowLoadTimeout));
-        };
-
-        // Determines and sets the "current page" (settings.currentPageIndex); called within adjustPages
-        // The "direction" is either 1 (downward scroll) or -1 (upward scroll)
-        var setCurrentPage = function (direction)
-        {
-            var middleOfViewport = settings.topScrollSoFar + (settings.panelHeight / 2);
-            var currentPage = settings.currentPageIndex;
-            var pageToConsider = settings.currentPageIndex + direction;
-            var changeCurrentPage = false;
-            var pageSelector = settings.selector + 'page-' + pageToConsider;
-
-            // When scrolling up:
-            if (direction < 0)
-            {
-                // If the previous page > middle of viewport
-                if (pageToConsider >= 0 && (settings.heightAbovePages[pageToConsider] + getPageData(pageToConsider, 'h') + (settings.verticalPadding) >= middleOfViewport))
-                {
-                    changeCurrentPage = true;
-                }
-            }
-            else if (direction > 0)
-            {
-                // When scrolling down:
-                // If this page < middle of viewport
-                if (settings.heightAbovePages[currentPage] + getPageData(currentPage, 'h') + settings.verticalPadding < middleOfViewport)
-                {
-                    changeCurrentPage = true;
-                }
-            }
-
-            if (changeCurrentPage)
-            {
-                // Set this to the current page
-                settings.currentPageIndex = pageToConsider;
-                // Now try to change the next page, given that we're not going to a specific page
-                // Calls itself recursively - this way we accurately obtain the current page
-                if (direction !== 0)
-                {
-                    if (!setCurrentPage(direction))
-                    {
-                        var filename = settings.pages[pageToConsider].f;
-                        executeCallback(settings.onSetCurrentPage, pageToConsider, filename);
-                        Events.publish("VisiblePageDidChange", [pageToConsider, filename]);
-                    }
-                }
-                return true;
-            }
-
-            return false;
-        };
-
-        // Sets the current page in grid view
-        var setCurrentRow = function (direction)
-        {
-            var currentRow = Math.floor(settings.currentPageIndex / settings.pagesPerRow);
-            var rowToConsider = currentRow + parseInt(direction, 10);
-            var middleOfViewport = settings.topScrollSoFar + (settings.panelHeight / 2);
-            var changeCurrentRow = false;
-
-            if (direction < 0)
-            {
-                if (rowToConsider >= 0 && (settings.rowHeight * currentRow >= middleOfViewport || settings.rowHeight * rowToConsider >= settings.topScrollSoFar))
-                {
-                    changeCurrentRow = true;
-                }
-            }
-            else if (direction > 0)
-            {
-                if ((settings.rowHeight * (currentRow + 1)) < settings.topScrollSoFar && isRowValid(rowToConsider))
-                {
-                    changeCurrentRow = true;
-                }
-            }
-
-            if (changeCurrentRow)
-            {
-                settings.currentPageIndex = rowToConsider * settings.pagesPerRow;
-
-                if (direction !== 0)
-                {
-                    if (!setCurrentRow(direction))
-                    {
-                        var pageIndex = settings.currentPageIndex;
-                        var filename = settings.pages[pageIndex].f;
-                        Events.publish("VisiblePageDidChange", [pageIndex, filename]);
-                    }
-                }
-
-                return true;
-            }
-
-            return false;
-        };
-
-        // Helper function for going to a particular page
-        // Vertical offset: from the top of the page (including the top padding)
-        // Horizontal offset: from the center of the page; can be negative if to the left
-        var gotoPage = function (pageIndex, verticalOffset, horizontalOffset)
-        {
-            verticalOffset = (typeof verticalOffset !== 'undefined') ? verticalOffset : 0;
-            horizontalOffset = (typeof horizontalOffset !== 'undefined') ? horizontalOffset: 0;
-            var desiredTop = settings.heightAbovePages[pageIndex] + verticalOffset;
-            var desiredLeft = (settings.maxWidths[settings.zoomLevel] - settings.panelWidth) / 2 + settings.horizontalPadding + horizontalOffset;
-
-            $(settings.outerSelector).scrollTop(desiredTop);
-            $(settings.outerSelector).scrollLeft(desiredLeft);
-
-            // Pretend that this is the current page
-            settings.currentPageIndex = pageIndex;
-            //settings.toolbar.updateCurrentPage();
-            var filename = settings.pages[pageIndex].f;
-
-            Events.publish("VisiblePageDidChange", [pageIndex, filename]);
-            executeCallback(settings.onSetCurrentPage, pageIndex, filename);
-
-            // Execute the onJump callback
-            executeCallback(settings.onJump, pageIndex);
-        };
-
-        // Calculates the desired row, then scrolls there
-        var gotoRow = function (pageIndex)
-        {
-            var desiredRow = Math.floor(pageIndex / settings.pagesPerRow);
-            var desiredTop = desiredRow * settings.rowHeight;
-            $(settings.outerSelector).scrollTop(desiredTop);
-
-            // Pretend that this is the current page (it probably isn't)
-            settings.currentPageIndex = pageIndex;
-            var filename = settings.pages[pageIndex].f;
-            Events.publish("VisiblePageDidChange", [pageIndex, filename]);
-        };
-
-        // Helper function called by loadDocument to scroll to the desired place
-        var documentScroll = function ()
-        {
-            // If settings.preZoomOffset is defined, the zoom was trigged by double-clicking
-            // We then zoom in on a specific region
-            if (settings.preZoomOffset)
-            {
-                var clickedPage = settings.preZoomOffset.i;
-                var heightAbovePage = settings.heightAbovePages[clickedPage] + settings.verticalPadding;
-                var pageLeftOffset = settings.pageLeftOffsets[clickedPage];
-                var zoomRatio = Math.pow(2, settings.zoomLevel - settings.oldZoomLevel);
-
-                var distanceFromViewport = {
-                    x: settings.preZoomOffset.originalX - settings.viewerXOffset,
-                    y: settings.preZoomOffset.originalY - settings.viewerYOffset
-                };
-
-                var newDistanceToEdge = {
-                    x: settings.preZoomOffset.x * zoomRatio,
-                    y: settings.preZoomOffset.y * zoomRatio
-                };
-
-                var newScroll = {
-                    x: newDistanceToEdge.x - distanceFromViewport.x + pageLeftOffset,
-                    y: newDistanceToEdge.y - distanceFromViewport.y + heightAbovePage
-                };
-
-                $(settings.outerSelector).scrollTop(newScroll.y).scrollLeft(newScroll.x);
-
-                settings.preZoomOffset = undefined;
-            }
-            else
-            {
-                // Otherwise, we just scroll to the page saved in settings.goDirectlyTo (must be valid)
-                // Make sure the value for settings.goDirectlyTo is valid
-                if (!isPageValid(settings.goDirectlyTo))
-                {
-                    settings.goDirectlyTo = 0;
-                }
-
-                // We use the stored y/x offsets (relative to the top of the page and the center, respectively)
-                gotoPage(settings.goDirectlyTo, settings.verticalOffset, settings.horizontalOffset);
-                settings.horizontalOffset = 0;
-                settings.verticalOffset = 0;
-            }
-        };
-
-        // Don't call this when not in grid mode please
-        // Scrolls to the relevant place when in grid view
-        var gridScroll = function ()
-        {
-            // Figure out and scroll to the row containing the current page
-            gotoRow(settings.goDirectlyTo);
-        };
-
-        // If the given zoom level is valid, returns it; else, returns the min
-        var getValidZoomLevel = function (zoomLevel)
-        {
-            return (zoomLevel >= settings.minZoomLevel && zoomLevel <= settings.maxZoomLevel) ? zoomLevel : settings.minZoomLevel;
-        };
-
-        var getValidPagesPerRow = function (pagesPerRow)
-        {
-            return (pagesPerRow >= settings.minPagesPerRow && pagesPerRow <= settings.maxPagesPerRow) ? pagesPerRow : settings.maxPagesPerRow;
-        };
-
-        // Reset some settings and empty the viewport
-        var clearViewer = function ()
-        {
-            settings.allTilesLoaded = [];
-            $(settings.outerSelector).scrollTop(0);
-            settings.topScrollSoFar = 0;
-            $(settings.innerSelector).empty();
-            settings.firstPageLoaded = 0;
-            settings.firstRowLoaded = -1;
-            settings.previousTopScroll = 0;
-
-            // Clear all the timeouts to prevent undesired pages from loading
-            clearTimeout(settings.resizeTimer);
-
-            while (settings.pageTimeouts.length)
-            {
-                clearTimeout(settings.pageTimeouts.pop());
-            }
-        };
-
-        // Called when we don't necessarily know which view to go into
-        var loadViewer = function ()
-        {
-            if (settings.inGrid)
-            {
-                loadGrid();
-            }
-            else
-            {
-                loadDocument();
-            }
-        };
-
-        // Called every time we need to load document view (after zooming, fullscreen, etc)
-        var loadDocument = function ()
-        {
-            clearViewer();
-
-            // Make sure the zoom level we've been given is valid
-            settings.zoomLevel = getValidZoomLevel(settings.zoomLevel);
-            var z = settings.zoomLevel;
-
-            // Calculate the horizontal and vertical inter-page padding
-            if (settings.adaptivePadding > 0)
-            {
-                settings.horizontalPadding = settings.averageWidths[z] * settings.adaptivePadding;
-                settings.verticalPadding = settings.averageHeights[z] * settings.adaptivePadding;
-            }
-            else
-            {
-                // It's less than or equal to 0; use fixedPadding instead
-                settings.horizontalPadding = settings.fixedPadding;
-                settings.verticalPadding = settings.fixedPadding;
-            }
-
-            // Make sure the vertical padding is at least 40, if plugin icons are enabled
-            if (settings.pageTools.length)
-            {
-                settings.verticalPadding = Math.max(40, settings.horizontalPadding);
-            }
-
-            // Now reset some things that need to be changed after each zoom
-            settings.totalHeight = settings.totalHeights[z] + settings.verticalPadding * (settings.numPages + 1);
-            settings.dimAfterZoom = settings.totalHeight;
-
-            // Determine the width of the inner element (based on the max width)
-            var maxWidthToSet = settings.maxWidths[z] + settings.horizontalPadding * 2;
-            var widthToSet = Math.max(maxWidthToSet, settings.panelWidth);
-
-            // Needed to set settings.heightAbovePages - initially just the top padding
-            var heightSoFar = 0;
-            var i;
-
-            for (i = 0; i < settings.numPages; i++)
-            {
-                // First set the height above that page by adding this height to the previous total
-                // A page includes the padding above it
-                settings.heightAbovePages[i] = heightSoFar;
-
-                // Has to be done this way otherwise you get the height of the page included too
-                heightSoFar = settings.heightAbovePages[i] + getPageData(i, 'h') + settings.verticalPadding;
-
-                // Figure out the pageLeftOffset stuff
-                settings.pageLeftOffsets[i] = (widthToSet - getPageData(i, 'w')) / 2;
-
-                // Now try to load the page ONLY if the page needs to be loaded
-                // Take scrolling into account later, just try this for now
-                if (isPageVisible(i))
-                {
-                    loadPage(i);
-                    settings.lastPageLoaded = i;
-                }
-            }
-
-            // If this is not the initial load, execute the zoom callbacks
-            if (settings.oldZoomLevel >= 0)
-            {
-                if (settings.oldZoomLevel < settings.zoomLevel)
-                {
-                    executeCallback(settings.onZoomIn, z);
-                }
-                else
-                {
-                    executeCallback(settings.onZoomOut, z);
-                }
-
-                executeCallback(settings.onZoom, z);
-            }
-
-            // Set the height and width of documentpane (necessary for dragscrollable)
-            $(settings.innerSelector).height(Math.round(settings.totalHeight));
-            $(settings.innerSelector).width(Math.round(widthToSet));
-
-            // Scroll to the proper place
-            documentScroll();
-
-            // For the iPad - wait until this request finishes before accepting others
-            if (settings.scaleWait)
-            {
-                settings.scaleWait = false;
-            }
-
-            var fileName = settings.pages[settings.currentPageIndex].f;
-            executeCallback(settings.onDocumentLoaded, settings.lastPageLoaded, fileName);
-            Events.publish("DocumentHasFinishedLoading", [settings.lastPageLoaded, fileName]);
-        };
-
-        var loadGrid = function ()
-        {
-            clearViewer();
-
-            // Make sure the pages per row setting is valid
-            settings.pagesPerRow = getValidPagesPerRow(settings.pagesPerRow);
-
-            var horizontalPadding = settings.fixedPadding * (settings.pagesPerRow + 1);
-            var pageWidth = (settings.panelWidth - horizontalPadding) / settings.pagesPerRow;
-            settings.gridPageWidth = pageWidth;
-
-            // Calculate the row height depending on whether we want to fix the width or the height
-            settings.rowHeight = (settings.fixedHeightGrid) ? settings.fixedPadding + settings.minRatio * pageWidth : settings.fixedPadding + settings.maxRatio * pageWidth;
-            settings.numRows = Math.ceil(settings.numPages / settings.pagesPerRow);
-            settings.totalHeight = settings.numRows * settings.rowHeight + settings.fixedPadding;
-
-            $(settings.innerSelector).height(Math.round(settings.totalHeight));
-            $(settings.innerSelector).width(Math.round(settings.panelWidth));
-
-            // First scroll directly to the row containing the current page
-            gridScroll();
-
-            var i, rowIndex;
-
-            // Figure out the row each page is in
-            var np = settings.numPages;
-            for (i = 0; i < np; i += settings.pagesPerRow)
-            {
-                rowIndex = Math.floor(i / settings.pagesPerRow);
-
-                if (isRowVisible(rowIndex))
-                {
-                    settings.firstRowLoaded = (settings.firstRowLoaded < 0) ? rowIndex : settings.firstRowLoaded;
-                    loadRow(rowIndex);
-                    settings.lastRowLoaded = rowIndex;
-                }
-            }
-        };
-
-        // Handles switching in and out of fullscreen mode
-        // Should only be called after changing settings.inFullscreen
-        var handleModeChange = function (changeView)
-        {
-            // Save some offsets (required for scrolling properly), if it's not the initial load
-            if (settings.oldZoomLevel >= 0)
-            {
-                if (!settings.inGrid)
-                {
-                    var pageOffset = $(settings.selector + 'page-' + settings.currentPageIndex).offset();
-                    var topOffset = -(pageOffset.top - settings.verticalPadding - settings.viewerYOffset);
-                    var expectedLeft = (settings.panelWidth - getPageData(settings.currentPageIndex, 'w')) / 2;
-                    var leftOffset = -(pageOffset.left - settings.viewerXOffset - expectedLeft);
-                    settings.verticalOffset = topOffset;
-                    settings.horizontalOffset = leftOffset;
-                }
-            }
-
-            // Change the look of the toolbar
-            Events.publish("ModeDidSwitch", null);
-
-            // Toggle the classes
-            $(settings.selector + 'fullscreen').toggleClass('diva-in-fullscreen');
-            $(settings.outerSelector).toggleClass('diva-fullscreen');
-            $('body').toggleClass('diva-hide-scrollbar');
-            $(settings.parentSelector).toggleClass('diva-full-width');
-
-            // Reset the panel dimensions
-            settings.panelHeight = $(settings.outerSelector).height();
-            settings.panelWidth = $(settings.outerSelector).width() - settings.scrollbarWidth;
-            $(settings.innerSelector).width(settings.panelWidth);
-
-            // Recalculate the viewer offsets
-            settings.viewerXOffset = $(settings.outerSelector).offset().left;
-            settings.viewerYOffset = $(settings.outerSelector).offset().top;
-
-            // Used by setState when we need to change the view and the mode
-            if (changeView)
-            {
-                settings.inGrid = !settings.inGrid;
-                handleViewChange();
-            }
-            else
-            {
-                loadViewer();
-            }
-
-            // Execute callbacks
-            executeCallback(settings.onModeToggle, settings.inFullscreen);
-            Events.publish("ModeHasChanged", [settings.inFullScreen]);
-        };
-
-        // Handles switching in and out of grid view
-        // Should only be called after changing settings.inGrid
-        var handleViewChange = function ()
-        {
-            // Switch the slider
-            // Events.publish("ViewDidSwitch", null);
-
-            loadViewer();
-            executeCallback(settings.onViewToggle, settings.inGrid);
-            Events.publish("ViewDidSwitch", [settings.inGrid]);
-        };
-
-        // Called when the fullscreen icon is clicked
-        var toggleFullscreen = function ()
-        {
-            settings.goDirectlyTo = settings.currentPageIndex;
-            settings.inFullscreen = !settings.inFullscreen;
-            handleModeChange(false);
-        };
-
-        // Called when the grid icon is clicked
-        var toggleGrid = function ()
-        {
-            settings.goDirectlyTo = settings.currentPageIndex;
-            settings.inGrid = !settings.inGrid;
-            handleViewChange();
-        };
-
-        // Called after double-click or ctrl+double-click events on pages in document view
-        var handleDocumentDoubleClick = function (event)
-        {
-            var pageOffset = $(this).offset();
-            var offsetX = event.pageX - pageOffset.left;
-            var offsetY = event.pageY - pageOffset.top;
-
-            // Store the offset information so that it can be used in documentScroll()
-            settings.preZoomOffset = {
-                x: offsetX,
-                y: offsetY,
-                originalX: event.pageX,
-                originalY: event.pageY,
-                i: $(this).attr('data-index')
-            };
-
-            // Hold control to zoom out, otherwise, zoom in
-            var newZoomLevel = (event.ctrlKey) ? settings.zoomLevel - 1 : settings.zoomLevel + 1;
-
-            handleZoom(newZoomLevel);
-        };
-
-        // Called after double-clicking on a page in grid view
-        var handleGridDoubleClick = function (event)
-        {
-            // Figure out the page that was clicked, scroll to that page
-            var sel = document.getElementById(settings.ID + "outer");
-            var centerX = (event.pageX - settings.viewerXOffset) + sel.scrollLeft;
-            var centerY = (event.pageY - settings.viewerYOffset) + sel.scrollTop;
-            var rowIndex = Math.floor(centerY / settings.rowHeight);
-            var colIndex = Math.floor(centerX / (settings.panelWidth / settings.pagesPerRow));
-            var pageIndex = rowIndex * settings.pagesPerRow + colIndex;
-            settings.goDirectlyTo = pageIndex;
-
-            // Leave grid view, jump directly to the desired page
-            settings.inGrid = false;
-            handleViewChange();
-        };
-
-        // Handles pinch-zooming for mobile devices
-        var handlePinchZoom = function (event)
-        {
-            var newZoomLevel = settings.zoomLevel;
-
-            // First figure out the new zoom level:
-            if (event.scale > 1 && newZoomLevel < settings.maxZoomLevel)
-            {
-                newZoomLevel++;
-            }
-            else if (event.scale < 1 && newZoomLevel > settings.minZoomLevel)
-            {
-                newZoomLevel--;
-            }
-            else
-            {
-                return;
-            }
-
-            // Set it to true so we have to wait for this one to finish
-            settings.scaleWait = true;
-
-            // Has to call handleZoomSlide so that the coordinates are kept
-            handleZoom(newZoomLevel);
-        };
-
-        // Called to handle any zoom level
-        var handleZoom = function (newValue)
-        {
-            var newZoomLevel = getValidZoomLevel(newValue);
-
-            // If the zoom level provided is invalid, return false
-            if (newZoomLevel !== newValue)
-            {
-                return false;
-            }
-
-            settings.oldZoomLevel = settings.zoomLevel;
-            settings.zoomLevel = newZoomLevel;
-
-            // Update the slider
-            Events.publish("ZoomLevelDidChange", null);
-
-            loadDocument();
-
-            return true;
-        };
-
-        // Called to handle changing the pages per row slider
-        var handleGrid = function (newValue)
-        {
-            var newPagesPerRow = getValidPagesPerRow(newValue);
-
-            // If the value provided is invalid, return false
-            if (newPagesPerRow !== newValue)
-            {
-                return false;
-            }
-
-            settings.oldPagesPerRow = settings.zoomLevel;
-            settings.pagesPerRow = newPagesPerRow;
-
-            // Update the slider
-            Events.publish("GridRowNumberDidChange", null);
-
-            loadGrid();
-        };
-
-        var getYOffset = function ()
-        {
-            var yScroll = document.getElementById(settings.ID + "outer").scrollTop;
-            var topOfPage = settings.heightAbovePages[settings.currentPageIndex];
-
-            return parseInt(yScroll - topOfPage, 10);
-        };
-
-        var getXOffset = function ()
-        {
-            var innerWidth = settings.maxWidths[settings.zoomLevel] + settings.horizontalPadding * 2;
-            var centerX = (innerWidth - settings.panelWidth) / 2;
-            var xoff = document.getElementById(settings.ID + "outer").scrollLeft - centerX;
-            return parseInt(xoff, 10);
-        };
-
-        var getState = function ()
-        {
-            var state = {
-                'f': settings.inFullscreen,
-                'g': settings.inGrid,
-                'z': settings.zoomLevel,
-                'n': settings.pagesPerRow,
-                'i': (settings.enableFilename) ? settings.pages[settings.currentPageIndex].f : false,
-                'p': (settings.enableFilename) ? false : settings.currentPageIndex + 1,
-                'y': (settings.inGrid) ? false : getYOffset(),
-                'x': (settings.inGrid) ? false : getXOffset(),
-                'h': (settings.inFullscreen) ? false : settings.panelHeight,
-                'w': (settings.inFullscreen) ? false : $(settings.outerSelector).width()
-            };
-
-            return state;
-        };
-
-        var getURLHash = function ()
-        {
-            var hashParams = getState();
-            var hashStringBuilder = [];
-            var param;
-
-            for (param in hashParams)
-            {
-                if (hashParams[param] !== false)
-                {
-                    hashStringBuilder.push(param + settings.hashParamSuffix + '=' + hashParams[param]);
-                }
-            }
-
-            return hashStringBuilder.join('&');
-        };
-
-        // Returns the URL to the current state of the document viewer (so it should be an exact replica)
-        var getCurrentURL = function ()
-        {
-            return location.protocol + '//' + location.host + location.pathname + '#' + getURLHash();
-        };
-
-        // Called in init and when the orientation changes
-        var adjustMobileWebkitDims = function ()
-        {
-            var outerOffset = $(settings.outerSelector).offset().top;
-            settings.panelHeight = window.innerHeight - outerOffset - settings.viewerHeightPadding;
-            settings.panelWidth = window.innerWidth - settings.viewerWidthPadding;
-
-            // $(settings.parentSelector).width(settings.panelWidth);
-            // document.getElementById(settings.parentSelector.substring(1)).style.width = settings.panelWidth + "px";
-            settings.parentSelector.style.width = settings.panelWidth + "px";
-
-            if (settings.enableAutoHeight)
-            {
-                document.getElementById(settings.ID + "outer").style.height = settings.panelHeight + "px";
-            }
-
-            if (settings.enableAutoWidth)
-            {
-                document.getElementById(settings.ID + "outer").style.width = settings.panelWidth + "px";
-            }
-        };
-
-        // Will return true if something has changed, false otherwise
-        var adjustBrowserDims = function ()
-        {
-            // Only resize if the browser viewport is too small
-            var newHeight = $(settings.outerSelector).height();
-            var newWidth = $(settings.parentSelector).width() - settings.scrollbarWidth;
-            var outerOffset = $(settings.outerSelector).offset().top;
-
-            var windowHeight = window.innerHeight || document.documentElement.clientHeight;
-            var windowWidth = window.innerWidth || document.documentElement.clientWidth;
-            // 2 or 1 pixels for the border
-            var desiredWidth = windowWidth - settings.viewerWidthPadding - settings.scrollbarWidth - 2;
-            var desiredHeight = windowHeight - outerOffset - settings.viewerHeightPadding - 1;
-
-            if (settings.enableAutoHeight)
-            {
-                if (newHeight + outerOffset + 16 > window.innerHeight)
-                {
-                    newHeight = desiredHeight;
-                }
-                else if (newHeight <= settings.originalHeight)
-                {
-                    newHeight = Math.min(desiredHeight, settings.originalHeight);
-                }
-            }
-
-            if (settings.enableAutoWidth)
-            {
-                if (newWidth + 32 > window.innerWidth)
-                {
-                    newWidth = desiredWidth;
-                }
-                else if (newWidth <= settings.originalWidth)
-                {
-                    newWidth = Math.min(desiredWidth, settings.originalWidth);
-                }
-
-                settings.parentSelector[0].style.width = newWidth + settings.scrollbarWidth;
-            }
-
-            if (newWidth !== settings.panelWidth || newHeight !== settings.panelHeight)
-            {
-                var el = document.getElementById(settings.ID + "outer");
-                el.style.height = newHeight + "px";
-                el.style.width = newWidth + settings.scrollbarWidth + "px";
-                settings.panelWidth = newWidth;
-                settings.panelHeight = newHeight;
-                return true;
-            }
-
-            return false;
-        };
-
-        // Update the panelHeight and panelWidth based on the window size
-        var adjustFullscreenDims = function ()
-        {
-            settings.panelWidth = window.innerWidth - settings.scrollbarWidth;
-            settings.panelHeight = window.innerHeight;
-
-            return true;
-        };
-
-        var resizeViewer = function (newWidth, newHeight)
-        {
-            if (newWidth >= settings.minWidth)
-            {
-                settings.originalWidth = newWidth;
-                $(settings.outerSelector).width(newWidth);
-                document.getElementById(settings.ID + "outer").style.width = newWidth + "px";
-
-                settings.panelWidth = newWidth - settings.scrollbarWidth;
-
-                // Should also change the width of the container
-                settings.parentSelector[0].style.width = newWidth + "px";
-            }
-
-            if (newHeight >= settings.minHeight)
-            {
-                settings.originalHeight = newHeight;
-                document.getElementById(settings.ID + "outer").style.height = newHeight + "px";
-
-                settings.panelHeight = newHeight;
-            }
-        };
-
-        // Binds most of the event handlers (some more in createToolbar)
-        var handleEvents = function ()
-        {
-            // Create the fullscreen toggle icon if fullscreen is enabled
-            if (settings.enableFullscreen)
-            {
-                // Event handler for fullscreen toggling
-                $(settings.selector + 'fullscreen').click(function ()
-                {
-                    toggleFullscreen();
-                });
-            }
-
-            // Change the cursor for dragging
-            $(settings.innerSelector).mouseover(function ()
-            {
-                $(this).removeClass('diva-grabbing').addClass('diva-grab');
-            });
-
-            $(settings.innerSelector).mouseout(function ()
-            {
-                $(this).removeClass('diva-grab');
-            });
-
-            $(settings.innerSelector).mousedown(function ()
-            {
-                $(this).removeClass('diva-grab').addClass('diva-grabbing');
-            });
-
-            $(settings.innerSelector).mouseup(function ()
-            {
-                $(this).removeClass('diva-grabbing').addClass('diva-grab');
-            });
-
-            // Set drag scroll on first descendant of class dragger on both selected elements
-            $(settings.outerSelector + ', ' + settings.innerSelector).dragscrollable({dragSelector: '.diva-dragger', acceptPropagatedEvent: true});
-
-            // Handle the scroll
-            $(settings.outerSelector).scroll(function ()
-            {
-                settings.topScrollSoFar = document.getElementById(settings.ID + "outer").scrollTop;
-                var direction = settings.topScrollSoFar - settings.previousTopScroll;
-
-                if (settings.inGrid)
-                {
-                    adjustRows(direction);
-                }
-                else
-                {
-                    adjustPages(direction);
-                    settings.leftScrollSoFar = $(this).scrollLeft();
-                }
-
-                settings.previousTopScroll = settings.topScrollSoFar;
-            });
-
-            // Double-click to zoom
-            $(settings.outerSelector).on('dblclick', '.diva-document-page', function (event)
-            {
-                handleDocumentDoubleClick.call(this, event);
-            });
-
-            // Handle the control key for macs (in conjunction with double-clicking)
-            $(settings.outerSelector).on('contextmenu', '.diva-document-page', function (event)
-            {
-                if (event.ctrlKey)
-                {
-                    // In Firefox, this doesn't trigger a double-click, so we apply one manually
-                    clearTimeout(settings.singleClickTimeout);
-
-                    if (settings.singleClick)
-                    {
-                        handleDocumentDoubleClick.call(this, event);
-                        settings.singleClick = false;
-                    }
-                    else
-                    {
-                        settings.singleClick = true;
-
-                        // Set it to false again after 500 milliseconds (standard double-click timeout)
-                        settings.singleClickTimeout = setTimeout(function ()
-                        {
-                            settings.singleClick = false;
-                        }, 500);
-                    }
-
-                    return false;
-                }
-            });
-
-            $(settings.outerSelector).on('dblclick', '.diva-row', function (event)
-            {
-                handleGridDoubleClick.call(this, event);
-            });
-
-            // Check if the user is on a iPhone or iPod touch or iPad
-            if (settings.mobileWebkit)
-            {
-                // Prevent resizing (below from http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/)
-                var toAppend = [];
-                toAppend.push('<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" />');
-
-                // Eliminate URL and button bars if added to home screen
-                toAppend.push('<meta name="apple-mobile-web-app-capable" content="yes" />');
-
-                // Choose how to handle the phone status bar
-                toAppend.push('<meta name="apple-mobile-web-app-status-bar-style" content="black" />');
-                $('head').append(toAppend.join('\n'));
-
-                // Block the user from moving the window only if it's not integrated
-                if (settings.blockMobileMove)
-                {
-                    $('body').bind('touchmove', function (event)
-                    {
-                        var e = event.originalEvent;
-                        e.preventDefault();
-
-                        return false;
-                    });
-                }
-
-                // Allow pinch-zooming
-                $('body').bind('gestureend', function (event)
-                {
-                    var e = event.originalEvent;
-
-                    if (!settings.scaleWait)
-                    {
-                        // Save the page we're currently on so we scroll there
-                        settings.goDirectlyTo = settings.currentPageIndex;
-
-                        if (settings.inGrid)
-                        {
-                            settings.inGrid = false;
-
-                            handleViewChange();
-                        }
-                        else
-                        {
-                            handlePinchZoom(e);
-                        }
-                    }
-                    return false;
-                });
-
-                // Listen to orientation change event
-                $(window).bind('orientationchange', function (event)
-                {
-                    settings.orientationChange = true;
-                    adjustMobileWebkitDims();
-
-                    // Reload the viewer to account for the resized viewport
-                    settings.goDirectlyTo = settings.currentPageIndex;
-                    loadViewer();
-                });
-
-                // Inertial scrolling
-                $(settings.outerSelector).kinetic();
-            }
-
-            // Only check if either scrollBySpace or scrollByKeys is enabled
-            if (settings.enableSpaceScroll || settings.enableKeyScroll)
-            {
-                var spaceKey = $.ui.keyCode.SPACE;
-                var pageUpKey = $.ui.keyCode.PAGE_UP;
-                var pageDownKey = $.ui.keyCode.PAGE_DOWN;
-                var homeKey = $.ui.keyCode.HOME;
-                var endKey = $.ui.keyCode.END;
-
-                // Catch the key presses in document
-                $(document).keydown(function (event)
-                {
-                    // Space or page down - go to the next page
-                    if ((settings.enableSpaceScroll && event.keyCode === spaceKey) || (settings.enableKeyScroll && event.keyCode === pageDownKey))
-                    {
-                        $(settings.outerSelector).scrollTop(settings.topScrollSoFar + settings.panelHeight);
-                        return false;
-                    }
-
-                    // Page up - go to the previous page
-                    if (settings.enableKeyScroll && event.keyCode === pageUpKey)
-                    {
-                        $(settings.outerSelector).scrollTop(settings.topScrollSoFar - settings.panelHeight);
-                        return false;
-                    }
-
-                    // Home key - go to the beginning of the document
-                    if (settings.enableKeyScroll && event.keyCode === homeKey)
-                    {
-                        $(settings.outerSelector).scrollTop(0);
-                        return false;
-                    }
-
-                    // End key - go to the end of the document
-                    if (settings.enableKeyScroll && event.keyCode === endKey)
-                    {
-                        $(settings.outerSelector).scrollTop(settings.totalHeight);
-                        return false;
-                    }
-                });
-
-                // Handle window resizing events
-                if (!settings.mobileWebkit)
-                {
-                    $(window).resize(function ()
-                    {
-                        var adjustSuccess = (settings.inFullscreen) ? adjustFullscreenDims() : adjustBrowserDims();
-
-                        if (adjustSuccess)
-                        {
-                            // Cancel any previously-set resize timeouts
-                            clearTimeout(settings.resizeTimer);
-
-                            settings.resizeTimer = setTimeout(function ()
-                            {
-                                settings.goDirectlyTo = settings.currentPageIndex;
-                                loadViewer();
-                            }, 200);
-                        }
-                    });
-                }
-            }
-        };
-
-        // Handles all status updating etc (both fullscreen and not)
-        var createToolbar = function () {
-            // Prepare the HTML for the various components
-            var gridIconHTML = (settings.enableGridIcon) ? '<div class="diva-grid-icon' + (settings.inGrid ? ' diva-in-grid' : '') + '" id="' + settings.ID + 'grid-icon" title="Toggle grid view"></div>' : '';
-            var linkIconHTML = (settings.enableLinkIcon) ? '<div class="diva-link-icon" id="' + settings.ID + 'link-icon" style="' + (settings.enableGridIcon ? 'border-left: 0px' : '') + '" title="Link to this page"></div>' : '';
-            var zoomSliderHTML = (settings.enableZoomSlider) ? '<div id="' + settings.ID + 'zoom-slider"></div>' : '';
-            var gridSliderHTML = (settings.enableGridSlider) ? '<div id="' + settings.ID + 'grid-slider"></div>' : '';
-            var gotoPageHTML = (settings.enableGotoPage) ? '<form id="' + settings.ID + 'goto-page" class="diva-goto-form"><input type="text" id="' + settings.ID + 'goto-page-input" / class="diva-input"> <input type="submit" value="Go" style="margin-top: 0px;" /></form>' : '';
-            var zoomSliderLabelHTML = (settings.enableZoomSlider) ? '<div id="' + settings.ID + 'zoom-slider-label" class="diva-slider-label">Zoom level: <span id="' + settings.ID + 'zoom-level">' + settings.zoomLevel + '</span></div>' : '';
-            var gridSliderLabelHTML = (settings.enableGridSlider) ? '<div id="' + settings.ID + 'grid-slider-label" class="diva-slider-label">Pages per row: <span id="' + settings.ID + 'pages-per-row">' + settings.pagesPerRow + '</span></div>' : '';
-            var pageNumberHTML = '<div class="diva-page-label">Page <span id="' + settings.ID + 'current-page">1</span> of <span id="' + settings.ID + 'num-pages">' + settings.numPages + '</span></div>';
-
-            // If the viewer is specified to be "contained", we make room for the fullscreen icon
-            var otherToolbarClass = '';
-
-            if (settings.contained)
-            {
-                // Make sure the container element does not have a static position
-                // (Needed for the fullscreen icon to be contained)
-                if ($(settings.parentSelector).css('position') === 'static')
-                {
-                    $(settings.parentSelector).addClass('diva-relative-position');
-                }
-
-                otherToolbarClass = ' diva-fullscreen-space';
-
-                // If enableAutoTitle is set to TRUE, move it down
-                if (settings.enableAutoTitle)
-                {
-                    $(settings.selector + 'fullscreen').addClass('diva-contained');
-                }
-            }
-
-            var toolbarHTML = '<div id="' + settings.ID + 'tools-left" class="diva-tools-left' + otherToolbarClass + '">' + zoomSliderHTML + gridSliderHTML + zoomSliderLabelHTML + gridSliderLabelHTML + '</div><div id="' + settings.ID + 'tools-right" class="diva-tools-right">' + linkIconHTML + gridIconHTML + '<div class="diva-page-nav">' + gotoPageHTML + pageNumberHTML + '</div></div>';
-
-            if (settings.toolbarParentSelector)
-            {
-                $(settings.toolbarParentSelector).prepend('<div id="' + settings.ID + 'tools" class="diva-tools">' + toolbarHTML + '</div>');
-            }
-            else
-            {
-                $(settings.parentSelector).prepend('<div id="' + settings.ID + 'tools" class="diva-tools">' + toolbarHTML + '</div>');
-            }
-
-            // Create the zoom slider
-            $(settings.selector + 'zoom-slider').slider({
-                value: settings.zoomLevel,
-                min: settings.minZoomLevel,
-                max: settings.maxZoomLevel,
-                step: 1,
-                slide: function (event, ui)
-                {
-                    var i = settings.currentPageIndex;
-                    settings.goDirectlyTo = i;
-
-                    // Figure out the horizontal and vertical offsets
-                    // (Try to zoom in on the current center)
-                    var zoomRatio = Math.pow(2, ui.value - settings.zoomLevel);
-                    var innerWidth = settings.maxWidths[settings.zoomLevel] + settings.horizontalPadding * 2;
-                    var centerX = $(settings.outerSelector).scrollLeft() - (innerWidth - settings.panelWidth) / 2;
-                    settings.horizontalOffset = (innerWidth > settings.panelWidth) ? centerX * zoomRatio : 0;
-                    settings.verticalOffset = zoomRatio * ($(settings.outerSelector).scrollTop() - settings.heightAbovePages[i]);
-
-                    handleZoom(ui.value);
-                },
-                change: function (event, ui)
-                {
-                    if (ui.value !== settings.zoomLevel)
-                    {
-                        handleZoom(ui.value);
-                    }
-                }
-            });
-
-            // Create the grid slider
-            $(settings.selector + 'grid-slider').slider(
-            {
-                value: settings.pagesPerRow,
-                min: settings.minPagesPerRow,
-                max: settings.maxPagesPerRow,
-                step: 1,
-                slide: function (event, ui)
-                {
-                    handleGrid(ui.value);
-                },
-                change: function (event, ui)
-                {
-                    if (ui.value !== settings.pagesPerRow)
-                    {
-                        handleGrid(ui.value);
-                    }
-                }
-            });
-
-            // Handle clicking of the grid icon
-            $(settings.selector + 'grid-icon').click(function ()
-            {
-                toggleGrid();
-            });
-
-            // Handle going to a specific page using the input box
-            $(settings.selector + 'goto-page').submit(function ()
-            {
-                var desiredPage = parseInt($(settings.selector + 'goto-page-input').val(), 10);
-                var pageIndex = desiredPage - 1;
-
-                if (!isPageValid(pageIndex))
-                {
-                    alert("Invalid page number");
-                }
-                else
-                {
-                    if (settings.inGrid)
-                    {
-                        gotoRow(pageIndex);
-                    }
-                    else
-                    {
-                        gotoPage(pageIndex, 0, 0);
-                    }
-                }
-
-                // Prevent the default action of reloading the page
-                return false;
-            });
-
-            // Handle the creation of the link popup box
-            $(settings.selector + 'link-icon').click(function ()
-            {
-                $('body').prepend('<div id="' + settings.ID + 'link-popup" class="diva-link-popup"><input id="' + settings.ID + 'link-popup-input" class="diva-input" type="text" value="' + getCurrentURL() + '"/></div>');
-
-                if (settings.inFullscreen)
-                {
-                    $(settings.selector + 'link-popup').addClass('in-fullscreen');
-                }
-                else
-                {
-                    // Calculate the left and top offsets
-                    // Compensate for border, popup width
-                    var leftOffset = $(settings.outerSelector).offset().left + settings.panelWidth;
-                    leftOffset += settings.scrollbarWidth - 240 - 1;
-                    var topOffset = $(settings.outerSelector).offset().top + 1;
-
-                    $(settings.selector + 'link-popup').removeClass('in-fullscreen').css(
-                    {
-                        'top': topOffset + 'px',
-                        'left': leftOffset + 'px'
-                    });
-                }
-
-                // Catch onmouseup events outside of this div
-                $('body').mouseup(function (event)
-                {
-                    var targetID = event.target.id;
-
-                    if (targetID !== settings.ID + 'link-popup' && targetID !== settings.ID + 'link-popup-input')
-                    {
-                        $(settings.selector + 'link-popup').remove();
-                    }
-                });
-
-                // Also delete it upon scroll and page up/down key events
-                $(settings.outerSelector).scroll(function ()
-                {
-                    $(settings.selector + 'link-popup').remove();
-                });
-                $(settings.selector + 'link-popup input').click(function ()
-                {
-                    $(this).focus().select();
-                });
-                return false;
-            });
-
-            // Show the relevant slider
-            var currentSlider = (settings.inGrid) ? 'grid' : 'zoom';
-            $(settings.selector + currentSlider + '-slider').show();
-            $(settings.selector + currentSlider + '-slider-label').show();
-
-            var switchMode = function ()
-            {
-                // Switch from fullscreen to not
-                $(settings.selector + 'tools').toggleClass('diva-fullscreen-tools');
-
-                if (!settings.inFullscreen)
-                {
-                    // Leaving fullscreen
-                    $(settings.selector + 'tools-left').after($(settings.selector + 'tools-right'));
-                    $(settings.selector + 'tools-left').removeClass('in-fullscreen');
-                }
-                else
-                {
-                    // Entering fullscreen
-                    $(settings.selector + 'tools-right').after($(settings.selector + 'tools-left'));
-                    $(settings.selector + 'tools-left').addClass('in-fullscreen');
-                }
-            };
-
-            var switchView = function ()
-            {
-                // Switch from grid to document view etc
-                $(settings.selector + currentSlider + '-slider').hide();
-                $(settings.selector + currentSlider + '-slider-label').hide();
-                currentSlider = (settings.inGrid) ? 'grid' : 'zoom';
-                $(settings.selector + currentSlider + '-slider').show();
-                $(settings.selector + currentSlider + '-slider-label').show();
-
-                // Also change the image for the grid icon
-                $(settings.selector + 'grid-icon').toggleClass('diva-in-grid');
-            };
-
-            var toolbar =
-            {
-                updateCurrentPage: function ()
-                {
-                    $(settings.selector + 'current-page').text(settings.currentPageIndex + 1);
-                },
-                setNumPages: function (newNumber)
-                {
-                    $(settings.selector + 'num-pages').text(newNumber);
-                },
-                updateZoomSlider: function ()
-                {
-                    // Update the position of the handle within the slider
-                    if (settings.zoomLevel !== $(settings.selector + 'zoom-slider').slider('value'))
-                    {
-                        $(settings.selector + 'zoom-slider').slider(
-                        {
-                            value: settings.zoomLevel
-                        });
-                    }
-
-                    // Update the slider label
-                    $(settings.selector + 'zoom-level').text(settings.zoomLevel);
-                },
-                updateGridSlider: function ()
-                {
-                    // Update the position of the handle within the slider
-                    if (settings.pagesPerRow !== $(settings.selector + 'grid-slider').slider('value'))
-                    {
-                        $(settings.selector + 'grid-slider').slider(
-                        {
-                            value: settings.pagesPerRow
-                        });
-                    }
-
-                    // Update the slider label
-                    $(settings.selector + 'pages-per-row').text(settings.pagesPerRow);
-                },
-                switchView: switchView,
-                switchMode: switchMode
-            };
-            return toolbar;
-        };
-
-        var initPlugins = function ()
-        {
-            if (window.divaPlugins)
-            {
-                var pageTools = [];
-
-                // Add all the plugins that have not been explicitly disabled to settings.plugins
-                $.each(window.divaPlugins, function (index, plugin)
-                {
-                    var pluginProperName = plugin.pluginName[0].toUpperCase() + plugin.pluginName.substring(1);
-
-                    if (settings['enable' + pluginProperName])
-                    {
-                        // Call the init function and check return value
-                        var enablePlugin = plugin.init(settings, self);
-
-                        // If int returns false, consider the plugin disabled
-                        if (!enablePlugin)
-                        {
-                            return;
-                        }
-
-                        // If the title text is undefined, use the name of the plugin
-                        var titleText = plugin.titleText || pluginProperName + " plugin";
-
-                        // Create the pageTools bar if handleClick is set to a function
-                        if (typeof plugin.handleClick === 'function')
-                        {
-                            pageTools.push('<div class="diva-' + plugin.pluginName + '-icon" title="' + titleText + '"></div>');
-
-                            // Delegate the click event - pass it the settings
-                            $(settings.outerSelector).delegate('.diva-' + plugin.pluginName + '-icon', 'click', function (event)
-                            {
-                                plugin.handleClick.call(this, event, settings);
-                            });
-                        }
-
-                        // Add it to settings.plugins so it can be used later
-                        settings.plugins.push(plugin);
-                    }
-                });
-
-                // Save the page tools bar so it can be added for each page
-                if (pageTools.length)
-                {
-                    settings.pageTools = '<div class="diva-page-tools">' + pageTools.join('') + '</div>';
-                }
-            }
-        };
-
-        var hideThrobber = function ()
-        {
-            // Clear the timeout, if it hasn't executed yet
-            clearTimeout(settings.throbberTimeoutID);
-
-            // Hide the throbber if it has already executed
-            $(settings.selector + 'throbber').hide();
-        };
-
-        var setupViewer = function ()
-        {
-            // Create the throbber element
-            var throbberHTML = '<div id="' + settings.ID + 'throbber" class="diva-throbber"></div>';
-            $(settings.outerSelector).append(throbberHTML);
-
-            // If the request hasn't completed after a specified time, show it
-            settings.throbberTimeoutID = setTimeout(function ()
-            {
-                $(settings.selector + 'throbber').show();
-            }, settings.throbberTimeout);
-
-            $.ajax({
-                url: settings.objectData,
-                cache: true,
-                dataType: 'json',
-                error: function (jqxhr, status, error)
-                {
-                    hideThrobber();
-
-                    // Show a basic error message within the document viewer pane
-                    $(settings.outerSelector).text("Invalid URL. Error code: " + status + " " + error);
-                },
-                success: function (data, status, jqxhr)
-                {
-                    hideThrobber();
-
-                    // Save all the data we need
-                    settings.pages = data.pgs;
-                    settings.maxRatio = data.dims.max_ratio;
-                    settings.minRatio = data.dims.min_ratio;
-                    settings.itemTitle = data.item_title;
-                    settings.numPages = data.pgs.length;
-
-                    // These are arrays, the index corresponding to the zoom level
-                    settings.maxWidths = data.dims.max_w;
-                    settings.averageWidths = data.dims.a_wid;
-                    settings.averageHeights = data.dims.a_hei;
-                    settings.totalHeights = data.dims.t_hei;
-
-                    // Make sure the set max and min values are valid
-                    settings.realMaxZoom = data.max_zoom;
-                    settings.maxZoomLevel = (settings.maxZoomLevel >= 0 && settings.maxZoomLevel <= data.max_zoom) ? settings.maxZoomLevel : data.max_zoom;
-                    settings.minZoomLevel = (settings.minZoomLevel >= 0 && settings.minZoomLevel <= settings.maxZoomLevel) ? settings.minZoomLevel : 0;
-                    settings.minPagesPerRow = Math.max(2, settings.minPagesPerRow);
-                    settings.maxPagesPerRow = Math.max(settings.minPagesPerRow, settings.maxPagesPerRow);
-
-                    // Check that the desired page is in range
-                    if (settings.enableFilename)
-                    {
-                        var iParam = $.getHashParam('i' + settings.hashParamSuffix);
-                        var iParamPage = getPageIndex(iParam);
-
-                        if (isPageValid(iParamPage))
-                        {
-                            settings.goDirectlyTo = iParamPage;
-                        }
-                    }
-                    else
-                    {
-                        // Not using the i parameter, check the p parameter
-                        // Subtract 1 to get the page index
-                        var pParam = parseInt($.getHashParam('p' + settings.hashParamSuffix), 10) - 1;
-
-                        if (isPageValid(pParam))
-                        {
-                            settings.goDirectlyTo = pParam;
-                        }
-                    }
-
-                    // Execute the setup hook for each plugin (if defined)
-                    $.each(settings.plugins, function (index, plugin)
-                    {
-                        executeCallback(plugin.setupHook, settings);
-                    });
-
-                    // Create the toolbar and display the title + total number of pages
-                    if (settings.enableToolbar)
-                    {
-                        settings.toolbar = createToolbar();
-                        Events.subscribe("VisiblePageDidChange", settings.toolbar.updateCurrentPage);
-                        Events.subscribe("ModeDidSwitch", settings.toolbar.switchMode);
-                        Events.subscribe("ViewDidSwitch", settings.toolbar.switchView);
-                        Events.subscribe("ZoomLevelDidChange", settings.toolbar.updateZoomSlider);
-                        Events.subscribe("GridRowNumberDidChange", settings.toolbar.updateGridSlider);
-                    }
-
-                    $(settings.selector + 'current label').text(settings.numPages);
-
-                    if (settings.enableAutoTitle)
-                    {
-                        $(settings.parentSelector).prepend('<div id="' + settings.ID + 'title" class="diva-title">' + settings.itemTitle + '</div>');
-                    }
-
-                    // Adjust the document panel dimensions for touch devices
-                    if (settings.mobileWebkit)
-                    {
-                        adjustMobileWebkitDims();
-                    }
-                    else
-                    {
-                        settings.originalWidth = $(settings.parentSelector).width() - settings.scrollbarWidth;
-                        settings.originalHeight = $(settings.outerSelector).height();
-                        adjustBrowserDims();
-                    }
-
-                    // Calculate the viewer x and y offsets
-                    var viewerOffset = $(settings.outerSelector).offset();
-                    settings.viewerXOffset = viewerOffset.left;
-                    settings.viewerYOffset = viewerOffset.top;
-
-                    if (settings.inFullscreen)
-                    {
-                        handleModeChange(false);
-                    }
-                    else
-                    {
-                        loadViewer();
-                    }
-
-                    // Execute the callback
-                    executeCallback(settings.onReady, settings);
-                    Events.publish("ViewerHasFinishedLoading", [settings]);
-
-                    // signal that everything should be set up and ready to go.
-                    settings.loaded = true;
-                }
-            });
-        };
-
-        var checkLoaded = function()
-        {
-            if (!settings.loaded)
-            {
-                console.warn("The viewer is not completely initialized. This is likely because it is still downloading data. To fix this, only call this function if the isReady() method returns true.");
-                return false;
-            }
-            return true;
-        };
-
-        var init = function ()
-        {
-            // First figure out the width of the scrollbar in this browser
-            settings.scrollbarWidth = $.getScrollbarWidth();
-
-            // If window.orientation is defined, then it's probably mobileWebkit
-            settings.mobileWebkit = window.orientation !== undefined;
-
-            // Generate an ID that can be used as a prefix for all the other IDs
-            settings.ID = $.generateId('diva-');
-            settings.selector = '#' + settings.ID;
-
-            // Figure out the hashParamSuffix from the ID
-            var divaNumber = parseInt(settings.ID, 10);
-
-            if (divaNumber > 1)
-            {
-                // If this is document viewer #1, don't use a suffix; otherwise, use the document viewer number
-                settings.hashParamSuffix = divaNumber;
-            }
-
-            // Since we need to reference these two a lot
-            settings.outerSelector = settings.selector + 'outer';
-            settings.innerSelector = settings.selector + 'inner';
-
-            // Create the inner and outer panels
-            $(settings.parentSelector).append('<div id="' + settings.ID + 'outer" class="diva-outer"></div>');
-            $(settings.outerSelector).append('<div id="' + settings.ID + 'inner" class="diva-inner diva-dragger"></div>');
-
-            // Create the fullscreen icon
-            if (settings.enableFullscreen)
-            {
-                $(settings.parentSelector).prepend('<div id="' + settings.ID + 'fullscreen" class="diva-fullscreen-icon" title="Toggle fullscreen mode"></div>');
-            }
-
-            // First, n - check if it's in range
-            var nParam = parseInt($.getHashParam('n' + settings.hashParamSuffix), 10);
-
-            if (nParam >= settings.minPagesPerRow && nParam <= settings.maxPagesPerRow)
-            {
-                settings.pagesPerRow = nParam;
-            }
-
-            // Now z - check that it's in range
-            var zParam = $.getHashParam('z' + settings.hashParamSuffix);
-
-            if (zParam !== '')
-            {
-                // If it's empty, we don't want to change the default zoom level
-                zParam = parseInt(zParam, 10);
-
-                // Can't check if it exceeds the max zoom level or not because that data is not available yet ...
-                if (zParam >= settings.minZoomLevel)
-                {
-                    settings.zoomLevel = zParam;
-                }
-            }
-
-            // y - vertical offset from the top of the relevant page
-            var yParam = parseInt($.getHashParam('y' + settings.hashParamSuffix), 10);
-
-            if (!isNaN(yParam))
-            {
-                settings.verticalOffset = yParam;
-            }
-
-            // x - horizontal offset from the center of the page
-            var xParam = parseInt($.getHashParam('x' + settings.hashParamSuffix), 10);
-
-            if (!isNaN(xParam))
-            {
-                settings.horizontalOffset = xParam;
-            }
-
-            // If the "fullscreen" hash param is true, go to fullscreen initially
-            // If the grid hash param is true, go to grid view initially
-            var gridParam = $.getHashParam('g' + settings.hashParamSuffix);
-            var goIntoGrid = gridParam === 'true';
-            var fullscreenParam = $.getHashParam('f' + settings.hashParamSuffix);
-            var goIntoFullscreen = fullscreenParam === 'true';
-
-            settings.inGrid = (settings.inGrid && gridParam !== 'false') || goIntoGrid;
-            settings.inFullscreen = (settings.inFullscreen && fullscreenParam !== 'false') || goIntoFullscreen;
-
-            // Store the height and width of the viewer (the outer div), if present
-            var desiredHeight = parseInt($.getHashParam('h' + settings.hashParamSuffix), 10);
-            var desiredWidth = parseInt($.getHashParam('w' + settings.hashParamSuffix), 10);
-
-            // Store the minimum and maximum height too
-            settings.minHeight = parseInt($(settings.outerSelector).css('min-height'), 10);
-            settings.minWidth = parseInt($(settings.outerSelector).css('min-width'), 10);
-
-            // Just call resize, it'll take care of bounds-checking etc
-            if (desiredHeight > 0 || desiredWidth > 0)
-            {
-                resizeViewer(desiredWidth, desiredHeight);
-            }
-
-            // Do the initial AJAX request and viewer loading
-            setupViewer();
-
-            // Do all the plugin initialisation
-            initPlugins();
-
-            handleEvents();
-        };
-
-        // Call the init function when this object is created.
-        init();
-
-        /* PUBLIC FUNCTIONS
-===============================================
-*/
-
-        // Returns the title of the document, based on the directory name
-        this.getItemTitle = function ()
-        {
-            return settings.itemTitle;
-        };
-
-        // Go to a particular page by its page number (with indexing starting at 1)
-        // returns True if the page number passed is valid; false if it is not.
-        this.gotoPageByNumber = function (pageNumber)
-        {
-            var pageIndex = pageNumber - 1;
-            if (isPageValid(pageIndex))
-            {
-                gotoPage(pageIndex, 0, 0);
-                return true;
-            }
-            return false;
-        };
-
-        // Go to a particular page (with indexing starting at 0)
-        // returns True if the page index is valid; false if it is not.
-        this.gotoPageByIndex = function (pageIndex)
-        {
-            if (isPageValid(pageIndex))
-            {
-                gotoPage(pageIndex, 0, 0);
-                return true;
-            }
-            return false;
-        };
-
-        // Returns the page index (with indexing starting at 0)
-        this.getCurrentPage = function ()
-        {
-            console.warn("Deprecated. Use getCurrentPageIndex instead.");
-            return settings.currentPageIndex;
-        };
-
-        this.getNumberOfPages = function()
-        {
-            if (!checkLoaded())
-            {
-                return false;
-            }
-
-            return settings.numPages;
-        }
-
-        // Returns the dimensions of a given page index at a given zoom level
-        this.getPageDimensionsAtZoomLevel = function(pageIdx, zoomLevel)
-        {
-            if (!checkLoaded())
-            {
-                return false;
-            }
-
-            var zoomLevel = zoomLevel - 1; // zoom levels are 1-based, but our array is 0-based;
-            var pg = settings.pages[pageIdx];
-            var pgAtZoom = pg.d[parseInt(zoomLevel, 10)];
-            return {'width': pgAtZoom.w, 'height': pgAtZoom.h}
-        };
-
-        // Returns the dimensions of the current page at the current zoom level
-        this.getCurrentPageDimensionsAtCurrentZoomLevel = function()
-        {
-            return this.getPageDimensionsAtZoomLevel(settings.currentPageIndex, settings.zoomLevel);
-        };
-
-        this.isReady = function()
-        {
-            return settings.loaded;
-        };
-
-        this.getCurrentPageIndex = function ()
-        {
-            return settings.currentPageIndex;
-        };
-
-        this.getCurrentPageFilename = function ()
-        {
-            return settings.pages[settings.currentPageIndex].f;
-        };
-
-        this.getCurrentPageNumber = function ()
-        {
-            return settings.currentPageIndex + 1;
-        };
-
-        // Returns the current zoom level
-        this.getZoomLevel = function ()
-        {
-            return settings.zoomLevel;
-        };
-
-        // gets the maximum zoom level for the entire document
-        this.getMaxZoomLevel = function ()
-        {
-            return settings.maxZoomLevel;
-        };
-
-        // gets the max zoom level for a given page
-        this.getMaxZoomLevelForPage = function(pageIdx)
-        {
-            if (!checkLoaded)
-            {
-                return false;
-            }
-
-            return settings.pages[pageIdx].m;
-        }
-
-        this.getMinZoomLevel = function ()
-        {
-            return settings.minZoomLevel;
-        };
-
-        // Use the provided zoom level (will check for validity first)
-        // Returns false if the zoom level is invalid, true otherwise
-        this.setZoomLevel = function (zoomLevel)
-        {
-            if (settings.inGrid)
-            {
-                toggleGrid();
-            }
-
-            return handleZoom(zoomLevel);
-        };
-
-        // Zoom in. Will return false if it's at the maximum zoom
-        this.zoomIn = function ()
-        {
-            return this.setZoomLevel(settings.zoomLevel + 1);
-        };
-
-        // Zoom out. Will return false if it's at the minimum zoom
-        this.zoomOut = function ()
-        {
-            return this.setZoomLevel(settings.zoomLevel - 1);
-        };
-
-        // Uses the isVerticallyInViewport() function, but relative to a page
-        // Check if something (e.g. a highlight box on a particular page) is visible
-        this.inViewport = function (pageNumber, topOffset, height)
-        {
-            var pageIndex = pageNumber - 1;
-            var top = settings.heightAbovePages[pageIndex] + topOffset;
-            var bottom = top + height;
-
-            return isVerticallyInViewport(top, bottom);
-        };
-
-        // Toggle fullscreen mode
-        this.toggleFullscreenMode = function ()
-        {
-            toggleFullscreen();
-        };
-
-        // Enter fullscreen mode if currently not in fullscreen mode
-        // Returns false if in fullscreen mode initially, true otherwise
-        // This function will work even if enableFullscreen is set to false
-        this.enterFullscreenMode = function ()
-        {
-            if (!settings.inFullscreen)
-            {
-                toggleFullscreen();
-                return true;
-            }
-
-            return false;
-        };
-
-        // Leave fullscreen mode if currently in fullscreen mode
-        // Returns true if in fullscreen mode intitially, false otherwise
-        this.leaveFullscreenMode = function ()
-        {
-            if (settings.inFullscreen)
-            {
-                toggleFullscreen();
-                return true;
-            }
-
-            return false;
-        };
-
-        // Toggle grid view
-        this.toggleGridView = function ()
-        {
-            toggleGrid();
-        };
-
-        // Enter grid view if currently not in grid view
-        // Returns false if in grid view initially, true otherwise
-        this.enterGridView = function ()
-        {
-            if (!settings.inGrid) {
-                toggleGrid();
-                return true;
-            }
-
-            return false;
-        };
-
-        // Leave grid view if currently in grid view
-        // Returns true if in grid view initially, false otherwise
-        this.leaveGridView = function ()
-        {
-            if (settings.inGrid)
-            {
-                toggleGrid();
-                return true;
-            }
-
-            return false;
-        };
-
-        // Jump to a page based on its filename
-        // Returns true if successful and false if the filename is invalid
-        this.gotoPageByName = function (filename)
-        {
-            var pageIndex = getPageIndex(filename);
-            if (isPageValid(pageIndex))
-            {
-                gotoPage(pageIndex, 0, 0);
-                return true;
-            }
-
-            return false;
-        };
-
-        // Get the page index (0-based) corresponding to a given filename
-        // If the page index doesn't exist, this will return -1
-        this.getPageIndex = function (filename)
-        {
-            return getPageIndex(filename);
-        };
-
-        // Get the current URL (exposes the private method)
-        this.getCurrentURL = function ()
-        {
-            return getCurrentURL();
-        };
-
-        // Get the hash part only of the current URL (without the leading #)
-        this.getURLHash = function ()
-        {
-            return getURLHash();
-        };
-
-        // Get an object representing the state of this diva instance (for setState)
-        this.getState = function ()
-        {
-            return getState();
-        };
-
-        // Get the instance selector for this instance, since it's auto-generated.
-        this.getInstanceSelector = function ()
-        {
-            return settings.selector;
-        };
-
-        // Get the instance ID -- essentially the selector without the leading '#'.
-        this.getInstanceId = function()
-        {
-            return settings.ID;
-        };
-
-        this.getSettings = function()
-        {
-            return settings;
-        };
-
-        // Align this diva instance with a state object (as returned by getState)
-        this.setState = function (state)
-        {
-            var pageIndex;
-
-            // If we need to resize the viewer, do that first
-            resizeViewer(state.w, state.h);
-
-            // Only change settings.goDirectlyTo if state.i or state.p is valid
-            pageIndex = getPageIndex(state.i);
-
-            if (isPageValid(pageIndex))
-            {
-                settings.goDirectlyTo = pageIndex;
-            }
-            else if (isPageValid(state.p))
-            {
-                settings.goDirectlyTo = state.p;
-            }
-
-            settings.horizontalOffset = parseInt(state.x, 10);
-            settings.verticalOffset = parseInt(state.y, 10);
-
-            // Only change the zoom if state.z is valid
-            if (state.z >= settings.minZoomLevel && state.z <= settings.maxZoomLevel)
-            {
-                settings.zoomLevel = state.z;
-            }
-
-            // Only change the pages per row setting if state.n is valid
-            if (state.n >= settings.minPagesPerRow && state.n <= settings.maxPagesPerRow)
-            {
-                settings.pagesPerRow = state.n;
-            }
-
-            if (settings.inFullscreen !== state.f)
-            {
-                // The parameter determines if we need to change the view as well
-                settings.inFullscreen = state.f;
-                handleModeChange(settings.inGrid !== state.g);
-            }
-            else
-            {
-                // Don't need to change the mode, may need to change view
-                if (settings.inGrid !== state.g)
-                {
-                    settings.inGrid = state.g;
-                    handleViewChange();
-                }
-                else
-                {
-                    // Reload the viewer, just in case
-                    loadViewer();
-                }
-            }
-        };
-
-        // Resizes the outer div to the specified width and height
-        this.resize = function (newWidth, newHeight)
-        {
-            resizeViewer(newWidth, newHeight);
-            loadViewer();
-        };
-
-        // Destroys this instance, tells plugins to do the same (for testing)
-        this.destroy = function ()
-        {
-            // Removes the hide-scrollbar class from the body
-            $('body').removeClass('diva-hide-scrollbar');
-
-            // Empty the parent container and remove any diva-related data
-            $(settings.parentSelector).empty().removeData('diva');
-
-            // Call the destroy function for all the enabled plugins (if it exists)
-            $.each(settings.plugins, function (index, plugin)
-            {
-                executeCallback(plugin.destroy);
-            });
-
-            // Remove any additional styling on the parent element
-            $(settings.parentSelector).removeAttr('style').removeAttr('class');
-        };
-    };
-
-    $.fn.diva = function (options)
-    {
-        return this.each(function ()
-        {
-            var element = $(this);
-
-            // Return early if this element already has a plugin instance
-            if (element.data('diva'))
-            {
-                return;
-            }
-
-            // Save the reference to the container element
-            options.parentSelector = element;
-
-            // Otherwise, instantiate the document viewer
-            var diva = new Diva(this, options);
-            element.data('diva', diva);
-        });
-    };
-
-})(jQuery);
\ No newline at end of file
+!function(e){var t={};function i(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(s,n,function(t){return e[t]}.bind(null,n));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/build/",i(i.s=2)}([function(e,t,i){(function(e,i){var s=200,n="Expected a function",o="__lodash_hash_undefined__",r=1,a=2,l=1/0,h=9007199254740991,c="[object Arguments]",u="[object Array]",d="[object Boolean]",g="[object Date]",v="[object Error]",p="[object Function]",f="[object GeneratorFunction]",m="[object Map]",w="[object Number]",b="[object Object]",y="[object RegExp]",_="[object Set]",P="[object String]",S="[object Symbol]",C="[object ArrayBuffer]",L="[object DataView]",O=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,x=/^\w*$/,E=/^\./,I=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,T=/\\(\\)?/g,D=/^\[object .+?Constructor\]$/,M=/^(?:0|[1-9]\d*)$/,z={};z["[object Float32Array]"]=z["[object Float64Array]"]=z["[object Int8Array]"]=z["[object Int16Array]"]=z["[object Int32Array]"]=z["[object Uint8Array]"]=z["[object Uint8ClampedArray]"]=z["[object Uint16Array]"]=z["[object Uint32Array]"]=!0,z[c]=z[u]=z[C]=z[d]=z[L]=z[g]=z[v]=z[p]=z[m]=z[w]=z[b]=z[y]=z[_]=z[P]=z["[object WeakMap]"]=!1;var V="object"==typeof e&&e&&e.Object===Object&&e,k="object"==typeof self&&self&&self.Object===Object&&self,F=V||k||Function("return this")(),j="object"==typeof t&&t&&!t.nodeType&&t,A=j&&"object"==typeof i&&i&&!i.nodeType&&i,R=A&&A.exports===j&&V.process,H=function(){try{return R&&R.binding("util")}catch(e){}}(),B=H&&H.isTypedArray;function Z(e,t){for(var i=-1,s=e?e.length:0;++i<s;)if(t(e[i],i,e))return!0;return!1}function G(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function N(e){var t=-1,i=Array(e.size);return e.forEach(function(e,s){i[++t]=[s,e]}),i}function U(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var W=Array.prototype,Y=Function.prototype,q=Object.prototype,X=F["__core-js_shared__"],K=function(){var e=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),$=Y.toString,J=q.hasOwnProperty,Q=q.toString,ee=RegExp("^"+$.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),te=F.Symbol,ie=F.Uint8Array,se=q.propertyIsEnumerable,ne=W.splice,oe=function(e,t){return function(i){return e(t(i))}}(Object.keys,Object),re=je(F,"DataView"),ae=je(F,"Map"),le=je(F,"Promise"),he=je(F,"Set"),ce=je(F,"WeakMap"),ue=je(Object,"create"),de=Ue(re),ge=Ue(ae),ve=Ue(le),pe=Ue(he),fe=Ue(ce),me=te?te.prototype:void 0,we=me?me.valueOf:void 0,be=me?me.toString:void 0;function ye(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function _e(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function Pe(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function Se(e){var t=-1,i=e?e.length:0;for(this.__data__=new Pe;++t<i;)this.add(e[t])}function Ce(e){this.__data__=new _e(e)}function Le(e,t){var i=Xe(e)||qe(e)?function(e,t){for(var i=-1,s=Array(e);++i<e;)s[i]=t(i);return s}(e.length,String):[],s=i.length,n=!!s;for(var o in e)!t&&!J.call(e,o)||n&&("length"==o||Re(o,s))||i.push(o);return i}function Oe(e,t){for(var i=e.length;i--;)if(Ye(e[i][0],t))return i;return-1}function xe(e,t){for(var i=0,s=(t=He(t,e)?[t]:Ve(t)).length;null!=e&&i<s;)e=e[Ne(t[i++])];return i&&i==s?e:void 0}function Ee(e,t){return e>t}function Ie(e,t){return null!=e&&t in Object(e)}function Te(e,t,i,s,n){return e===t||(null==e||null==t||!Qe(e)&&!et(t)?e!=e&&t!=t:function(e,t,i,s,n,o){var l=Xe(e),h=Xe(t),p=u,f=u;l||(p=(p=Ae(e))==c?b:p);h||(f=(f=Ae(t))==c?b:f);var O=p==b&&!G(e),x=f==b&&!G(t),E=p==f;if(E&&!O)return o||(o=new Ce),l||it(e)?ke(e,t,i,s,n,o):function(e,t,i,s,n,o,l){switch(i){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case C:return!(e.byteLength!=t.byteLength||!s(new ie(e),new ie(t)));case d:case g:case w:return Ye(+e,+t);case v:return e.name==t.name&&e.message==t.message;case y:case P:return e==t+"";case m:var h=N;case _:var c=o&a;if(h||(h=U),e.size!=t.size&&!c)return!1;var u=l.get(e);if(u)return u==t;o|=r,l.set(e,t);var p=ke(h(e),h(t),s,n,o,l);return l.delete(e),p;case S:if(we)return we.call(e)==we.call(t)}return!1}(e,t,p,i,s,n,o);if(!(n&a)){var I=O&&J.call(e,"__wrapped__"),T=x&&J.call(t,"__wrapped__");if(I||T){var D=I?e.value():e,M=T?t.value():t;return o||(o=new Ce),i(D,M,s,n,o)}}if(!E)return!1;return o||(o=new Ce),function(e,t,i,s,n,o){var r=n&a,l=st(e),h=l.length,c=st(t).length;if(h!=c&&!r)return!1;for(var u=h;u--;){var d=l[u];if(!(r?d in t:J.call(t,d)))return!1}var g=o.get(e);if(g&&o.get(t))return g==t;var v=!0;o.set(e,t),o.set(t,e);for(var p=r;++u<h;){d=l[u];var f=e[d],m=t[d];if(s)var w=r?s(m,f,d,t,e,o):s(f,m,d,e,t,o);if(!(void 0===w?f===m||i(f,m,s,n,o):w)){v=!1;break}p||(p="constructor"==d)}if(v&&!p){var b=e.constructor,y=t.constructor;b!=y&&"constructor"in e&&"constructor"in t&&!("function"==typeof b&&b instanceof b&&"function"==typeof y&&y instanceof y)&&(v=!1)}return o.delete(e),o.delete(t),v}(e,t,i,s,n,o)}(e,t,Te,i,s,n))}function De(e){return!(!Qe(e)||function(e){return!!K&&K in e}(e))&&($e(e)||G(e)?ee:D).test(Ue(e))}function Me(e){return"function"==typeof e?e:null==e?nt:"object"==typeof e?Xe(e)?function(e,t){if(He(e)&&Be(t))return Ze(Ne(e),t);return function(i){var s=function(e,t,i){var s=null==e?void 0:xe(e,t);return void 0===s?i:s}(i,e);return void 0===s&&s===t?function(e,t){return null!=e&&function(e,t,i){var s,n=-1,o=(t=He(t,e)?[t]:Ve(t)).length;for(;++n<o;){var r=Ne(t[n]);if(!(s=null!=e&&i(e,r)))break;e=e[r]}if(s)return s;return!!(o=e?e.length:0)&&Je(o)&&Re(r,o)&&(Xe(e)||qe(e))}(e,t,Ie)}(i,e):Te(t,s,void 0,r|a)}}(e[0],e[1]):function(e){var t=function(e){var t=st(e),i=t.length;for(;i--;){var s=t[i],n=e[s];t[i]=[s,n,Be(n)]}return t}(e);if(1==t.length&&t[0][2])return Ze(t[0][0],t[0][1]);return function(i){return i===e||function(e,t,i,s){var n=i.length,o=n,l=!s;if(null==e)return!o;for(e=Object(e);n--;){var h=i[n];if(l&&h[2]?h[1]!==e[h[0]]:!(h[0]in e))return!1}for(;++n<o;){var c=(h=i[n])[0],u=e[c],d=h[1];if(l&&h[2]){if(void 0===u&&!(c in e))return!1}else{var g=new Ce;if(s)var v=s(u,d,c,e,t,g);if(!(void 0===v?Te(d,u,s,r|a,g):v))return!1}}return!0}(i,e,t)}}(e):function(e){return He(e)?function(e){return function(t){return null==t?void 0:t[e]}}(Ne(e)):function(e){return function(t){return xe(t,e)}}(e)}(e)}function ze(e){if(!function(e){var t=e&&e.constructor,i="function"==typeof t&&t.prototype||q;return e===i}(e))return oe(e);var t=[];for(var i in Object(e))J.call(e,i)&&"constructor"!=i&&t.push(i);return t}function Ve(e){return Xe(e)?e:Ge(e)}function ke(e,t,i,s,n,o){var l=n&a,h=e.length,c=t.length;if(h!=c&&!(l&&c>h))return!1;var u=o.get(e);if(u&&o.get(t))return u==t;var d=-1,g=!0,v=n&r?new Se:void 0;for(o.set(e,t),o.set(t,e);++d<h;){var p=e[d],f=t[d];if(s)var m=l?s(f,p,d,t,e,o):s(p,f,d,e,t,o);if(void 0!==m){if(m)continue;g=!1;break}if(v){if(!Z(t,function(e,t){if(!v.has(t)&&(p===e||i(p,e,s,n,o)))return v.add(t)})){g=!1;break}}else if(p!==f&&!i(p,f,s,n,o)){g=!1;break}}return o.delete(e),o.delete(t),g}function Fe(e,t){var i=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?i["string"==typeof t?"string":"hash"]:i.map}function je(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return De(i)?i:void 0}ye.prototype.clear=function(){this.__data__=ue?ue(null):{}},ye.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ye.prototype.get=function(e){var t=this.__data__;if(ue){var i=t[e];return i===o?void 0:i}return J.call(t,e)?t[e]:void 0},ye.prototype.has=function(e){var t=this.__data__;return ue?void 0!==t[e]:J.call(t,e)},ye.prototype.set=function(e,t){return this.__data__[e]=ue&&void 0===t?o:t,this},_e.prototype.clear=function(){this.__data__=[]},_e.prototype.delete=function(e){var t=this.__data__,i=Oe(t,e);return!(i<0||(i==t.length-1?t.pop():ne.call(t,i,1),0))},_e.prototype.get=function(e){var t=this.__data__,i=Oe(t,e);return i<0?void 0:t[i][1]},_e.prototype.has=function(e){return Oe(this.__data__,e)>-1},_e.prototype.set=function(e,t){var i=this.__data__,s=Oe(i,e);return s<0?i.push([e,t]):i[s][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new ye,map:new(ae||_e),string:new ye}},Pe.prototype.delete=function(e){return Fe(this,e).delete(e)},Pe.prototype.get=function(e){return Fe(this,e).get(e)},Pe.prototype.has=function(e){return Fe(this,e).has(e)},Pe.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},Se.prototype.add=Se.prototype.push=function(e){return this.__data__.set(e,o),this},Se.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.clear=function(){this.__data__=new _e},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var i=this.__data__;if(i instanceof _e){var n=i.__data__;if(!ae||n.length<s-1)return n.push([e,t]),this;i=this.__data__=new Pe(n)}return i.set(e,t),this};var Ae=function(e){return Q.call(e)};function Re(e,t){return!!(t=null==t?h:t)&&("number"==typeof e||M.test(e))&&e>-1&&e%1==0&&e<t}function He(e,t){if(Xe(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!tt(e))||(x.test(e)||!O.test(e)||null!=t&&e in Object(t))}function Be(e){return e==e&&!Qe(e)}function Ze(e,t){return function(i){return null!=i&&(i[e]===t&&(void 0!==t||e in Object(i)))}}(re&&Ae(new re(new ArrayBuffer(1)))!=L||ae&&Ae(new ae)!=m||le&&"[object Promise]"!=Ae(le.resolve())||he&&Ae(new he)!=_||ce&&"[object WeakMap]"!=Ae(new ce))&&(Ae=function(e){var t=Q.call(e),i=t==b?e.constructor:void 0,s=i?Ue(i):void 0;if(s)switch(s){case de:return L;case ge:return m;case ve:return"[object Promise]";case pe:return _;case fe:return"[object WeakMap]"}return t});var Ge=We(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(tt(e))return be?be.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}(e)}(e);var t=[];return E.test(e)&&t.push(""),e.replace(I,function(e,i,s,n){t.push(s?n.replace(T,"$1"):i||e)}),t});function Ne(e){if("string"==typeof e||tt(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function Ue(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function We(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(n);var i=function(){var s=arguments,n=t?t.apply(this,s):s[0],o=i.cache;if(o.has(n))return o.get(n);var r=e.apply(this,s);return i.cache=o.set(n,r),r};return i.cache=new(We.Cache||Pe),i}function Ye(e,t){return e===t||e!=e&&t!=t}function qe(e){return function(e){return et(e)&&Ke(e)}(e)&&J.call(e,"callee")&&(!se.call(e,"callee")||Q.call(e)==c)}We.Cache=Pe;var Xe=Array.isArray;function Ke(e){return null!=e&&Je(e.length)&&!$e(e)}function $e(e){var t=Qe(e)?Q.call(e):"";return t==p||t==f}function Je(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Qe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function et(e){return!!e&&"object"==typeof e}function tt(e){return"symbol"==typeof e||et(e)&&Q.call(e)==S}var it=B?function(e){return function(t){return e(t)}}(B):function(e){return et(e)&&Je(e.length)&&!!z[Q.call(e)]};function st(e){return Ke(e)?Le(e):ze(e)}function nt(e){return e}i.exports=function(e,t){return e&&e.length?function(e,t,i){for(var s=-1,n=e.length;++s<n;){var o=e[s],r=t(o);if(null!=r&&(void 0===a?r==r&&!tt(r):i(r,a)))var a=r,l=o}return l}(e,Me(t),Ee):void 0}}).call(this,i(6),i(7)(e))},function(e,t,i){(function(s){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==s&&"env"in s&&(e=s.env.DEBUG),e}(t=e.exports=i(9)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var i=this.useColors;if(e[0]=(i?"%c":"")+this.namespace+(i?" %c":" ")+e[0]+(i?"%c ":" ")+"+"+t.humanize(this.diff),!i)return;var s="color: "+this.color;e.splice(1,0,s,"color: inherit");var n=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++n)}),e.splice(o,0,s)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}).call(this,i(8))},function(e,t,i){i(3),i(16),e.exports=i(11)},function(e,t){!function(){if(!Array.prototype.fill){var e=function(e){if(null==this)throw new TypeError("this is null or not defined");for(var t=Object(this),i=t.length>>>0,s=arguments[1]>>0,n=s<0?Math.max(i+s,0):Math.min(s,i),o=arguments[2],r=void 0===o?i:o>>0,a=r<0?Math.max(i+r,0):Math.min(r,i);n<a;)t[n]=e,n++;return t};if(Object.defineProperty)try{Object.defineProperty(Array.prototype,"fill",{value:e,configurable:!0,enumerable:!1,writable:!0})}catch(e){}Array.prototype.fill||(Array.prototype.fill=e)}}()},function(e,t){!function(){var e=window.requestAnimationFrame,t="ontouchend"in document,i=function(){for(var e=1;e<arguments.length;e++)for(var t in arguments[e])arguments[e].hasOwnProperty(t)&&(arguments[0][t]=arguments[e][t]);return arguments[0]},s=function(e,t){return this.settings=i({},s.DEFAULTS,t),this.el=e,this.ACTIVE_CLASS="kinetic-active",this._initElements(),this.el._VanillaKinetic=this,this};s.DEFAULTS={cursor:"move",decelerate:!0,triggerHardware:!1,threshold:0,y:!0,x:!0,slowdown:.9,maxvelocity:40,throttleFPS:60,invert:!1,movingClass:{up:"kinetic-moving-up",down:"kinetic-moving-down",left:"kinetic-moving-left",right:"kinetic-moving-right"},deceleratingClass:{up:"kinetic-decelerating-up",down:"kinetic-decelerating-down",left:"kinetic-decelerating-left",right:"kinetic-decelerating-right"}},s.prototype.start=function(e){this.settings=i(this.settings,e),this.velocity=e.velocity||this.velocity,this.velocityY=e.velocityY||this.velocityY,this.settings.decelerate=!1,this._move()},s.prototype.end=function(){this.settings.decelerate=!0},s.prototype.stop=function(){this.velocity=0,this.velocityY=0,this.settings.decelerate=!0,"function"==typeof this.settings.stopped&&this.settings.stopped.call(this)},s.prototype.detach=function(){this._detachListeners(),this.el.classList.remove(this.ACTIVE_CLASS),this.el.style.cursor=""},s.prototype.attach=function(){this.el.classList.contains(this.ACTIVE_CLASS)||(this._attachListeners(),this.el.classList.add(this.ACTIVE_CLASS),this.el.style.cursor=this.settings.cursor)},s.prototype._initElements=function(){this.el.classList.add(this.ACTIVE_CLASS),i(this,{xpos:null,prevXPos:!1,ypos:null,prevYPos:!1,mouseDown:!1,throttleTimeout:1e3/this.settings.throttleFPS,lastMove:null,elementFocused:null}),this.velocity=0,this.velocityY=0;var e=this;this.documentResetHandler=function(){e._resetMouse.apply(e)};var t=document.documentElement;if(t.addEventListener("mouseup",this.documentResetHandler,!1),t.addEventListener("click",this.documentResetHandler,!1),this._initEvents(),this.el.style.cursor=this.settings.cursor,this.settings.triggerHardware)for(var s=["","-ms-","-webkit-","-moz-"],n={transform:"translate3d(0,0,0)",perspective:"1000","backface-visibility":"hidden"},o=0;o<s.length;o++){var r=s[o];for(var a in n)n.hasOwnProperty(a)&&(this.el.style[r+a]=n[a])}},s.prototype._initEvents=function(){var e=this;this.settings.events={touchStart:function(t){var i;e._useTarget(t.target,t)&&(i=t.originalEvent.touches[0],e.threshold=e._threshold(t.target,t),e._start(i.clientX,i.clientY),t.stopPropagation())},touchMove:function(t){var i;e.mouseDown&&(i=t.originalEvent.touches[0],e._inputmove(i.clientX,i.clientY),t.preventDefault&&t.preventDefault())},inputDown:function(t){e._useTarget(t.target,t)&&(e.threshold=e._threshold(t.target,t),e._start(t.clientX,t.clientY),e.elementFocused=t.target,"IMG"===t.target.nodeName&&t.preventDefault(),t.stopPropagation())},inputEnd:function(t){e._useTarget(t.target,t)&&(e._end(),e.elementFocused=null,t.preventDefault&&t.preventDefault())},inputMove:function(t){e.mouseDown&&(e._inputmove(t.clientX,t.clientY),t.preventDefault&&t.preventDefault())},scroll:function(t){"function"==typeof e.settings.moved&&e.settings.moved.call(e,e.settings),t.preventDefault&&t.preventDefault()},inputClick:function(t){if(Math.abs(e.velocity)>0||Math.abs(e.velocityY)>0)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1},dragStart:function(t){if(e._useTarget(t.target,t)&&e.elementFocused)return t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1},selectStart:function(t){return"function"==typeof e.settings.selectStart?e.settings.selectStart.apply(e,arguments):e._useTarget(t.target,t)?(t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1):void 0}},this._attachListeners()},s.prototype._inputmove=function(e,t){if((!this.lastMove||new Date>new Date(this.lastMove.getTime()+this.throttleTimeout))&&(this.lastMove=new Date,this.mouseDown&&(this.xpos||this.ypos))){var i=e-this.xpos,s=t-this.ypos;if(this.settings.invert&&(i*=-1,s*=-1),this.threshold>0){var n=Math.sqrt(i*i+s*s);if(this.threshold>n)return;this.threshold=0}this.elementFocused&&(this.elementFocused.blur(),this.elementFocused=null,this.el.focus()),this.settings.decelerate=!1,this.velocity=this.velocityY=0;var o=this.scrollLeft(),r=this.scrollTop();this.scrollLeft(this.settings.x?o-i:o),this.scrollTop(this.settings.y?r-s:r),this.prevXPos=this.xpos,this.prevYPos=this.ypos,this.xpos=e,this.ypos=t,this._calculateVelocities(),this._setMoveClasses(this.settings.movingClass),"function"==typeof this.settings.moved&&this.settings.moved.call(this,this.settings)}},s.prototype._calculateVelocities=function(){this.velocity=this._capVelocity(this.prevXPos-this.xpos,this.settings.maxvelocity),this.velocityY=this._capVelocity(this.prevYPos-this.ypos,this.settings.maxvelocity),this.settings.invert&&(this.velocity*=-1,this.velocityY*=-1)},s.prototype._end=function(){this.xpos&&this.prevXPos&&!1===this.settings.decelerate&&(this.settings.decelerate=!0,this._calculateVelocities(),this.xpos=this.prevXPos=this.mouseDown=!1,this._move())},s.prototype._useTarget=function(e,t){return"function"!=typeof this.settings.filterTarget||!1!==this.settings.filterTarget.call(this,e,t)},s.prototype._threshold=function(e,t){return"function"==typeof this.settings.threshold?this.settings.threshold.call(this,e,t):this.settings.threshold},s.prototype._start=function(e,t){this.mouseDown=!0,this.velocity=this.prevXPos=0,this.velocityY=this.prevYPos=0,this.xpos=e,this.ypos=t},s.prototype._resetMouse=function(){this.xpos=!1,this.ypos=!1,this.mouseDown=!1},s.prototype._decelerateVelocity=function(e,t){return 0===Math.floor(Math.abs(e))?0:e*t},s.prototype._capVelocity=function(e,t){var i=e;return e>0?e>t&&(i=t):e<0-t&&(i=0-t),i},s.prototype._setMoveClasses=function(e){var t=this.settings,i=this.el;i.classList.remove(t.movingClass.up),i.classList.remove(t.movingClass.down),i.classList.remove(t.movingClass.left),i.classList.remove(t.movingClass.right),i.classList.remove(t.deceleratingClass.up),i.classList.remove(t.deceleratingClass.down),i.classList.remove(t.deceleratingClass.left),i.classList.remove(t.deceleratingClass.right),this.velocity>0&&i.classList.add(e.right),this.velocity<0&&i.classList.add(e.left),this.velocityY>0&&i.classList.add(e.down),this.velocityY<0&&i.classList.add(e.up)},s.prototype._move=function(){var t=this._getScroller(),i=this,s=this.settings;s.x&&t.scrollWidth>0?(this.scrollLeft(this.scrollLeft()+this.velocity),Math.abs(this.velocity)>0&&(this.velocity=s.decelerate?i._decelerateVelocity(this.velocity,s.slowdown):this.velocity)):this.velocity=0,s.y&&t.scrollHeight>0?(this.scrollTop(this.scrollTop()+this.velocityY),Math.abs(this.velocityY)>0&&(this.velocityY=s.decelerate?i._decelerateVelocity(this.velocityY,s.slowdown):this.velocityY)):this.velocityY=0,i._setMoveClasses(s.deceleratingClass),"function"==typeof s.moved&&s.moved.call(this,s),Math.abs(this.velocity)>0||Math.abs(this.velocityY)>0?this.moving||(this.moving=!0,e(function(){i.moving=!1,i._move()})):i.stop()},s.prototype._getScroller=function(){return this.el},s.prototype.scrollLeft=function(e){var t=this._getScroller();if("number"!=typeof e)return t.scrollLeft;t.scrollLeft=e,this.settings.scrollLeft=e},s.prototype.scrollTop=function(e){var t=this._getScroller();if("number"!=typeof e)return t.scrollTop;t.scrollTop=e,this.settings.scrollTop=e},s.prototype._attachListeners=function(){var e=this.el,i=this.settings;t&&(e.addEventListener("touchstart",i.events.touchStart,!1),e.addEventListener("touchend",i.events.inputEnd,!1),e.addEventListener("touchmove",i.events.touchMove,!1)),e.addEventListener("mousedown",i.events.inputDown,!1),e.addEventListener("mouseup",i.events.inputEnd,!1),e.addEventListener("mousemove",i.events.inputMove,!1),e.addEventListener("click",i.events.inputClick,!1),e.addEventListener("scroll",i.events.scroll,!1),e.addEventListener("selectstart",i.events.selectStart,!1),e.addEventListener("dragstart",i.events.dragStart,!1)},s.prototype._detachListeners=function(){var e=this.el,i=this.settings;t&&(e.removeEventListener("touchstart",i.events.touchStart,!1),e.removeEventListener("touchend",i.events.inputEnd,!1),e.removeEventListener("touchmove",i.events.touchMove,!1)),e.removeEventListener("mousedown",i.events.inputDown,!1),e.removeEventListener("mouseup",i.events.inputEnd,!1),e.removeEventListener("mousemove",i.events.inputMove,!1),e.removeEventListener("click",i.events.inputClick,!1),e.removeEventListener("scroll",i.events.scroll,!1),e.removeEventListener("selectstart",i.events.selectStart,!1),e.removeEventListener("dragstart",i.events.dragStart,!1)},window.VanillaKinetic=s}()},function(e,t,i){var s,n,o;
+/**
+ * @fileoverview dragscroll - scroll area by dragging
+ * @version 0.0.8
+ *
+ * @license MIT, see http://github.com/asvd/dragscroll
+ * @copyright 2015 asvd <heliosframework@gmail.com>
+ */n=[t],void 0===(o="function"==typeof(s=function(e){var t,i,s=window,n=document,o=[],r=function(e,r){for(e=0;e<o.length;)(r=(r=o[e++]).container||r).removeEventListener("mousedown",r.md,0),s.removeEventListener("mouseup",r.mu,0),s.removeEventListener("mousemove",r.mm,0);for(o=[].slice.call(n.getElementsByClassName("dragscroll")),e=0;e<o.length;)!function(e,o,r,a,l,h){(h=e.container||e).addEventListener("mousedown",h.md=function(t){e.hasAttribute("nochilddrag")&&n.elementFromPoint(t.pageX,t.pageY)!==h||(a=1,o=t.clientX,r=t.clientY,t.preventDefault())},0),s.addEventListener("mouseup",h.mu=function(){a=0},0),s.addEventListener("mousemove",h.mm=function(s){a&&((l=e.scroller||e).scrollLeft-=t=-o+(o=s.clientX),l.scrollTop-=i=-r+(r=s.clientY),e===n.body&&((l=n.documentElement).scrollLeft-=t,l.scrollTop-=i))},0)}(o[e++])};"complete"===n.readyState?r():s.addEventListener("load",r,0),e.reset=r,window.resetDragscroll=r})?s.apply(t,n):s)||(e.exports=o)},function(e,t){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){var i,s,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function a(e){if(i===setTimeout)return setTimeout(e,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:o}catch(e){i=o}try{s="function"==typeof clearTimeout?clearTimeout:r}catch(e){s=r}}();var l,h=[],c=!1,u=-1;function d(){c&&l&&(c=!1,l.length?h=l.concat(h):u=-1,h.length&&g())}function g(){if(!c){var e=a(d);c=!0;for(var t=h.length;t;){for(l=h,h=[];++u<t;)l&&l[u].run();u=-1,t=h.length}l=null,c=!1,function(e){if(s===clearTimeout)return clearTimeout(e);if((s===r||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];h.push(new v(e,t)),1!==h.length||c||a(g)},v.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(e,t,i){function s(e){var i;function s(){if(s.enabled){var e=s,n=+new Date,o=n-(i||n);e.diff=o,e.prev=i,e.curr=n,i=n;for(var r=new Array(arguments.length),a=0;a<r.length;a++)r[a]=arguments[a];r[0]=t.coerce(r[0]),"string"!=typeof r[0]&&r.unshift("%O");var l=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,function(i,s){if("%%"===i)return i;l++;var n=t.formatters[s];if("function"==typeof n){var o=r[l];i=n.call(e,o),r.splice(l,1),l--}return i}),t.formatArgs.call(e,r),(s.log||t.log||console.log.bind(console)).apply(e,r)}}return s.namespace=e,s.enabled=t.enabled(e),s.useColors=t.useColors(),s.color=function(e){var i,s=0;for(i in e)s=(s<<5)-s+e.charCodeAt(i),s|=0;return t.colors[Math.abs(s)%t.colors.length]}(e),s.destroy=n,"function"==typeof t.init&&t.init(s),t.instances.push(s),s}function n(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=s.debug=s.default=s).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var i;t.save(e),t.names=[],t.skips=[];var s=("string"==typeof e?e:"").split(/[\s,]+/),n=s.length;for(i=0;i<n;i++)s[i]&&("-"===(e=s[i].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(i=0;i<t.instances.length;i++){var o=t.instances[i];o.enabled=t.enabled(o.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var i,s;for(i=0,s=t.skips.length;i<s;i++)if(t.skips[i].test(e))return!1;for(i=0,s=t.names.length;i<s;i++)if(t.names[i].test(e))return!0;return!1},t.humanize=i(10),t.instances=[],t.names=[],t.skips=[],t.formatters={}},function(e,t){var i=1e3,s=60*i,n=60*s,o=24*n,r=365.25*o;function a(e,t,i){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+i:Math.ceil(e/t)+" "+i+"s"}e.exports=function(e,t){t=t||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*r;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*n;case"minutes":case"minute":case"mins":case"min":case"m":return a*s;case"seconds":case"second":case"secs":case"sec":case"s":return a*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===l&&!1===isNaN(e))return t.long?function(e){return a(e,o,"day")||a(e,n,"hour")||a(e,s,"minute")||a(e,i,"second")||e+" ms"}(e):function(e){if(e>=o)return Math.round(e/o)+"d";if(e>=n)return Math.round(e/n)+"h";if(e>=s)return Math.round(e/s)+"m";if(e>=i)return Math.round(e/i)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,i){var s=i(12);"string"==typeof s&&(s=[[e.i,s,""]]);var n={hmr:!0,transform:void 0,insertInto:void 0};i(14)(s,n);s.locals&&(e.exports=s.locals)},function(e,t,i){},,function(e,t,i){var s={},n=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),o=function(e){var t={};return function(e,i){if("function"==typeof e)return e();if(void 0===t[e]){var s=function(e,t){return t?t.querySelector(e):document.querySelector(e)}.call(this,e,i);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}t[e]=s}return t[e]}}(),r=null,a=0,l=[],h=i(15);function c(e,t){for(var i=0;i<e.length;i++){var n=e[i],o=s[n.id];if(o){o.refs++;for(var r=0;r<o.parts.length;r++)o.parts[r](n.parts[r]);for(;r<n.parts.length;r++)o.parts.push(f(n.parts[r],t))}else{var a=[];for(r=0;r<n.parts.length;r++)a.push(f(n.parts[r],t));s[n.id]={id:n.id,refs:1,parts:a}}}}function u(e,t){for(var i=[],s={},n=0;n<e.length;n++){var o=e[n],r=t.base?o[0]+t.base:o[0],a={css:o[1],media:o[2],sourceMap:o[3]};s[r]?s[r].parts.push(a):i.push(s[r]={id:r,parts:[a]})}return i}function d(e,t){var i=o(e.insertInto);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var s=l[l.length-1];if("top"===e.insertAt)s?s.nextSibling?i.insertBefore(t,s.nextSibling):i.appendChild(t):i.insertBefore(t,i.firstChild),l.push(t);else if("bottom"===e.insertAt)i.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var n=o(e.insertAt.before,i);i.insertBefore(t,n)}}function g(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=l.indexOf(e);t>=0&&l.splice(t,1)}function v(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var s=function(){0;return i.nc}();s&&(e.attrs.nonce=s)}return p(t,e.attrs),d(e,t),t}function p(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function f(e,t){var i,s,n,o;if(t.transform&&e.css){if(!(o=t.transform(e.css)))return function(){};e.css=o}if(t.singleton){var l=a++;i=r||(r=v(t)),s=w.bind(null,i,l,!1),n=w.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",p(t,e.attrs),d(e,t),t}(t),s=function(e,t,i){var s=i.css,n=i.sourceMap,o=void 0===t.convertToAbsoluteUrls&&n;(t.convertToAbsoluteUrls||o)&&(s=h(s));n&&(s+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */");var r=new Blob([s],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(r),a&&URL.revokeObjectURL(a)}.bind(null,i,t),n=function(){g(i),i.href&&URL.revokeObjectURL(i.href)}):(i=v(t),s=function(e,t){var i=t.css,s=t.media;s&&e.setAttribute("media",s);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),n=function(){g(i)});return s(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;s(e=t)}else n()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=n()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=u(e,t);return c(i,t),function(e){for(var n=[],o=0;o<i.length;o++){var r=i[o];(a=s[r.id]).refs--,n.push(a)}e&&c(u(e,t),t);for(o=0;o<n.length;o++){var a;if(0===(a=n[o]).refs){for(var l=0;l<a.parts.length;l++)a.parts[l]();delete s[a.id]}}}};var m=function(){var e=[];return function(t,i){return e[t]=i,e.filter(Boolean).join("\n")}}();function w(e,t,i,s){var n=i?"":s.css;if(e.styleSheet)e.styleSheet.cssText=m(t,n);else{var o=document.createTextNode(n),r=e.childNodes;r[t]&&e.removeChild(r[t]),r.length?e.insertBefore(o,r[t]):e.appendChild(o)}}},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var i=t.protocol+"//"+t.host,s=i+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var n,o=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(o)?e:(n=0===o.indexOf("//")?o:0===o.indexOf("/")?i+o:s+o.replace(/^\.\//,""),"url("+JSON.stringify(n)+")")})}},function(e,t,i){"use strict";i.r(t);i(4),i(5);function s(e){const t=document.createElement(e),i=Array.prototype.slice.call(arguments,1);for(;i.length;){n(t,i.shift())}return t}function n(e,t){if(null!=t)if("object"!=typeof t&&"function"!=typeof t)e.appendChild(document.createTextNode(t));else if(t instanceof window.Node)e.appendChild(t);else if(t instanceof Array){const i=t.length;for(let s=0;s<i;s++)n(e,t[s])}else o(e,t)}function o(e,t){for(const i in t)t.hasOwnProperty(i)&&("style"===i?r(e,t.style):e.setAttribute(i,t[i]))}function r(e,t){if(t)if("object"==typeof t)for(const i in t)t.hasOwnProperty(i)&&(e.style[i]=t[i]);else e.style.cssText=t}function a(e){this.name="DivaParentElementNotFoundException",this.message=e,this.stack=(new Error).stack}function l(e){this.name="NotAnIIIFManifestException",this.message=e,this.stack=(new Error).stack}function h(e){this.name="ObjectDataNotSuppliedException",this.message=e,this.stack=(new Error).stack}a.prototype=new Error,l.prototype=new Error,h.prototype=new Error;var c={Events:new class{constructor(){this._cache={}}publish(e,t,i){if(this._cache[e]){const s=this._cache[e];if(void 0!==s.global){const e=s.global,n=e.length;for(let s=0;s<n;s++)e[s].apply(i||null,t||[])}if(i&&void 0!==i.getInstanceId){const s=i.getInstanceId();if(this._cache[e][s]){const n=this._cache[e][s],o=n.length;for(let e=0;e<o;e++)n[e].apply(i,t||[])}}}}subscribe(e,t,i){return this._cache[e]||(this._cache[e]={}),"string"==typeof i?(this._cache[e][i]||(this._cache[e][i]=[]),this._cache[e][i].push(t)):(this._cache[e].global||(this._cache[e].global=[]),this._cache[e].global.push(t)),i?[e,t,i]:[e,t]}unsubscribe(e,t){const i=e[0];if(this._cache[i]){let s;const n=3===e.length?e[2]:"global";if(!(s=this._cache[i][n]))return!1;if(t)return delete this._cache[i][n],s.length>0;let o=s.length;for(;o--;)if(s[o]===e[1])return this._cache[i][n].splice(o,1),!0}return!1}unsubscribeAll(e){if(e){const t=Object.keys(this._cache);let i,s=t.length;for(;s--;)i=t[s],void 0!==this._cache[i][e]&&delete this._cache[i][e]}else this._cache={}}}};var u={onDoubleClick:function(e,t){e.addEventListener("dblclick",function(e){e.ctrlKey||t(e,m(e.currentTarget,e))});const i=f(d);e.addEventListener("contextmenu",function(e){e.preventDefault(),e.ctrlKey&&(i.isTriggered()?(i.reset(),t(e,m(e.currentTarget,e))):i.trigger())})},onPinch:function(e,t){let i=0;e.addEventListener("touchstart",function(e){e.preventDefault(),2===e.originalEvent.touches.length&&(i=p(e.originalEvent.touches[0].clientX,e.originalEvent.touches[0].clientY,e.originalEvent.touches[1].clientX,e.originalEvent.touches[1].clientY))}),e.addEventListener("touchmove",function(e){if(e.preventDefault(),2===e.originalEvent.touches.length){const s=e.originalEvent.touches,n=p(s[0].clientX,s[0].clientY,s[1].clientX,s[1].clientY),o=n-i;if(Math.abs(o)>0){const o={pageX:(s[0].clientX+s[1].clientX)/2,pageY:(s[0].clientY+s[1].clientY)/2};t(e,m(e.currentTarget,o),i,n)}}})},onDoubleTap:function(e,t){const i=f(v);let s=null;e.addEventListener("touchend",e=>{if(e.preventDefault(),i.isTriggered()){i.reset();const n={pageX:e.originalEvent.changedTouches[0].clientX,pageY:e.originalEvent.changedTouches[0].clientY},o=p(s.pageX,s.pageY,n.pageX,n.pageY);o<g&&t(e,m(e.currentTarget,n)),s=null}else s={pageX:e.originalEvent.changedTouches[0].clientX,pageY:e.originalEvent.changedTouches[0].clientY},i.trigger()})}};const d=500,g=50,v=250;function p(e,t,i,s){return Math.sqrt((i-e)*(i-e)+(s-t)*(s-t))}function f(e){let t=!1,i=null;return{trigger(){t=!0,s(),i=setTimeout(function(){t=!1,i=null},e)},isTriggered:()=>t,reset(){t=!1,s()}};function s(){null!==i&&(clearTimeout(i),i=null)}}function m(e,t){const i=e.getBoundingClientRect();return{left:t.pageX-i.left,top:t.pageY-i.top}}var w=i(0),b=i.n(w);class y{constructor(e,t){this.page=e,this._viewerCore=t,this._innerElement=this._viewerCore.getSettings().innerElement,this._pageToolsElem=null,this.labelWidth=0}mount(){null===this._pageToolsElem&&(this._buttons=this._initializePageToolButtons(),this._pageToolsElem=s("div",{class:"diva-page-tools-wrapper"},s("div",{class:"diva-page-tools"},this._buttons)),this._pageLabelsElem=s("div",{class:"diva-page-labels-wrapper"},s("div",{class:"diva-page-labels"},this._viewerCore.settings.manifest.pages[this.page].l))),this.refresh(),this._innerElement.appendChild(this._pageToolsElem),this._innerElement.appendChild(this._pageLabelsElem)}_initializePageToolButtons(){const e=this._viewerCore.getSettings(),t=this._viewerCore.getPublicInstance(),i=this.page;return this._viewerCore.getPageTools().map(s=>{const n=s.pageToolsIcon.cloneNode(!0);return n.addEventListener("click",n=>{s.handleClick.call(s,n,e,t,i)},!1),n.addEventListener("touchend",n=>{n.preventDefault(),s.handleClick.call(s,n,e,t,i)},!1),n})}unmount(){this._innerElement.removeChild(this._pageToolsElem),this._innerElement.removeChild(this._pageLabelsElem)}refresh(){const e=this._viewerCore.getPageRegion(this.page,{includePadding:!0,incorporateViewport:!0});let t=window.getComputedStyle(this._innerElement,null).getPropertyValue("margin-left");this._pageToolsElem.style.top=`${e.top}px`,this._pageToolsElem.style.left=`${e.left-parseInt(t)}px`,this._pageLabelsElem.style.top=`${e.top}px`,this._pageLabelsElem.style.left=`${e.right-parseInt(t)-this.labelWidth-5}px`}}class _{constructor(e){if(this._viewerCore=e,this._viewerState=e.getInternalState(),this._overlays=[],this._viewerCore.getPageTools().length){const t=e.getSettings().numPages;for(let i=0;i<t;i++){const t=new y(i,e);this._overlays.push(t),this._viewerCore.addPageOverlay(t);let s=document.createElement("span");s.innerHTML=e.settings.manifest.pages[i].l,s.classList.add("diva-page-labels"),s.setAttribute("style","display: inline-block;"),document.body.appendChild(s);let n=s.clientWidth;document.body.removeChild(s),t.labelWidth=n}}}onDoubleClick(e,t){const i=this._viewerCore.getSettings(),s=e.ctrlKey?i.zoomLevel-1:i.zoomLevel+1,n=this._viewerCore.getPagePositionAtViewportOffset(t);this._viewerCore.zoom(s,n)}onPinch(e,t,i,s){const n=this._viewerCore.getInternalState(),o=this._viewerCore.getSettings();let r=Math.log(Math.pow(2,o.zoomLevel)*s/(i*Math.log(2)))/Math.log(2);if(r=Math.max(o.minZoomLevel,r),(r=Math.min(o.maxZoomLevel,r))===o.zoomLevel)return;const a=this._viewerCore.getPagePositionAtViewportOffset(t),l=this._viewerCore.getCurrentLayout().getPageToViewportCenterOffset(a.anchorPage,n.viewport),h=1/Math.pow(2,o.zoomLevel-r);this._viewerCore.reload({zoomLevel:r,goDirectlyTo:a.anchorPage,horizontalOffset:l.x-a.offset.left+a.offset.left*h,verticalOffset:l.y-a.offset.top+a.offset.top*h})}onViewWillLoad(){this._viewerCore.publish("DocumentWillLoad",this._viewerCore.getSettings())}onViewDidLoad(){this._handleZoomLevelChange();const e=this._viewerCore.getSettings().activePageIndex,t=this._viewerCore.getPageName(e);this._viewerCore.publish("DocumentDidLoad",e,t)}onViewDidUpdate(e,t){const i=null!==t?t:function(e,t,i){const s=i.top+i.height/2,n=i.left+i.width/2,o=b()(e,e=>{const i=t.getPageDimensions(e),o=t.getPageOffset(e,{includePadding:!1}),r=o.left+i.height/2,a=o.top+i.width/2,l=Math.max(Math.abs(n-r)-i.width/2,0),h=Math.max(Math.abs(s-a)-i.height/2,0);return-(l*l+h*h)});return null!=o?o:null}(e,this._viewerCore.getCurrentLayout(),this._viewerCore.getViewport());let s=this._viewerState.viewport.intersectionTolerance;this._viewerState.viewport.intersectionTolerance=0;let n=e.filter(e=>this._viewerState.renderer.isPageVisible(e));this._viewerState.viewport.intersectionTolerance=s,null!==i&&this._viewerCore.setCurrentPages(i,n),null!==t&&this._viewerCore.publish("ViewerDidJump",t),this._handleZoomLevelChange()}_handleZoomLevelChange(){const e=this._viewerState,t=e.options.zoomLevel;e.oldZoomLevel!==t&&e.oldZoomLevel>=0&&(e.oldZoomLevel<t?this._viewerCore.publish("ViewerDidZoomIn",t):this._viewerCore.publish("ViewerDidZoomOut",t),this._viewerCore.publish("ViewerDidZoom",t)),e.oldZoomLevel=t}destroy(){this._overlays.forEach(e=>{this._viewerCore.removePageOverlay(e)},this)}}class P{constructor(e){this._viewerCore=e}onDoubleClick(e,t){const i=this._viewerCore.getPagePositionAtViewportOffset(t),s=this._viewerCore.getCurrentLayout(),n=this._viewerCore.getViewport(),o=s.getPageToViewportCenterOffset(i.anchorPage,n);this._viewerCore.reload({inGrid:!1,goDirectlyTo:i.anchorPage,horizontalOffset:o.x+i.offset.left,verticalOffset:o.y+i.offset.top})}onPinch(){this._viewerCore.reload({inGrid:!1})}onViewWillLoad(){}onViewDidLoad(){}onViewDidUpdate(e,t){if(0===e.length)return;let i=this._viewerCore.viewerState.viewport.intersectionTolerance;this._viewerCore.viewerState.viewport.intersectionTolerance=0;let s=e.filter(e=>this._viewerCore.viewerState.renderer.isPageVisible(e));if(this._viewerCore.viewerState.viewport.intersectionTolerance=i,null!==t)return void this._viewerCore.setCurrentPages(t,s);const n=this._viewerCore.getCurrentLayout(),o=[];e.forEach(e=>{const t=n.getPageInfo(e).group;0!==o.length&&t===o[o.length-1]||o.push(t)});const r=this._viewerCore.getViewport();let a;a=1===o.length||o[0].region.top>=r.top?o[0]:o[1].region.bottom<=r.bottom?o[1]:function(e,t){const i=t.top+t.height/2;return b()(e,e=>{const t=e.region.top+e.dimensions.height/2;return-Math.abs(i-t)})}(o,r);const l=this._viewerCore.getSettings().activePageIndex;a.pages.some(e=>e.index===l)||this._viewerCore.setCurrentPages(a.pages[0].index,s)}destroy(){}}class S{constructor(){this._pages={},this._renderedPages=[],this._renderedPageMap={}}addOverlay(e){(this._pages[e.page]||(this._pages[e.page]=[])).push(e),this._renderedPageMap[e.page]&&e.mount()}removeOverlay(e){const t=e.page,i=this._pages[t];if(!i)return;const s=i.indexOf(e);-1!==s&&(this._renderedPageMap[t]&&i[s].unmount(),i.splice(s,1),0===i.length&&delete this._pages[t])}updateOverlays(e){const t=this._renderedPages,i={};e.map(e=>{i[e]=!0,this._renderedPageMap[e]||(this._renderedPageMap[e]=!0,this._invokeOnOverlays(e,e=>{e.mount()}))}),t.map(e=>{i[e]?this._invokeOnOverlays(e,e=>{e.refresh()}):(delete this._renderedPageMap[e],this._invokeOnOverlays(e,e=>{e.unmount()}))}),this._renderedPages=e}_invokeOnOverlays(e,t){const i=this._pages[e];i&&i.map(e=>t(e))}}class C{constructor(e,t){this._rows=e,this._cols=t,this._map=new Array(e).fill(null).map(()=>new Array(t).fill(!1))}isLoaded(e,t){return e>=this._rows||t>=this._cols||this._map[e][t]}set(e,t,i){this._map[e][t]=i}}class L{constructor(e){this._levels=e;const t=this._urlsToTiles={};e.forEach(e=>{e.tiles.forEach(i=>{t[i.url]={zoomLevel:e.zoomLevel,row:i.row,col:i.col}})}),this.clear()}clear(){const e=this._loadedByLevel={};this._levels.forEach(t=>{e[t.zoomLevel]=new C(t.rows,t.cols)})}getTiles(e){const t=[],i=this._levels[0].zoomLevel,s=new C(this._levels[0].rows,this._levels[0].cols);let n;if(null===e)n=0;else{const t=Math.ceil(e);n=function(e,t){const i=e.length;for(let s=0;s<i;s++)if(t(e[s],s))return s;return-1}(this._levels,e=>e.zoomLevel<=t)}this._levels.slice(0,n+1).reverse().concat(this._levels.slice(n+1)).forEach(e=>{const n=this._loadedByLevel[e.zoomLevel];let o=e.tiles.filter(e=>n.isLoaded(e.row,e.col));const r=Math.pow(2,i-e.zoomLevel);o=o.filter(e=>{let t=!1;const i=e.row*r,n=e.col*r;for(let e=0;e<r;e++)for(let o=0;o<r;o++)s.isLoaded(i+e,n+o)||(t=!0,s.set(i+e,n+o,!0));return t}),t.push(o)},this),t.reverse();const o=[];return t.forEach(e=>{o.push.apply(o,e)}),o}updateFromCache(e){this.clear(),this._levels.forEach(t=>{const i=this._loadedByLevel[t.zoomLevel];t.tiles.forEach(t=>{e.has(t.url)&&i.set(t.row,t.col,!0)})},this)}updateWithLoadedUrls(e){e.forEach(e=>{const t=this._urlsToTiles[e];this._loadedByLevel[t.zoomLevel].set(t.row,t.col,!0)},this)}}class O{constructor(e,t){const i=function(e,t){const i=null===t?e.pageLayouts:function(e,t){const i=Math.pow(2,t-e.maxZoomLevel);return e.pageLayouts.map(e=>({dimensions:E(e.dimensions,i),pages:e.pages.map(e=>({index:e.index,groupOffset:{top:Math.floor(e.groupOffset.top*i),left:Math.floor(e.groupOffset.left*i)},dimensions:E(e.dimensions,i)}))}))}(e,t),s=function(e,t){let i,s;const n=e.padding.document;e.verticallyOriented?(i="width",s=n.left+n.right):(i="height",s=n.top+n.bottom);return s+t.reduce((e,t)=>Math.max(t.dimensions[i],e),0)}(e,i);let n=e.verticallyOriented?e.padding.document.top:e.padding.document.left;const o=[],r={top:e.padding.page.top,left:e.padding.page.left};let a,l;i.forEach((t,i)=>{let a,l;e.verticallyOriented?(a=n,l=(s-t.dimensions.width)/2):(a=(s-t.dimensions.height)/2,l=n);const h={top:a,bottom:a+r.top+t.dimensions.height,left:l,right:l+r.left+t.dimensions.width};o.push({index:i,dimensions:t.dimensions,pages:t.pages,region:h,padding:r}),n=e.verticallyOriented?h.bottom:h.right}),e.verticallyOriented?(a=n+r.top,l=s):(a=s,l=n+r.left);return{dimensions:{height:a,width:l},pageGroups:o}}(e,t);this.dimensions=i.dimensions,this.pageGroups=i.pageGroups,this._pageLookup=function(e){const t={};return e.forEach(e=>{e.pages.forEach(i=>{t[i.index]={index:i.index,group:e,dimensions:i.dimensions,groupOffset:i.groupOffset}})}),t}(i.pageGroups)}getPageInfo(e){return this._pageLookup[e]||null}getPageDimensions(e){if(!this._pageLookup||!this._pageLookup[e])return null;const t=x(this._pageLookup[e]);return{height:t.bottom-t.top,width:t.right-t.left}}getPageOffset(e,t){const i=this.getPageRegion(e,t);return i?{top:i.top,left:i.left}:null}getPageRegion(e,t){const i=this._pageLookup[e];if(!i)return null;const s=x(i),n=i.group.padding;return t&&t.includePadding?{top:s.top+n.top,left:s.left+n.left,bottom:s.bottom,right:s.right}:{top:s.top,left:s.left,bottom:s.bottom+n.top,right:s.right}}getPageToViewportCenterOffset(e,t){const i=t.left,s=t.right-t.left,n=this.getPageOffset(e),o=i-n.left+parseInt(s/2,10),r=t.top,a=t.bottom-t.top;return{x:o,y:r-n.top+parseInt(a/2,10)}}}function x(e){const t=e.groupOffset.top+e.group.region.top,i=t+e.dimensions.height,s=e.groupOffset.left+e.group.region.left;return{top:t,bottom:i,left:s,right:s+e.dimensions.width}}function E(e,t){return{height:Math.floor(e.height*t),width:Math.floor(e.width*t)}}const I=i(1)("diva:ImageCache"),T=100;class D{constructor(e){e=e||{maxKeys:T},this.maxKeys=e.maxKeys||T,this._held={},this._urls={},this._lru=[]}get(e){const t=this._urls[e];return t?t.img:null}has(e){return!!this._urls[e]}put(e,t){let i=this._urls[e];i?(i.img=t,this._promote(i)):(i={img:t,url:e},this._urls[e]=i,this._tryEvict(1),this._lru.unshift(i))}_promote(e){const t=this._lru.indexOf(e);this._lru.splice(t,1),this._lru.unshift(e)}_tryEvict(e){const t=this.maxKeys-e;if(this._lru.length<=t)return;let i=this._lru.length-1;for(;;){const e=this._lru[i];if(!this._held[e.url]&&(I("Evicting image %s",e.url),this._lru.splice(i,1),delete this._urls[e.url],this._lru.length<=t))break;if(0===i){I.enabled&&I("Cache overfull by %s (all entries are being held)",this._lru.length-t);break}i--}}acquire(e){this._held[e]=(this._held[e]||0)+1,this._promote(this._urls[e])}release(e){this._held[e]>1?this._held[e]--:delete this._held[e],this._tryEvict(0)}}class M{constructor(e){this._url=e.url,this._callback=e.load,this._errorCallback=e.error,this.timeoutTime=e.timeoutTime||0,this._aborted=this._complete=!1,this.timeout=setTimeout(()=>{this._image=new Image,this._image.onload=this._handleLoad.bind(this),this._image.onerror=this._handleError.bind(this),this._image.src=e.url},this.timeoutTime)}abort(){clearTimeout(this.timeout),this._image&&(this._image.onload=this._image.onerror=null,this._image.src=""),this._aborted=!0}_handleLoad(){this._aborted?console.error("ImageRequestHandler invoked on cancelled request for "+this._url):this._complete?console.error("ImageRequestHandler invoked on completed request for "+this._url):(this._complete=!0,this._callback(this._image))}_handleError(){this._errorCallback(this._image)}}var z={animate:function(e){const t=e.duration,i=e.parameters,s=e.onUpdate,n=e.onEnd,o=V(),r=o+t,a={},l={},h=Object.keys(i);h.forEach(e=>{const t=i[e];a[e]=function(e,t,i){return s=>e+(t-e)*i(s)}(t.from,t.to,t.easing||k)});let c=requestAnimationFrame(function e(){const i=V();const n=Math.min((i-o)/t,1);!function(e){h.forEach(t=>{l[t]=a[t](e)})}(n);s(l);i<r?c=requestAnimationFrame(e):u({interrupted:!1})});return{cancel(){null!==c&&(cancelAnimationFrame(c),u({interrupted:!0}))}};function u(e){c=null,n&&n(e)}},easing:{linear:function(e){return e},cubic:k}};let V;function k(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1}V="undefined"!=typeof performance&&performance.now?()=>performance.now():()=>Date.now();const F=250;class j{constructor(e,t){this._viewport=e.viewport,this._outerElement=e.outerElement,this._documentElement=e.innerElement,this._settings=e.settings,this._hooks=t||{},this._canvas=s("canvas",{class:"diva-viewer-canvas"}),this._ctx=this._canvas.getContext("2d"),this.layout=null,this._sourceResolver=null,this._renderedPages=null,this._config=null,this._zoomLevel=null,this._compositeImages=null,this._renderedTiles=null,this._animation=null,this._cache=new D,this._pendingRequests={}}static getCompatibilityErrors(){return"undefined"!=typeof HTMLCanvasElement?null:["Your browser lacks support for the ",s("pre","canvas")," element. Please upgrade your browser."]}load(e,t,i){if(this._clearAnimation(),this._hooks.onViewWillLoad&&this._hooks.onViewWillLoad(),this._sourceResolver=i,this._config=e,this._compositeImages={},this._setLayoutToZoomLevel(t.zoomLevel),!this.layout.getPageInfo(t.anchorPage))throw new Error("invalid page: "+t.anchorPage);this._canvas.width===this._viewport.width&&this._canvas.height===this._viewport.height||(this._canvas.width=this._viewport.width,this._canvas.height=this._viewport.height),this.goto(t.anchorPage,t.verticalOffset,t.horizontalOffset),this._canvas.parentNode!==this._outerElement&&this._outerElement.insertBefore(this._canvas,this._outerElement.firstChild),this._hooks.onViewDidLoad&&this._hooks.onViewDidLoad()}_setViewportPosition(e){if(e.zoomLevel!==this._zoomLevel){if(null===this._zoomLevel)throw new TypeError("The current view is not zoomable");if(null===e.zoomLevel)throw new TypeError("The current view requires a zoom level");this._setLayoutToZoomLevel(e.zoomLevel)}this._goto(e.anchorPage,e.verticalOffset,e.horizontalOffset)}_setLayoutToZoomLevel(e){this.layout=new O(this._config,e),this._zoomLevel=e,o(this._documentElement,{style:{height:this.layout.dimensions.height+"px",width:this.layout.dimensions.width+"px"}}),this._viewport.setInnerDimensions(this.layout.dimensions)}adjust(){this._clearAnimation(),this._render(),this._hooks.onViewDidUpdate&&this._hooks.onViewDidUpdate(this._renderedPages.slice(),null)}_render(){const e=[];this.layout.pageGroups.forEach(t=>{if(!this._viewport.intersectsRegion(t.region))return;const i=t.pages.filter(function(e){return this.isPageVisible(e.index)},this).map(e=>e.index);e.push.apply(e,i)},this),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._paintOutline(e),e.forEach(e=>{if(!this._compositeImages[e]){const t=this.layout.getPageInfo(e),i=this._sourceResolver.getAllZoomLevelsForPage(t),s=new L(i);s.updateFromCache(this._cache),this._compositeImages[e]=s}},this),this._initiateTileRequests(e);const t=R(this._renderedPages||[],e);t.removed.forEach(e=>{delete this._compositeImages[e]},this),this._renderedPages=e,this._paint(),this._hooks.onPageWillLoad&&t.added.forEach(e=>{this._hooks.onPageWillLoad(e)},this)}_paint(){const e=[];this._renderedPages.forEach(t=>{this._compositeImages[t].getTiles(this._zoomLevel).forEach(i=>{const s=A(i,this._zoomLevel);this._isTileVisible(t,s)&&(e.push(i.url),this._drawTile(t,s,this._cache.get(i.url)))})});const t=this._cache,i=R(this._renderedTiles||[],e);i.added.forEach(e=>{t.acquire(e)}),i.removed.forEach(e=>{t.release(e)}),i.removed&&this._renderedPages.forEach(e=>{this._compositeImages[e].updateFromCache(this._cache)},this),this._renderedTiles=e}_paintOutline(e){e.forEach(e=>{let t=this.layout.getPageInfo(e),i=this._getImageOffset(e),s=Math.max(0,(this._viewport.width-this.layout.dimensions.width)/2),n=Math.max(0,(this._viewport.height-this.layout.dimensions.height)/2),o=i.left-this._viewport.left+s,r=i.top-this._viewport.top+n,a=o<0?-o:0,l=r<0?-r:0,h=Math.max(0,o),c=Math.max(0,r),u=t.dimensions.width-a,d=t.dimensions.height-l;this._ctx.strokeStyle="#AAA",this._ctx.strokeRect(h+.5,c+.5,u,d)})}_initiateTileRequests(e){const t={},i=(e,i)=>{const s=this._compositeImages[i];t[e.url]=new M({url:e.url,timeoutTime:F,load:t=>{delete this._pendingRequests[e.url],this._cache.put(e.url,t),s===this._compositeImages[i]?(s.updateWithLoadedUrls([e.url]),this._isTileForSourceVisible(i,e)&&this._paint()):this._isTileForSourceVisible(i,e)&&this._paint()},error:()=>{delete this._pendingRequests[e.url]}})};for(let s=0;s<e.length;s++){const n=e[s],o=this._sourceResolver.getBestZoomLevelForPage(this.layout.getPageInfo(n)).tiles;for(let e=0;e<o.length;e++){const s=o[e];!this._cache.has(s.url)&&this._isTileForSourceVisible(n,s)&&(this._pendingRequests[s.url]?(t[s.url]=this._pendingRequests[s.url],delete this._pendingRequests[s.url]):i(s,n))}}for(const e in this._pendingRequests)this._pendingRequests[e].abort();this._pendingRequests=t}_drawTile(e,t,i){let s=this._getTileToDocumentOffset(e,t),n=Math.max(0,(this._viewport.width-this.layout.dimensions.width)/2),o=Math.max(0,(this._viewport.height-this.layout.dimensions.height)/2),r=s.left-this._viewport.left+n,a=s.top-this._viewport.top+o,l=r<0?-r:0,h=a<0?-a:0,c=Math.max(0,r),u=Math.max(0,a),d=l/t.scaleRatio,g=h/t.scaleRatio,v=Math.min(t.dimensions.width,i.width*t.scaleRatio)-l,p=Math.min(t.dimensions.height,i.height*t.scaleRatio)-h,f=Math.max(1,Math.round(v)),m=Math.max(1,Math.round(p)),w=f/t.scaleRatio,b=m/t.scaleRatio;this._ctx.drawImage(i,d,g,w,b,c,u,f,m)}_isTileForSourceVisible(e,t){return this._isTileVisible(e,A(t,this._zoomLevel))}_isTileVisible(e,t){const i=this._getTileToDocumentOffset(e,t);return this._viewport.intersectsRegion({top:i.top,bottom:i.top+t.dimensions.height,left:i.left,right:i.left+t.dimensions.width})}_getTileToDocumentOffset(e,t){const i=this._getImageOffset(e);return{top:i.top+t.offset.top,left:i.left+t.offset.left}}_getImageOffset(e){return this.layout.getPageOffset(e,{includePadding:!0})}goto(e,t,i){this._clearAnimation(),this._goto(e,t,i),this._hooks.onViewDidUpdate&&this._hooks.onViewDidUpdate(this._renderedPages.slice(),e)}_goto(e,t,i){const s=this.layout.getPageOffset(e),n=s.top+t-Math.round(this._viewport.height/2),o=s.left+i-Math.round(this._viewport.width/2);this._viewport.top=n,this._viewport.left=o,this._render()}transitionViewportPosition(e){this._clearAnimation();const t=e.getPosition,i=this._hooks.onViewDidTransition;this._animation=z.animate({duration:e.duration,parameters:e.parameters,onUpdate:e=>{this._setViewportPosition(t(e)),this._hooks.onZoomLevelWillChange(e.zoomLevel),i&&i()},onEnd:t=>{e.onEnd&&e.onEnd(t),this._hooks.onViewDidUpdate&&!t.interrupted&&this._hooks.onViewDidUpdate(this._renderedPages.slice(),null)}})}_clearAnimation(){this._animation&&(this._animation.cancel(),this._animation=null)}isPageVisible(e){if(!this.layout)return!1;return!!this.layout.getPageInfo(e)&&this._viewport.intersectsRegion(this.layout.getPageRegion(e))}getRenderedPages(){return this._renderedPages.slice()}destroy(){this._clearAnimation(),Object.keys(this._pendingRequests).forEach(e=>{const t=this._pendingRequests[e];delete this._pendingRequests[e],t.abort()},this),this._canvas.parentNode.removeChild(this._canvas)}}function A(e,t){let i;return i=null===t?1:Math.pow(2,t-e.zoomLevel),{sourceZoomLevel:e.zoomLevel,scaleRatio:i,row:e.row,col:e.col,dimensions:{width:e.dimensions.width*i,height:e.dimensions.height*i},offset:{left:e.offset.left*i,top:e.offset.top*i},url:e.url}}function R(e,t){if(e===t)return{added:[],removed:[]};const i=e.filter(e=>-1===t.indexOf(e));return{added:t.filter(t=>-1===e.indexOf(t)),removed:i}}function H(e,t){const i=t.getMaxPageDimensions(e);return{width:Math.floor(i.width),height:Math.floor(i.height)}}function B(e){return function(e){const t=e.manifest,i=[];let s=null,n=[];const o=()=>{for(let e=0,t=n.length;e<t;e++)i.push([n[e]]);n=[]};t.pages.forEach((r,a)=>{const l={index:a,dimensions:H(a,t),paged:!t.paged||r.paged};(e.showNonPagedPages||l.paged)&&(l.paged?0===a||r.facingPages?(i.push([l]),o()):null===s?s=l:(i.push([s,l]),s=null,o()):n.push(l))}),null!==s&&(i.push([s]),o());return i}(e).map(t=>(function(e,t){const i=e.verticallyOriented;if(2===t.length)return function(e,t,i){const s=e.dimensions,n=t.dimensions,o=Math.max(s.height,n.height);let r,a,l;if(i){const e=Math.max(s.width,n.width);r=2*e,a=e-s.width,l=e}else r=s.width+n.width,a=0,l=s.width;return{dimensions:{height:o,width:r},pages:[{index:e.index,dimensions:s,groupOffset:{top:0,left:a}},{index:t.index,dimensions:n,groupOffset:{top:0,left:l}}]}}(t[0],t[1],i);const s=t[0],n=s.dimensions;let o;o=s.paged?0===s.index&&i?n.width:0:i?n.width/2:0;const r=i&&!e.manifest.pages[s.index].facingPages;return{dimensions:{height:n.height,width:r?2*n.width:n.width},pages:[{index:s.index,groupOffset:{top:0,left:o},dimensions:n}]}})(e,t))}function Z(e){const t=e.viewport.width,i=e.manifest,s=e.pagesPerRow,n=e.fixedHeightGrid,o=e.fixedPadding,r=e.showNonPagedPages,a=(t-o*(s+1))/s,l=a,h=n?o+i.minRatio*a:o+i.maxRatio*a,c=[];let u=[];const d={height:h,width:t};return i.pages.forEach((e,t)=>{if(!r&&i.paged&&!e.paged)return;const a=(e=>{const t=e.d[e.d.length-1],i=t.h/t.w;let s,r;return n?(s=(h-o)/i,r=h-o):r=(s=l)*i,{width:Math.round(s),height:Math.round(r)}})(e);let g=Math.floor(u.length*(o+l)+o);n&&(g+=(l-a.width)/2),u.push({index:t,dimensions:a,groupOffset:{top:0,left:g}}),u.length===s&&(c.push({dimensions:d,pages:u}),u=[])}),u.length>0&&c.push({dimensions:d,pages:u}),c}function G(e){if(e.inGrid)return Z(N(e,["manifest","viewport","pagesPerRow","fixedHeightGrid","fixedPadding","showNonPagedPages"]));{const t=N(e,["manifest","verticallyOriented","showNonPagedPages"]);return e.inBookLayout?B(t):function(e){const t=e.manifest,i=[];return t.pages.forEach((s,n)=>{if(!e.showNonPagedPages&&t.paged&&!s.paged)return;const o=H(n,t);i.push({dimensions:o,pages:[{index:n,groupOffset:{top:0,left:0},dimensions:o}]})}),i}(t)}}function N(e,t){const i={};return t.forEach(function(t){i[t]=e[t]}),i}function U(e){const t={};return e.forEach(e=>{!function(e,t){Object.keys(t).forEach(i=>{Object.defineProperty(e,i,{get:()=>t[i],set:()=>{throw new TypeError("Cannot set settings."+i)}})})}(t,e)}),t}class W{constructor(e){this.whitelistedKeys=e.whitelistedKeys||[],this.additionalProperties=e.additionalProperties||[],this.validations=e.validations}isValid(e,t,i){let s=null;if(this.validations.some((t,i)=>t.key===e&&(s=i,!0)),null===s)return!0;const n={};n[e]=t;const o=Y(i,n,this);return!this._runValidation(s,t,o)}validate(e){this._validateOptions({},e)}getValidatedOptions(e,t){const i=Object.assign({},t);return this._validateOptions(e,i),i}_validateOptions(e,t){const i=Y(e,t,this);this._applyValidations(t,i)}_applyValidations(e,t){this.validations.forEach((i,s)=>{if(!e.hasOwnProperty(i.key))return;const n=e[i.key],o=this._runValidation(s,n,t);o&&(o.warningSuppressed||function(e,t,i){console.warn("Invalid value for "+e+": "+t+". Using "+i+" instead.")}(i.key,n,o.value),e[i.key]=o.value)},this)}_runValidation(e,t,i){const s=this.validations[e];i.index=e;let n=!1;const o={suppressWarning:()=>{n=!0}},r=s.validate(t,i.proxy,o);return void 0===r||r===t?null:{value:r,warningSuppressed:n}}}function Y(e,t,i){const s={proxy:{},index:null},n=function(e,t,i){if(i in t)return t[i];return e[i]}.bind(null,e,t),o={};return i.whitelistedKeys.forEach(e=>{o[e]={get:n.bind(null,e)}}),i.additionalProperties.forEach(e=>{o[e.key]={get:e.get}}),i.validations.forEach((e,t)=>{o[e.key]={get:()=>{if(t<s.index)return n(e.key);const o=i.validations[s.index].key;throw new TypeError("Cannot access setting "+e.key+" while validating "+o)}}}),Object.defineProperties(s.proxy,o),s}class q{constructor(e,t){t=t||{},this.intersectionTolerance=t.intersectionTolerance||0,this.outer=e,this._top=this._left=this._width=this._height=this._innerDimensions=null,this.invalidate()}intersectsRegion(e){return this.hasHorizontalOverlap(e)&&this.hasVerticalOverlap(e)}hasVerticalOverlap(e){const t=this.top-this.intersectionTolerance,i=this.bottom+this.intersectionTolerance;return $(e.top,t,i)||$(e.bottom,t,i)||e.top<=t&&e.bottom>=i}hasHorizontalOverlap(e){const t=this.left-this.intersectionTolerance,i=this.right+this.intersectionTolerance;return $(e.left,t,i)||$(e.right,t,i)||e.left<=t&&e.right>=i}invalidate(){this._width=this.outer.clientWidth,this._height=this.outer.clientHeight,this._top=this.outer.scrollTop,this._left=this.outer.scrollLeft}setInnerDimensions(e){this._innerDimensions=e,e&&(this._top=J(this._top,0,e.height-this._height),this._left=J(this._left,0,e.width-this._width))}}function X(e,t){const i="_"+e,s="scroll"+e.charAt(0).toUpperCase()+e.slice(1);return{get:function(){return this[i]},set:function(e){let n;if(this._innerDimensions){n=J(e,0,this._innerDimensions[t]-this[t])}else n=Q(e,0);this[i]=this.outer[s]=n}}}function K(e){return{get:function(){return this["_"+e]}}}function $(e,t,i){return e>=t&&e<=i}function J(e,t,i){return Q(function(e,t){return Math.min(e,t)}(e,i),t)}function Q(e,t){return Math.max(e,t)}Object.defineProperties(q.prototype,{top:X("top","height"),left:X("left","width"),width:K("width"),height:K("height"),bottom:{get:function(){return this._top+this._height}},right:{get:function(){return this._left+this._width}}});const ee=i(1)("diva:ViewerCore");function te(){return te.counter++}te.counter=1;const ie=[{key:"goDirectlyTo",validate:(e,t)=>{if(e<0||e>=t.manifest.pages.length)return 0}},{key:"minPagesPerRow",validate:e=>Math.max(2,e)},{key:"maxPagesPerRow",validate:(e,t)=>Math.max(e,t.minPagesPerRow)},{key:"pagesPerRow",validate:(e,t)=>{if(e<t.minPagesPerRow||e>t.maxPagesPerRow)return t.maxPagesPerRow}},{key:"maxZoomLevel",validate:(e,t,i)=>{if(i.suppressWarning(),e<0||e>t.manifest.maxZoom)return t.manifest.maxZoom}},{key:"minZoomLevel",validate:(e,t,i)=>e>t.manifest.maxZoom?(i.suppressWarning(),0):e<0||e>t.maxZoomLevel?0:void 0},{key:"zoomLevel",validate:(e,t,i)=>e>t.manifest.maxZoom?(i.suppressWarning(),0):e<t.minZoomLevel||e>t.maxZoomLevel?t.minZoomLevel:void 0}];class se{constructor(e,t,i){this.parentObject=e,this.publicInstance=i,this.viewerState={currentPageIndices:[0],activePageIndex:0,horizontalOffset:0,horizontalPadding:0,ID:null,initialKeyScroll:!1,initialSpaceScroll:!1,innerElement:null,innerObject:{},isActiveDiva:!0,isScrollable:!0,isZooming:!1,loaded:!1,manifest:null,mobileWebkit:!1,numPages:0,oldZoomLevel:-1,options:t,outerElement:null,outerObject:{},pageOverlays:new S,pageTools:[],parentObject:this.parentObject,pendingManifestRequest:null,pluginInstances:[],renderer:null,resizeTimer:-1,scrollbarWidth:0,selector:"",throbberTimeoutID:-1,toolbar:null,verticalOffset:0,verticalPadding:0,viewHandler:null,viewport:null,viewportElement:null,viewportObject:null,zoomDuration:400},this.settings=U([t,this.viewerState]);const n=te();this.viewerState.ID="diva-"+n+"-",this.viewerState.selector=this.settings.ID,Object.defineProperties(this.settings,{panelHeight:{get:()=>this.viewerState.viewport.height},panelWidth:{get:()=>this.viewerState.viewport.width}}),this.optionsValidator=new W({additionalProperties:[{key:"manifest",get:()=>this.viewerState.manifest}],validations:ie}),this.viewerState.scrollbarWidth=function(){let e=document.createElement("p");e.style.width="100%",e.style.height="200px";let t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.visibility="hidden",t.style.width="200px",t.style.height="150px",t.style.overflow="hidden",t.appendChild(e),document.body.appendChild(t);let i=e.offsetWidth;t.style.overflow="scroll";let s=e.offsetWidth;return i===s&&(s=t.clientWidth),document.body.removeChild(t),i-s}(),this.viewerState.mobileWebkit=void 0!==window.orientation,null===t.hashParamSuffix&&(t.hashParamSuffix=1===n?"":n+"");const o=s("div",this.elemAttrs("inner",{class:"diva-inner"})),r=s("div",this.elemAttrs("viewport"),o),a=s("div",this.elemAttrs("outer"),r,s("div",this.elemAttrs("throbber"),[s("div",{class:"cube cube1"}),s("div",{class:"cube cube2"}),s("div",{class:"cube cube3"}),s("div",{class:"cube cube4"}),s("div",{class:"cube cube5"}),s("div",{class:"cube cube6"}),s("div",{class:"cube cube7"}),s("div",{class:"cube cube8"}),s("div",{class:"cube cube9"})]));this.viewerState.innerElement=o,this.viewerState.viewportElement=r,this.viewerState.outerElement=a,this.viewerState.innerObject=o,this.viewerState.viewportObject=r,this.viewerState.outerObject=a,this.settings.parentObject.append(a),this.viewerState.viewport=new q(this.viewerState.viewportElement,{intersectionTolerance:this.settings.viewportMargin}),this.boundScrollFunction=this.scrollFunction.bind(this),this.boundEscapeListener=this.escapeListener.bind(this),this.initPlugins(),this.handleEvents(),this.showThrobber()}isValidOption(e,t){return this.optionsValidator.isValid(e,t,this.viewerState.options)}elemAttrs(e,t){const i={id:this.settings.ID+e,class:"diva-"+e};return t?Object.assign(i,t):i}getPageData(e,t){return this.settings.manifest.pages[e].d[this.settings.zoomLevel][t]}clearViewer(){this.viewerState.viewport.top=0,clearTimeout(this.viewerState.resizeTimer)}hasChangedOption(e,t){return t in e&&e[t]!==this.settings[t]}escapeListener(e){27===e.keyCode&&this.publicInstance.leaveFullscreenMode()}reloadViewer(e){const t=[];if(e=this.optionsValidator.getValidatedOptions(this.settings,e),this.hasChangedOption(e,"zoomLevel")&&(this.viewerState.oldZoomLevel=this.settings.zoomLevel,this.viewerState.options.zoomLevel=e.zoomLevel,t.push(["ZoomLevelDidChange",e.zoomLevel])),this.hasChangedOption(e,"pagesPerRow")&&(this.viewerState.options.pagesPerRow=e.pagesPerRow,t.push(["GridRowNumberDidChange",e.pagesPerRow])),this.hasChangedOption(e,"verticallyOriented")&&(this.viewerState.options.verticallyOriented=e.verticallyOriented),this.hasChangedOption(e,"showNonPagedPages")&&(this.viewerState.options.showNonPagedPages=e.showNonPagedPages),"goDirectlyTo"in e?(this.viewerState.options.goDirectlyTo=e.goDirectlyTo,"verticalOffset"in e&&(this.viewerState.verticalOffset=e.verticalOffset),"horizontalOffset"in e&&(this.viewerState.horizontalOffset=e.horizontalOffset)):this.viewerState.options.goDirectlyTo=this.settings.activePageIndex,(this.hasChangedOption(e,"inGrid")||this.hasChangedOption(e,"inBookLayout"))&&("inGrid"in e&&(this.viewerState.options.inGrid=e.inGrid),"inBookLayout"in e&&(this.viewerState.options.inBookLayout=e.inBookLayout),t.push(["ViewDidSwitch",this.settings.inGrid])),this.hasChangedOption(e,"inFullscreen")&&(this.viewerState.options.inFullscreen=e.inFullscreen,this.prepareModeChange(e),t.push(["ModeDidSwitch",this.settings.inFullscreen])),this.clearViewer(),this.updateViewHandlerAndRendering(),this.viewerState.renderer){const e={pageLayouts:G(this.settings),padding:this.getPadding(),maxZoomLevel:this.settings.inGrid?null:this.viewerState.manifest.maxZoom,verticallyOriented:this.settings.verticallyOriented||this.settings.inGrid},t={zoomLevel:this.settings.inGrid?null:this.settings.zoomLevel,anchorPage:this.settings.goDirectlyTo,verticalOffset:this.viewerState.verticalOffset,horizontalOffset:this.viewerState.horizontalOffset},i=this.getCurrentSourceProvider();if(ee.enabled){const t=Object.keys(e).filter(function(e){return"pageLayouts"!==e&&"padding"!==e}).map(function(t){const i=e[t];return t+": "+JSON.stringify(i)}).join(", ");ee("reload with %s",t)}this.viewerState.renderer.load(e,t,i)}return t.forEach(e=>{this.publish.apply(this,e)}),!0}prepareModeChange(e){const t=e.inFullscreen?"add":"remove";this.viewerState.outerObject.classList[t]("diva-fullscreen"),document.body.classList[t]("diva-hide-scrollbar"),this.settings.parentObject.classList[t]("diva-full-width");const i=this.settings.panelHeight,s=this.settings.panelWidth;if(this.viewerState.viewport.invalidate(),!(this.viewerState.loaded||this.settings.inGrid||"verticalOffset"in e)){const e=this.settings.panelHeight,t=this.settings.panelWidth;this.viewerState.verticalOffset+=(i-e)/2,this.viewerState.horizontalOffset+=(s-t)/2}e.inFullscreen?document.addEventListener("keyup",this.boundEscapeListener):document.removeEventListener("keyup",this.boundEscapeListener)}updateViewHandlerAndRendering(){const e=this.settings.inGrid?P:_;!this.viewerState.viewHandler||this.viewerState.viewHandler instanceof e||(this.viewerState.viewHandler.destroy(),this.viewerState.viewHandler=null),this.viewerState.viewHandler||(this.viewerState.viewHandler=new e(this)),this.viewerState.renderer||this.initializeRenderer()}initializeRenderer(){const e=j.getCompatibilityErrors();if(e)this.showError(e);else{const e={viewport:this.viewerState.viewport,outerElement:this.viewerState.outerElement,innerElement:this.viewerState.innerElement,settings:this.settings},t={onViewWillLoad:()=>{this.viewerState.viewHandler.onViewWillLoad()},onViewDidLoad:()=>{this.updatePageOverlays(),this.viewerState.viewHandler.onViewDidLoad()},onViewDidUpdate:(e,t)=>{this.updatePageOverlays(),this.viewerState.viewHandler.onViewDidUpdate(e,t)},onViewDidTransition:()=>{this.updatePageOverlays()},onPageWillLoad:e=>{this.publish("PageWillLoad",e)},onZoomLevelWillChange:e=>{this.publish("ZoomLevelWillChange",e)}};this.viewerState.renderer=new j(e,t)}}getCurrentSourceProvider(){if(this.settings.inGrid){const e={getAllZoomLevelsForPage:t=>[e.getBestZoomLevelForPage(t)],getBestZoomLevelForPage:e=>{return{zoomLevel:1,rows:1,cols:1,tiles:[{url:this.settings.manifest.getPageImageURL(e.index,{width:e.dimensions.width}),zoomLevel:1,row:0,col:0,dimensions:e.dimensions,offset:{top:0,left:0}}]}}};return e}const e={width:this.settings.tileWidth,height:this.settings.tileHeight};return{getBestZoomLevelForPage:t=>this.settings.manifest.getPageImageTiles(t.index,Math.ceil(this.settings.zoomLevel),e),getAllZoomLevelsForPage:t=>{const i=[],s=this.viewerState.manifest.maxZoom;for(let n=0;n<=s;n++)i.push(this.settings.manifest.getPageImageTiles(t.index,n,e));return i.reverse(),i}}}getPadding(){let e,t,i,s;return this.settings.inGrid?(i=this.settings.fixedPadding,e=t=s=0):(e=this.settings.verticallyOriented?this.viewerState.verticalPadding:0,t=this.settings.verticallyOriented?0:this.viewerState.horizontalPadding,i=this.settings.verticallyOriented?0:this.viewerState.verticalPadding,s=this.settings.verticallyOriented?this.viewerState.horizontalPadding:0),{document:{top:i,bottom:i,left:s,right:s},page:{top:e,bottom:0,left:t,right:0}}}updatePageOverlays(){this.viewerState.pageOverlays.updateOverlays(this.viewerState.renderer.getRenderedPages())}handleZoom(e,t){if(!this.isValidOption("zoomLevel",e))return!1;if(this.viewerState.viewportObject.removeEventListener("scroll",this.boundScrollFunction),!t){const e=this.viewerState.viewport,i=this.viewerState.renderer.layout.getPageRegion(this.settings.activePageIndex);t={anchorPage:this.settings.activePageIndex,offset:{left:e.width/2-(i.left-e.left),top:e.height/2-(i.top-e.top)}}}const i=this.viewerState.renderer.layout.getPageRegion(t.anchorPage),s=i.left+t.offset.left-(this.settings.viewport.left+this.settings.viewport.width/2),n=i.top+t.offset.top-(this.settings.viewport.top+this.settings.viewport.height/2),o=(e,i)=>{const o=Math.pow(2,e-i),r=t.offset.left*o-s,a=t.offset.top*o-n;return{zoomLevel:e,anchorPage:t.anchorPage,verticalOffset:a,horizontalOffset:r}};this.viewerState.options.zoomLevel=e;let r=this.viewerState.oldZoomLevel;this.viewerState.oldZoomLevel=this.settings.zoomLevel;const a=o(e,r);this.viewerState.options.goDirectlyTo=a.anchorPage,this.viewerState.verticalOffset=a.verticalOffset,this.viewerState.horizontalOffset=a.horizontalOffset,this.viewerState.renderer.transitionViewportPosition({duration:this.settings.zoomDuration,parameters:{zoomLevel:{from:r,to:e}},getPosition:e=>o(e.zoomLevel,r),onEnd:t=>{this.viewerState.viewportObject.addEventListener("scroll",this.boundScrollFunction),t.interrupted&&(this.viewerState.oldZoomLevel=e)}});let l=document.getElementById(this.settings.selector+"zoom-in-button"),h=document.getElementById(this.settings.selector+"zoom-out-button");return l.disabled=!0,h.disabled=!0,setTimeout(()=>{l.disabled=!1,h.disabled=!1},this.settings.zoomDuration),this.publish("ZoomLevelDidChange",e),!0}getYOffset(e,t){let i=void 0===e?this.settings.activePageIndex:e;return"center"===t||"centre"===t?parseInt(this.getPageData(i,"h")/2,10):"bottom"===t?parseInt(this.getPageData(i,"h")-this.settings.panelHeight/2,10):parseInt(this.settings.panelHeight/2,10)}getXOffset(e,t){let i=void 0===e?this.settings.activePageIndex:e;return"left"===t?parseInt(this.settings.panelWidth/2,10):"right"===t?parseInt(this.getPageData(i,"w")-this.settings.panelWidth/2,10):parseInt(this.getPageData(i,"w")/2,10)}updatePanelSize(){return this.viewerState.viewport.invalidate(),this.viewerState.renderer&&(this.updateOffsets(),this.viewerState.renderer.goto(this.settings.activePageIndex,this.viewerState.verticalOffset,this.viewerState.horizontalOffset)),!0}updateOffsets(){const e=this.viewerState.renderer.layout.getPageToViewportCenterOffset(this.settings.activePageIndex,this.viewerState.viewport);e&&(this.viewerState.horizontalOffset=e.x,this.viewerState.verticalOffset=e.y)}bindMouseEvents(){this.viewerState.viewportObject.classList.add("dragscroll"),u.onDoubleClick(this.viewerState.viewportObject,(e,t)=>{ee("Double click at %s, %s",t.left,t.top),this.viewerState.viewHandler.onDoubleClick(e,t)})}onResize(){this.updatePanelSize(),clearTimeout(this.viewerState.resizeTimer),this.viewerState.resizeTimer=setTimeout(()=>{const e=this.viewerState.renderer.layout.getPageToViewportCenterOffset(this.settings.activePageIndex,this.viewerState.viewport);e?this.reloadViewer({goDirectlyTo:this.settings.activePageIndex,verticalOffset:e.y,horizontalOffset:e.x}):this.reloadViewer({goDirectlyTo:this.settings.activePageIndex})},200)}bindTouchEvents(){this.settings.blockMobileMove&&document.body.addEventListener("touchmove",e=>{return e.originalEvent.preventDefault(),!1}),u.onPinch(this.viewerState.viewportObject,function(e,t,i,s){ee("Pinch %s at %s, %s",s-i,t.left,t.top),this.viewerState.viewHandler.onPinch(e,t,i,s)}),u.onDoubleTap(this.viewerState.viewportObject,function(e,t){ee("Double tap at %s, %s",t.left,t.top),this.viewerState.viewHandler.onDoubleClick(e,t)})}scrollFunction(){const e=this.viewerState.viewport.top,t=this.viewerState.viewport.left;let i;this.viewerState.viewport.invalidate();const s=this.viewerState.viewport.top,n=this.viewerState.viewport.left;i=this.settings.verticallyOriented||this.settings.inGrid?s-e:n-t,this.viewerState.renderer.adjust();const o=this.settings.verticallyOriented||this.settings.inGrid?s:n;this.publish("ViewerDidScroll",o),i>0?this.publish("ViewerDidScrollDown",o):i<0&&this.publish("ViewerDidScrollUp",o),this.updateOffsets()}handleEvents(){this.viewerState.innerObject.addEventListener("mousedown",()=>{this.viewerState.innerObject.classList.add("diva-grabbing")}),this.viewerState.innerObject.addEventListener("mouseup",()=>{this.viewerState.innerObject.classList.remove("diva-grabbing")}),this.bindMouseEvents(),this.viewerState.viewportObject.addEventListener("scroll",this.boundScrollFunction);document.addEventListener("keydown.diva",e=>{if(!this.viewerState.isActiveDiva)return!0;if(this.settings.enableSpaceScroll&&!e.shiftKey&&32===e.keyCode||this.settings.enableKeyScroll&&34===e.keyCode)return this.viewerState.viewport.top+=this.settings.panelHeight,!1;if(this.settings.enableSpaceScroll||32!==e.keyCode||e.preventDefault(),this.settings.enableKeyScroll){if(e.shiftKey||e.ctrlKey||e.metaKey)return!0;switch(e.keyCode){case 33:return this.viewerState.viewport.top-=this.settings.panelHeight,!1;case 38:return this.viewerState.viewport.top-=this.settings.arrowScrollAmount,!1;case 40:return this.viewerState.viewport.top+=this.settings.arrowScrollAmount,!1;case 37:return this.viewerState.viewport.left-=this.settings.arrowScrollAmount,!1;case 39:return this.viewerState.viewport.left+=this.settings.arrowScrollAmount,!1;case 36:return this.viewerState.viewport.top=0,!1;case 35:return this.settings.verticallyOriented?this.viewerState.viewport.top=1/0:this.viewerState.viewport.left=1/0,!1;default:return!0}}return!0}),c.Events.subscribe("ViewerDidTerminate",function(){document.removeEventListener("keydown.diva")},this.settings.ID),window.addEventListener("resize",this.onResize.bind(this),!1),c.Events.subscribe("ViewerDidTerminate",function(){window.removeEventListener("resize",this.onResize,!1)},this.settings.ID),"onorientationchange"in window&&(window.addEventListener("orientationchange",this.onResize,!1),c.Events.subscribe("ViewerDidTerminate",function(){window.removeEventListener("orientationchange",this.onResize,!1)},this.settings.ID)),c.Events.subscribe("PanelSizeDidChange",this.updatePanelSize,this.settings.ID),c.Events.subscribe("ViewerDidTerminate",()=>{this.viewerState.renderer&&this.viewerState.renderer.destroy(),clearTimeout(this.viewerState.resizeTimer)},this.settings.ID)}initPlugins(){if(!this.settings.hasOwnProperty("plugins"))return null;this.viewerState.pluginInstances=this.settings.plugins.map(e=>{const t=new e(this);return t.isPageTool&&this.viewerState.pageTools.push(t),t})}showThrobber(){this.hideThrobber(),this.viewerState.throbberTimeoutID=setTimeout(()=>{let e=document.getElementById(this.settings.selector+"throbber");e&&(e.style.display="block")},this.settings.throbberTimeout)}hideThrobber(){clearTimeout(this.viewerState.throbberTimeoutID);let e=document.getElementById(this.settings.selector+"throbber");e&&(e.style.display="none")}showError(e){const t=s("div",this.elemAttrs("error"),[s("button",this.elemAttrs("error-close",{"aria-label":"Close dialog"})),s("p",s("strong","Error")),s("div",e)]);this.viewerState.outerObject.appendChild(t),document.querySelector("#"+this.settings.selector+"error-close").addEventListener("click",()=>{t.parentNode.removeChild(t)})}setManifest(e,t){if(this.viewerState.manifest=e,this.hideThrobber(),this.viewerState.numPages=this.settings.manifest.pages.length,this.optionsValidator.validate(this.viewerState.options),this.publish("NumberOfPagesDidChange",this.settings.numPages),this.settings.adaptivePadding>0){const e=Math.floor((this.settings.minZoomLevel+this.settings.maxZoomLevel)/2);this.viewerState.horizontalPadding=parseInt(this.settings.manifest.getAverageWidth(e)*this.settings.adaptivePadding,10),this.viewerState.verticalPadding=parseInt(this.settings.manifest.getAverageHeight(e)*this.settings.adaptivePadding,10)}else this.viewerState.horizontalPadding=this.settings.fixedPadding,this.viewerState.verticalPadding=this.settings.fixedPadding;let i,n;this.viewerState.pageTools.length&&(this.viewerState.verticalPadding=Math.max(40,this.viewerState.verticalPadding)),this.settings.manifest.paged&&(this.viewerState.options.inBookLayout=!0),this.publish("ObjectDidLoad",this.settings),this.updatePanelSize();let o=!1,r=!1;if(null==t.goDirectlyTo?(t.goDirectlyTo=this.settings.goDirectlyTo,i=n=!0):(i=null==t.horizontalOffset||isNaN(t.horizontalOffset),n=null==t.verticalOffset||isNaN(t.verticalOffset)),i&&(0===t.goDirectlyTo&&this.settings.inBookLayout&&this.settings.verticallyOriented?t.horizontalOffset=this.viewerState.horizontalPadding:(r=!0,t.horizontalOffset=this.getXOffset(t.goDirectlyTo,"center"))),n&&(o=!0,t.verticalOffset=this.getYOffset(t.goDirectlyTo,"top")),this.reloadViewer(t),this.updatePanelSize(),this.settings.enableAutoTitle){let e=document.getElementById(this.settings.selector+"title");e?e.innerHTML=this.settings.manifest.itemTitle:this.settings.parentObject.insertBefore(s("div",this.elemAttrs("title"),[this.settings.manifest.itemTitle]),this.settings.parentObject.firstChild)}this.settings.verticallyOriented?this.viewerState.innerElement.style.minWidth=this.settings.panelWidth+"px":this.viewerState.innerElement.style.minHeight=this.settings.panelHeight+"px",(o||r)&&(o&&(this.viewerState.verticalOffset=this.getYOffset(this.settings.activePageIndex,"top")),r&&(this.viewerState.horizontalOffset=this.getXOffset(this.settings.activePageIndex,"center")),this.viewerState.renderer.goto(this.settings.activePageIndex,this.viewerState.verticalOffset,this.viewerState.horizontalOffset)),this.viewerState.loaded=!0,this.publish("ViewerDidLoad",this.settings)}publish(e){const t=Array.prototype.slice.call(arguments,1);c.Events.publish(e,t,this.publicInstance)}getSettings(){return this.settings}getInternalState(){return this.viewerState}getPublicInstance(){return this.publicInstance}getPageTools(){return this.viewerState.pageTools}getCurrentLayout(){return this.viewerState.renderer?this.viewerState.renderer.layout:null}getViewport(){const e=this.viewerState.viewport;return{top:e.top,left:e.left,bottom:e.bottom,right:e.right,width:e.width,height:e.height}}addPageOverlay(e){this.viewerState.pageOverlays.addOverlay(e)}removePageOverlay(e){this.viewerState.pageOverlays.removeOverlay(e)}getPageRegion(e,t){const i=this.viewerState.renderer.layout,s=i.getPageRegion(e,t);if(t&&t.incorporateViewport){const e=this.settings.verticallyOriented?"width":"height";if(this.viewerState.viewport[e]>i.dimensions[e]){const t=(this.viewerState.viewport[e]-i.dimensions[e])/2;return this.settings.verticallyOriented?{top:s.top,bottom:s.bottom,left:s.left+t,right:s.right+t}:{top:s.top+t,bottom:s.bottom+t,left:s.left,right:s.right}}}return s}getPagePositionAtViewportOffset(e){const t=e.left+this.viewerState.viewport.left,i=e.top+this.viewerState.viewport.top,s=this.viewerState.renderer.getRenderedPages(),n=s.length;for(let e=0;e<n;e++){const n=s[e],o=this.viewerState.renderer.layout.getPageRegion(n);if(o.left<=t&&o.right>=t&&o.top<=i&&o.bottom>=i)return{anchorPage:n,offset:{left:t-o.left,top:i-o.top}}}const o=this.viewerState.renderer.layout.getPageRegion(this.settings.activePageIndex);return{anchorPage:this.settings.activePageIndex,offset:{left:t-o.left,top:i-o.top}}}setCurrentPages(e,t){(function(e,t){if(e.length!==t.length)return!1;for(let i=0,s=e.length;i<s;i++)if(e[i]!==t[i])return!1;return!0})(this.viewerState.currentPageIndices,t)||(this.viewerState.currentPageIndices=t,this.viewerState.activePageIndex=e,this.publish("VisiblePageDidChange",t),this.viewerState.manifest.pages[e].otherImages.length>0&&this.publish("VisiblePageHasAlternateViews",e))}getPageName(e){return this.viewerState.manifest.pages[e].f}reload(e){this.reloadViewer(e)}zoom(e,t){return this.handleZoom(e,t)}enableScrollable(){this.viewerState.isScrollable||(this.bindMouseEvents(),this.enableDragScrollable(),this.viewerState.options.enableKeyScroll=this.viewerState.initialKeyScroll,this.viewerState.options.enableSpaceScroll=this.viewerState.initialSpaceScroll,this.viewerState.viewportElement.style.overflow="auto",this.viewerState.isScrollable=!0)}enableDragScrollable(){this.viewerState.viewportObject.hasAttribute("nochilddrag")&&this.viewerState.viewportObject.removeAttribute("nochilddrag")}disableScrollable(){this.viewerState.isScrollable&&(this.disableDragScrollable(),this.viewerState.outerObject.dblclick=null,this.viewerState.outerObject.contextmenu=null,this.viewerState.viewportElement.style.overflow="hidden",this.viewerState.initialKeyScroll=this.settings.enableKeyScroll,this.viewerState.initialSpaceScroll=this.settings.enableSpaceScroll,this.viewerState.options.enableKeyScroll=!1,this.viewerState.options.enableSpaceScroll=!1,this.viewerState.isScrollable=!1)}disableDragScrollable(){this.viewerState.viewportObject.hasAttribute("nochilddrag")||this.viewerState.viewportObject.setAttribute("nochilddrag","")}clear(){this.clearViewer()}setPendingManifestRequest(e){this.viewerState.pendingManifestRequest=e}destroy(){this.publish("ViewerWillTerminate",this.settings),this.settings.pendingManifestRequest&&this.settings.pendingManifestRequest.abort(),document.body.removeClass("diva-hide-scrollbar"),this.settings.parentObject.parent().empty().removeData("diva"),this.settings.parentObject.parent().removeAttr("style").removeAttr("class"),this.publish("ViewerDidTerminate",this.settings),c.Events.unsubscribeAll(this.settings.ID)}}const ne=(e,t)=>{const i=Math.max(e,t);return i<128?0:Math.ceil(Math.log((i+1)/257)/Math.log(2))},oe=(e,t)=>e/Math.pow(2,t),re=(e,t)=>e.map(e=>{const i=e.width,s=e.height,n=he(e),o="/"!==n.url.slice(-1)?n.url+"/":n.url,r=new Array(t+1);for(let e=0;e<t+1;e++)r[e]={h:Math.floor(oe(s,t-e)),w:Math.floor(oe(i,t-e))};return{f:n.url,url:o,il:e.label||"",d:r}}),ae=e=>"http://iiif.io/api/presentation/2/context.json"===e?2:Array.isArray(e)&&e.includes("http://iiif.io/api/presentation/2/context.json")?2:Array.isArray(e)&&e.includes("http://iiif.io/api/presentation/3/context.json")?3:2;function le(e){let t=e["@context"];if(!t)return console.error("Invalid IIIF Manifest; No @context found."),null;const i=ae(t),s=e.sequences?e.sequences[0]:null,n=s?s.canvases:e.items,o=n.length,r=new Array(n.length);let a,l,h,c,u,d,g,v,p,f,m,w,b,y,_,P,S,C=[],L=100,O=0,x=100;for(let e=0;e<o;e++){const t=n[e],i=t.width,s=t.height,o=ne(i,s),r=s/i;O=Math.max(r,O),x=Math.min(r,x),L=Math.min(L,o)}const E=new Array(L+1).fill(0),I=new Array(L+1).fill(0),T=new Array(L+1).fill(0),D=new Array(L+1).fill(0);for(let e=0;e<o;e++){if(w=(a=n[e])["@id"]||a.id,b=a.label,C=[],"oa:Choice"===(l=a.images?a.images[0].resource:a.items[0].items[0].body)["@type"]||"Choice"===l.type?(h=l.default||l.items[0],c=l.item||l.items.slice(1),C=re(c,L)):h=l,p=a.width||h.width,f=a.height||h.height,p<=0||f<=0){console.warn("Invalid width or height for canvas "+b+". Skipping");continue}m=ne(p,f),y=h.label||null,d="/"!==(g=he(h)).url.slice(-1)?g.url+"/":g.url,v="http://iiif.io/api/image/2/context.json"===(u=h.service["@context"]||h.service.type)||"ImageService2"===u?2:"http://library.stanford.edu/iiif/image-api/1.1/context.json"===u?1.1:1,_=new Array(L+1);for(let e=0;e<L+1;e++)P=Math.floor(oe(p,L-e)),S=Math.floor(oe(f,L-e)),_[e]={h:S,w:P},E[e]+=P,I[e]+=S,T[e]=Math.max(P,T[e]),D[e]=Math.max(S,D[e]);let t="non-paged"!==a.viewingHint||!!a.behavior&&"non-paged"!==a.behavior[0],i="facing-pages"===a.viewingHint||!!a.behavior&&"facing-pages"===a.behavior[0];r[e]={d:_,m:m,l:b,il:y,f:g.url,url:d,api:v,paged:t,facingPages:i,canvas:w,otherImages:C,xoffset:g.x||null,yoffset:g.y||null}}const M=new Array(L+1),z=new Array(L+1);for(let e=0;e<L+1;e++)M[e]=E[e]/o,z[e]=I[e]/o;const V={a_wid:M,a_hei:z,max_w:T,max_h:D,max_ratio:O,min_ratio:x,t_hei:I,t_wid:E};return{version:i,item_title:function(e){let t,i=e.label,s="object"==typeof i?i[Object.keys(i)[0]][0]:i,n=e.value;return t=Array.isArray(n)?n.map(e=>e[Object.keys(e)[0]]):"object"==typeof n?n[Object.keys(n)[0]]:n,Array.isArray(t)&&(t=t.join(", ")),{label:s,value:t}}(e).label,metadata:e.metadata||null,dims:V,max_zoom:L,pgs:r,paged:"paged"===e.viewingHint||!!e.behaviour&&"paged"===e.behaviour[0]||!!s&&"paged"===s.viewingHint}}function he(e){let t=e["@id"]||e.id;const i=/#xywh=([0-9]+,[0-9]+,[0-9]+,[0-9]+)/;let s="",n=!0;if(/\/([0-9]+,[0-9]+,[0-9]+,[0-9]+)\//.test(t)){const e=t.split("/");s=e[e.length-4]}else if(i.test(t)){s=i.exec(t)[1]}else e.service&&(e.service["@id"]||e.service.id)&&(t=e.service["@id"]||e.service.id,n=!1);n&&(t=t.split("/").slice(0,-4).join("/"));const o={url:t};if(s.length){const e=s.split(",");o.x=parseInt(e[0],10),o.y=parseInt(e[1],10),o.w=parseInt(e[2],10),o.h=parseInt(e[3],10)}return o}class ce{getPageImageURL(e,t,i){let s;s=!i||null==i.width&&null==i.height?"full":(null==i.width?"":i.width)+","+(null==i.height?"":i.height);const n=e.pages[t],o=n.api>1.1?"default":"native";return encodeURI(n.url+"full/"+s+"/0/"+o+".jpg")}getTileImageURL(e,t,i){const s=e.pages[t];let n,o;n=i.row===i.rowCount-1?s.d[i.zoomLevel].h-(i.rowCount-1)*i.tileDimensions.height:i.tileDimensions.height,o=i.col===i.colCount-1?s.d[i.zoomLevel].w-(i.colCount-1)*i.tileDimensions.width:i.tileDimensions.width;const r=Math.pow(2,e.maxZoom-i.zoomLevel);let a=i.col*i.tileDimensions.width*r,l=i.row*i.tileDimensions.height*r;s.hasOwnProperty("xoffset")&&(a+=s.xoffset,l+=s.yoffset);const h=[a,l,o*r,n*r].join(","),c=s.api>1.1?"default":"native";return encodeURI(s.url+h+"/"+o+","+n+"/0/"+c+".jpg")}}class ue{constructor(e,t){this.pages=e.pgs,this.maxZoom=e.max_zoom,this.maxRatio=e.dims.max_ratio,this.minRatio=e.dims.min_ratio,this.itemTitle=e.item_title,this.metadata=e.metadata,this.paged=!!e.paged,this._maxWidths=e.dims.max_w,this._maxHeights=e.dims.max_h,this._averageWidths=e.dims.a_wid,this._averageHeights=e.dims.a_hei,this._totalHeights=e.dims.t_hei,this._totalWidths=e.dims.t_wid,this._urlAdapter=t}static fromIIIF(e){const t=le(e);return new ue(t,new ce)}isPageValid(e,t){return!(!t&&this.paged&&!this.pages[e].paged)&&(e>=0&&e<this.pages.length)}getMaxPageDimensions(e){const t=this.pages[e].d[this.maxZoom];return{height:t.h,width:t.w}}getPageDimensionsAtZoomLevel(e,t){const i=this.pages[e].d[this.maxZoom],s=function(e,t){return 1/Math.pow(2,e-t)}(this.maxZoom,t);return{height:i.h*s,width:i.w*s}}getPageImageURL(e,t){return this._urlAdapter.getPageImageURL(this,e,t)}getPageImageTiles(e,t,i){const s=this.pages[e];if(!isFinite(t)||t%1!=0)throw new TypeError("Zoom level must be an integer: "+t);const n=Math.ceil(s.d[t].h/i.height),o=Math.ceil(s.d[t].w/i.width),r=[];let a,l,h;for(a=0;a<n;a++)for(l=0;l<o;l++)h=this._urlAdapter.getTileImageURL(this,e,{row:a,col:l,rowCount:n,colCount:o,zoomLevel:t,tileDimensions:i}),r.push({row:a,col:l,zoomLevel:t,dimensions:{height:i.height,width:i.width},offset:{top:a*i.height,left:l*i.width},url:h});return{zoomLevel:t,rows:n,cols:o,tiles:r}}}function de(e){return function(t){return this[e][t]}}ue.prototype.getMaxWidth=de("_maxWidths"),ue.prototype.getMaxHeight=de("_maxHeights"),ue.prototype.getAverageWidth=de("_averageWidths"),ue.prototype.getAverageHeight=de("_averageHeights"),ue.prototype.getTotalWidth=de("_totalWidths"),ue.prototype.getTotalHeight=de("_totalHeights");class ge{constructor(e){this.viewer=e,this.settings=e.settings}_elemAttrs(e,t){const i={id:this.settings.ID+e,class:"diva-"+e};return t?Object.assign(i,t):i}_subscribe(e,t){c.Events.subscribe(e,t,this.settings.ID)}createButton(e,t,i,n){const o=s("button",{type:"button",id:this.settings.ID+e,class:"diva-"+e+" diva-button",title:t});return n&&o.appendChild(n),i&&o.addEventListener("click",i),o}createLabel(e,t,i,n,o){return s("div",{id:this.settings.ID+t,class:e+" diva-label"},[i,s("span",{id:this.settings.ID+n},o)])}createZoomButtons(){let e=this._createZoomOutIcon(),t=this._createZoomInIcon(),i=[this.createButton("zoom-out-button","Zoom Out",()=>{this.viewer.setZoomLevel(this.settings.zoomLevel-1)},e),this.createButton("zoom-in-button","Zoom In",()=>{this.viewer.setZoomLevel(this.settings.zoomLevel+1)},t),this.createLabel("diva-zoom-label","zoom-label","Zoom level: ","zoom-level",this.settings.zoomLevel+1)],n=function(){document.getElementById(this.settings.ID+"zoom-level").textContent=this.settings.zoomLevel+1};return this._subscribe("ZoomLevelDidChange",n),this._subscribe("ViewerDidLoad",n),s("div",{id:this.settings.ID+"zoom-controls",style:"display: none"},i)}createGridControls(){let e=this._createGridMoreIcon(),t=this._createGridFewerIcon(),i=[this.createButton("grid-out-button","Fewer",()=>{this.viewer.setGridPagesPerRow(this.settings.pagesPerRow-1)},t),this.createButton("grid-in-button","More",()=>{this.viewer.setGridPagesPerRow(this.settings.pagesPerRow+1)},e),this.createLabel("diva-grid-label","grid-label","Pages per row: ","pages-per-row",this.settings.pagesPerRow)];return this._subscribe("GridRowNumberDidChange",function(){document.getElementById(this.settings.ID+"pages-per-row").textContent=this.settings.pagesPerRow}),s("div",{id:this.settings.ID+"grid-controls",style:"display:none"},i)}createPageLabel(){const e=s("span",{id:this.settings.ID+"current-page"}),t=()=>{let t=this.viewer.getCurrentPageIndices(),i=t[0],s=t[t.length-1],n=this.settings.manifest.pages[i].l,o=this.settings.manifest.pages[s].l;i!==s?this.settings.enableIndexAsLabel?e.textContent=i+" - "+s:e.textContent=n+" - "+o:this.settings.enableIndexAsLabel?e.textContent=i:e.textContent=n};return this._subscribe("VisiblePageDidChange",t),this._subscribe("ViewerDidLoad",t),this._subscribe("ViewDidSwitch",t),s("span",{class:"diva-page-label diva-label"},e)}createGotoPageForm(){const e=s("input",{id:this.settings.ID+"goto-page-input",class:"diva-input diva-goto-page-input",autocomplete:"off",type:"text"}),t=s("input",{id:this.settings.ID+"goto-page-submit",class:"diva-button diva-button-text",type:"submit",value:"Go"}),i=s("div",{id:this.settings.ID+"input-suggestions",class:"diva-input-suggestions"}),n=s("form",{id:this.settings.ID+"goto-page",class:"diva-goto-form"},e,t,i);return n.addEventListener("submit",t=>{t.preventDefault();const s=e.value;if(this.settings.onGotoSubmit&&"function"==typeof this.settings.onGotoSubmit){const e=this.settings.onGotoSubmit(s);this.viewer.gotoPageByIndex(e)||window.alert("No page could be found with that label or page number")}else this.viewer.gotoPageByLabel(s)||window.alert("No page could be found with that label or page number");return i.style.display="none",!1}),["input","focus"].forEach(t=>{e.addEventListener(t,()=>{i.innerHTML="";const t=e.value;let n=0;if(this.settings.enableGotoSuggestions&&t){const e=this.settings.manifest.pages;for(let o=0,r=e.length;o<r&&n<10;o++)if(e[o].l.toLowerCase().indexOf(t.toLowerCase())>-1){const t=s("div",{class:"diva-input-suggestion"},e[o].l);i.appendChild(t),n++}n>0&&(i.style.display="block")}else i.style.display="none"})}),e.addEventListener("keydown",t=>{let i;if(13===t.keyCode){const t=document.getElementsByClassName("active")[0];void 0!==t&&(e.value=t.innerText)}if(38===t.keyCode){const e=(i=document.getElementsByClassName("active")[0])?i.previousSibling:void 0;if(void 0!==e)i.classList.remove("active"),null!==e&&e.classList.add("active");else{let e=document.getElementsByClassName("diva-input-suggestion").length-1;document.getElementsByClassName("diva-input-suggestion")[e].classList.add("active")}}else if(40===t.keyCode){const e=(i=document.getElementsByClassName("active")[0])?i.nextSibling:void 0;void 0!==e?(i.classList.remove("active"),null!==e&&e.classList.add("active")):document.getElementsByClassName("diva-input-suggestion")[0].classList.add("active")}}),function(e,t,i,s){e.addEventListener(t,function(e){for(var t=e.target;t&&t!==this;)t.matches(i)&&s.call(t,e),t=t.parentNode})}(i,"mousedown",".diva-input-suggestion",function(){e.value=this.textContent,i.style.display="none";let t=new Event("submit");n.dispatchEvent(t)}),e.addEventListener("blur",()=>{i.style.display="none"}),n}createViewMenu(){const e=s("div",this._elemAttrs("view-options")),t=this._createGridViewIcon(),i=this._createBookViewIcon(),n=this._createPageViewIcon(),o=this.createButton("view-icon","Change view",()=>{e.style.display="none"===e.style.display?"block":"none"}),r=t=>{this.viewer.changeView(t),e.style.display="none"},a=()=>{this.settings.inGrid?(o.appendChild(t),o.className="diva-grid-icon diva-view-icon diva-button"):this.settings.inBookLayout?(o.appendChild(i),o.className="diva-book-icon diva-view-icon diva-button"):(o.appendChild(n),o.className="diva-document-icon diva-view-icon diva-button");const s=document.createDocumentFragment();for((this.settings.inGrid||this.settings.inBookLayout)&&s.appendChild(this.createButton("document-icon","Document View",r.bind(null,"document"),n)),!this.settings.inGrid&&this.settings.inBookLayout||s.appendChild(this.createButton("book-icon","Book View",r.bind(null,"book"),i)),this.settings.inGrid||s.appendChild(this.createButton("grid-icon","Grid View",r.bind(null,"grid"),t));e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s)};return document.addEventListener("mouseup",t=>{e!==t.target&&(e.style.display="none")}),this._subscribe("ViewDidSwitch",a),this._subscribe("ObjectDidLoad",a),s("div",this._elemAttrs("view-menu"),o,e)}createFullscreenButton(){let e=this._createFullscreenIcon();return this.createButton("fullscreen-icon","Toggle fullscreen mode",()=>{this.viewer.toggleFullscreenMode()},e)}toggleZoomGridControls(){this.settings.inGrid?(document.getElementById(this.settings.ID+"zoom-controls").style.display="none",document.getElementById(this.settings.ID+"grid-controls").style.display="block"):(document.getElementById(this.settings.ID+"zoom-controls").style.display="block",document.getElementById(this.settings.ID+"grid-controls").style.display="none")}render(){this._subscribe("ViewDidSwitch",this.toggleZoomGridControls),this._subscribe("ObjectDidLoad",this.toggleZoomGridControls);let e=[this.createZoomButtons(),this.createGridControls()],t=[this.createPageLabel(),this.createViewMenu()];this.settings.enableFullscreen&&t.push(this.createFullscreenButton()),this.settings.enableGotoPage&&t.splice(1,0,this.createGotoPageForm());let i=this.viewer.viewerState.pluginInstances;for(let s=0,o=i.length;s<o;s++){let o=i[s];o.toolbarSide&&(o.toolbarIcon=o.createIcon(),o.toolbarIcon&&("right"===o.toolbarSide?t.splice(2,0,o.toolbarIcon):"left"===o.toolbarSide&&e.splice(2,0,o.toolbarIcon),o.toolbarIcon.addEventListener("click",n.bind(this,o))))}function n(e){e.handleClick(this.viewer)}const o=s("div",this._elemAttrs("tools"),s("div",this._elemAttrs("tools-left"),e),s("div",this._elemAttrs("tools-right"),t));this.settings.toolbarParentObject.insertBefore(o,this.settings.toolbarParentObject.firstChild)}_createToolbarIcon(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttributeNS(null,"viewBox","0 0 25 25"),t.setAttributeNS(null,"x","0px"),t.setAttributeNS(null,"y","0px"),t.setAttributeNS(null,"style","enable-background:new 0 0 48 48;");let i=document.createElementNS("http://www.w3.org/2000/svg","g");return i.setAttributeNS(null,"transform","matrix(1, 0, 0, 1, -12, -12)"),e.forEach(e=>{let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttributeNS(null,"d",e),i.appendChild(t)}),t.appendChild(i),t}_createZoomOutIcon(){return this._createToolbarIcon(["M19.5,23c-0.275,0-0.5-0.225-0.5-0.5v-1c0-0.275,0.225-0.5,0.5-0.5h7c0.275,0,0.5,0.225,0.5,0.5v1c0,0.275-0.225,0.5-0.5,0.5H19.5z","M37.219,34.257l-2.213,2.212c-0.202,0.202-0.534,0.202-0.736,0l-6.098-6.099c-1.537,0.993-3.362,1.577-5.323,1.577c-5.431,0-9.849-4.418-9.849-9.849c0-5.431,4.418-9.849,9.849-9.849c5.431,0,9.849,4.418,9.849,9.849c0,1.961-0.584,3.786-1.576,5.323l6.098,6.098C37.422,33.722,37.422,34.054,37.219,34.257z M29.568,22.099c0-3.706-3.014-6.72-6.72-6.72c-3.706,0-6.72,3.014-6.72,6.72c0,3.706,3.014,6.72,6.72,6.72C26.555,28.818,29.568,25.805,29.568,22.099z"])}_createZoomInIcon(){return this._createToolbarIcon(["M37.469,34.257l-2.213,2.212c-0.202,0.202-0.534,0.202-0.736,0l-6.098-6.099c-1.537,0.993-3.362,1.577-5.323,1.577c-5.431,0-9.849-4.418-9.849-9.849c0-5.431,4.418-9.849,9.849-9.849c5.431,0,9.849,4.418,9.849,9.849c0,1.961-0.584,3.786-1.576,5.323l6.098,6.098C37.672,33.722,37.672,34.054,37.469,34.257z M29.818,22.099c0-3.706-3.014-6.72-6.72-6.72c-3.706,0-6.72,3.014-6.72,6.72c0,3.706,3.014,6.72,6.72,6.72C26.805,28.818,29.818,25.805,29.818,22.099z M26.5,21H24v-2.5c0-0.275-0.225-0.5-0.5-0.5h-1c-0.275,0-0.5,0.225-0.5,0.5V21h-2.5c-0.275,0-0.5,0.225-0.5,0.5v1c0,0.275,0.225,0.5,0.5,0.5H22v2.5c0,0.275,0.225,0.5,0.5,0.5h1c0.275,0,0.5-0.225,0.5-0.5V23h2.5c0.275,0,0.5-0.225,0.5-0.5v-1C27,21.225,26.775,21,26.5,21z"])}_createGridMoreIcon(){return this._createToolbarIcon(["M29.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z"])}_createGridFewerIcon(){return this._createToolbarIcon(["M25.5,35c-0.275,0-0.5-0.225-0.5-0.5v-9c0-0.275,0.225-0.5,0.5-0.5h9c0.275,0,0.5,0.225,0.5,0.5v9c0,0.275-0.225,0.5-0.5,0.5H25.5z M22.5,35c0.275,0,0.5-0.225,0.5-0.5v-9c0-0.275-0.225-0.5-0.5-0.5h-9c-0.275,0-0.5,0.225-0.5,0.5v9c0,0.275,0.225,0.5,0.5,0.5H22.5z M34.5,23c0.275,0,0.5-0.225,0.5-0.5v-9c0-0.275-0.225-0.5-0.5-0.5h-9c-0.275,0-0.5,0.225-0.5,0.5v9c0,0.275,0.225,0.5,0.5,0.5H34.5z M22.5,23c0.275,0,0.5-0.225,0.5-0.5v-9c0-0.275-0.225-0.5-0.5-0.5h-9c-0.275,0-0.5,0.225-0.5,0.5v9c0,0.275,0.225,0.5,0.5,0.5H22.5z"])}_createGridViewIcon(){return this._createToolbarIcon(["M29.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z"])}_createBookViewIcon(){return this._createToolbarIcon(["M35,16.8v-1.323c0,0-2.292-1.328-5.74-1.328c-3.448,0-5.26,1.25-5.26,1.25s-1.813-1.25-5.26-1.25c-3.448,0-5.74,1.328-5.74,1.328V16.8l-1,0.531v0.021v15.687c0,0,4.531-1.578,6.999-1.578c2.468,0,5.001,0.885,5.001,0.885s2.532-0.885,5-0.885c0.306,0,0.643,0.024,1,0.066v4.325l1.531-2.016L33,35.852v-3.72c2,0.43,3,0.906,3,0.906V17.352v-0.021L35,16.8z M23,29.03c-1-0.292-2.584-0.679-3.981-0.679c-2.246,0-3.019,0.404-4.019,0.699V16.634c0,0,1.125-0.699,4.019-0.699c1.694,0,2.981,0.417,3.981,1.126V29.03z M33,29.051c-1-0.295-1.773-0.699-4.02-0.699c-1.396,0-2.981,0.387-3.98,0.679V17.06c1-0.709,2.286-1.126,3.98-1.126c2.895,0,4.02,0.699,4.02,0.699V29.051z"])}_createPageViewIcon(){return this._createToolbarIcon(["M29.425,29h4.47L29,33.934v-4.47C29,29.19,29.151,29,29.425,29z M34,14.563V28h-5.569C28.157,28,28,28.196,28,28.47V34H14.497C14.223,34,14,33.71,14,33.437V14.563C14,14.29,14.223,14,14.497,14h18.9C33.672,14,34,14.29,34,14.563z M25.497,26.497C25.497,26.223,25.275,26,25,26h-7c-0.275,0-0.497,0.223-0.497,0.497v1.006C17.503,27.777,17.725,28,18,28h7c0.275,0,0.497-0.223,0.497-0.497V26.497z M30.497,22.497C30.497,22.223,30.275,22,30,22H18c-0.275,0-0.497,0.223-0.497,0.497v1.006C17.503,23.777,17.725,24,18,24h12c0.275,0,0.497-0.223,0.497-0.497V22.497z M30.497,18.497C30.497,18.223,30.275,18,30,18H18c-0.275,0-0.497,0.223-0.497,0.497v1.006C17.503,19.777,17.725,20,18,20h12c0.275,0,0.497-0.223,0.497-0.497V18.497z"])}_createFullscreenIcon(){return this._createToolbarIcon(["M35,12H13c-0.55,0-1,0.45-1,1v22c0,0.55,0.45,1,1,1h22c0.55,0,1-0.45,1-1V13C36,12.45,35.55,12,35,12z M34,34H14V14h20V34z","M17,21.75v-4.5c0-0.138,0.112-0.25,0.25-0.25h4.5c0.138,0,0.17,0.08,0.073,0.177l-1.616,1.616l1.823,1.823c0.097,0.097,0.097,0.256,0,0.354l-1.061,1.06c-0.097,0.097-0.256,0.097-0.354,0l-1.823-1.823l-1.616,1.616C17.08,21.92,17,21.888,17,21.75z M20.97,25.97c-0.097-0.097-0.256-0.097-0.354,0l-1.823,1.823l-1.616-1.616C17.08,26.08,17,26.112,17,26.25v4.5c0,0.138,0.112,0.25,0.25,0.25h4.5c0.138,0,0.17-0.08,0.073-0.177l-1.616-1.616l1.823-1.823c0.097-0.097,0.097-0.256,0-0.354L20.97,25.97z M30.75,17h-4.5c-0.138,0-0.17,0.08-0.073,0.177l1.616,1.616l-1.823,1.823c-0.097,0.097-0.097,0.256,0,0.354l1.061,1.06c0.097,0.097,0.256,0.097,0.354,0l1.823-1.823l1.616,1.616C30.92,21.92,31,21.888,31,21.75v-4.5C31,17.112,30.888,17,30.75,17z M30.823,26.177l-1.616,1.616l-1.823-1.823c-0.097-0.097-0.256-0.097-0.354,0l-1.061,1.06c-0.097,0.097-0.097,0.256,0,0.354l1.823,1.823l-1.616,1.616C26.08,30.92,26.112,31,26.25,31h4.5c0.138,0,0.25-0.112,0.25-0.25v-4.5C31,26.112,30.92,26.08,30.823,26.177z M26,22.5c0-0.275-0.225-0.5-0.5-0.5h-3c-0.275,0-0.5,0.225-0.5,0.5v3c0,0.275,0.225,0.5,0.5,0.5h3c0.275,0,0.5-0.225,0.5-0.5V22.5z"])}}var ve={get:pe,update:function(e,t){const i=pe(e),s=window.location.hash;if(i!==t)if("string"==typeof i){const n=s.indexOf("&"+e+"=")>0?s.indexOf("&"+e+"="):s.indexOf("#"+e+"="),o=n+e.length+2+i.length,r=0===n?"#":"&";window.location.replace(s.substring(0,n)+r+e+"="+t+s.substring(o))}else 0===s.length?window.location.replace("#"+e+"="+t):window.location.replace(s+"&"+e+"="+t)}};function pe(e){const t=window.location.hash;if(""!==t){let i=t.indexOf("&"+e+"=")>0?t.indexOf("&"+e+"="):t.indexOf("#"+e+"=");if(i>=0){i+=e.length+2;const s=t.indexOf("&",i);return s>i?decodeURIComponent(t.substring(i,s)):s<0?decodeURIComponent(t.substring(i)):""}return!1}return!1}class fe{constructor(e,t){if(!(e instanceof HTMLElement)&&(this.element=document.getElementById(e),null===this.element))throw new a;if(!t.objectData)throw new h("You must supply either a URL or a literal object to the `objectData` key.");this.options=Object.assign({acceptHeader:"application/json",adaptivePadding:.05,arrowScrollAmount:40,blockMobileMove:!1,objectData:"",enableAutoTitle:!0,enableFilename:!0,enableFullscreen:!0,enableGotoPage:!0,enableGotoSuggestions:!0,enableGridIcon:!0,enableGridControls:"buttons",enableImageTitles:!0,enableIndexAsLabel:!1,enableKeyScroll:!0,enableLinkIcon:!0,enableNonPagedVisibilityIcon:!0,enableSpaceScroll:!1,enableToolbar:!0,enableZoomControls:"buttons",fillParentHeight:!0,fixedPadding:10,fixedHeightGrid:!0,goDirectlyTo:0,hashParamSuffix:null,inFullscreen:!1,inBookLayout:!1,inGrid:!1,maxPagesPerRow:8,maxZoomLevel:-1,minPagesPerRow:2,minZoomLevel:0,onGotoSubmit:null,pageAliases:{},pageAliasFunction:function(){return!1},pageLoadTimeout:200,pagesPerRow:5,showNonPagedPages:!1,throbberTimeout:100,tileHeight:256,tileWidth:256,toolbarParentObject:null,verticallyOriented:!0,viewportMargin:200,zoomLevel:2},t);const i=s("div",{class:`diva-wrapper${this.options.fillParentHeight?" diva-wrapper-flexbox":""}`});this.element.appendChild(i),this.options.toolbarParentObject=this.options.toolbarParentObject||i;const n=new se(i,this.options,this);this.viewerState=n.getInternalState(),this.settings=n.getSettings(),this.toolbar=this.settings.enableToolbar?new ge(this):null,i.id=this.settings.ID+"wrapper",this.divaState={viewerCore:n,toolbar:this.toolbar};let o=c.Events.subscribe("ObjectDidLoad",()=>{null!==this.toolbar&&this.toolbar.render(),c.Events.unsubscribe(o)});this.hashState=this._getHashParamState(),this._loadOrFetchObjectData()}_loadOrFetchObjectData(){if("object"==typeof this.settings.objectData)setTimeout(()=>{this._loadObjectData(this.settings.objectData,this.hashState)},0);else{let e={Accept:this.settings.acceptHeader};this.settings.addRequestHeaders&&Object.assign(e,this.settings.addRequestHeaders);const t=fetch(this.settings.objectData,{headers:e}).then(e=>{if(!e.ok){c.Events.publish("ManifestFetchError",[e],this),this._ajaxError(e);let t=new Error(e.statusText);throw t.response=e,t}return e.json()}).then(e=>{this._loadObjectData(e,this.hashState)});this.divaState.viewerCore.setPendingManifestRequest(t)}}_showError(e){this.divaState.viewerCore.showError(e)}_ajaxError(e){const t=["Invalid objectData setting. Error code: "+e.status+" "+e.statusText];if(0===this.settings.objectData.lastIndexOf("http",0)){const e=this.settings.objectData.replace(/https?:\/\//i,"").split(/[/?#]/)[0];window.location.hostname!==e&&t.push(s("p","Attempted to access cross-origin data without CORS."),s("p","You may need to update your server configuration to support CORS. For help, see the ",s("a",{href:"https://github.com/DDMAL/diva.js/wiki/Installation#a-note-about-cross-site-requests",target:"_blank"},"cross-site request documentation.")))}this._showError(t)}_loadObjectData(e,t){let i;if(!e.hasOwnProperty("@context")&&(-1===e["@context"].indexOf("iiif")||-1===e["@context"].indexOf("shared-canvas")))throw new l("This does not appear to be a IIIF Manifest.");c.Events.publish("ManifestDidLoad",[e],this),i=ue.fromIIIF(e);const s=t?this._getLoadOptionsForState(t,i):{};this.divaState.viewerCore.setManifest(i,s)}_getHashParamState(){const e={};return["f","v","z","n","i","p","y","x"].forEach(t=>{const i=ve.get(t+this.settings.hashParamSuffix);!1!==i&&(e[t]=i)}),"true"===e.f?e.f=!0:"false"===e.f&&(e.f=!1),["z","n","p","x","y"].forEach(t=>{t in e&&(e[t]=parseInt(e[t],10))}),e}_getLoadOptionsForState(e,t){t=t||this.settings.manifest;const i="v"in e?this._getViewState(e.v):{};"f"in e&&(i.inFullscreen=e.f),"z"in e&&(i.zoomLevel=e.z),"n"in e&&(i.pagesPerRow=e.n);let s=this._getPageIndexForManifest(t,e.i);if(s>=0&&s<t.pages.length||(s=e.p-1)>=0&&s<t.pages.length||(s=null),null!==s){const t=parseInt(e.x,10),n=parseInt(e.y,10);i.goDirectlyTo=s,i.horizontalOffset=t,i.verticalOffset=n}return i}_getViewState(e){switch(e){case"d":return{inGrid:!1,inBookLayout:!1};case"b":return{inGrid:!1,inBookLayout:!0};case"g":return{inGrid:!0,inBookLayout:!1};default:return{}}}_getPageIndexForManifest(e,t){let i;const s=e.pages.length;for(i=0;i<s;i++)if(e.pages[i].f===t)return i;return-1}_getState(){let e;e=this.settings.inGrid?"g":this.settings.inBookLayout?"b":"d";const t=this.divaState.viewerCore.getCurrentLayout().getPageToViewportCenterOffset(this.settings.activePageIndex,this.viewerState.viewport);return{f:this.settings.inFullscreen,v:e,z:this.settings.zoomLevel,n:this.settings.pagesPerRow,i:!!this.settings.enableFilename&&this.settings.manifest.pages[this.settings.activePageIndex].f,p:!this.settings.enableFilename&&this.settings.activePageIndex+1,y:!!t&&t.y,x:!!t&&t.x}}_getURLHash(){const e=this._getState(),t=[];let i;for(i in e)!1!==e[i]&&t.push(i+this.settings.hashParamSuffix+"="+encodeURIComponent(e[i]));return t.join("&")}_getPageIndex(e){return this._getPageIndexForManifest(this.settings.manifest,e)}_checkLoaded(){return!!this.viewerState.loaded||(console.warn("The viewer is not completely initialized. This is likely because it is still downloading data. To fix this, only call this function if the isReady() method returns true."),!1)}_toggleFullscreen(){let e;this._reloadViewer({inFullscreen:!this.settings.inFullscreen});let t=!1,i=document.getElementById(this.settings.selector+"tools");const s=2e3;function n(){i.style.opacity=1,clearTimeout(e),!t&&this.settings.inFullscreen&&(e=setTimeout(function(){i.style.opacity=0},s))}this.settings.inFullscreen?(i.classList.add("diva-fullscreen-tools"),document.addEventListener("mousemove",n.bind(this)),document.getElementsByClassName("diva-viewport")[0].addEventListener("scroll",n.bind(this)),i.addEventListener("mouseenter",function(){t=!0}),i.addEventListener("mouseleave",function(){t=!1})):i.classList.remove("diva-fullscreen-tools")}_togglePageLayoutOrientation(){const e=!this.settings.verticallyOriented;return this._reloadViewer({inGrid:!1,verticallyOriented:e,goDirectlyTo:this.settings.activePageIndex,verticalOffset:this.divaState.viewerCore.getYOffset(),horizontalOffset:this.divaState.viewerCore.getXOffset()}),e}_changeView(e){switch(e){case"document":return this._reloadViewer({inGrid:!1,inBookLayout:!1});case"book":return this._reloadViewer({inGrid:!1,inBookLayout:!0});case"grid":return this._reloadViewer({inGrid:!0});default:return!1}}_gotoPageByIndex(e,t,i){let s=parseInt(e,10);if(this._isPageIndexValid(s)){const e=this.divaState.viewerCore.getXOffset(s,t),n=this.divaState.viewerCore.getYOffset(s,i);return this.viewerState.renderer.goto(s,n,e),!0}return!1}_isPageIndexValid(e){return this.settings.manifest.isPageValid(e,this.settings.showNonPagedPages)}_getPageIndexForPageXYValues(e,t){const i=this.viewerState.outerElement.getBoundingClientRect(),s=i.top,n=i.left,o=i.bottom,r=i.right;if(e<n||e>r)return-1;if(t<s||t>o)return-1;const a=document.getElementsByClassName("diva-page");let l=a.length;for(;l--;){const i=a[l],s=i.getBoundingClientRect();if(!(e<s.left||e>s.right)&&!(t<s.top||t>s.bottom))return i.getAttribute("data-index")}return-1}_reloadViewer(e){return this.divaState.viewerCore.reload(e)}_getCurrentURL(){return location.protocol+"//"+location.host+location.pathname+location.search+"#"+this._getURLHash()}activate(){this.viewerState.isActiveDiva=!0}changeObject(e){this.viewerState.loaded=!1,this.divaState.viewerCore.clear(),this.viewerState.renderer&&this.viewerState.renderer.destroy(),this.viewerState.options.objectData=e,this._loadOrFetchObjectData()}changeView(e){this._changeView(e)}deactivate(){this.viewerState.isActiveDiva=!1}destroy(){this.divaState.viewerCore.destroy()}disableScrollable(){this.divaState.viewerCore.disableScrollable()}enableScrollable(){this.divaState.viewerCore.enableScrollable()}disableDragScrollable(){this.divaState.viewerCore.disableDragScrollable()}enableDragScrollable(){this.divaState.viewerCore.enableDragScrollable()}enterFullscreenMode(){return!this.settings.inFullscreen&&(this._toggleFullscreen(),!0)}enterGridView(){return!this.settings.inGrid&&(this._changeView("grid"),!0)}getAllPageURIs(){return this.settings.manifest.pages.map(e=>e.f)}getCurrentCanvas(){return this.settings.manifest.pages[this.settings.activePageIndex].canvas}getCurrentPageDimensionsAtCurrentZoomLevel(){return this.getPageDimensionsAtCurrentZoomLevel(this.settings.activePageIndex)}getCurrentPageFilename(){return console.warn("This method will be deprecated in the next version of Diva. Please use getCurrentPageURI instead."),this.settings.manifest.pages[this.settings.activePageIndex].f}getCurrentPageIndices(){return this.settings.currentPageIndices}getActivePageIndex(){return this.settings.activePageIndex}getCurrentPageOffset(){return this.getPageOffset(this.settings.activePageIndex)}getCurrentPageURI(){return this.settings.manifest.pages[this.settings.activePageIndex].f}getCurrentURL(){return this._getCurrentURL()}getFilenames(){return console.warn("This will be removed in the next version of Diva. Use getAllPageURIs instead."),this.settings.manifest.pages.map(e=>e.f)}getGridPagesPerRow(){return this.settings.pagesPerRow}getInstanceId(){return this.settings.ID}getInstanceSelector(){return this.divaState.viewerCore.selector}getItemTitle(){return this.settings.manifest.itemTitle}getMaxZoomLevel(){return this.settings.maxZoomLevel}getMaxZoomLevelForPage(e){return!!this._checkLoaded()&&this.settings.manifest.pages[e].m}getMinZoomLevel(){return this.settings.minZoomLevel}getNumberOfPages(){return!!this._checkLoaded()&&this.settings.numPages}getOtherImages(e){return this.settings.manifest.pages[e].otherImages}getPageDimensions(e){return this._checkLoaded()?this.divaState.viewerCore.getCurrentLayout().getPageDimensions(e):null}getPageDimensionsAtCurrentZoomLevel(e){let t=parseInt(e,10);if(!this._isPageIndexValid(t))throw new Error("Invalid Page Index");return this.divaState.viewerCore.getCurrentLayout().getPageDimensions(t)}getPageDimensionsAtZoomLevel(e,t){if(!this._checkLoaded())return!1;t>this.settings.maxZoomLevel&&(t=this.settings.maxZoomLevel);const i=this.settings.manifest.pages[parseInt(e,10)].d[parseInt(t,10)];return{width:i.w,height:i.h}}getPageImageURL(e,t){return this.settings.manifest.getPageImageURL(e,t)}getPageIndexForPageXYValues(e,t){return this._getPageIndexForPageXYValues(e,t)}getPageOffset(e,t){const i=this.divaState.viewerCore.getPageRegion(e,t);return{top:i.top,left:i.left}}getSettings(){return this.settings}getState(){return this._getState()}getZoomLevel(){return this.settings.zoomLevel}gotoPageByIndex(e,t,i){this._gotoPageByIndex(e,t,i)}gotoPageByLabel(e,t,i){const s=this.settings.manifest.pages;let n=e.toLowerCase();for(let e=0,o=s.length;e<o;e++)if(s[e].l.toLowerCase().indexOf(n)>-1)return this._gotoPageByIndex(e,t,i);const o=parseInt(e,10)-1;return this._gotoPageByIndex(o,t,i)}gotoPageByName(e,t,i){console.warn("This method will be removed in the next version of Diva.js. Use gotoPageByURI instead.");const s=this._getPageIndex(e);return this._gotoPageByIndex(s,t,i)}gotoPageByURI(e,t,i){const s=this._getPageIndex(e);return this._gotoPageByIndex(s,t,i)}hasOtherImages(e){return!0===this.settings.manifest.pages[e].otherImages}hideNonPagedPages(){this._reloadViewer({showNonPagedPages:!1})}isInFullscreen(){return this.settings.inFullscreen}isPageIndexValid(e){return this._isPageIndexValid(e)}isPageInViewport(e){return this.viewerState.renderer.isPageVisible(e)}isReady(){return this.viewerState.loaded}isRegionInViewport(e,t,i,s,n){const o=this.divaState.viewerCore.getCurrentLayout();if(!o)return!1;const r=o.getPageOffset(e),a=r.top+i,l=r.left+t;return this.viewerState.viewport.intersectsRegion({top:a,bottom:a+n,left:l,right:l+s})}isVerticallyOriented(){return this.settings.verticallyOriented}leaveFullscreenMode(){return!!this.settings.inFullscreen&&(this._toggleFullscreen(),!0)}leaveGridView(){return!!this.settings.inGrid&&(this._reloadViewer({inGrid:!1}),!0)}setGridPagesPerRow(e){return!!this.divaState.viewerCore.isValidOption("pagesPerRow",e)&&this._reloadViewer({inGrid:!0,pagesPerRow:e})}setState(e){this._reloadViewer(this._getLoadOptionsForState(e))}setZoomLevel(e){return this.settings.inGrid&&this._reloadViewer({inGrid:!1}),this.divaState.viewerCore.zoom(e)}showNonPagedPages(){this._reloadViewer({showNonPagedPages:!0})}toggleFullscreenMode(){this._toggleFullscreen()}toggleNonPagedPagesVisibility(){this._reloadViewer({showNonPagedPages:!this.settings.showNonPagedPages})}toggleOrientation(){return this._togglePageLayoutOrientation()}translateFromMaxZoomLevel(e){const t=this.settings.maxZoomLevel-this.settings.zoomLevel;return e/Math.pow(2,t)}translateToMaxZoomLevel(e){const t=this.settings.maxZoomLevel-this.settings.zoomLevel;return 0===t?e:e*Math.pow(2,t)}zoomIn(){return this.setZoomLevel(this.settings.zoomLevel+1)}zoomOut(){return this.setZoomLevel(this.settings.zoomLevel-1)}}t.default=fe;!function(e){e.Diva=e.Diva||fe,e.Diva.Events=c.Events}(window)}]);
+//# sourceMappingURL=diva.js.map
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/imageServer/resources/js/diva.js.map	Fri Jul 05 16:05:57 2019 +0200
@@ -0,0 +1,1 @@
+{"version":3,"file":"diva.js","sources":["webpack:///diva.js"],"sourcesContent":["!function(e){var t={};function i(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var n in e)i.d(s,n,function(t){return e[t]}.bind(null,n));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,\"a\",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p=\"/build/\",i(i.s=2)}([function(e,t,i){(function(e,i){var s=200,n=\"Expected a function\",o=\"__lodash_hash_undefined__\",r=1,a=2,l=1/0,h=9007199254740991,c=\"[object Arguments]\",u=\"[object Array]\",d=\"[object Boolean]\",g=\"[object Date]\",v=\"[object Error]\",p=\"[object Function]\",f=\"[object GeneratorFunction]\",m=\"[object Map]\",w=\"[object Number]\",b=\"[object Object]\",y=\"[object RegExp]\",_=\"[object Set]\",P=\"[object String]\",S=\"[object Symbol]\",C=\"[object ArrayBuffer]\",L=\"[object DataView]\",O=/\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,x=/^\\w*$/,E=/^\\./,I=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g,T=/\\\\(\\\\)?/g,D=/^\\[object .+?Constructor\\]$/,M=/^(?:0|[1-9]\\d*)$/,z={};z[\"[object Float32Array]\"]=z[\"[object Float64Array]\"]=z[\"[object Int8Array]\"]=z[\"[object Int16Array]\"]=z[\"[object Int32Array]\"]=z[\"[object Uint8Array]\"]=z[\"[object Uint8ClampedArray]\"]=z[\"[object Uint16Array]\"]=z[\"[object Uint32Array]\"]=!0,z[c]=z[u]=z[C]=z[d]=z[L]=z[g]=z[v]=z[p]=z[m]=z[w]=z[b]=z[y]=z[_]=z[P]=z[\"[object WeakMap]\"]=!1;var V=\"object\"==typeof e&&e&&e.Object===Object&&e,k=\"object\"==typeof self&&self&&self.Object===Object&&self,F=V||k||Function(\"return this\")(),j=\"object\"==typeof t&&t&&!t.nodeType&&t,A=j&&\"object\"==typeof i&&i&&!i.nodeType&&i,R=A&&A.exports===j&&V.process,H=function(){try{return R&&R.binding(\"util\")}catch(e){}}(),B=H&&H.isTypedArray;function Z(e,t){for(var i=-1,s=e?e.length:0;++i<s;)if(t(e[i],i,e))return!0;return!1}function G(e){var t=!1;if(null!=e&&\"function\"!=typeof e.toString)try{t=!!(e+\"\")}catch(e){}return t}function N(e){var t=-1,i=Array(e.size);return e.forEach(function(e,s){i[++t]=[s,e]}),i}function U(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var W=Array.prototype,Y=Function.prototype,q=Object.prototype,X=F[\"__core-js_shared__\"],K=function(){var e=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||\"\");return e?\"Symbol(src)_1.\"+e:\"\"}(),$=Y.toString,J=q.hasOwnProperty,Q=q.toString,ee=RegExp(\"^\"+$.call(J).replace(/[\\\\^$.*+?()[\\]{}|]/g,\"\\\\$&\").replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g,\"$1.*?\")+\"$\"),te=F.Symbol,ie=F.Uint8Array,se=q.propertyIsEnumerable,ne=W.splice,oe=function(e,t){return function(i){return e(t(i))}}(Object.keys,Object),re=je(F,\"DataView\"),ae=je(F,\"Map\"),le=je(F,\"Promise\"),he=je(F,\"Set\"),ce=je(F,\"WeakMap\"),ue=je(Object,\"create\"),de=Ue(re),ge=Ue(ae),ve=Ue(le),pe=Ue(he),fe=Ue(ce),me=te?te.prototype:void 0,we=me?me.valueOf:void 0,be=me?me.toString:void 0;function ye(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function _e(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function Pe(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function Se(e){var t=-1,i=e?e.length:0;for(this.__data__=new Pe;++t<i;)this.add(e[t])}function Ce(e){this.__data__=new _e(e)}function Le(e,t){var i=Xe(e)||qe(e)?function(e,t){for(var i=-1,s=Array(e);++i<e;)s[i]=t(i);return s}(e.length,String):[],s=i.length,n=!!s;for(var o in e)!t&&!J.call(e,o)||n&&(\"length\"==o||Re(o,s))||i.push(o);return i}function Oe(e,t){for(var i=e.length;i--;)if(Ye(e[i][0],t))return i;return-1}function xe(e,t){for(var i=0,s=(t=He(t,e)?[t]:Ve(t)).length;null!=e&&i<s;)e=e[Ne(t[i++])];return i&&i==s?e:void 0}function Ee(e,t){return e>t}function Ie(e,t){return null!=e&&t in Object(e)}function Te(e,t,i,s,n){return e===t||(null==e||null==t||!Qe(e)&&!et(t)?e!=e&&t!=t:function(e,t,i,s,n,o){var l=Xe(e),h=Xe(t),p=u,f=u;l||(p=(p=Ae(e))==c?b:p);h||(f=(f=Ae(t))==c?b:f);var O=p==b&&!G(e),x=f==b&&!G(t),E=p==f;if(E&&!O)return o||(o=new Ce),l||it(e)?ke(e,t,i,s,n,o):function(e,t,i,s,n,o,l){switch(i){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case C:return!(e.byteLength!=t.byteLength||!s(new ie(e),new ie(t)));case d:case g:case w:return Ye(+e,+t);case v:return e.name==t.name&&e.message==t.message;case y:case P:return e==t+\"\";case m:var h=N;case _:var c=o&a;if(h||(h=U),e.size!=t.size&&!c)return!1;var u=l.get(e);if(u)return u==t;o|=r,l.set(e,t);var p=ke(h(e),h(t),s,n,o,l);return l.delete(e),p;case S:if(we)return we.call(e)==we.call(t)}return!1}(e,t,p,i,s,n,o);if(!(n&a)){var I=O&&J.call(e,\"__wrapped__\"),T=x&&J.call(t,\"__wrapped__\");if(I||T){var D=I?e.value():e,M=T?t.value():t;return o||(o=new Ce),i(D,M,s,n,o)}}if(!E)return!1;return o||(o=new Ce),function(e,t,i,s,n,o){var r=n&a,l=st(e),h=l.length,c=st(t).length;if(h!=c&&!r)return!1;for(var u=h;u--;){var d=l[u];if(!(r?d in t:J.call(t,d)))return!1}var g=o.get(e);if(g&&o.get(t))return g==t;var v=!0;o.set(e,t),o.set(t,e);for(var p=r;++u<h;){d=l[u];var f=e[d],m=t[d];if(s)var w=r?s(m,f,d,t,e,o):s(f,m,d,e,t,o);if(!(void 0===w?f===m||i(f,m,s,n,o):w)){v=!1;break}p||(p=\"constructor\"==d)}if(v&&!p){var b=e.constructor,y=t.constructor;b!=y&&\"constructor\"in e&&\"constructor\"in t&&!(\"function\"==typeof b&&b instanceof b&&\"function\"==typeof y&&y instanceof y)&&(v=!1)}return o.delete(e),o.delete(t),v}(e,t,i,s,n,o)}(e,t,Te,i,s,n))}function De(e){return!(!Qe(e)||function(e){return!!K&&K in e}(e))&&($e(e)||G(e)?ee:D).test(Ue(e))}function Me(e){return\"function\"==typeof e?e:null==e?nt:\"object\"==typeof e?Xe(e)?function(e,t){if(He(e)&&Be(t))return Ze(Ne(e),t);return function(i){var s=function(e,t,i){var s=null==e?void 0:xe(e,t);return void 0===s?i:s}(i,e);return void 0===s&&s===t?function(e,t){return null!=e&&function(e,t,i){var s,n=-1,o=(t=He(t,e)?[t]:Ve(t)).length;for(;++n<o;){var r=Ne(t[n]);if(!(s=null!=e&&i(e,r)))break;e=e[r]}if(s)return s;return!!(o=e?e.length:0)&&Je(o)&&Re(r,o)&&(Xe(e)||qe(e))}(e,t,Ie)}(i,e):Te(t,s,void 0,r|a)}}(e[0],e[1]):function(e){var t=function(e){var t=st(e),i=t.length;for(;i--;){var s=t[i],n=e[s];t[i]=[s,n,Be(n)]}return t}(e);if(1==t.length&&t[0][2])return Ze(t[0][0],t[0][1]);return function(i){return i===e||function(e,t,i,s){var n=i.length,o=n,l=!s;if(null==e)return!o;for(e=Object(e);n--;){var h=i[n];if(l&&h[2]?h[1]!==e[h[0]]:!(h[0]in e))return!1}for(;++n<o;){var c=(h=i[n])[0],u=e[c],d=h[1];if(l&&h[2]){if(void 0===u&&!(c in e))return!1}else{var g=new Ce;if(s)var v=s(u,d,c,e,t,g);if(!(void 0===v?Te(d,u,s,r|a,g):v))return!1}}return!0}(i,e,t)}}(e):function(e){return He(e)?function(e){return function(t){return null==t?void 0:t[e]}}(Ne(e)):function(e){return function(t){return xe(t,e)}}(e)}(e)}function ze(e){if(!function(e){var t=e&&e.constructor,i=\"function\"==typeof t&&t.prototype||q;return e===i}(e))return oe(e);var t=[];for(var i in Object(e))J.call(e,i)&&\"constructor\"!=i&&t.push(i);return t}function Ve(e){return Xe(e)?e:Ge(e)}function ke(e,t,i,s,n,o){var l=n&a,h=e.length,c=t.length;if(h!=c&&!(l&&c>h))return!1;var u=o.get(e);if(u&&o.get(t))return u==t;var d=-1,g=!0,v=n&r?new Se:void 0;for(o.set(e,t),o.set(t,e);++d<h;){var p=e[d],f=t[d];if(s)var m=l?s(f,p,d,t,e,o):s(p,f,d,e,t,o);if(void 0!==m){if(m)continue;g=!1;break}if(v){if(!Z(t,function(e,t){if(!v.has(t)&&(p===e||i(p,e,s,n,o)))return v.add(t)})){g=!1;break}}else if(p!==f&&!i(p,f,s,n,o)){g=!1;break}}return o.delete(e),o.delete(t),g}function Fe(e,t){var i=e.__data__;return function(e){var t=typeof e;return\"string\"==t||\"number\"==t||\"symbol\"==t||\"boolean\"==t?\"__proto__\"!==e:null===e}(t)?i[\"string\"==typeof t?\"string\":\"hash\"]:i.map}function je(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return De(i)?i:void 0}ye.prototype.clear=function(){this.__data__=ue?ue(null):{}},ye.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ye.prototype.get=function(e){var t=this.__data__;if(ue){var i=t[e];return i===o?void 0:i}return J.call(t,e)?t[e]:void 0},ye.prototype.has=function(e){var t=this.__data__;return ue?void 0!==t[e]:J.call(t,e)},ye.prototype.set=function(e,t){return this.__data__[e]=ue&&void 0===t?o:t,this},_e.prototype.clear=function(){this.__data__=[]},_e.prototype.delete=function(e){var t=this.__data__,i=Oe(t,e);return!(i<0||(i==t.length-1?t.pop():ne.call(t,i,1),0))},_e.prototype.get=function(e){var t=this.__data__,i=Oe(t,e);return i<0?void 0:t[i][1]},_e.prototype.has=function(e){return Oe(this.__data__,e)>-1},_e.prototype.set=function(e,t){var i=this.__data__,s=Oe(i,e);return s<0?i.push([e,t]):i[s][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new ye,map:new(ae||_e),string:new ye}},Pe.prototype.delete=function(e){return Fe(this,e).delete(e)},Pe.prototype.get=function(e){return Fe(this,e).get(e)},Pe.prototype.has=function(e){return Fe(this,e).has(e)},Pe.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},Se.prototype.add=Se.prototype.push=function(e){return this.__data__.set(e,o),this},Se.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.clear=function(){this.__data__=new _e},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var i=this.__data__;if(i instanceof _e){var n=i.__data__;if(!ae||n.length<s-1)return n.push([e,t]),this;i=this.__data__=new Pe(n)}return i.set(e,t),this};var Ae=function(e){return Q.call(e)};function Re(e,t){return!!(t=null==t?h:t)&&(\"number\"==typeof e||M.test(e))&&e>-1&&e%1==0&&e<t}function He(e,t){if(Xe(e))return!1;var i=typeof e;return!(\"number\"!=i&&\"symbol\"!=i&&\"boolean\"!=i&&null!=e&&!tt(e))||(x.test(e)||!O.test(e)||null!=t&&e in Object(t))}function Be(e){return e==e&&!Qe(e)}function Ze(e,t){return function(i){return null!=i&&(i[e]===t&&(void 0!==t||e in Object(i)))}}(re&&Ae(new re(new ArrayBuffer(1)))!=L||ae&&Ae(new ae)!=m||le&&\"[object Promise]\"!=Ae(le.resolve())||he&&Ae(new he)!=_||ce&&\"[object WeakMap]\"!=Ae(new ce))&&(Ae=function(e){var t=Q.call(e),i=t==b?e.constructor:void 0,s=i?Ue(i):void 0;if(s)switch(s){case de:return L;case ge:return m;case ve:return\"[object Promise]\";case pe:return _;case fe:return\"[object WeakMap]\"}return t});var Ge=We(function(e){e=function(e){return null==e?\"\":function(e){if(\"string\"==typeof e)return e;if(tt(e))return be?be.call(e):\"\";var t=e+\"\";return\"0\"==t&&1/e==-l?\"-0\":t}(e)}(e);var t=[];return E.test(e)&&t.push(\"\"),e.replace(I,function(e,i,s,n){t.push(s?n.replace(T,\"$1\"):i||e)}),t});function Ne(e){if(\"string\"==typeof e||tt(e))return e;var t=e+\"\";return\"0\"==t&&1/e==-l?\"-0\":t}function Ue(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+\"\"}catch(e){}}return\"\"}function We(e,t){if(\"function\"!=typeof e||t&&\"function\"!=typeof t)throw new TypeError(n);var i=function(){var s=arguments,n=t?t.apply(this,s):s[0],o=i.cache;if(o.has(n))return o.get(n);var r=e.apply(this,s);return i.cache=o.set(n,r),r};return i.cache=new(We.Cache||Pe),i}function Ye(e,t){return e===t||e!=e&&t!=t}function qe(e){return function(e){return et(e)&&Ke(e)}(e)&&J.call(e,\"callee\")&&(!se.call(e,\"callee\")||Q.call(e)==c)}We.Cache=Pe;var Xe=Array.isArray;function Ke(e){return null!=e&&Je(e.length)&&!$e(e)}function $e(e){var t=Qe(e)?Q.call(e):\"\";return t==p||t==f}function Je(e){return\"number\"==typeof e&&e>-1&&e%1==0&&e<=h}function Qe(e){var t=typeof e;return!!e&&(\"object\"==t||\"function\"==t)}function et(e){return!!e&&\"object\"==typeof e}function tt(e){return\"symbol\"==typeof e||et(e)&&Q.call(e)==S}var it=B?function(e){return function(t){return e(t)}}(B):function(e){return et(e)&&Je(e.length)&&!!z[Q.call(e)]};function st(e){return Ke(e)?Le(e):ze(e)}function nt(e){return e}i.exports=function(e,t){return e&&e.length?function(e,t,i){for(var s=-1,n=e.length;++s<n;){var o=e[s],r=t(o);if(null!=r&&(void 0===a?r==r&&!tt(r):i(r,a)))var a=r,l=o}return l}(e,Me(t),Ee):void 0}}).call(this,i(6),i(7)(e))},function(e,t,i){(function(s){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==s&&\"env\"in s&&(e=s.env.DEBUG),e}(t=e.exports=i(9)).log=function(){return\"object\"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var i=this.useColors;if(e[0]=(i?\"%c\":\"\")+this.namespace+(i?\" %c\":\" \")+e[0]+(i?\"%c \":\" \")+\"+\"+t.humanize(this.diff),!i)return;var s=\"color: \"+this.color;e.splice(1,0,s,\"color: inherit\");var n=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){\"%%\"!==e&&\"%c\"===e&&(o=++n)}),e.splice(o,0,s)},t.save=function(e){try{null==e?t.storage.removeItem(\"debug\"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if(\"undefined\"!=typeof window&&window.process&&\"renderer\"===window.process.type)return!0;if(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))return!1;return\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)},t.storage=\"undefined\"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return\"[UnexpectedJSONParseError]: \"+e.message}},t.enable(n())}).call(this,i(8))},function(e,t,i){i(3),i(16),e.exports=i(11)},function(e,t){!function(){if(!Array.prototype.fill){var e=function(e){if(null==this)throw new TypeError(\"this is null or not defined\");for(var t=Object(this),i=t.length>>>0,s=arguments[1]>>0,n=s<0?Math.max(i+s,0):Math.min(s,i),o=arguments[2],r=void 0===o?i:o>>0,a=r<0?Math.max(i+r,0):Math.min(r,i);n<a;)t[n]=e,n++;return t};if(Object.defineProperty)try{Object.defineProperty(Array.prototype,\"fill\",{value:e,configurable:!0,enumerable:!1,writable:!0})}catch(e){}Array.prototype.fill||(Array.prototype.fill=e)}}()},function(e,t){!function(){var e=window.requestAnimationFrame,t=\"ontouchend\"in document,i=function(){for(var e=1;e<arguments.length;e++)for(var t in arguments[e])arguments[e].hasOwnProperty(t)&&(arguments[0][t]=arguments[e][t]);return arguments[0]},s=function(e,t){return this.settings=i({},s.DEFAULTS,t),this.el=e,this.ACTIVE_CLASS=\"kinetic-active\",this._initElements(),this.el._VanillaKinetic=this,this};s.DEFAULTS={cursor:\"move\",decelerate:!0,triggerHardware:!1,threshold:0,y:!0,x:!0,slowdown:.9,maxvelocity:40,throttleFPS:60,invert:!1,movingClass:{up:\"kinetic-moving-up\",down:\"kinetic-moving-down\",left:\"kinetic-moving-left\",right:\"kinetic-moving-right\"},deceleratingClass:{up:\"kinetic-decelerating-up\",down:\"kinetic-decelerating-down\",left:\"kinetic-decelerating-left\",right:\"kinetic-decelerating-right\"}},s.prototype.start=function(e){this.settings=i(this.settings,e),this.velocity=e.velocity||this.velocity,this.velocityY=e.velocityY||this.velocityY,this.settings.decelerate=!1,this._move()},s.prototype.end=function(){this.settings.decelerate=!0},s.prototype.stop=function(){this.velocity=0,this.velocityY=0,this.settings.decelerate=!0,\"function\"==typeof this.settings.stopped&&this.settings.stopped.call(this)},s.prototype.detach=function(){this._detachListeners(),this.el.classList.remove(this.ACTIVE_CLASS),this.el.style.cursor=\"\"},s.prototype.attach=function(){this.el.classList.contains(this.ACTIVE_CLASS)||(this._attachListeners(),this.el.classList.add(this.ACTIVE_CLASS),this.el.style.cursor=this.settings.cursor)},s.prototype._initElements=function(){this.el.classList.add(this.ACTIVE_CLASS),i(this,{xpos:null,prevXPos:!1,ypos:null,prevYPos:!1,mouseDown:!1,throttleTimeout:1e3/this.settings.throttleFPS,lastMove:null,elementFocused:null}),this.velocity=0,this.velocityY=0;var e=this;this.documentResetHandler=function(){e._resetMouse.apply(e)};var t=document.documentElement;if(t.addEventListener(\"mouseup\",this.documentResetHandler,!1),t.addEventListener(\"click\",this.documentResetHandler,!1),this._initEvents(),this.el.style.cursor=this.settings.cursor,this.settings.triggerHardware)for(var s=[\"\",\"-ms-\",\"-webkit-\",\"-moz-\"],n={transform:\"translate3d(0,0,0)\",perspective:\"1000\",\"backface-visibility\":\"hidden\"},o=0;o<s.length;o++){var r=s[o];for(var a in n)n.hasOwnProperty(a)&&(this.el.style[r+a]=n[a])}},s.prototype._initEvents=function(){var e=this;this.settings.events={touchStart:function(t){var i;e._useTarget(t.target,t)&&(i=t.originalEvent.touches[0],e.threshold=e._threshold(t.target,t),e._start(i.clientX,i.clientY),t.stopPropagation())},touchMove:function(t){var i;e.mouseDown&&(i=t.originalEvent.touches[0],e._inputmove(i.clientX,i.clientY),t.preventDefault&&t.preventDefault())},inputDown:function(t){e._useTarget(t.target,t)&&(e.threshold=e._threshold(t.target,t),e._start(t.clientX,t.clientY),e.elementFocused=t.target,\"IMG\"===t.target.nodeName&&t.preventDefault(),t.stopPropagation())},inputEnd:function(t){e._useTarget(t.target,t)&&(e._end(),e.elementFocused=null,t.preventDefault&&t.preventDefault())},inputMove:function(t){e.mouseDown&&(e._inputmove(t.clientX,t.clientY),t.preventDefault&&t.preventDefault())},scroll:function(t){\"function\"==typeof e.settings.moved&&e.settings.moved.call(e,e.settings),t.preventDefault&&t.preventDefault()},inputClick:function(t){if(Math.abs(e.velocity)>0||Math.abs(e.velocityY)>0)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1},dragStart:function(t){if(e._useTarget(t.target,t)&&e.elementFocused)return t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1},selectStart:function(t){return\"function\"==typeof e.settings.selectStart?e.settings.selectStart.apply(e,arguments):e._useTarget(t.target,t)?(t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1):void 0}},this._attachListeners()},s.prototype._inputmove=function(e,t){if((!this.lastMove||new Date>new Date(this.lastMove.getTime()+this.throttleTimeout))&&(this.lastMove=new Date,this.mouseDown&&(this.xpos||this.ypos))){var i=e-this.xpos,s=t-this.ypos;if(this.settings.invert&&(i*=-1,s*=-1),this.threshold>0){var n=Math.sqrt(i*i+s*s);if(this.threshold>n)return;this.threshold=0}this.elementFocused&&(this.elementFocused.blur(),this.elementFocused=null,this.el.focus()),this.settings.decelerate=!1,this.velocity=this.velocityY=0;var o=this.scrollLeft(),r=this.scrollTop();this.scrollLeft(this.settings.x?o-i:o),this.scrollTop(this.settings.y?r-s:r),this.prevXPos=this.xpos,this.prevYPos=this.ypos,this.xpos=e,this.ypos=t,this._calculateVelocities(),this._setMoveClasses(this.settings.movingClass),\"function\"==typeof this.settings.moved&&this.settings.moved.call(this,this.settings)}},s.prototype._calculateVelocities=function(){this.velocity=this._capVelocity(this.prevXPos-this.xpos,this.settings.maxvelocity),this.velocityY=this._capVelocity(this.prevYPos-this.ypos,this.settings.maxvelocity),this.settings.invert&&(this.velocity*=-1,this.velocityY*=-1)},s.prototype._end=function(){this.xpos&&this.prevXPos&&!1===this.settings.decelerate&&(this.settings.decelerate=!0,this._calculateVelocities(),this.xpos=this.prevXPos=this.mouseDown=!1,this._move())},s.prototype._useTarget=function(e,t){return\"function\"!=typeof this.settings.filterTarget||!1!==this.settings.filterTarget.call(this,e,t)},s.prototype._threshold=function(e,t){return\"function\"==typeof this.settings.threshold?this.settings.threshold.call(this,e,t):this.settings.threshold},s.prototype._start=function(e,t){this.mouseDown=!0,this.velocity=this.prevXPos=0,this.velocityY=this.prevYPos=0,this.xpos=e,this.ypos=t},s.prototype._resetMouse=function(){this.xpos=!1,this.ypos=!1,this.mouseDown=!1},s.prototype._decelerateVelocity=function(e,t){return 0===Math.floor(Math.abs(e))?0:e*t},s.prototype._capVelocity=function(e,t){var i=e;return e>0?e>t&&(i=t):e<0-t&&(i=0-t),i},s.prototype._setMoveClasses=function(e){var t=this.settings,i=this.el;i.classList.remove(t.movingClass.up),i.classList.remove(t.movingClass.down),i.classList.remove(t.movingClass.left),i.classList.remove(t.movingClass.right),i.classList.remove(t.deceleratingClass.up),i.classList.remove(t.deceleratingClass.down),i.classList.remove(t.deceleratingClass.left),i.classList.remove(t.deceleratingClass.right),this.velocity>0&&i.classList.add(e.right),this.velocity<0&&i.classList.add(e.left),this.velocityY>0&&i.classList.add(e.down),this.velocityY<0&&i.classList.add(e.up)},s.prototype._move=function(){var t=this._getScroller(),i=this,s=this.settings;s.x&&t.scrollWidth>0?(this.scrollLeft(this.scrollLeft()+this.velocity),Math.abs(this.velocity)>0&&(this.velocity=s.decelerate?i._decelerateVelocity(this.velocity,s.slowdown):this.velocity)):this.velocity=0,s.y&&t.scrollHeight>0?(this.scrollTop(this.scrollTop()+this.velocityY),Math.abs(this.velocityY)>0&&(this.velocityY=s.decelerate?i._decelerateVelocity(this.velocityY,s.slowdown):this.velocityY)):this.velocityY=0,i._setMoveClasses(s.deceleratingClass),\"function\"==typeof s.moved&&s.moved.call(this,s),Math.abs(this.velocity)>0||Math.abs(this.velocityY)>0?this.moving||(this.moving=!0,e(function(){i.moving=!1,i._move()})):i.stop()},s.prototype._getScroller=function(){return this.el},s.prototype.scrollLeft=function(e){var t=this._getScroller();if(\"number\"!=typeof e)return t.scrollLeft;t.scrollLeft=e,this.settings.scrollLeft=e},s.prototype.scrollTop=function(e){var t=this._getScroller();if(\"number\"!=typeof e)return t.scrollTop;t.scrollTop=e,this.settings.scrollTop=e},s.prototype._attachListeners=function(){var e=this.el,i=this.settings;t&&(e.addEventListener(\"touchstart\",i.events.touchStart,!1),e.addEventListener(\"touchend\",i.events.inputEnd,!1),e.addEventListener(\"touchmove\",i.events.touchMove,!1)),e.addEventListener(\"mousedown\",i.events.inputDown,!1),e.addEventListener(\"mouseup\",i.events.inputEnd,!1),e.addEventListener(\"mousemove\",i.events.inputMove,!1),e.addEventListener(\"click\",i.events.inputClick,!1),e.addEventListener(\"scroll\",i.events.scroll,!1),e.addEventListener(\"selectstart\",i.events.selectStart,!1),e.addEventListener(\"dragstart\",i.events.dragStart,!1)},s.prototype._detachListeners=function(){var e=this.el,i=this.settings;t&&(e.removeEventListener(\"touchstart\",i.events.touchStart,!1),e.removeEventListener(\"touchend\",i.events.inputEnd,!1),e.removeEventListener(\"touchmove\",i.events.touchMove,!1)),e.removeEventListener(\"mousedown\",i.events.inputDown,!1),e.removeEventListener(\"mouseup\",i.events.inputEnd,!1),e.removeEventListener(\"mousemove\",i.events.inputMove,!1),e.removeEventListener(\"click\",i.events.inputClick,!1),e.removeEventListener(\"scroll\",i.events.scroll,!1),e.removeEventListener(\"selectstart\",i.events.selectStart,!1),e.removeEventListener(\"dragstart\",i.events.dragStart,!1)},window.VanillaKinetic=s}()},function(e,t,i){var s,n,o;\n/**\n * @fileoverview dragscroll - scroll area by dragging\n * @version 0.0.8\n *\n * @license MIT, see http://github.com/asvd/dragscroll\n * @copyright 2015 asvd <heliosframework@gmail.com>\n */n=[t],void 0===(o=\"function\"==typeof(s=function(e){var t,i,s=window,n=document,o=[],r=function(e,r){for(e=0;e<o.length;)(r=(r=o[e++]).container||r).removeEventListener(\"mousedown\",r.md,0),s.removeEventListener(\"mouseup\",r.mu,0),s.removeEventListener(\"mousemove\",r.mm,0);for(o=[].slice.call(n.getElementsByClassName(\"dragscroll\")),e=0;e<o.length;)!function(e,o,r,a,l,h){(h=e.container||e).addEventListener(\"mousedown\",h.md=function(t){e.hasAttribute(\"nochilddrag\")&&n.elementFromPoint(t.pageX,t.pageY)!==h||(a=1,o=t.clientX,r=t.clientY,t.preventDefault())},0),s.addEventListener(\"mouseup\",h.mu=function(){a=0},0),s.addEventListener(\"mousemove\",h.mm=function(s){a&&((l=e.scroller||e).scrollLeft-=t=-o+(o=s.clientX),l.scrollTop-=i=-r+(r=s.clientY),e===n.body&&((l=n.documentElement).scrollLeft-=t,l.scrollTop-=i))},0)}(o[e++])};\"complete\"===n.readyState?r():s.addEventListener(\"load\",r,0),e.reset=r,window.resetDragscroll=r})?s.apply(t,n):s)||(e.exports=o)},function(e,t){var i;i=function(){return this}();try{i=i||Function(\"return this\")()||(0,eval)(\"this\")}catch(e){\"object\"==typeof window&&(i=window)}e.exports=i},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,\"loaded\",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,\"id\",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){var i,s,n=e.exports={};function o(){throw new Error(\"setTimeout has not been defined\")}function r(){throw new Error(\"clearTimeout has not been defined\")}function a(e){if(i===setTimeout)return setTimeout(e,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i=\"function\"==typeof setTimeout?setTimeout:o}catch(e){i=o}try{s=\"function\"==typeof clearTimeout?clearTimeout:r}catch(e){s=r}}();var l,h=[],c=!1,u=-1;function d(){c&&l&&(c=!1,l.length?h=l.concat(h):u=-1,h.length&&g())}function g(){if(!c){var e=a(d);c=!0;for(var t=h.length;t;){for(l=h,h=[];++u<t;)l&&l[u].run();u=-1,t=h.length}l=null,c=!1,function(e){if(s===clearTimeout)return clearTimeout(e);if((s===r||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];h.push(new v(e,t)),1!==h.length||c||a(g)},v.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.browser=!0,n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(e){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0}},function(e,t,i){function s(e){var i;function s(){if(s.enabled){var e=s,n=+new Date,o=n-(i||n);e.diff=o,e.prev=i,e.curr=n,i=n;for(var r=new Array(arguments.length),a=0;a<r.length;a++)r[a]=arguments[a];r[0]=t.coerce(r[0]),\"string\"!=typeof r[0]&&r.unshift(\"%O\");var l=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,function(i,s){if(\"%%\"===i)return i;l++;var n=t.formatters[s];if(\"function\"==typeof n){var o=r[l];i=n.call(e,o),r.splice(l,1),l--}return i}),t.formatArgs.call(e,r),(s.log||t.log||console.log.bind(console)).apply(e,r)}}return s.namespace=e,s.enabled=t.enabled(e),s.useColors=t.useColors(),s.color=function(e){var i,s=0;for(i in e)s=(s<<5)-s+e.charCodeAt(i),s|=0;return t.colors[Math.abs(s)%t.colors.length]}(e),s.destroy=n,\"function\"==typeof t.init&&t.init(s),t.instances.push(s),s}function n(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=s.debug=s.default=s).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable(\"\")},t.enable=function(e){var i;t.save(e),t.names=[],t.skips=[];var s=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),n=s.length;for(i=0;i<n;i++)s[i]&&(\"-\"===(e=s[i].replace(/\\*/g,\".*?\"))[0]?t.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):t.names.push(new RegExp(\"^\"+e+\"$\")));for(i=0;i<t.instances.length;i++){var o=t.instances[i];o.enabled=t.enabled(o.namespace)}},t.enabled=function(e){if(\"*\"===e[e.length-1])return!0;var i,s;for(i=0,s=t.skips.length;i<s;i++)if(t.skips[i].test(e))return!1;for(i=0,s=t.names.length;i<s;i++)if(t.names[i].test(e))return!0;return!1},t.humanize=i(10),t.instances=[],t.names=[],t.skips=[],t.formatters={}},function(e,t){var i=1e3,s=60*i,n=60*s,o=24*n,r=365.25*o;function a(e,t,i){if(!(e<t))return e<1.5*t?Math.floor(e/t)+\" \"+i:Math.ceil(e/t)+\" \"+i+\"s\"}e.exports=function(e,t){t=t||{};var l=typeof e;if(\"string\"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return a*r;case\"days\":case\"day\":case\"d\":return a*o;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return a*n;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return a*s;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return a*i;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return a;default:return}}(e);if(\"number\"===l&&!1===isNaN(e))return t.long?function(e){return a(e,o,\"day\")||a(e,n,\"hour\")||a(e,s,\"minute\")||a(e,i,\"second\")||e+\" ms\"}(e):function(e){if(e>=o)return Math.round(e/o)+\"d\";if(e>=n)return Math.round(e/n)+\"h\";if(e>=s)return Math.round(e/s)+\"m\";if(e>=i)return Math.round(e/i)+\"s\";return e+\"ms\"}(e);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(e))}},function(e,t,i){var s=i(12);\"string\"==typeof s&&(s=[[e.i,s,\"\"]]);var n={hmr:!0,transform:void 0,insertInto:void 0};i(14)(s,n);s.locals&&(e.exports=s.locals)},function(e,t,i){},,function(e,t,i){var s={},n=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),o=function(e){var t={};return function(e,i){if(\"function\"==typeof e)return e();if(void 0===t[e]){var s=function(e,t){return t?t.querySelector(e):document.querySelector(e)}.call(this,e,i);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}t[e]=s}return t[e]}}(),r=null,a=0,l=[],h=i(15);function c(e,t){for(var i=0;i<e.length;i++){var n=e[i],o=s[n.id];if(o){o.refs++;for(var r=0;r<o.parts.length;r++)o.parts[r](n.parts[r]);for(;r<n.parts.length;r++)o.parts.push(f(n.parts[r],t))}else{var a=[];for(r=0;r<n.parts.length;r++)a.push(f(n.parts[r],t));s[n.id]={id:n.id,refs:1,parts:a}}}}function u(e,t){for(var i=[],s={},n=0;n<e.length;n++){var o=e[n],r=t.base?o[0]+t.base:o[0],a={css:o[1],media:o[2],sourceMap:o[3]};s[r]?s[r].parts.push(a):i.push(s[r]={id:r,parts:[a]})}return i}function d(e,t){var i=o(e.insertInto);if(!i)throw new Error(\"Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.\");var s=l[l.length-1];if(\"top\"===e.insertAt)s?s.nextSibling?i.insertBefore(t,s.nextSibling):i.appendChild(t):i.insertBefore(t,i.firstChild),l.push(t);else if(\"bottom\"===e.insertAt)i.appendChild(t);else{if(\"object\"!=typeof e.insertAt||!e.insertAt.before)throw new Error(\"[Style Loader]\\n\\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\\n Must be 'top', 'bottom', or Object.\\n (https://github.com/webpack-contrib/style-loader#insertat)\\n\");var n=o(e.insertAt.before,i);i.insertBefore(t,n)}}function g(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=l.indexOf(e);t>=0&&l.splice(t,1)}function v(e){var t=document.createElement(\"style\");if(void 0===e.attrs.type&&(e.attrs.type=\"text/css\"),void 0===e.attrs.nonce){var s=function(){0;return i.nc}();s&&(e.attrs.nonce=s)}return p(t,e.attrs),d(e,t),t}function p(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function f(e,t){var i,s,n,o;if(t.transform&&e.css){if(!(o=t.transform(e.css)))return function(){};e.css=o}if(t.singleton){var l=a++;i=r||(r=v(t)),s=w.bind(null,i,l,!1),n=w.bind(null,i,l,!0)}else e.sourceMap&&\"function\"==typeof URL&&\"function\"==typeof URL.createObjectURL&&\"function\"==typeof URL.revokeObjectURL&&\"function\"==typeof Blob&&\"function\"==typeof btoa?(i=function(e){var t=document.createElement(\"link\");return void 0===e.attrs.type&&(e.attrs.type=\"text/css\"),e.attrs.rel=\"stylesheet\",p(t,e.attrs),d(e,t),t}(t),s=function(e,t,i){var s=i.css,n=i.sourceMap,o=void 0===t.convertToAbsoluteUrls&&n;(t.convertToAbsoluteUrls||o)&&(s=h(s));n&&(s+=\"\\n/*# sourceMappingURL=data:application/json;base64,\"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+\" */\");var r=new Blob([s],{type:\"text/css\"}),a=e.href;e.href=URL.createObjectURL(r),a&&URL.revokeObjectURL(a)}.bind(null,i,t),n=function(){g(i),i.href&&URL.revokeObjectURL(i.href)}):(i=v(t),s=function(e,t){var i=t.css,s=t.media;s&&e.setAttribute(\"media\",s);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),n=function(){g(i)});return s(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;s(e=t)}else n()}}e.exports=function(e,t){if(\"undefined\"!=typeof DEBUG&&DEBUG&&\"object\"!=typeof document)throw new Error(\"The style-loader cannot be used in a non-browser environment\");(t=t||{}).attrs=\"object\"==typeof t.attrs?t.attrs:{},t.singleton||\"boolean\"==typeof t.singleton||(t.singleton=n()),t.insertInto||(t.insertInto=\"head\"),t.insertAt||(t.insertAt=\"bottom\");var i=u(e,t);return c(i,t),function(e){for(var n=[],o=0;o<i.length;o++){var r=i[o];(a=s[r.id]).refs--,n.push(a)}e&&c(u(e,t),t);for(o=0;o<n.length;o++){var a;if(0===(a=n[o]).refs){for(var l=0;l<a.parts.length;l++)a.parts[l]();delete s[a.id]}}}};var m=function(){var e=[];return function(t,i){return e[t]=i,e.filter(Boolean).join(\"\\n\")}}();function w(e,t,i,s){var n=i?\"\":s.css;if(e.styleSheet)e.styleSheet.cssText=m(t,n);else{var o=document.createTextNode(n),r=e.childNodes;r[t]&&e.removeChild(r[t]),r.length?e.insertBefore(o,r[t]):e.appendChild(o)}}},function(e,t){e.exports=function(e){var t=\"undefined\"!=typeof window&&window.location;if(!t)throw new Error(\"fixUrls requires window.location\");if(!e||\"string\"!=typeof e)return e;var i=t.protocol+\"//\"+t.host,s=i+t.pathname.replace(/\\/[^\\/]*$/,\"/\");return e.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi,function(e,t){var n,o=t.trim().replace(/^\"(.*)\"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});return/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/|\\s*$)/i.test(o)?e:(n=0===o.indexOf(\"//\")?o:0===o.indexOf(\"/\")?i+o:s+o.replace(/^\\.\\//,\"\"),\"url(\"+JSON.stringify(n)+\")\")})}},function(e,t,i){\"use strict\";i.r(t);i(4),i(5);function s(e){const t=document.createElement(e),i=Array.prototype.slice.call(arguments,1);for(;i.length;){n(t,i.shift())}return t}function n(e,t){if(null!=t)if(\"object\"!=typeof t&&\"function\"!=typeof t)e.appendChild(document.createTextNode(t));else if(t instanceof window.Node)e.appendChild(t);else if(t instanceof Array){const i=t.length;for(let s=0;s<i;s++)n(e,t[s])}else o(e,t)}function o(e,t){for(const i in t)t.hasOwnProperty(i)&&(\"style\"===i?r(e,t.style):e.setAttribute(i,t[i]))}function r(e,t){if(t)if(\"object\"==typeof t)for(const i in t)t.hasOwnProperty(i)&&(e.style[i]=t[i]);else e.style.cssText=t}function a(e){this.name=\"DivaParentElementNotFoundException\",this.message=e,this.stack=(new Error).stack}function l(e){this.name=\"NotAnIIIFManifestException\",this.message=e,this.stack=(new Error).stack}function h(e){this.name=\"ObjectDataNotSuppliedException\",this.message=e,this.stack=(new Error).stack}a.prototype=new Error,l.prototype=new Error,h.prototype=new Error;var c={Events:new class{constructor(){this._cache={}}publish(e,t,i){if(this._cache[e]){const s=this._cache[e];if(void 0!==s.global){const e=s.global,n=e.length;for(let s=0;s<n;s++)e[s].apply(i||null,t||[])}if(i&&void 0!==i.getInstanceId){const s=i.getInstanceId();if(this._cache[e][s]){const n=this._cache[e][s],o=n.length;for(let e=0;e<o;e++)n[e].apply(i,t||[])}}}}subscribe(e,t,i){return this._cache[e]||(this._cache[e]={}),\"string\"==typeof i?(this._cache[e][i]||(this._cache[e][i]=[]),this._cache[e][i].push(t)):(this._cache[e].global||(this._cache[e].global=[]),this._cache[e].global.push(t)),i?[e,t,i]:[e,t]}unsubscribe(e,t){const i=e[0];if(this._cache[i]){let s;const n=3===e.length?e[2]:\"global\";if(!(s=this._cache[i][n]))return!1;if(t)return delete this._cache[i][n],s.length>0;let o=s.length;for(;o--;)if(s[o]===e[1])return this._cache[i][n].splice(o,1),!0}return!1}unsubscribeAll(e){if(e){const t=Object.keys(this._cache);let i,s=t.length;for(;s--;)i=t[s],void 0!==this._cache[i][e]&&delete this._cache[i][e]}else this._cache={}}}};var u={onDoubleClick:function(e,t){e.addEventListener(\"dblclick\",function(e){e.ctrlKey||t(e,m(e.currentTarget,e))});const i=f(d);e.addEventListener(\"contextmenu\",function(e){e.preventDefault(),e.ctrlKey&&(i.isTriggered()?(i.reset(),t(e,m(e.currentTarget,e))):i.trigger())})},onPinch:function(e,t){let i=0;e.addEventListener(\"touchstart\",function(e){e.preventDefault(),2===e.originalEvent.touches.length&&(i=p(e.originalEvent.touches[0].clientX,e.originalEvent.touches[0].clientY,e.originalEvent.touches[1].clientX,e.originalEvent.touches[1].clientY))}),e.addEventListener(\"touchmove\",function(e){if(e.preventDefault(),2===e.originalEvent.touches.length){const s=e.originalEvent.touches,n=p(s[0].clientX,s[0].clientY,s[1].clientX,s[1].clientY),o=n-i;if(Math.abs(o)>0){const o={pageX:(s[0].clientX+s[1].clientX)/2,pageY:(s[0].clientY+s[1].clientY)/2};t(e,m(e.currentTarget,o),i,n)}}})},onDoubleTap:function(e,t){const i=f(v);let s=null;e.addEventListener(\"touchend\",e=>{if(e.preventDefault(),i.isTriggered()){i.reset();const n={pageX:e.originalEvent.changedTouches[0].clientX,pageY:e.originalEvent.changedTouches[0].clientY},o=p(s.pageX,s.pageY,n.pageX,n.pageY);o<g&&t(e,m(e.currentTarget,n)),s=null}else s={pageX:e.originalEvent.changedTouches[0].clientX,pageY:e.originalEvent.changedTouches[0].clientY},i.trigger()})}};const d=500,g=50,v=250;function p(e,t,i,s){return Math.sqrt((i-e)*(i-e)+(s-t)*(s-t))}function f(e){let t=!1,i=null;return{trigger(){t=!0,s(),i=setTimeout(function(){t=!1,i=null},e)},isTriggered:()=>t,reset(){t=!1,s()}};function s(){null!==i&&(clearTimeout(i),i=null)}}function m(e,t){const i=e.getBoundingClientRect();return{left:t.pageX-i.left,top:t.pageY-i.top}}var w=i(0),b=i.n(w);class y{constructor(e,t){this.page=e,this._viewerCore=t,this._innerElement=this._viewerCore.getSettings().innerElement,this._pageToolsElem=null,this.labelWidth=0}mount(){null===this._pageToolsElem&&(this._buttons=this._initializePageToolButtons(),this._pageToolsElem=s(\"div\",{class:\"diva-page-tools-wrapper\"},s(\"div\",{class:\"diva-page-tools\"},this._buttons)),this._pageLabelsElem=s(\"div\",{class:\"diva-page-labels-wrapper\"},s(\"div\",{class:\"diva-page-labels\"},this._viewerCore.settings.manifest.pages[this.page].l))),this.refresh(),this._innerElement.appendChild(this._pageToolsElem),this._innerElement.appendChild(this._pageLabelsElem)}_initializePageToolButtons(){const e=this._viewerCore.getSettings(),t=this._viewerCore.getPublicInstance(),i=this.page;return this._viewerCore.getPageTools().map(s=>{const n=s.pageToolsIcon.cloneNode(!0);return n.addEventListener(\"click\",n=>{s.handleClick.call(s,n,e,t,i)},!1),n.addEventListener(\"touchend\",n=>{n.preventDefault(),s.handleClick.call(s,n,e,t,i)},!1),n})}unmount(){this._innerElement.removeChild(this._pageToolsElem),this._innerElement.removeChild(this._pageLabelsElem)}refresh(){const e=this._viewerCore.getPageRegion(this.page,{includePadding:!0,incorporateViewport:!0});let t=window.getComputedStyle(this._innerElement,null).getPropertyValue(\"margin-left\");this._pageToolsElem.style.top=`${e.top}px`,this._pageToolsElem.style.left=`${e.left-parseInt(t)}px`,this._pageLabelsElem.style.top=`${e.top}px`,this._pageLabelsElem.style.left=`${e.right-parseInt(t)-this.labelWidth-5}px`}}class _{constructor(e){if(this._viewerCore=e,this._viewerState=e.getInternalState(),this._overlays=[],this._viewerCore.getPageTools().length){const t=e.getSettings().numPages;for(let i=0;i<t;i++){const t=new y(i,e);this._overlays.push(t),this._viewerCore.addPageOverlay(t);let s=document.createElement(\"span\");s.innerHTML=e.settings.manifest.pages[i].l,s.classList.add(\"diva-page-labels\"),s.setAttribute(\"style\",\"display: inline-block;\"),document.body.appendChild(s);let n=s.clientWidth;document.body.removeChild(s),t.labelWidth=n}}}onDoubleClick(e,t){const i=this._viewerCore.getSettings(),s=e.ctrlKey?i.zoomLevel-1:i.zoomLevel+1,n=this._viewerCore.getPagePositionAtViewportOffset(t);this._viewerCore.zoom(s,n)}onPinch(e,t,i,s){const n=this._viewerCore.getInternalState(),o=this._viewerCore.getSettings();let r=Math.log(Math.pow(2,o.zoomLevel)*s/(i*Math.log(2)))/Math.log(2);if(r=Math.max(o.minZoomLevel,r),(r=Math.min(o.maxZoomLevel,r))===o.zoomLevel)return;const a=this._viewerCore.getPagePositionAtViewportOffset(t),l=this._viewerCore.getCurrentLayout().getPageToViewportCenterOffset(a.anchorPage,n.viewport),h=1/Math.pow(2,o.zoomLevel-r);this._viewerCore.reload({zoomLevel:r,goDirectlyTo:a.anchorPage,horizontalOffset:l.x-a.offset.left+a.offset.left*h,verticalOffset:l.y-a.offset.top+a.offset.top*h})}onViewWillLoad(){this._viewerCore.publish(\"DocumentWillLoad\",this._viewerCore.getSettings())}onViewDidLoad(){this._handleZoomLevelChange();const e=this._viewerCore.getSettings().activePageIndex,t=this._viewerCore.getPageName(e);this._viewerCore.publish(\"DocumentDidLoad\",e,t)}onViewDidUpdate(e,t){const i=null!==t?t:function(e,t,i){const s=i.top+i.height/2,n=i.left+i.width/2,o=b()(e,e=>{const i=t.getPageDimensions(e),o=t.getPageOffset(e,{includePadding:!1}),r=o.left+i.height/2,a=o.top+i.width/2,l=Math.max(Math.abs(n-r)-i.width/2,0),h=Math.max(Math.abs(s-a)-i.height/2,0);return-(l*l+h*h)});return null!=o?o:null}(e,this._viewerCore.getCurrentLayout(),this._viewerCore.getViewport());let s=this._viewerState.viewport.intersectionTolerance;this._viewerState.viewport.intersectionTolerance=0;let n=e.filter(e=>this._viewerState.renderer.isPageVisible(e));this._viewerState.viewport.intersectionTolerance=s,null!==i&&this._viewerCore.setCurrentPages(i,n),null!==t&&this._viewerCore.publish(\"ViewerDidJump\",t),this._handleZoomLevelChange()}_handleZoomLevelChange(){const e=this._viewerState,t=e.options.zoomLevel;e.oldZoomLevel!==t&&e.oldZoomLevel>=0&&(e.oldZoomLevel<t?this._viewerCore.publish(\"ViewerDidZoomIn\",t):this._viewerCore.publish(\"ViewerDidZoomOut\",t),this._viewerCore.publish(\"ViewerDidZoom\",t)),e.oldZoomLevel=t}destroy(){this._overlays.forEach(e=>{this._viewerCore.removePageOverlay(e)},this)}}class P{constructor(e){this._viewerCore=e}onDoubleClick(e,t){const i=this._viewerCore.getPagePositionAtViewportOffset(t),s=this._viewerCore.getCurrentLayout(),n=this._viewerCore.getViewport(),o=s.getPageToViewportCenterOffset(i.anchorPage,n);this._viewerCore.reload({inGrid:!1,goDirectlyTo:i.anchorPage,horizontalOffset:o.x+i.offset.left,verticalOffset:o.y+i.offset.top})}onPinch(){this._viewerCore.reload({inGrid:!1})}onViewWillLoad(){}onViewDidLoad(){}onViewDidUpdate(e,t){if(0===e.length)return;let i=this._viewerCore.viewerState.viewport.intersectionTolerance;this._viewerCore.viewerState.viewport.intersectionTolerance=0;let s=e.filter(e=>this._viewerCore.viewerState.renderer.isPageVisible(e));if(this._viewerCore.viewerState.viewport.intersectionTolerance=i,null!==t)return void this._viewerCore.setCurrentPages(t,s);const n=this._viewerCore.getCurrentLayout(),o=[];e.forEach(e=>{const t=n.getPageInfo(e).group;0!==o.length&&t===o[o.length-1]||o.push(t)});const r=this._viewerCore.getViewport();let a;a=1===o.length||o[0].region.top>=r.top?o[0]:o[1].region.bottom<=r.bottom?o[1]:function(e,t){const i=t.top+t.height/2;return b()(e,e=>{const t=e.region.top+e.dimensions.height/2;return-Math.abs(i-t)})}(o,r);const l=this._viewerCore.getSettings().activePageIndex;a.pages.some(e=>e.index===l)||this._viewerCore.setCurrentPages(a.pages[0].index,s)}destroy(){}}class S{constructor(){this._pages={},this._renderedPages=[],this._renderedPageMap={}}addOverlay(e){(this._pages[e.page]||(this._pages[e.page]=[])).push(e),this._renderedPageMap[e.page]&&e.mount()}removeOverlay(e){const t=e.page,i=this._pages[t];if(!i)return;const s=i.indexOf(e);-1!==s&&(this._renderedPageMap[t]&&i[s].unmount(),i.splice(s,1),0===i.length&&delete this._pages[t])}updateOverlays(e){const t=this._renderedPages,i={};e.map(e=>{i[e]=!0,this._renderedPageMap[e]||(this._renderedPageMap[e]=!0,this._invokeOnOverlays(e,e=>{e.mount()}))}),t.map(e=>{i[e]?this._invokeOnOverlays(e,e=>{e.refresh()}):(delete this._renderedPageMap[e],this._invokeOnOverlays(e,e=>{e.unmount()}))}),this._renderedPages=e}_invokeOnOverlays(e,t){const i=this._pages[e];i&&i.map(e=>t(e))}}class C{constructor(e,t){this._rows=e,this._cols=t,this._map=new Array(e).fill(null).map(()=>new Array(t).fill(!1))}isLoaded(e,t){return e>=this._rows||t>=this._cols||this._map[e][t]}set(e,t,i){this._map[e][t]=i}}class L{constructor(e){this._levels=e;const t=this._urlsToTiles={};e.forEach(e=>{e.tiles.forEach(i=>{t[i.url]={zoomLevel:e.zoomLevel,row:i.row,col:i.col}})}),this.clear()}clear(){const e=this._loadedByLevel={};this._levels.forEach(t=>{e[t.zoomLevel]=new C(t.rows,t.cols)})}getTiles(e){const t=[],i=this._levels[0].zoomLevel,s=new C(this._levels[0].rows,this._levels[0].cols);let n;if(null===e)n=0;else{const t=Math.ceil(e);n=function(e,t){const i=e.length;for(let s=0;s<i;s++)if(t(e[s],s))return s;return-1}(this._levels,e=>e.zoomLevel<=t)}this._levels.slice(0,n+1).reverse().concat(this._levels.slice(n+1)).forEach(e=>{const n=this._loadedByLevel[e.zoomLevel];let o=e.tiles.filter(e=>n.isLoaded(e.row,e.col));const r=Math.pow(2,i-e.zoomLevel);o=o.filter(e=>{let t=!1;const i=e.row*r,n=e.col*r;for(let e=0;e<r;e++)for(let o=0;o<r;o++)s.isLoaded(i+e,n+o)||(t=!0,s.set(i+e,n+o,!0));return t}),t.push(o)},this),t.reverse();const o=[];return t.forEach(e=>{o.push.apply(o,e)}),o}updateFromCache(e){this.clear(),this._levels.forEach(t=>{const i=this._loadedByLevel[t.zoomLevel];t.tiles.forEach(t=>{e.has(t.url)&&i.set(t.row,t.col,!0)})},this)}updateWithLoadedUrls(e){e.forEach(e=>{const t=this._urlsToTiles[e];this._loadedByLevel[t.zoomLevel].set(t.row,t.col,!0)},this)}}class O{constructor(e,t){const i=function(e,t){const i=null===t?e.pageLayouts:function(e,t){const i=Math.pow(2,t-e.maxZoomLevel);return e.pageLayouts.map(e=>({dimensions:E(e.dimensions,i),pages:e.pages.map(e=>({index:e.index,groupOffset:{top:Math.floor(e.groupOffset.top*i),left:Math.floor(e.groupOffset.left*i)},dimensions:E(e.dimensions,i)}))}))}(e,t),s=function(e,t){let i,s;const n=e.padding.document;e.verticallyOriented?(i=\"width\",s=n.left+n.right):(i=\"height\",s=n.top+n.bottom);return s+t.reduce((e,t)=>Math.max(t.dimensions[i],e),0)}(e,i);let n=e.verticallyOriented?e.padding.document.top:e.padding.document.left;const o=[],r={top:e.padding.page.top,left:e.padding.page.left};let a,l;i.forEach((t,i)=>{let a,l;e.verticallyOriented?(a=n,l=(s-t.dimensions.width)/2):(a=(s-t.dimensions.height)/2,l=n);const h={top:a,bottom:a+r.top+t.dimensions.height,left:l,right:l+r.left+t.dimensions.width};o.push({index:i,dimensions:t.dimensions,pages:t.pages,region:h,padding:r}),n=e.verticallyOriented?h.bottom:h.right}),e.verticallyOriented?(a=n+r.top,l=s):(a=s,l=n+r.left);return{dimensions:{height:a,width:l},pageGroups:o}}(e,t);this.dimensions=i.dimensions,this.pageGroups=i.pageGroups,this._pageLookup=function(e){const t={};return e.forEach(e=>{e.pages.forEach(i=>{t[i.index]={index:i.index,group:e,dimensions:i.dimensions,groupOffset:i.groupOffset}})}),t}(i.pageGroups)}getPageInfo(e){return this._pageLookup[e]||null}getPageDimensions(e){if(!this._pageLookup||!this._pageLookup[e])return null;const t=x(this._pageLookup[e]);return{height:t.bottom-t.top,width:t.right-t.left}}getPageOffset(e,t){const i=this.getPageRegion(e,t);return i?{top:i.top,left:i.left}:null}getPageRegion(e,t){const i=this._pageLookup[e];if(!i)return null;const s=x(i),n=i.group.padding;return t&&t.includePadding?{top:s.top+n.top,left:s.left+n.left,bottom:s.bottom,right:s.right}:{top:s.top,left:s.left,bottom:s.bottom+n.top,right:s.right}}getPageToViewportCenterOffset(e,t){const i=t.left,s=t.right-t.left,n=this.getPageOffset(e),o=i-n.left+parseInt(s/2,10),r=t.top,a=t.bottom-t.top;return{x:o,y:r-n.top+parseInt(a/2,10)}}}function x(e){const t=e.groupOffset.top+e.group.region.top,i=t+e.dimensions.height,s=e.groupOffset.left+e.group.region.left;return{top:t,bottom:i,left:s,right:s+e.dimensions.width}}function E(e,t){return{height:Math.floor(e.height*t),width:Math.floor(e.width*t)}}const I=i(1)(\"diva:ImageCache\"),T=100;class D{constructor(e){e=e||{maxKeys:T},this.maxKeys=e.maxKeys||T,this._held={},this._urls={},this._lru=[]}get(e){const t=this._urls[e];return t?t.img:null}has(e){return!!this._urls[e]}put(e,t){let i=this._urls[e];i?(i.img=t,this._promote(i)):(i={img:t,url:e},this._urls[e]=i,this._tryEvict(1),this._lru.unshift(i))}_promote(e){const t=this._lru.indexOf(e);this._lru.splice(t,1),this._lru.unshift(e)}_tryEvict(e){const t=this.maxKeys-e;if(this._lru.length<=t)return;let i=this._lru.length-1;for(;;){const e=this._lru[i];if(!this._held[e.url]&&(I(\"Evicting image %s\",e.url),this._lru.splice(i,1),delete this._urls[e.url],this._lru.length<=t))break;if(0===i){I.enabled&&I(\"Cache overfull by %s (all entries are being held)\",this._lru.length-t);break}i--}}acquire(e){this._held[e]=(this._held[e]||0)+1,this._promote(this._urls[e])}release(e){this._held[e]>1?this._held[e]--:delete this._held[e],this._tryEvict(0)}}class M{constructor(e){this._url=e.url,this._callback=e.load,this._errorCallback=e.error,this.timeoutTime=e.timeoutTime||0,this._aborted=this._complete=!1,this.timeout=setTimeout(()=>{this._image=new Image,this._image.onload=this._handleLoad.bind(this),this._image.onerror=this._handleError.bind(this),this._image.src=e.url},this.timeoutTime)}abort(){clearTimeout(this.timeout),this._image&&(this._image.onload=this._image.onerror=null,this._image.src=\"\"),this._aborted=!0}_handleLoad(){this._aborted?console.error(\"ImageRequestHandler invoked on cancelled request for \"+this._url):this._complete?console.error(\"ImageRequestHandler invoked on completed request for \"+this._url):(this._complete=!0,this._callback(this._image))}_handleError(){this._errorCallback(this._image)}}var z={animate:function(e){const t=e.duration,i=e.parameters,s=e.onUpdate,n=e.onEnd,o=V(),r=o+t,a={},l={},h=Object.keys(i);h.forEach(e=>{const t=i[e];a[e]=function(e,t,i){return s=>e+(t-e)*i(s)}(t.from,t.to,t.easing||k)});let c=requestAnimationFrame(function e(){const i=V();const n=Math.min((i-o)/t,1);!function(e){h.forEach(t=>{l[t]=a[t](e)})}(n);s(l);i<r?c=requestAnimationFrame(e):u({interrupted:!1})});return{cancel(){null!==c&&(cancelAnimationFrame(c),u({interrupted:!0}))}};function u(e){c=null,n&&n(e)}},easing:{linear:function(e){return e},cubic:k}};let V;function k(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1}V=\"undefined\"!=typeof performance&&performance.now?()=>performance.now():()=>Date.now();const F=250;class j{constructor(e,t){this._viewport=e.viewport,this._outerElement=e.outerElement,this._documentElement=e.innerElement,this._settings=e.settings,this._hooks=t||{},this._canvas=s(\"canvas\",{class:\"diva-viewer-canvas\"}),this._ctx=this._canvas.getContext(\"2d\"),this.layout=null,this._sourceResolver=null,this._renderedPages=null,this._config=null,this._zoomLevel=null,this._compositeImages=null,this._renderedTiles=null,this._animation=null,this._cache=new D,this._pendingRequests={}}static getCompatibilityErrors(){return\"undefined\"!=typeof HTMLCanvasElement?null:[\"Your browser lacks support for the \",s(\"pre\",\"canvas\"),\" element. Please upgrade your browser.\"]}load(e,t,i){if(this._clearAnimation(),this._hooks.onViewWillLoad&&this._hooks.onViewWillLoad(),this._sourceResolver=i,this._config=e,this._compositeImages={},this._setLayoutToZoomLevel(t.zoomLevel),!this.layout.getPageInfo(t.anchorPage))throw new Error(\"invalid page: \"+t.anchorPage);this._canvas.width===this._viewport.width&&this._canvas.height===this._viewport.height||(this._canvas.width=this._viewport.width,this._canvas.height=this._viewport.height),this.goto(t.anchorPage,t.verticalOffset,t.horizontalOffset),this._canvas.parentNode!==this._outerElement&&this._outerElement.insertBefore(this._canvas,this._outerElement.firstChild),this._hooks.onViewDidLoad&&this._hooks.onViewDidLoad()}_setViewportPosition(e){if(e.zoomLevel!==this._zoomLevel){if(null===this._zoomLevel)throw new TypeError(\"The current view is not zoomable\");if(null===e.zoomLevel)throw new TypeError(\"The current view requires a zoom level\");this._setLayoutToZoomLevel(e.zoomLevel)}this._goto(e.anchorPage,e.verticalOffset,e.horizontalOffset)}_setLayoutToZoomLevel(e){this.layout=new O(this._config,e),this._zoomLevel=e,o(this._documentElement,{style:{height:this.layout.dimensions.height+\"px\",width:this.layout.dimensions.width+\"px\"}}),this._viewport.setInnerDimensions(this.layout.dimensions)}adjust(){this._clearAnimation(),this._render(),this._hooks.onViewDidUpdate&&this._hooks.onViewDidUpdate(this._renderedPages.slice(),null)}_render(){const e=[];this.layout.pageGroups.forEach(t=>{if(!this._viewport.intersectsRegion(t.region))return;const i=t.pages.filter(function(e){return this.isPageVisible(e.index)},this).map(e=>e.index);e.push.apply(e,i)},this),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._paintOutline(e),e.forEach(e=>{if(!this._compositeImages[e]){const t=this.layout.getPageInfo(e),i=this._sourceResolver.getAllZoomLevelsForPage(t),s=new L(i);s.updateFromCache(this._cache),this._compositeImages[e]=s}},this),this._initiateTileRequests(e);const t=R(this._renderedPages||[],e);t.removed.forEach(e=>{delete this._compositeImages[e]},this),this._renderedPages=e,this._paint(),this._hooks.onPageWillLoad&&t.added.forEach(e=>{this._hooks.onPageWillLoad(e)},this)}_paint(){const e=[];this._renderedPages.forEach(t=>{this._compositeImages[t].getTiles(this._zoomLevel).forEach(i=>{const s=A(i,this._zoomLevel);this._isTileVisible(t,s)&&(e.push(i.url),this._drawTile(t,s,this._cache.get(i.url)))})});const t=this._cache,i=R(this._renderedTiles||[],e);i.added.forEach(e=>{t.acquire(e)}),i.removed.forEach(e=>{t.release(e)}),i.removed&&this._renderedPages.forEach(e=>{this._compositeImages[e].updateFromCache(this._cache)},this),this._renderedTiles=e}_paintOutline(e){e.forEach(e=>{let t=this.layout.getPageInfo(e),i=this._getImageOffset(e),s=Math.max(0,(this._viewport.width-this.layout.dimensions.width)/2),n=Math.max(0,(this._viewport.height-this.layout.dimensions.height)/2),o=i.left-this._viewport.left+s,r=i.top-this._viewport.top+n,a=o<0?-o:0,l=r<0?-r:0,h=Math.max(0,o),c=Math.max(0,r),u=t.dimensions.width-a,d=t.dimensions.height-l;this._ctx.strokeStyle=\"#AAA\",this._ctx.strokeRect(h+.5,c+.5,u,d)})}_initiateTileRequests(e){const t={},i=(e,i)=>{const s=this._compositeImages[i];t[e.url]=new M({url:e.url,timeoutTime:F,load:t=>{delete this._pendingRequests[e.url],this._cache.put(e.url,t),s===this._compositeImages[i]?(s.updateWithLoadedUrls([e.url]),this._isTileForSourceVisible(i,e)&&this._paint()):this._isTileForSourceVisible(i,e)&&this._paint()},error:()=>{delete this._pendingRequests[e.url]}})};for(let s=0;s<e.length;s++){const n=e[s],o=this._sourceResolver.getBestZoomLevelForPage(this.layout.getPageInfo(n)).tiles;for(let e=0;e<o.length;e++){const s=o[e];!this._cache.has(s.url)&&this._isTileForSourceVisible(n,s)&&(this._pendingRequests[s.url]?(t[s.url]=this._pendingRequests[s.url],delete this._pendingRequests[s.url]):i(s,n))}}for(const e in this._pendingRequests)this._pendingRequests[e].abort();this._pendingRequests=t}_drawTile(e,t,i){let s=this._getTileToDocumentOffset(e,t),n=Math.max(0,(this._viewport.width-this.layout.dimensions.width)/2),o=Math.max(0,(this._viewport.height-this.layout.dimensions.height)/2),r=s.left-this._viewport.left+n,a=s.top-this._viewport.top+o,l=r<0?-r:0,h=a<0?-a:0,c=Math.max(0,r),u=Math.max(0,a),d=l/t.scaleRatio,g=h/t.scaleRatio,v=Math.min(t.dimensions.width,i.width*t.scaleRatio)-l,p=Math.min(t.dimensions.height,i.height*t.scaleRatio)-h,f=Math.max(1,Math.round(v)),m=Math.max(1,Math.round(p)),w=f/t.scaleRatio,b=m/t.scaleRatio;this._ctx.drawImage(i,d,g,w,b,c,u,f,m)}_isTileForSourceVisible(e,t){return this._isTileVisible(e,A(t,this._zoomLevel))}_isTileVisible(e,t){const i=this._getTileToDocumentOffset(e,t);return this._viewport.intersectsRegion({top:i.top,bottom:i.top+t.dimensions.height,left:i.left,right:i.left+t.dimensions.width})}_getTileToDocumentOffset(e,t){const i=this._getImageOffset(e);return{top:i.top+t.offset.top,left:i.left+t.offset.left}}_getImageOffset(e){return this.layout.getPageOffset(e,{includePadding:!0})}goto(e,t,i){this._clearAnimation(),this._goto(e,t,i),this._hooks.onViewDidUpdate&&this._hooks.onViewDidUpdate(this._renderedPages.slice(),e)}_goto(e,t,i){const s=this.layout.getPageOffset(e),n=s.top+t-Math.round(this._viewport.height/2),o=s.left+i-Math.round(this._viewport.width/2);this._viewport.top=n,this._viewport.left=o,this._render()}transitionViewportPosition(e){this._clearAnimation();const t=e.getPosition,i=this._hooks.onViewDidTransition;this._animation=z.animate({duration:e.duration,parameters:e.parameters,onUpdate:e=>{this._setViewportPosition(t(e)),this._hooks.onZoomLevelWillChange(e.zoomLevel),i&&i()},onEnd:t=>{e.onEnd&&e.onEnd(t),this._hooks.onViewDidUpdate&&!t.interrupted&&this._hooks.onViewDidUpdate(this._renderedPages.slice(),null)}})}_clearAnimation(){this._animation&&(this._animation.cancel(),this._animation=null)}isPageVisible(e){if(!this.layout)return!1;return!!this.layout.getPageInfo(e)&&this._viewport.intersectsRegion(this.layout.getPageRegion(e))}getRenderedPages(){return this._renderedPages.slice()}destroy(){this._clearAnimation(),Object.keys(this._pendingRequests).forEach(e=>{const t=this._pendingRequests[e];delete this._pendingRequests[e],t.abort()},this),this._canvas.parentNode.removeChild(this._canvas)}}function A(e,t){let i;return i=null===t?1:Math.pow(2,t-e.zoomLevel),{sourceZoomLevel:e.zoomLevel,scaleRatio:i,row:e.row,col:e.col,dimensions:{width:e.dimensions.width*i,height:e.dimensions.height*i},offset:{left:e.offset.left*i,top:e.offset.top*i},url:e.url}}function R(e,t){if(e===t)return{added:[],removed:[]};const i=e.filter(e=>-1===t.indexOf(e));return{added:t.filter(t=>-1===e.indexOf(t)),removed:i}}function H(e,t){const i=t.getMaxPageDimensions(e);return{width:Math.floor(i.width),height:Math.floor(i.height)}}function B(e){return function(e){const t=e.manifest,i=[];let s=null,n=[];const o=()=>{for(let e=0,t=n.length;e<t;e++)i.push([n[e]]);n=[]};t.pages.forEach((r,a)=>{const l={index:a,dimensions:H(a,t),paged:!t.paged||r.paged};(e.showNonPagedPages||l.paged)&&(l.paged?0===a||r.facingPages?(i.push([l]),o()):null===s?s=l:(i.push([s,l]),s=null,o()):n.push(l))}),null!==s&&(i.push([s]),o());return i}(e).map(t=>(function(e,t){const i=e.verticallyOriented;if(2===t.length)return function(e,t,i){const s=e.dimensions,n=t.dimensions,o=Math.max(s.height,n.height);let r,a,l;if(i){const e=Math.max(s.width,n.width);r=2*e,a=e-s.width,l=e}else r=s.width+n.width,a=0,l=s.width;return{dimensions:{height:o,width:r},pages:[{index:e.index,dimensions:s,groupOffset:{top:0,left:a}},{index:t.index,dimensions:n,groupOffset:{top:0,left:l}}]}}(t[0],t[1],i);const s=t[0],n=s.dimensions;let o;o=s.paged?0===s.index&&i?n.width:0:i?n.width/2:0;const r=i&&!e.manifest.pages[s.index].facingPages;return{dimensions:{height:n.height,width:r?2*n.width:n.width},pages:[{index:s.index,groupOffset:{top:0,left:o},dimensions:n}]}})(e,t))}function Z(e){const t=e.viewport.width,i=e.manifest,s=e.pagesPerRow,n=e.fixedHeightGrid,o=e.fixedPadding,r=e.showNonPagedPages,a=(t-o*(s+1))/s,l=a,h=n?o+i.minRatio*a:o+i.maxRatio*a,c=[];let u=[];const d={height:h,width:t};return i.pages.forEach((e,t)=>{if(!r&&i.paged&&!e.paged)return;const a=(e=>{const t=e.d[e.d.length-1],i=t.h/t.w;let s,r;return n?(s=(h-o)/i,r=h-o):r=(s=l)*i,{width:Math.round(s),height:Math.round(r)}})(e);let g=Math.floor(u.length*(o+l)+o);n&&(g+=(l-a.width)/2),u.push({index:t,dimensions:a,groupOffset:{top:0,left:g}}),u.length===s&&(c.push({dimensions:d,pages:u}),u=[])}),u.length>0&&c.push({dimensions:d,pages:u}),c}function G(e){if(e.inGrid)return Z(N(e,[\"manifest\",\"viewport\",\"pagesPerRow\",\"fixedHeightGrid\",\"fixedPadding\",\"showNonPagedPages\"]));{const t=N(e,[\"manifest\",\"verticallyOriented\",\"showNonPagedPages\"]);return e.inBookLayout?B(t):function(e){const t=e.manifest,i=[];return t.pages.forEach((s,n)=>{if(!e.showNonPagedPages&&t.paged&&!s.paged)return;const o=H(n,t);i.push({dimensions:o,pages:[{index:n,groupOffset:{top:0,left:0},dimensions:o}]})}),i}(t)}}function N(e,t){const i={};return t.forEach(function(t){i[t]=e[t]}),i}function U(e){const t={};return e.forEach(e=>{!function(e,t){Object.keys(t).forEach(i=>{Object.defineProperty(e,i,{get:()=>t[i],set:()=>{throw new TypeError(\"Cannot set settings.\"+i)}})})}(t,e)}),t}class W{constructor(e){this.whitelistedKeys=e.whitelistedKeys||[],this.additionalProperties=e.additionalProperties||[],this.validations=e.validations}isValid(e,t,i){let s=null;if(this.validations.some((t,i)=>t.key===e&&(s=i,!0)),null===s)return!0;const n={};n[e]=t;const o=Y(i,n,this);return!this._runValidation(s,t,o)}validate(e){this._validateOptions({},e)}getValidatedOptions(e,t){const i=Object.assign({},t);return this._validateOptions(e,i),i}_validateOptions(e,t){const i=Y(e,t,this);this._applyValidations(t,i)}_applyValidations(e,t){this.validations.forEach((i,s)=>{if(!e.hasOwnProperty(i.key))return;const n=e[i.key],o=this._runValidation(s,n,t);o&&(o.warningSuppressed||function(e,t,i){console.warn(\"Invalid value for \"+e+\": \"+t+\". Using \"+i+\" instead.\")}(i.key,n,o.value),e[i.key]=o.value)},this)}_runValidation(e,t,i){const s=this.validations[e];i.index=e;let n=!1;const o={suppressWarning:()=>{n=!0}},r=s.validate(t,i.proxy,o);return void 0===r||r===t?null:{value:r,warningSuppressed:n}}}function Y(e,t,i){const s={proxy:{},index:null},n=function(e,t,i){if(i in t)return t[i];return e[i]}.bind(null,e,t),o={};return i.whitelistedKeys.forEach(e=>{o[e]={get:n.bind(null,e)}}),i.additionalProperties.forEach(e=>{o[e.key]={get:e.get}}),i.validations.forEach((e,t)=>{o[e.key]={get:()=>{if(t<s.index)return n(e.key);const o=i.validations[s.index].key;throw new TypeError(\"Cannot access setting \"+e.key+\" while validating \"+o)}}}),Object.defineProperties(s.proxy,o),s}class q{constructor(e,t){t=t||{},this.intersectionTolerance=t.intersectionTolerance||0,this.outer=e,this._top=this._left=this._width=this._height=this._innerDimensions=null,this.invalidate()}intersectsRegion(e){return this.hasHorizontalOverlap(e)&&this.hasVerticalOverlap(e)}hasVerticalOverlap(e){const t=this.top-this.intersectionTolerance,i=this.bottom+this.intersectionTolerance;return $(e.top,t,i)||$(e.bottom,t,i)||e.top<=t&&e.bottom>=i}hasHorizontalOverlap(e){const t=this.left-this.intersectionTolerance,i=this.right+this.intersectionTolerance;return $(e.left,t,i)||$(e.right,t,i)||e.left<=t&&e.right>=i}invalidate(){this._width=this.outer.clientWidth,this._height=this.outer.clientHeight,this._top=this.outer.scrollTop,this._left=this.outer.scrollLeft}setInnerDimensions(e){this._innerDimensions=e,e&&(this._top=J(this._top,0,e.height-this._height),this._left=J(this._left,0,e.width-this._width))}}function X(e,t){const i=\"_\"+e,s=\"scroll\"+e.charAt(0).toUpperCase()+e.slice(1);return{get:function(){return this[i]},set:function(e){let n;if(this._innerDimensions){n=J(e,0,this._innerDimensions[t]-this[t])}else n=Q(e,0);this[i]=this.outer[s]=n}}}function K(e){return{get:function(){return this[\"_\"+e]}}}function $(e,t,i){return e>=t&&e<=i}function J(e,t,i){return Q(function(e,t){return Math.min(e,t)}(e,i),t)}function Q(e,t){return Math.max(e,t)}Object.defineProperties(q.prototype,{top:X(\"top\",\"height\"),left:X(\"left\",\"width\"),width:K(\"width\"),height:K(\"height\"),bottom:{get:function(){return this._top+this._height}},right:{get:function(){return this._left+this._width}}});const ee=i(1)(\"diva:ViewerCore\");function te(){return te.counter++}te.counter=1;const ie=[{key:\"goDirectlyTo\",validate:(e,t)=>{if(e<0||e>=t.manifest.pages.length)return 0}},{key:\"minPagesPerRow\",validate:e=>Math.max(2,e)},{key:\"maxPagesPerRow\",validate:(e,t)=>Math.max(e,t.minPagesPerRow)},{key:\"pagesPerRow\",validate:(e,t)=>{if(e<t.minPagesPerRow||e>t.maxPagesPerRow)return t.maxPagesPerRow}},{key:\"maxZoomLevel\",validate:(e,t,i)=>{if(i.suppressWarning(),e<0||e>t.manifest.maxZoom)return t.manifest.maxZoom}},{key:\"minZoomLevel\",validate:(e,t,i)=>e>t.manifest.maxZoom?(i.suppressWarning(),0):e<0||e>t.maxZoomLevel?0:void 0},{key:\"zoomLevel\",validate:(e,t,i)=>e>t.manifest.maxZoom?(i.suppressWarning(),0):e<t.minZoomLevel||e>t.maxZoomLevel?t.minZoomLevel:void 0}];class se{constructor(e,t,i){this.parentObject=e,this.publicInstance=i,this.viewerState={currentPageIndices:[0],activePageIndex:0,horizontalOffset:0,horizontalPadding:0,ID:null,initialKeyScroll:!1,initialSpaceScroll:!1,innerElement:null,innerObject:{},isActiveDiva:!0,isScrollable:!0,isZooming:!1,loaded:!1,manifest:null,mobileWebkit:!1,numPages:0,oldZoomLevel:-1,options:t,outerElement:null,outerObject:{},pageOverlays:new S,pageTools:[],parentObject:this.parentObject,pendingManifestRequest:null,pluginInstances:[],renderer:null,resizeTimer:-1,scrollbarWidth:0,selector:\"\",throbberTimeoutID:-1,toolbar:null,verticalOffset:0,verticalPadding:0,viewHandler:null,viewport:null,viewportElement:null,viewportObject:null,zoomDuration:400},this.settings=U([t,this.viewerState]);const n=te();this.viewerState.ID=\"diva-\"+n+\"-\",this.viewerState.selector=this.settings.ID,Object.defineProperties(this.settings,{panelHeight:{get:()=>this.viewerState.viewport.height},panelWidth:{get:()=>this.viewerState.viewport.width}}),this.optionsValidator=new W({additionalProperties:[{key:\"manifest\",get:()=>this.viewerState.manifest}],validations:ie}),this.viewerState.scrollbarWidth=function(){let e=document.createElement(\"p\");e.style.width=\"100%\",e.style.height=\"200px\";let t=document.createElement(\"div\");t.style.position=\"absolute\",t.style.top=\"0px\",t.style.left=\"0px\",t.style.visibility=\"hidden\",t.style.width=\"200px\",t.style.height=\"150px\",t.style.overflow=\"hidden\",t.appendChild(e),document.body.appendChild(t);let i=e.offsetWidth;t.style.overflow=\"scroll\";let s=e.offsetWidth;return i===s&&(s=t.clientWidth),document.body.removeChild(t),i-s}(),this.viewerState.mobileWebkit=void 0!==window.orientation,null===t.hashParamSuffix&&(t.hashParamSuffix=1===n?\"\":n+\"\");const o=s(\"div\",this.elemAttrs(\"inner\",{class:\"diva-inner\"})),r=s(\"div\",this.elemAttrs(\"viewport\"),o),a=s(\"div\",this.elemAttrs(\"outer\"),r,s(\"div\",this.elemAttrs(\"throbber\"),[s(\"div\",{class:\"cube cube1\"}),s(\"div\",{class:\"cube cube2\"}),s(\"div\",{class:\"cube cube3\"}),s(\"div\",{class:\"cube cube4\"}),s(\"div\",{class:\"cube cube5\"}),s(\"div\",{class:\"cube cube6\"}),s(\"div\",{class:\"cube cube7\"}),s(\"div\",{class:\"cube cube8\"}),s(\"div\",{class:\"cube cube9\"})]));this.viewerState.innerElement=o,this.viewerState.viewportElement=r,this.viewerState.outerElement=a,this.viewerState.innerObject=o,this.viewerState.viewportObject=r,this.viewerState.outerObject=a,this.settings.parentObject.append(a),this.viewerState.viewport=new q(this.viewerState.viewportElement,{intersectionTolerance:this.settings.viewportMargin}),this.boundScrollFunction=this.scrollFunction.bind(this),this.boundEscapeListener=this.escapeListener.bind(this),this.initPlugins(),this.handleEvents(),this.showThrobber()}isValidOption(e,t){return this.optionsValidator.isValid(e,t,this.viewerState.options)}elemAttrs(e,t){const i={id:this.settings.ID+e,class:\"diva-\"+e};return t?Object.assign(i,t):i}getPageData(e,t){return this.settings.manifest.pages[e].d[this.settings.zoomLevel][t]}clearViewer(){this.viewerState.viewport.top=0,clearTimeout(this.viewerState.resizeTimer)}hasChangedOption(e,t){return t in e&&e[t]!==this.settings[t]}escapeListener(e){27===e.keyCode&&this.publicInstance.leaveFullscreenMode()}reloadViewer(e){const t=[];if(e=this.optionsValidator.getValidatedOptions(this.settings,e),this.hasChangedOption(e,\"zoomLevel\")&&(this.viewerState.oldZoomLevel=this.settings.zoomLevel,this.viewerState.options.zoomLevel=e.zoomLevel,t.push([\"ZoomLevelDidChange\",e.zoomLevel])),this.hasChangedOption(e,\"pagesPerRow\")&&(this.viewerState.options.pagesPerRow=e.pagesPerRow,t.push([\"GridRowNumberDidChange\",e.pagesPerRow])),this.hasChangedOption(e,\"verticallyOriented\")&&(this.viewerState.options.verticallyOriented=e.verticallyOriented),this.hasChangedOption(e,\"showNonPagedPages\")&&(this.viewerState.options.showNonPagedPages=e.showNonPagedPages),\"goDirectlyTo\"in e?(this.viewerState.options.goDirectlyTo=e.goDirectlyTo,\"verticalOffset\"in e&&(this.viewerState.verticalOffset=e.verticalOffset),\"horizontalOffset\"in e&&(this.viewerState.horizontalOffset=e.horizontalOffset)):this.viewerState.options.goDirectlyTo=this.settings.activePageIndex,(this.hasChangedOption(e,\"inGrid\")||this.hasChangedOption(e,\"inBookLayout\"))&&(\"inGrid\"in e&&(this.viewerState.options.inGrid=e.inGrid),\"inBookLayout\"in e&&(this.viewerState.options.inBookLayout=e.inBookLayout),t.push([\"ViewDidSwitch\",this.settings.inGrid])),this.hasChangedOption(e,\"inFullscreen\")&&(this.viewerState.options.inFullscreen=e.inFullscreen,this.prepareModeChange(e),t.push([\"ModeDidSwitch\",this.settings.inFullscreen])),this.clearViewer(),this.updateViewHandlerAndRendering(),this.viewerState.renderer){const e={pageLayouts:G(this.settings),padding:this.getPadding(),maxZoomLevel:this.settings.inGrid?null:this.viewerState.manifest.maxZoom,verticallyOriented:this.settings.verticallyOriented||this.settings.inGrid},t={zoomLevel:this.settings.inGrid?null:this.settings.zoomLevel,anchorPage:this.settings.goDirectlyTo,verticalOffset:this.viewerState.verticalOffset,horizontalOffset:this.viewerState.horizontalOffset},i=this.getCurrentSourceProvider();if(ee.enabled){const t=Object.keys(e).filter(function(e){return\"pageLayouts\"!==e&&\"padding\"!==e}).map(function(t){const i=e[t];return t+\": \"+JSON.stringify(i)}).join(\", \");ee(\"reload with %s\",t)}this.viewerState.renderer.load(e,t,i)}return t.forEach(e=>{this.publish.apply(this,e)}),!0}prepareModeChange(e){const t=e.inFullscreen?\"add\":\"remove\";this.viewerState.outerObject.classList[t](\"diva-fullscreen\"),document.body.classList[t](\"diva-hide-scrollbar\"),this.settings.parentObject.classList[t](\"diva-full-width\");const i=this.settings.panelHeight,s=this.settings.panelWidth;if(this.viewerState.viewport.invalidate(),!(this.viewerState.loaded||this.settings.inGrid||\"verticalOffset\"in e)){const e=this.settings.panelHeight,t=this.settings.panelWidth;this.viewerState.verticalOffset+=(i-e)/2,this.viewerState.horizontalOffset+=(s-t)/2}e.inFullscreen?document.addEventListener(\"keyup\",this.boundEscapeListener):document.removeEventListener(\"keyup\",this.boundEscapeListener)}updateViewHandlerAndRendering(){const e=this.settings.inGrid?P:_;!this.viewerState.viewHandler||this.viewerState.viewHandler instanceof e||(this.viewerState.viewHandler.destroy(),this.viewerState.viewHandler=null),this.viewerState.viewHandler||(this.viewerState.viewHandler=new e(this)),this.viewerState.renderer||this.initializeRenderer()}initializeRenderer(){const e=j.getCompatibilityErrors();if(e)this.showError(e);else{const e={viewport:this.viewerState.viewport,outerElement:this.viewerState.outerElement,innerElement:this.viewerState.innerElement,settings:this.settings},t={onViewWillLoad:()=>{this.viewerState.viewHandler.onViewWillLoad()},onViewDidLoad:()=>{this.updatePageOverlays(),this.viewerState.viewHandler.onViewDidLoad()},onViewDidUpdate:(e,t)=>{this.updatePageOverlays(),this.viewerState.viewHandler.onViewDidUpdate(e,t)},onViewDidTransition:()=>{this.updatePageOverlays()},onPageWillLoad:e=>{this.publish(\"PageWillLoad\",e)},onZoomLevelWillChange:e=>{this.publish(\"ZoomLevelWillChange\",e)}};this.viewerState.renderer=new j(e,t)}}getCurrentSourceProvider(){if(this.settings.inGrid){const e={getAllZoomLevelsForPage:t=>[e.getBestZoomLevelForPage(t)],getBestZoomLevelForPage:e=>{return{zoomLevel:1,rows:1,cols:1,tiles:[{url:this.settings.manifest.getPageImageURL(e.index,{width:e.dimensions.width}),zoomLevel:1,row:0,col:0,dimensions:e.dimensions,offset:{top:0,left:0}}]}}};return e}const e={width:this.settings.tileWidth,height:this.settings.tileHeight};return{getBestZoomLevelForPage:t=>this.settings.manifest.getPageImageTiles(t.index,Math.ceil(this.settings.zoomLevel),e),getAllZoomLevelsForPage:t=>{const i=[],s=this.viewerState.manifest.maxZoom;for(let n=0;n<=s;n++)i.push(this.settings.manifest.getPageImageTiles(t.index,n,e));return i.reverse(),i}}}getPadding(){let e,t,i,s;return this.settings.inGrid?(i=this.settings.fixedPadding,e=t=s=0):(e=this.settings.verticallyOriented?this.viewerState.verticalPadding:0,t=this.settings.verticallyOriented?0:this.viewerState.horizontalPadding,i=this.settings.verticallyOriented?0:this.viewerState.verticalPadding,s=this.settings.verticallyOriented?this.viewerState.horizontalPadding:0),{document:{top:i,bottom:i,left:s,right:s},page:{top:e,bottom:0,left:t,right:0}}}updatePageOverlays(){this.viewerState.pageOverlays.updateOverlays(this.viewerState.renderer.getRenderedPages())}handleZoom(e,t){if(!this.isValidOption(\"zoomLevel\",e))return!1;if(this.viewerState.viewportObject.removeEventListener(\"scroll\",this.boundScrollFunction),!t){const e=this.viewerState.viewport,i=this.viewerState.renderer.layout.getPageRegion(this.settings.activePageIndex);t={anchorPage:this.settings.activePageIndex,offset:{left:e.width/2-(i.left-e.left),top:e.height/2-(i.top-e.top)}}}const i=this.viewerState.renderer.layout.getPageRegion(t.anchorPage),s=i.left+t.offset.left-(this.settings.viewport.left+this.settings.viewport.width/2),n=i.top+t.offset.top-(this.settings.viewport.top+this.settings.viewport.height/2),o=(e,i)=>{const o=Math.pow(2,e-i),r=t.offset.left*o-s,a=t.offset.top*o-n;return{zoomLevel:e,anchorPage:t.anchorPage,verticalOffset:a,horizontalOffset:r}};this.viewerState.options.zoomLevel=e;let r=this.viewerState.oldZoomLevel;this.viewerState.oldZoomLevel=this.settings.zoomLevel;const a=o(e,r);this.viewerState.options.goDirectlyTo=a.anchorPage,this.viewerState.verticalOffset=a.verticalOffset,this.viewerState.horizontalOffset=a.horizontalOffset,this.viewerState.renderer.transitionViewportPosition({duration:this.settings.zoomDuration,parameters:{zoomLevel:{from:r,to:e}},getPosition:e=>o(e.zoomLevel,r),onEnd:t=>{this.viewerState.viewportObject.addEventListener(\"scroll\",this.boundScrollFunction),t.interrupted&&(this.viewerState.oldZoomLevel=e)}});let l=document.getElementById(this.settings.selector+\"zoom-in-button\"),h=document.getElementById(this.settings.selector+\"zoom-out-button\");return l.disabled=!0,h.disabled=!0,setTimeout(()=>{l.disabled=!1,h.disabled=!1},this.settings.zoomDuration),this.publish(\"ZoomLevelDidChange\",e),!0}getYOffset(e,t){let i=void 0===e?this.settings.activePageIndex:e;return\"center\"===t||\"centre\"===t?parseInt(this.getPageData(i,\"h\")/2,10):\"bottom\"===t?parseInt(this.getPageData(i,\"h\")-this.settings.panelHeight/2,10):parseInt(this.settings.panelHeight/2,10)}getXOffset(e,t){let i=void 0===e?this.settings.activePageIndex:e;return\"left\"===t?parseInt(this.settings.panelWidth/2,10):\"right\"===t?parseInt(this.getPageData(i,\"w\")-this.settings.panelWidth/2,10):parseInt(this.getPageData(i,\"w\")/2,10)}updatePanelSize(){return this.viewerState.viewport.invalidate(),this.viewerState.renderer&&(this.updateOffsets(),this.viewerState.renderer.goto(this.settings.activePageIndex,this.viewerState.verticalOffset,this.viewerState.horizontalOffset)),!0}updateOffsets(){const e=this.viewerState.renderer.layout.getPageToViewportCenterOffset(this.settings.activePageIndex,this.viewerState.viewport);e&&(this.viewerState.horizontalOffset=e.x,this.viewerState.verticalOffset=e.y)}bindMouseEvents(){this.viewerState.viewportObject.classList.add(\"dragscroll\"),u.onDoubleClick(this.viewerState.viewportObject,(e,t)=>{ee(\"Double click at %s, %s\",t.left,t.top),this.viewerState.viewHandler.onDoubleClick(e,t)})}onResize(){this.updatePanelSize(),clearTimeout(this.viewerState.resizeTimer),this.viewerState.resizeTimer=setTimeout(()=>{const e=this.viewerState.renderer.layout.getPageToViewportCenterOffset(this.settings.activePageIndex,this.viewerState.viewport);e?this.reloadViewer({goDirectlyTo:this.settings.activePageIndex,verticalOffset:e.y,horizontalOffset:e.x}):this.reloadViewer({goDirectlyTo:this.settings.activePageIndex})},200)}bindTouchEvents(){this.settings.blockMobileMove&&document.body.addEventListener(\"touchmove\",e=>{return e.originalEvent.preventDefault(),!1}),u.onPinch(this.viewerState.viewportObject,function(e,t,i,s){ee(\"Pinch %s at %s, %s\",s-i,t.left,t.top),this.viewerState.viewHandler.onPinch(e,t,i,s)}),u.onDoubleTap(this.viewerState.viewportObject,function(e,t){ee(\"Double tap at %s, %s\",t.left,t.top),this.viewerState.viewHandler.onDoubleClick(e,t)})}scrollFunction(){const e=this.viewerState.viewport.top,t=this.viewerState.viewport.left;let i;this.viewerState.viewport.invalidate();const s=this.viewerState.viewport.top,n=this.viewerState.viewport.left;i=this.settings.verticallyOriented||this.settings.inGrid?s-e:n-t,this.viewerState.renderer.adjust();const o=this.settings.verticallyOriented||this.settings.inGrid?s:n;this.publish(\"ViewerDidScroll\",o),i>0?this.publish(\"ViewerDidScrollDown\",o):i<0&&this.publish(\"ViewerDidScrollUp\",o),this.updateOffsets()}handleEvents(){this.viewerState.innerObject.addEventListener(\"mousedown\",()=>{this.viewerState.innerObject.classList.add(\"diva-grabbing\")}),this.viewerState.innerObject.addEventListener(\"mouseup\",()=>{this.viewerState.innerObject.classList.remove(\"diva-grabbing\")}),this.bindMouseEvents(),this.viewerState.viewportObject.addEventListener(\"scroll\",this.boundScrollFunction);document.addEventListener(\"keydown.diva\",e=>{if(!this.viewerState.isActiveDiva)return!0;if(this.settings.enableSpaceScroll&&!e.shiftKey&&32===e.keyCode||this.settings.enableKeyScroll&&34===e.keyCode)return this.viewerState.viewport.top+=this.settings.panelHeight,!1;if(this.settings.enableSpaceScroll||32!==e.keyCode||e.preventDefault(),this.settings.enableKeyScroll){if(e.shiftKey||e.ctrlKey||e.metaKey)return!0;switch(e.keyCode){case 33:return this.viewerState.viewport.top-=this.settings.panelHeight,!1;case 38:return this.viewerState.viewport.top-=this.settings.arrowScrollAmount,!1;case 40:return this.viewerState.viewport.top+=this.settings.arrowScrollAmount,!1;case 37:return this.viewerState.viewport.left-=this.settings.arrowScrollAmount,!1;case 39:return this.viewerState.viewport.left+=this.settings.arrowScrollAmount,!1;case 36:return this.viewerState.viewport.top=0,!1;case 35:return this.settings.verticallyOriented?this.viewerState.viewport.top=1/0:this.viewerState.viewport.left=1/0,!1;default:return!0}}return!0}),c.Events.subscribe(\"ViewerDidTerminate\",function(){document.removeEventListener(\"keydown.diva\")},this.settings.ID),window.addEventListener(\"resize\",this.onResize.bind(this),!1),c.Events.subscribe(\"ViewerDidTerminate\",function(){window.removeEventListener(\"resize\",this.onResize,!1)},this.settings.ID),\"onorientationchange\"in window&&(window.addEventListener(\"orientationchange\",this.onResize,!1),c.Events.subscribe(\"ViewerDidTerminate\",function(){window.removeEventListener(\"orientationchange\",this.onResize,!1)},this.settings.ID)),c.Events.subscribe(\"PanelSizeDidChange\",this.updatePanelSize,this.settings.ID),c.Events.subscribe(\"ViewerDidTerminate\",()=>{this.viewerState.renderer&&this.viewerState.renderer.destroy(),clearTimeout(this.viewerState.resizeTimer)},this.settings.ID)}initPlugins(){if(!this.settings.hasOwnProperty(\"plugins\"))return null;this.viewerState.pluginInstances=this.settings.plugins.map(e=>{const t=new e(this);return t.isPageTool&&this.viewerState.pageTools.push(t),t})}showThrobber(){this.hideThrobber(),this.viewerState.throbberTimeoutID=setTimeout(()=>{let e=document.getElementById(this.settings.selector+\"throbber\");e&&(e.style.display=\"block\")},this.settings.throbberTimeout)}hideThrobber(){clearTimeout(this.viewerState.throbberTimeoutID);let e=document.getElementById(this.settings.selector+\"throbber\");e&&(e.style.display=\"none\")}showError(e){const t=s(\"div\",this.elemAttrs(\"error\"),[s(\"button\",this.elemAttrs(\"error-close\",{\"aria-label\":\"Close dialog\"})),s(\"p\",s(\"strong\",\"Error\")),s(\"div\",e)]);this.viewerState.outerObject.appendChild(t),document.querySelector(\"#\"+this.settings.selector+\"error-close\").addEventListener(\"click\",()=>{t.parentNode.removeChild(t)})}setManifest(e,t){if(this.viewerState.manifest=e,this.hideThrobber(),this.viewerState.numPages=this.settings.manifest.pages.length,this.optionsValidator.validate(this.viewerState.options),this.publish(\"NumberOfPagesDidChange\",this.settings.numPages),this.settings.adaptivePadding>0){const e=Math.floor((this.settings.minZoomLevel+this.settings.maxZoomLevel)/2);this.viewerState.horizontalPadding=parseInt(this.settings.manifest.getAverageWidth(e)*this.settings.adaptivePadding,10),this.viewerState.verticalPadding=parseInt(this.settings.manifest.getAverageHeight(e)*this.settings.adaptivePadding,10)}else this.viewerState.horizontalPadding=this.settings.fixedPadding,this.viewerState.verticalPadding=this.settings.fixedPadding;let i,n;this.viewerState.pageTools.length&&(this.viewerState.verticalPadding=Math.max(40,this.viewerState.verticalPadding)),this.settings.manifest.paged&&(this.viewerState.options.inBookLayout=!0),this.publish(\"ObjectDidLoad\",this.settings),this.updatePanelSize();let o=!1,r=!1;if(null==t.goDirectlyTo?(t.goDirectlyTo=this.settings.goDirectlyTo,i=n=!0):(i=null==t.horizontalOffset||isNaN(t.horizontalOffset),n=null==t.verticalOffset||isNaN(t.verticalOffset)),i&&(0===t.goDirectlyTo&&this.settings.inBookLayout&&this.settings.verticallyOriented?t.horizontalOffset=this.viewerState.horizontalPadding:(r=!0,t.horizontalOffset=this.getXOffset(t.goDirectlyTo,\"center\"))),n&&(o=!0,t.verticalOffset=this.getYOffset(t.goDirectlyTo,\"top\")),this.reloadViewer(t),this.updatePanelSize(),this.settings.enableAutoTitle){let e=document.getElementById(this.settings.selector+\"title\");e?e.innerHTML=this.settings.manifest.itemTitle:this.settings.parentObject.insertBefore(s(\"div\",this.elemAttrs(\"title\"),[this.settings.manifest.itemTitle]),this.settings.parentObject.firstChild)}this.settings.verticallyOriented?this.viewerState.innerElement.style.minWidth=this.settings.panelWidth+\"px\":this.viewerState.innerElement.style.minHeight=this.settings.panelHeight+\"px\",(o||r)&&(o&&(this.viewerState.verticalOffset=this.getYOffset(this.settings.activePageIndex,\"top\")),r&&(this.viewerState.horizontalOffset=this.getXOffset(this.settings.activePageIndex,\"center\")),this.viewerState.renderer.goto(this.settings.activePageIndex,this.viewerState.verticalOffset,this.viewerState.horizontalOffset)),this.viewerState.loaded=!0,this.publish(\"ViewerDidLoad\",this.settings)}publish(e){const t=Array.prototype.slice.call(arguments,1);c.Events.publish(e,t,this.publicInstance)}getSettings(){return this.settings}getInternalState(){return this.viewerState}getPublicInstance(){return this.publicInstance}getPageTools(){return this.viewerState.pageTools}getCurrentLayout(){return this.viewerState.renderer?this.viewerState.renderer.layout:null}getViewport(){const e=this.viewerState.viewport;return{top:e.top,left:e.left,bottom:e.bottom,right:e.right,width:e.width,height:e.height}}addPageOverlay(e){this.viewerState.pageOverlays.addOverlay(e)}removePageOverlay(e){this.viewerState.pageOverlays.removeOverlay(e)}getPageRegion(e,t){const i=this.viewerState.renderer.layout,s=i.getPageRegion(e,t);if(t&&t.incorporateViewport){const e=this.settings.verticallyOriented?\"width\":\"height\";if(this.viewerState.viewport[e]>i.dimensions[e]){const t=(this.viewerState.viewport[e]-i.dimensions[e])/2;return this.settings.verticallyOriented?{top:s.top,bottom:s.bottom,left:s.left+t,right:s.right+t}:{top:s.top+t,bottom:s.bottom+t,left:s.left,right:s.right}}}return s}getPagePositionAtViewportOffset(e){const t=e.left+this.viewerState.viewport.left,i=e.top+this.viewerState.viewport.top,s=this.viewerState.renderer.getRenderedPages(),n=s.length;for(let e=0;e<n;e++){const n=s[e],o=this.viewerState.renderer.layout.getPageRegion(n);if(o.left<=t&&o.right>=t&&o.top<=i&&o.bottom>=i)return{anchorPage:n,offset:{left:t-o.left,top:i-o.top}}}const o=this.viewerState.renderer.layout.getPageRegion(this.settings.activePageIndex);return{anchorPage:this.settings.activePageIndex,offset:{left:t-o.left,top:i-o.top}}}setCurrentPages(e,t){(function(e,t){if(e.length!==t.length)return!1;for(let i=0,s=e.length;i<s;i++)if(e[i]!==t[i])return!1;return!0})(this.viewerState.currentPageIndices,t)||(this.viewerState.currentPageIndices=t,this.viewerState.activePageIndex=e,this.publish(\"VisiblePageDidChange\",t),this.viewerState.manifest.pages[e].otherImages.length>0&&this.publish(\"VisiblePageHasAlternateViews\",e))}getPageName(e){return this.viewerState.manifest.pages[e].f}reload(e){this.reloadViewer(e)}zoom(e,t){return this.handleZoom(e,t)}enableScrollable(){this.viewerState.isScrollable||(this.bindMouseEvents(),this.enableDragScrollable(),this.viewerState.options.enableKeyScroll=this.viewerState.initialKeyScroll,this.viewerState.options.enableSpaceScroll=this.viewerState.initialSpaceScroll,this.viewerState.viewportElement.style.overflow=\"auto\",this.viewerState.isScrollable=!0)}enableDragScrollable(){this.viewerState.viewportObject.hasAttribute(\"nochilddrag\")&&this.viewerState.viewportObject.removeAttribute(\"nochilddrag\")}disableScrollable(){this.viewerState.isScrollable&&(this.disableDragScrollable(),this.viewerState.outerObject.dblclick=null,this.viewerState.outerObject.contextmenu=null,this.viewerState.viewportElement.style.overflow=\"hidden\",this.viewerState.initialKeyScroll=this.settings.enableKeyScroll,this.viewerState.initialSpaceScroll=this.settings.enableSpaceScroll,this.viewerState.options.enableKeyScroll=!1,this.viewerState.options.enableSpaceScroll=!1,this.viewerState.isScrollable=!1)}disableDragScrollable(){this.viewerState.viewportObject.hasAttribute(\"nochilddrag\")||this.viewerState.viewportObject.setAttribute(\"nochilddrag\",\"\")}clear(){this.clearViewer()}setPendingManifestRequest(e){this.viewerState.pendingManifestRequest=e}destroy(){this.publish(\"ViewerWillTerminate\",this.settings),this.settings.pendingManifestRequest&&this.settings.pendingManifestRequest.abort(),document.body.removeClass(\"diva-hide-scrollbar\"),this.settings.parentObject.parent().empty().removeData(\"diva\"),this.settings.parentObject.parent().removeAttr(\"style\").removeAttr(\"class\"),this.publish(\"ViewerDidTerminate\",this.settings),c.Events.unsubscribeAll(this.settings.ID)}}const ne=(e,t)=>{const i=Math.max(e,t);return i<128?0:Math.ceil(Math.log((i+1)/257)/Math.log(2))},oe=(e,t)=>e/Math.pow(2,t),re=(e,t)=>e.map(e=>{const i=e.width,s=e.height,n=he(e),o=\"/\"!==n.url.slice(-1)?n.url+\"/\":n.url,r=new Array(t+1);for(let e=0;e<t+1;e++)r[e]={h:Math.floor(oe(s,t-e)),w:Math.floor(oe(i,t-e))};return{f:n.url,url:o,il:e.label||\"\",d:r}}),ae=e=>\"http://iiif.io/api/presentation/2/context.json\"===e?2:Array.isArray(e)&&e.includes(\"http://iiif.io/api/presentation/2/context.json\")?2:Array.isArray(e)&&e.includes(\"http://iiif.io/api/presentation/3/context.json\")?3:2;function le(e){let t=e[\"@context\"];if(!t)return console.error(\"Invalid IIIF Manifest; No @context found.\"),null;const i=ae(t),s=e.sequences?e.sequences[0]:null,n=s?s.canvases:e.items,o=n.length,r=new Array(n.length);let a,l,h,c,u,d,g,v,p,f,m,w,b,y,_,P,S,C=[],L=100,O=0,x=100;for(let e=0;e<o;e++){const t=n[e],i=t.width,s=t.height,o=ne(i,s),r=s/i;O=Math.max(r,O),x=Math.min(r,x),L=Math.min(L,o)}const E=new Array(L+1).fill(0),I=new Array(L+1).fill(0),T=new Array(L+1).fill(0),D=new Array(L+1).fill(0);for(let e=0;e<o;e++){if(w=(a=n[e])[\"@id\"]||a.id,b=a.label,C=[],\"oa:Choice\"===(l=a.images?a.images[0].resource:a.items[0].items[0].body)[\"@type\"]||\"Choice\"===l.type?(h=l.default||l.items[0],c=l.item||l.items.slice(1),C=re(c,L)):h=l,p=a.width||h.width,f=a.height||h.height,p<=0||f<=0){console.warn(\"Invalid width or height for canvas \"+b+\". Skipping\");continue}m=ne(p,f),y=h.label||null,d=\"/\"!==(g=he(h)).url.slice(-1)?g.url+\"/\":g.url,v=\"http://iiif.io/api/image/2/context.json\"===(u=h.service[\"@context\"]||h.service.type)||\"ImageService2\"===u?2:\"http://library.stanford.edu/iiif/image-api/1.1/context.json\"===u?1.1:1,_=new Array(L+1);for(let e=0;e<L+1;e++)P=Math.floor(oe(p,L-e)),S=Math.floor(oe(f,L-e)),_[e]={h:S,w:P},E[e]+=P,I[e]+=S,T[e]=Math.max(P,T[e]),D[e]=Math.max(S,D[e]);let t=\"non-paged\"!==a.viewingHint||!!a.behavior&&\"non-paged\"!==a.behavior[0],i=\"facing-pages\"===a.viewingHint||!!a.behavior&&\"facing-pages\"===a.behavior[0];r[e]={d:_,m:m,l:b,il:y,f:g.url,url:d,api:v,paged:t,facingPages:i,canvas:w,otherImages:C,xoffset:g.x||null,yoffset:g.y||null}}const M=new Array(L+1),z=new Array(L+1);for(let e=0;e<L+1;e++)M[e]=E[e]/o,z[e]=I[e]/o;const V={a_wid:M,a_hei:z,max_w:T,max_h:D,max_ratio:O,min_ratio:x,t_hei:I,t_wid:E};return{version:i,item_title:function(e){let t,i=e.label,s=\"object\"==typeof i?i[Object.keys(i)[0]][0]:i,n=e.value;return t=Array.isArray(n)?n.map(e=>e[Object.keys(e)[0]]):\"object\"==typeof n?n[Object.keys(n)[0]]:n,Array.isArray(t)&&(t=t.join(\", \")),{label:s,value:t}}(e).label,metadata:e.metadata||null,dims:V,max_zoom:L,pgs:r,paged:\"paged\"===e.viewingHint||!!e.behaviour&&\"paged\"===e.behaviour[0]||!!s&&\"paged\"===s.viewingHint}}function he(e){let t=e[\"@id\"]||e.id;const i=/#xywh=([0-9]+,[0-9]+,[0-9]+,[0-9]+)/;let s=\"\",n=!0;if(/\\/([0-9]+,[0-9]+,[0-9]+,[0-9]+)\\//.test(t)){const e=t.split(\"/\");s=e[e.length-4]}else if(i.test(t)){s=i.exec(t)[1]}else e.service&&(e.service[\"@id\"]||e.service.id)&&(t=e.service[\"@id\"]||e.service.id,n=!1);n&&(t=t.split(\"/\").slice(0,-4).join(\"/\"));const o={url:t};if(s.length){const e=s.split(\",\");o.x=parseInt(e[0],10),o.y=parseInt(e[1],10),o.w=parseInt(e[2],10),o.h=parseInt(e[3],10)}return o}class ce{getPageImageURL(e,t,i){let s;s=!i||null==i.width&&null==i.height?\"full\":(null==i.width?\"\":i.width)+\",\"+(null==i.height?\"\":i.height);const n=e.pages[t],o=n.api>1.1?\"default\":\"native\";return encodeURI(n.url+\"full/\"+s+\"/0/\"+o+\".jpg\")}getTileImageURL(e,t,i){const s=e.pages[t];let n,o;n=i.row===i.rowCount-1?s.d[i.zoomLevel].h-(i.rowCount-1)*i.tileDimensions.height:i.tileDimensions.height,o=i.col===i.colCount-1?s.d[i.zoomLevel].w-(i.colCount-1)*i.tileDimensions.width:i.tileDimensions.width;const r=Math.pow(2,e.maxZoom-i.zoomLevel);let a=i.col*i.tileDimensions.width*r,l=i.row*i.tileDimensions.height*r;s.hasOwnProperty(\"xoffset\")&&(a+=s.xoffset,l+=s.yoffset);const h=[a,l,o*r,n*r].join(\",\"),c=s.api>1.1?\"default\":\"native\";return encodeURI(s.url+h+\"/\"+o+\",\"+n+\"/0/\"+c+\".jpg\")}}class ue{constructor(e,t){this.pages=e.pgs,this.maxZoom=e.max_zoom,this.maxRatio=e.dims.max_ratio,this.minRatio=e.dims.min_ratio,this.itemTitle=e.item_title,this.metadata=e.metadata,this.paged=!!e.paged,this._maxWidths=e.dims.max_w,this._maxHeights=e.dims.max_h,this._averageWidths=e.dims.a_wid,this._averageHeights=e.dims.a_hei,this._totalHeights=e.dims.t_hei,this._totalWidths=e.dims.t_wid,this._urlAdapter=t}static fromIIIF(e){const t=le(e);return new ue(t,new ce)}isPageValid(e,t){return!(!t&&this.paged&&!this.pages[e].paged)&&(e>=0&&e<this.pages.length)}getMaxPageDimensions(e){const t=this.pages[e].d[this.maxZoom];return{height:t.h,width:t.w}}getPageDimensionsAtZoomLevel(e,t){const i=this.pages[e].d[this.maxZoom],s=function(e,t){return 1/Math.pow(2,e-t)}(this.maxZoom,t);return{height:i.h*s,width:i.w*s}}getPageImageURL(e,t){return this._urlAdapter.getPageImageURL(this,e,t)}getPageImageTiles(e,t,i){const s=this.pages[e];if(!isFinite(t)||t%1!=0)throw new TypeError(\"Zoom level must be an integer: \"+t);const n=Math.ceil(s.d[t].h/i.height),o=Math.ceil(s.d[t].w/i.width),r=[];let a,l,h;for(a=0;a<n;a++)for(l=0;l<o;l++)h=this._urlAdapter.getTileImageURL(this,e,{row:a,col:l,rowCount:n,colCount:o,zoomLevel:t,tileDimensions:i}),r.push({row:a,col:l,zoomLevel:t,dimensions:{height:i.height,width:i.width},offset:{top:a*i.height,left:l*i.width},url:h});return{zoomLevel:t,rows:n,cols:o,tiles:r}}}function de(e){return function(t){return this[e][t]}}ue.prototype.getMaxWidth=de(\"_maxWidths\"),ue.prototype.getMaxHeight=de(\"_maxHeights\"),ue.prototype.getAverageWidth=de(\"_averageWidths\"),ue.prototype.getAverageHeight=de(\"_averageHeights\"),ue.prototype.getTotalWidth=de(\"_totalWidths\"),ue.prototype.getTotalHeight=de(\"_totalHeights\");class ge{constructor(e){this.viewer=e,this.settings=e.settings}_elemAttrs(e,t){const i={id:this.settings.ID+e,class:\"diva-\"+e};return t?Object.assign(i,t):i}_subscribe(e,t){c.Events.subscribe(e,t,this.settings.ID)}createButton(e,t,i,n){const o=s(\"button\",{type:\"button\",id:this.settings.ID+e,class:\"diva-\"+e+\" diva-button\",title:t});return n&&o.appendChild(n),i&&o.addEventListener(\"click\",i),o}createLabel(e,t,i,n,o){return s(\"div\",{id:this.settings.ID+t,class:e+\" diva-label\"},[i,s(\"span\",{id:this.settings.ID+n},o)])}createZoomButtons(){let e=this._createZoomOutIcon(),t=this._createZoomInIcon(),i=[this.createButton(\"zoom-out-button\",\"Zoom Out\",()=>{this.viewer.setZoomLevel(this.settings.zoomLevel-1)},e),this.createButton(\"zoom-in-button\",\"Zoom In\",()=>{this.viewer.setZoomLevel(this.settings.zoomLevel+1)},t),this.createLabel(\"diva-zoom-label\",\"zoom-label\",\"Zoom level: \",\"zoom-level\",this.settings.zoomLevel+1)],n=function(){document.getElementById(this.settings.ID+\"zoom-level\").textContent=this.settings.zoomLevel+1};return this._subscribe(\"ZoomLevelDidChange\",n),this._subscribe(\"ViewerDidLoad\",n),s(\"div\",{id:this.settings.ID+\"zoom-controls\",style:\"display: none\"},i)}createGridControls(){let e=this._createGridMoreIcon(),t=this._createGridFewerIcon(),i=[this.createButton(\"grid-out-button\",\"Fewer\",()=>{this.viewer.setGridPagesPerRow(this.settings.pagesPerRow-1)},t),this.createButton(\"grid-in-button\",\"More\",()=>{this.viewer.setGridPagesPerRow(this.settings.pagesPerRow+1)},e),this.createLabel(\"diva-grid-label\",\"grid-label\",\"Pages per row: \",\"pages-per-row\",this.settings.pagesPerRow)];return this._subscribe(\"GridRowNumberDidChange\",function(){document.getElementById(this.settings.ID+\"pages-per-row\").textContent=this.settings.pagesPerRow}),s(\"div\",{id:this.settings.ID+\"grid-controls\",style:\"display:none\"},i)}createPageLabel(){const e=s(\"span\",{id:this.settings.ID+\"current-page\"}),t=()=>{let t=this.viewer.getCurrentPageIndices(),i=t[0],s=t[t.length-1],n=this.settings.manifest.pages[i].l,o=this.settings.manifest.pages[s].l;i!==s?this.settings.enableIndexAsLabel?e.textContent=i+\" - \"+s:e.textContent=n+\" - \"+o:this.settings.enableIndexAsLabel?e.textContent=i:e.textContent=n};return this._subscribe(\"VisiblePageDidChange\",t),this._subscribe(\"ViewerDidLoad\",t),this._subscribe(\"ViewDidSwitch\",t),s(\"span\",{class:\"diva-page-label diva-label\"},e)}createGotoPageForm(){const e=s(\"input\",{id:this.settings.ID+\"goto-page-input\",class:\"diva-input diva-goto-page-input\",autocomplete:\"off\",type:\"text\"}),t=s(\"input\",{id:this.settings.ID+\"goto-page-submit\",class:\"diva-button diva-button-text\",type:\"submit\",value:\"Go\"}),i=s(\"div\",{id:this.settings.ID+\"input-suggestions\",class:\"diva-input-suggestions\"}),n=s(\"form\",{id:this.settings.ID+\"goto-page\",class:\"diva-goto-form\"},e,t,i);return n.addEventListener(\"submit\",t=>{t.preventDefault();const s=e.value;if(this.settings.onGotoSubmit&&\"function\"==typeof this.settings.onGotoSubmit){const e=this.settings.onGotoSubmit(s);this.viewer.gotoPageByIndex(e)||window.alert(\"No page could be found with that label or page number\")}else this.viewer.gotoPageByLabel(s)||window.alert(\"No page could be found with that label or page number\");return i.style.display=\"none\",!1}),[\"input\",\"focus\"].forEach(t=>{e.addEventListener(t,()=>{i.innerHTML=\"\";const t=e.value;let n=0;if(this.settings.enableGotoSuggestions&&t){const e=this.settings.manifest.pages;for(let o=0,r=e.length;o<r&&n<10;o++)if(e[o].l.toLowerCase().indexOf(t.toLowerCase())>-1){const t=s(\"div\",{class:\"diva-input-suggestion\"},e[o].l);i.appendChild(t),n++}n>0&&(i.style.display=\"block\")}else i.style.display=\"none\"})}),e.addEventListener(\"keydown\",t=>{let i;if(13===t.keyCode){const t=document.getElementsByClassName(\"active\")[0];void 0!==t&&(e.value=t.innerText)}if(38===t.keyCode){const e=(i=document.getElementsByClassName(\"active\")[0])?i.previousSibling:void 0;if(void 0!==e)i.classList.remove(\"active\"),null!==e&&e.classList.add(\"active\");else{let e=document.getElementsByClassName(\"diva-input-suggestion\").length-1;document.getElementsByClassName(\"diva-input-suggestion\")[e].classList.add(\"active\")}}else if(40===t.keyCode){const e=(i=document.getElementsByClassName(\"active\")[0])?i.nextSibling:void 0;void 0!==e?(i.classList.remove(\"active\"),null!==e&&e.classList.add(\"active\")):document.getElementsByClassName(\"diva-input-suggestion\")[0].classList.add(\"active\")}}),function(e,t,i,s){e.addEventListener(t,function(e){for(var t=e.target;t&&t!==this;)t.matches(i)&&s.call(t,e),t=t.parentNode})}(i,\"mousedown\",\".diva-input-suggestion\",function(){e.value=this.textContent,i.style.display=\"none\";let t=new Event(\"submit\");n.dispatchEvent(t)}),e.addEventListener(\"blur\",()=>{i.style.display=\"none\"}),n}createViewMenu(){const e=s(\"div\",this._elemAttrs(\"view-options\")),t=this._createGridViewIcon(),i=this._createBookViewIcon(),n=this._createPageViewIcon(),o=this.createButton(\"view-icon\",\"Change view\",()=>{e.style.display=\"none\"===e.style.display?\"block\":\"none\"}),r=t=>{this.viewer.changeView(t),e.style.display=\"none\"},a=()=>{this.settings.inGrid?(o.appendChild(t),o.className=\"diva-grid-icon diva-view-icon diva-button\"):this.settings.inBookLayout?(o.appendChild(i),o.className=\"diva-book-icon diva-view-icon diva-button\"):(o.appendChild(n),o.className=\"diva-document-icon diva-view-icon diva-button\");const s=document.createDocumentFragment();for((this.settings.inGrid||this.settings.inBookLayout)&&s.appendChild(this.createButton(\"document-icon\",\"Document View\",r.bind(null,\"document\"),n)),!this.settings.inGrid&&this.settings.inBookLayout||s.appendChild(this.createButton(\"book-icon\",\"Book View\",r.bind(null,\"book\"),i)),this.settings.inGrid||s.appendChild(this.createButton(\"grid-icon\",\"Grid View\",r.bind(null,\"grid\"),t));e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s)};return document.addEventListener(\"mouseup\",t=>{e!==t.target&&(e.style.display=\"none\")}),this._subscribe(\"ViewDidSwitch\",a),this._subscribe(\"ObjectDidLoad\",a),s(\"div\",this._elemAttrs(\"view-menu\"),o,e)}createFullscreenButton(){let e=this._createFullscreenIcon();return this.createButton(\"fullscreen-icon\",\"Toggle fullscreen mode\",()=>{this.viewer.toggleFullscreenMode()},e)}toggleZoomGridControls(){this.settings.inGrid?(document.getElementById(this.settings.ID+\"zoom-controls\").style.display=\"none\",document.getElementById(this.settings.ID+\"grid-controls\").style.display=\"block\"):(document.getElementById(this.settings.ID+\"zoom-controls\").style.display=\"block\",document.getElementById(this.settings.ID+\"grid-controls\").style.display=\"none\")}render(){this._subscribe(\"ViewDidSwitch\",this.toggleZoomGridControls),this._subscribe(\"ObjectDidLoad\",this.toggleZoomGridControls);let e=[this.createZoomButtons(),this.createGridControls()],t=[this.createPageLabel(),this.createViewMenu()];this.settings.enableFullscreen&&t.push(this.createFullscreenButton()),this.settings.enableGotoPage&&t.splice(1,0,this.createGotoPageForm());let i=this.viewer.viewerState.pluginInstances;for(let s=0,o=i.length;s<o;s++){let o=i[s];o.toolbarSide&&(o.toolbarIcon=o.createIcon(),o.toolbarIcon&&(\"right\"===o.toolbarSide?t.splice(2,0,o.toolbarIcon):\"left\"===o.toolbarSide&&e.splice(2,0,o.toolbarIcon),o.toolbarIcon.addEventListener(\"click\",n.bind(this,o))))}function n(e){e.handleClick(this.viewer)}const o=s(\"div\",this._elemAttrs(\"tools\"),s(\"div\",this._elemAttrs(\"tools-left\"),e),s(\"div\",this._elemAttrs(\"tools-right\"),t));this.settings.toolbarParentObject.insertBefore(o,this.settings.toolbarParentObject.firstChild)}_createToolbarIcon(e){let t=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");t.setAttributeNS(null,\"viewBox\",\"0 0 25 25\"),t.setAttributeNS(null,\"x\",\"0px\"),t.setAttributeNS(null,\"y\",\"0px\"),t.setAttributeNS(null,\"style\",\"enable-background:new 0 0 48 48;\");let i=document.createElementNS(\"http://www.w3.org/2000/svg\",\"g\");return i.setAttributeNS(null,\"transform\",\"matrix(1, 0, 0, 1, -12, -12)\"),e.forEach(e=>{let t=document.createElementNS(\"http://www.w3.org/2000/svg\",\"path\");t.setAttributeNS(null,\"d\",e),i.appendChild(t)}),t.appendChild(i),t}_createZoomOutIcon(){return this._createToolbarIcon([\"M19.5,23c-0.275,0-0.5-0.225-0.5-0.5v-1c0-0.275,0.225-0.5,0.5-0.5h7c0.275,0,0.5,0.225,0.5,0.5v1c0,0.275-0.225,0.5-0.5,0.5H19.5z\",\"M37.219,34.257l-2.213,2.212c-0.202,0.202-0.534,0.202-0.736,0l-6.098-6.099c-1.537,0.993-3.362,1.577-5.323,1.577c-5.431,0-9.849-4.418-9.849-9.849c0-5.431,4.418-9.849,9.849-9.849c5.431,0,9.849,4.418,9.849,9.849c0,1.961-0.584,3.786-1.576,5.323l6.098,6.098C37.422,33.722,37.422,34.054,37.219,34.257z M29.568,22.099c0-3.706-3.014-6.72-6.72-6.72c-3.706,0-6.72,3.014-6.72,6.72c0,3.706,3.014,6.72,6.72,6.72C26.555,28.818,29.568,25.805,29.568,22.099z\"])}_createZoomInIcon(){return this._createToolbarIcon([\"M37.469,34.257l-2.213,2.212c-0.202,0.202-0.534,0.202-0.736,0l-6.098-6.099c-1.537,0.993-3.362,1.577-5.323,1.577c-5.431,0-9.849-4.418-9.849-9.849c0-5.431,4.418-9.849,9.849-9.849c5.431,0,9.849,4.418,9.849,9.849c0,1.961-0.584,3.786-1.576,5.323l6.098,6.098C37.672,33.722,37.672,34.054,37.469,34.257z M29.818,22.099c0-3.706-3.014-6.72-6.72-6.72c-3.706,0-6.72,3.014-6.72,6.72c0,3.706,3.014,6.72,6.72,6.72C26.805,28.818,29.818,25.805,29.818,22.099z M26.5,21H24v-2.5c0-0.275-0.225-0.5-0.5-0.5h-1c-0.275,0-0.5,0.225-0.5,0.5V21h-2.5c-0.275,0-0.5,0.225-0.5,0.5v1c0,0.275,0.225,0.5,0.5,0.5H22v2.5c0,0.275,0.225,0.5,0.5,0.5h1c0.275,0,0.5-0.225,0.5-0.5V23h2.5c0.275,0,0.5-0.225,0.5-0.5v-1C27,21.225,26.775,21,26.5,21z\"])}_createGridMoreIcon(){return this._createToolbarIcon([\"M29.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z\"])}_createGridFewerIcon(){return this._createToolbarIcon([\"M25.5,35c-0.275,0-0.5-0.225-0.5-0.5v-9c0-0.275,0.225-0.5,0.5-0.5h9c0.275,0,0.5,0.225,0.5,0.5v9c0,0.275-0.225,0.5-0.5,0.5H25.5z M22.5,35c0.275,0,0.5-0.225,0.5-0.5v-9c0-0.275-0.225-0.5-0.5-0.5h-9c-0.275,0-0.5,0.225-0.5,0.5v9c0,0.275,0.225,0.5,0.5,0.5H22.5z M34.5,23c0.275,0,0.5-0.225,0.5-0.5v-9c0-0.275-0.225-0.5-0.5-0.5h-9c-0.275,0-0.5,0.225-0.5,0.5v9c0,0.275,0.225,0.5,0.5,0.5H34.5z M22.5,23c0.275,0,0.5-0.225,0.5-0.5v-9c0-0.275-0.225-0.5-0.5-0.5h-9c-0.275,0-0.5,0.225-0.5,0.5v9c0,0.275,0.225,0.5,0.5,0.5H22.5z\"])}_createGridViewIcon(){return this._createToolbarIcon([\"M29.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,35c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,27c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z M29.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H29.5z M21.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H21.5z M13.5,19c-0.275,0-0.5-0.225-0.5-0.5v-5c0-0.275,0.225-0.5,0.5-0.5h5c0.275,0,0.5,0.225,0.5,0.5v5c0,0.275-0.225,0.5-0.5,0.5H13.5z\"])}_createBookViewIcon(){return this._createToolbarIcon([\"M35,16.8v-1.323c0,0-2.292-1.328-5.74-1.328c-3.448,0-5.26,1.25-5.26,1.25s-1.813-1.25-5.26-1.25c-3.448,0-5.74,1.328-5.74,1.328V16.8l-1,0.531v0.021v15.687c0,0,4.531-1.578,6.999-1.578c2.468,0,5.001,0.885,5.001,0.885s2.532-0.885,5-0.885c0.306,0,0.643,0.024,1,0.066v4.325l1.531-2.016L33,35.852v-3.72c2,0.43,3,0.906,3,0.906V17.352v-0.021L35,16.8z M23,29.03c-1-0.292-2.584-0.679-3.981-0.679c-2.246,0-3.019,0.404-4.019,0.699V16.634c0,0,1.125-0.699,4.019-0.699c1.694,0,2.981,0.417,3.981,1.126V29.03z M33,29.051c-1-0.295-1.773-0.699-4.02-0.699c-1.396,0-2.981,0.387-3.98,0.679V17.06c1-0.709,2.286-1.126,3.98-1.126c2.895,0,4.02,0.699,4.02,0.699V29.051z\"])}_createPageViewIcon(){return this._createToolbarIcon([\"M29.425,29h4.47L29,33.934v-4.47C29,29.19,29.151,29,29.425,29z M34,14.563V28h-5.569C28.157,28,28,28.196,28,28.47V34H14.497C14.223,34,14,33.71,14,33.437V14.563C14,14.29,14.223,14,14.497,14h18.9C33.672,14,34,14.29,34,14.563z M25.497,26.497C25.497,26.223,25.275,26,25,26h-7c-0.275,0-0.497,0.223-0.497,0.497v1.006C17.503,27.777,17.725,28,18,28h7c0.275,0,0.497-0.223,0.497-0.497V26.497z M30.497,22.497C30.497,22.223,30.275,22,30,22H18c-0.275,0-0.497,0.223-0.497,0.497v1.006C17.503,23.777,17.725,24,18,24h12c0.275,0,0.497-0.223,0.497-0.497V22.497z M30.497,18.497C30.497,18.223,30.275,18,30,18H18c-0.275,0-0.497,0.223-0.497,0.497v1.006C17.503,19.777,17.725,20,18,20h12c0.275,0,0.497-0.223,0.497-0.497V18.497z\"])}_createFullscreenIcon(){return this._createToolbarIcon([\"M35,12H13c-0.55,0-1,0.45-1,1v22c0,0.55,0.45,1,1,1h22c0.55,0,1-0.45,1-1V13C36,12.45,35.55,12,35,12z M34,34H14V14h20V34z\",\"M17,21.75v-4.5c0-0.138,0.112-0.25,0.25-0.25h4.5c0.138,0,0.17,0.08,0.073,0.177l-1.616,1.616l1.823,1.823c0.097,0.097,0.097,0.256,0,0.354l-1.061,1.06c-0.097,0.097-0.256,0.097-0.354,0l-1.823-1.823l-1.616,1.616C17.08,21.92,17,21.888,17,21.75z M20.97,25.97c-0.097-0.097-0.256-0.097-0.354,0l-1.823,1.823l-1.616-1.616C17.08,26.08,17,26.112,17,26.25v4.5c0,0.138,0.112,0.25,0.25,0.25h4.5c0.138,0,0.17-0.08,0.073-0.177l-1.616-1.616l1.823-1.823c0.097-0.097,0.097-0.256,0-0.354L20.97,25.97z M30.75,17h-4.5c-0.138,0-0.17,0.08-0.073,0.177l1.616,1.616l-1.823,1.823c-0.097,0.097-0.097,0.256,0,0.354l1.061,1.06c0.097,0.097,0.256,0.097,0.354,0l1.823-1.823l1.616,1.616C30.92,21.92,31,21.888,31,21.75v-4.5C31,17.112,30.888,17,30.75,17z M30.823,26.177l-1.616,1.616l-1.823-1.823c-0.097-0.097-0.256-0.097-0.354,0l-1.061,1.06c-0.097,0.097-0.097,0.256,0,0.354l1.823,1.823l-1.616,1.616C26.08,30.92,26.112,31,26.25,31h4.5c0.138,0,0.25-0.112,0.25-0.25v-4.5C31,26.112,30.92,26.08,30.823,26.177z M26,22.5c0-0.275-0.225-0.5-0.5-0.5h-3c-0.275,0-0.5,0.225-0.5,0.5v3c0,0.275,0.225,0.5,0.5,0.5h3c0.275,0,0.5-0.225,0.5-0.5V22.5z\"])}}var ve={get:pe,update:function(e,t){const i=pe(e),s=window.location.hash;if(i!==t)if(\"string\"==typeof i){const n=s.indexOf(\"&\"+e+\"=\")>0?s.indexOf(\"&\"+e+\"=\"):s.indexOf(\"#\"+e+\"=\"),o=n+e.length+2+i.length,r=0===n?\"#\":\"&\";window.location.replace(s.substring(0,n)+r+e+\"=\"+t+s.substring(o))}else 0===s.length?window.location.replace(\"#\"+e+\"=\"+t):window.location.replace(s+\"&\"+e+\"=\"+t)}};function pe(e){const t=window.location.hash;if(\"\"!==t){let i=t.indexOf(\"&\"+e+\"=\")>0?t.indexOf(\"&\"+e+\"=\"):t.indexOf(\"#\"+e+\"=\");if(i>=0){i+=e.length+2;const s=t.indexOf(\"&\",i);return s>i?decodeURIComponent(t.substring(i,s)):s<0?decodeURIComponent(t.substring(i)):\"\"}return!1}return!1}class fe{constructor(e,t){if(!(e instanceof HTMLElement)&&(this.element=document.getElementById(e),null===this.element))throw new a;if(!t.objectData)throw new h(\"You must supply either a URL or a literal object to the `objectData` key.\");this.options=Object.assign({acceptHeader:\"application/json\",adaptivePadding:.05,arrowScrollAmount:40,blockMobileMove:!1,objectData:\"\",enableAutoTitle:!0,enableFilename:!0,enableFullscreen:!0,enableGotoPage:!0,enableGotoSuggestions:!0,enableGridIcon:!0,enableGridControls:\"buttons\",enableImageTitles:!0,enableIndexAsLabel:!1,enableKeyScroll:!0,enableLinkIcon:!0,enableNonPagedVisibilityIcon:!0,enableSpaceScroll:!1,enableToolbar:!0,enableZoomControls:\"buttons\",fillParentHeight:!0,fixedPadding:10,fixedHeightGrid:!0,goDirectlyTo:0,hashParamSuffix:null,inFullscreen:!1,inBookLayout:!1,inGrid:!1,maxPagesPerRow:8,maxZoomLevel:-1,minPagesPerRow:2,minZoomLevel:0,onGotoSubmit:null,pageAliases:{},pageAliasFunction:function(){return!1},pageLoadTimeout:200,pagesPerRow:5,showNonPagedPages:!1,throbberTimeout:100,tileHeight:256,tileWidth:256,toolbarParentObject:null,verticallyOriented:!0,viewportMargin:200,zoomLevel:2},t);const i=s(\"div\",{class:`diva-wrapper${this.options.fillParentHeight?\" diva-wrapper-flexbox\":\"\"}`});this.element.appendChild(i),this.options.toolbarParentObject=this.options.toolbarParentObject||i;const n=new se(i,this.options,this);this.viewerState=n.getInternalState(),this.settings=n.getSettings(),this.toolbar=this.settings.enableToolbar?new ge(this):null,i.id=this.settings.ID+\"wrapper\",this.divaState={viewerCore:n,toolbar:this.toolbar};let o=c.Events.subscribe(\"ObjectDidLoad\",()=>{null!==this.toolbar&&this.toolbar.render(),c.Events.unsubscribe(o)});this.hashState=this._getHashParamState(),this._loadOrFetchObjectData()}_loadOrFetchObjectData(){if(\"object\"==typeof this.settings.objectData)setTimeout(()=>{this._loadObjectData(this.settings.objectData,this.hashState)},0);else{let e={Accept:this.settings.acceptHeader};this.settings.addRequestHeaders&&Object.assign(e,this.settings.addRequestHeaders);const t=fetch(this.settings.objectData,{headers:e}).then(e=>{if(!e.ok){c.Events.publish(\"ManifestFetchError\",[e],this),this._ajaxError(e);let t=new Error(e.statusText);throw t.response=e,t}return e.json()}).then(e=>{this._loadObjectData(e,this.hashState)});this.divaState.viewerCore.setPendingManifestRequest(t)}}_showError(e){this.divaState.viewerCore.showError(e)}_ajaxError(e){const t=[\"Invalid objectData setting. Error code: \"+e.status+\" \"+e.statusText];if(0===this.settings.objectData.lastIndexOf(\"http\",0)){const e=this.settings.objectData.replace(/https?:\\/\\//i,\"\").split(/[/?#]/)[0];window.location.hostname!==e&&t.push(s(\"p\",\"Attempted to access cross-origin data without CORS.\"),s(\"p\",\"You may need to update your server configuration to support CORS. For help, see the \",s(\"a\",{href:\"https://github.com/DDMAL/diva.js/wiki/Installation#a-note-about-cross-site-requests\",target:\"_blank\"},\"cross-site request documentation.\")))}this._showError(t)}_loadObjectData(e,t){let i;if(!e.hasOwnProperty(\"@context\")&&(-1===e[\"@context\"].indexOf(\"iiif\")||-1===e[\"@context\"].indexOf(\"shared-canvas\")))throw new l(\"This does not appear to be a IIIF Manifest.\");c.Events.publish(\"ManifestDidLoad\",[e],this),i=ue.fromIIIF(e);const s=t?this._getLoadOptionsForState(t,i):{};this.divaState.viewerCore.setManifest(i,s)}_getHashParamState(){const e={};return[\"f\",\"v\",\"z\",\"n\",\"i\",\"p\",\"y\",\"x\"].forEach(t=>{const i=ve.get(t+this.settings.hashParamSuffix);!1!==i&&(e[t]=i)}),\"true\"===e.f?e.f=!0:\"false\"===e.f&&(e.f=!1),[\"z\",\"n\",\"p\",\"x\",\"y\"].forEach(t=>{t in e&&(e[t]=parseInt(e[t],10))}),e}_getLoadOptionsForState(e,t){t=t||this.settings.manifest;const i=\"v\"in e?this._getViewState(e.v):{};\"f\"in e&&(i.inFullscreen=e.f),\"z\"in e&&(i.zoomLevel=e.z),\"n\"in e&&(i.pagesPerRow=e.n);let s=this._getPageIndexForManifest(t,e.i);if(s>=0&&s<t.pages.length||(s=e.p-1)>=0&&s<t.pages.length||(s=null),null!==s){const t=parseInt(e.x,10),n=parseInt(e.y,10);i.goDirectlyTo=s,i.horizontalOffset=t,i.verticalOffset=n}return i}_getViewState(e){switch(e){case\"d\":return{inGrid:!1,inBookLayout:!1};case\"b\":return{inGrid:!1,inBookLayout:!0};case\"g\":return{inGrid:!0,inBookLayout:!1};default:return{}}}_getPageIndexForManifest(e,t){let i;const s=e.pages.length;for(i=0;i<s;i++)if(e.pages[i].f===t)return i;return-1}_getState(){let e;e=this.settings.inGrid?\"g\":this.settings.inBookLayout?\"b\":\"d\";const t=this.divaState.viewerCore.getCurrentLayout().getPageToViewportCenterOffset(this.settings.activePageIndex,this.viewerState.viewport);return{f:this.settings.inFullscreen,v:e,z:this.settings.zoomLevel,n:this.settings.pagesPerRow,i:!!this.settings.enableFilename&&this.settings.manifest.pages[this.settings.activePageIndex].f,p:!this.settings.enableFilename&&this.settings.activePageIndex+1,y:!!t&&t.y,x:!!t&&t.x}}_getURLHash(){const e=this._getState(),t=[];let i;for(i in e)!1!==e[i]&&t.push(i+this.settings.hashParamSuffix+\"=\"+encodeURIComponent(e[i]));return t.join(\"&\")}_getPageIndex(e){return this._getPageIndexForManifest(this.settings.manifest,e)}_checkLoaded(){return!!this.viewerState.loaded||(console.warn(\"The viewer is not completely initialized. This is likely because it is still downloading data. To fix this, only call this function if the isReady() method returns true.\"),!1)}_toggleFullscreen(){let e;this._reloadViewer({inFullscreen:!this.settings.inFullscreen});let t=!1,i=document.getElementById(this.settings.selector+\"tools\");const s=2e3;function n(){i.style.opacity=1,clearTimeout(e),!t&&this.settings.inFullscreen&&(e=setTimeout(function(){i.style.opacity=0},s))}this.settings.inFullscreen?(i.classList.add(\"diva-fullscreen-tools\"),document.addEventListener(\"mousemove\",n.bind(this)),document.getElementsByClassName(\"diva-viewport\")[0].addEventListener(\"scroll\",n.bind(this)),i.addEventListener(\"mouseenter\",function(){t=!0}),i.addEventListener(\"mouseleave\",function(){t=!1})):i.classList.remove(\"diva-fullscreen-tools\")}_togglePageLayoutOrientation(){const e=!this.settings.verticallyOriented;return this._reloadViewer({inGrid:!1,verticallyOriented:e,goDirectlyTo:this.settings.activePageIndex,verticalOffset:this.divaState.viewerCore.getYOffset(),horizontalOffset:this.divaState.viewerCore.getXOffset()}),e}_changeView(e){switch(e){case\"document\":return this._reloadViewer({inGrid:!1,inBookLayout:!1});case\"book\":return this._reloadViewer({inGrid:!1,inBookLayout:!0});case\"grid\":return this._reloadViewer({inGrid:!0});default:return!1}}_gotoPageByIndex(e,t,i){let s=parseInt(e,10);if(this._isPageIndexValid(s)){const e=this.divaState.viewerCore.getXOffset(s,t),n=this.divaState.viewerCore.getYOffset(s,i);return this.viewerState.renderer.goto(s,n,e),!0}return!1}_isPageIndexValid(e){return this.settings.manifest.isPageValid(e,this.settings.showNonPagedPages)}_getPageIndexForPageXYValues(e,t){const i=this.viewerState.outerElement.getBoundingClientRect(),s=i.top,n=i.left,o=i.bottom,r=i.right;if(e<n||e>r)return-1;if(t<s||t>o)return-1;const a=document.getElementsByClassName(\"diva-page\");let l=a.length;for(;l--;){const i=a[l],s=i.getBoundingClientRect();if(!(e<s.left||e>s.right)&&!(t<s.top||t>s.bottom))return i.getAttribute(\"data-index\")}return-1}_reloadViewer(e){return this.divaState.viewerCore.reload(e)}_getCurrentURL(){return location.protocol+\"//\"+location.host+location.pathname+location.search+\"#\"+this._getURLHash()}activate(){this.viewerState.isActiveDiva=!0}changeObject(e){this.viewerState.loaded=!1,this.divaState.viewerCore.clear(),this.viewerState.renderer&&this.viewerState.renderer.destroy(),this.viewerState.options.objectData=e,this._loadOrFetchObjectData()}changeView(e){this._changeView(e)}deactivate(){this.viewerState.isActiveDiva=!1}destroy(){this.divaState.viewerCore.destroy()}disableScrollable(){this.divaState.viewerCore.disableScrollable()}enableScrollable(){this.divaState.viewerCore.enableScrollable()}disableDragScrollable(){this.divaState.viewerCore.disableDragScrollable()}enableDragScrollable(){this.divaState.viewerCore.enableDragScrollable()}enterFullscreenMode(){return!this.settings.inFullscreen&&(this._toggleFullscreen(),!0)}enterGridView(){return!this.settings.inGrid&&(this._changeView(\"grid\"),!0)}getAllPageURIs(){return this.settings.manifest.pages.map(e=>e.f)}getCurrentCanvas(){return this.settings.manifest.pages[this.settings.activePageIndex].canvas}getCurrentPageDimensionsAtCurrentZoomLevel(){return this.getPageDimensionsAtCurrentZoomLevel(this.settings.activePageIndex)}getCurrentPageFilename(){return console.warn(\"This method will be deprecated in the next version of Diva. Please use getCurrentPageURI instead.\"),this.settings.manifest.pages[this.settings.activePageIndex].f}getCurrentPageIndices(){return this.settings.currentPageIndices}getActivePageIndex(){return this.settings.activePageIndex}getCurrentPageOffset(){return this.getPageOffset(this.settings.activePageIndex)}getCurrentPageURI(){return this.settings.manifest.pages[this.settings.activePageIndex].f}getCurrentURL(){return this._getCurrentURL()}getFilenames(){return console.warn(\"This will be removed in the next version of Diva. Use getAllPageURIs instead.\"),this.settings.manifest.pages.map(e=>e.f)}getGridPagesPerRow(){return this.settings.pagesPerRow}getInstanceId(){return this.settings.ID}getInstanceSelector(){return this.divaState.viewerCore.selector}getItemTitle(){return this.settings.manifest.itemTitle}getMaxZoomLevel(){return this.settings.maxZoomLevel}getMaxZoomLevelForPage(e){return!!this._checkLoaded()&&this.settings.manifest.pages[e].m}getMinZoomLevel(){return this.settings.minZoomLevel}getNumberOfPages(){return!!this._checkLoaded()&&this.settings.numPages}getOtherImages(e){return this.settings.manifest.pages[e].otherImages}getPageDimensions(e){return this._checkLoaded()?this.divaState.viewerCore.getCurrentLayout().getPageDimensions(e):null}getPageDimensionsAtCurrentZoomLevel(e){let t=parseInt(e,10);if(!this._isPageIndexValid(t))throw new Error(\"Invalid Page Index\");return this.divaState.viewerCore.getCurrentLayout().getPageDimensions(t)}getPageDimensionsAtZoomLevel(e,t){if(!this._checkLoaded())return!1;t>this.settings.maxZoomLevel&&(t=this.settings.maxZoomLevel);const i=this.settings.manifest.pages[parseInt(e,10)].d[parseInt(t,10)];return{width:i.w,height:i.h}}getPageImageURL(e,t){return this.settings.manifest.getPageImageURL(e,t)}getPageIndexForPageXYValues(e,t){return this._getPageIndexForPageXYValues(e,t)}getPageOffset(e,t){const i=this.divaState.viewerCore.getPageRegion(e,t);return{top:i.top,left:i.left}}getSettings(){return this.settings}getState(){return this._getState()}getZoomLevel(){return this.settings.zoomLevel}gotoPageByIndex(e,t,i){this._gotoPageByIndex(e,t,i)}gotoPageByLabel(e,t,i){const s=this.settings.manifest.pages;let n=e.toLowerCase();for(let e=0,o=s.length;e<o;e++)if(s[e].l.toLowerCase().indexOf(n)>-1)return this._gotoPageByIndex(e,t,i);const o=parseInt(e,10)-1;return this._gotoPageByIndex(o,t,i)}gotoPageByName(e,t,i){console.warn(\"This method will be removed in the next version of Diva.js. Use gotoPageByURI instead.\");const s=this._getPageIndex(e);return this._gotoPageByIndex(s,t,i)}gotoPageByURI(e,t,i){const s=this._getPageIndex(e);return this._gotoPageByIndex(s,t,i)}hasOtherImages(e){return!0===this.settings.manifest.pages[e].otherImages}hideNonPagedPages(){this._reloadViewer({showNonPagedPages:!1})}isInFullscreen(){return this.settings.inFullscreen}isPageIndexValid(e){return this._isPageIndexValid(e)}isPageInViewport(e){return this.viewerState.renderer.isPageVisible(e)}isReady(){return this.viewerState.loaded}isRegionInViewport(e,t,i,s,n){const o=this.divaState.viewerCore.getCurrentLayout();if(!o)return!1;const r=o.getPageOffset(e),a=r.top+i,l=r.left+t;return this.viewerState.viewport.intersectsRegion({top:a,bottom:a+n,left:l,right:l+s})}isVerticallyOriented(){return this.settings.verticallyOriented}leaveFullscreenMode(){return!!this.settings.inFullscreen&&(this._toggleFullscreen(),!0)}leaveGridView(){return!!this.settings.inGrid&&(this._reloadViewer({inGrid:!1}),!0)}setGridPagesPerRow(e){return!!this.divaState.viewerCore.isValidOption(\"pagesPerRow\",e)&&this._reloadViewer({inGrid:!0,pagesPerRow:e})}setState(e){this._reloadViewer(this._getLoadOptionsForState(e))}setZoomLevel(e){return this.settings.inGrid&&this._reloadViewer({inGrid:!1}),this.divaState.viewerCore.zoom(e)}showNonPagedPages(){this._reloadViewer({showNonPagedPages:!0})}toggleFullscreenMode(){this._toggleFullscreen()}toggleNonPagedPagesVisibility(){this._reloadViewer({showNonPagedPages:!this.settings.showNonPagedPages})}toggleOrientation(){return this._togglePageLayoutOrientation()}translateFromMaxZoomLevel(e){const t=this.settings.maxZoomLevel-this.settings.zoomLevel;return e/Math.pow(2,t)}translateToMaxZoomLevel(e){const t=this.settings.maxZoomLevel-this.settings.zoomLevel;return 0===t?e:e*Math.pow(2,t)}zoomIn(){return this.setZoomLevel(this.settings.zoomLevel+1)}zoomOut(){return this.setZoomLevel(this.settings.zoomLevel-1)}}t.default=fe;!function(e){e.Diva=e.Diva||fe,e.Diva.Events=c.Events}(window)}]);"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourceRoot":""}
\ No newline at end of file
--- a/src/main/webapp/imageServer/resources/js/diva.min.js	Mon Jul 01 15:05:05 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-Storage.prototype.setObject=function(b,e){this.setItem(b,JSON.stringify(e))};Storage.prototype.getObject=function(b){return(b=this.getItem(b))&&JSON.parse(b)};(function(b){var e=1;b.generateId=function(b){var d;do d=e++ +(b?"-"+b:"");while(document.getElementById(d));return d}})(jQuery);
-(function(b){b.getScrollbarWidth=function(){var b=document.createElement("p");b.style.width="100%";b.style.height="200px";var f=document.createElement("div");f.style.position="absolute";f.style.top="0px";f.style.left="0px";f.style.visibility="hidden";f.style.width="200px";f.style.height="150px";f.style.overflow="hidden";f.appendChild(b);document.body.appendChild(f);var d=b.offsetWidth;f.style.overflow="scroll";b=b.offsetWidth;d==b&&(b=f.clientWidth);document.body.removeChild(f);return d-b}})(jQuery);
-(function(b){b.getHashParam=function(b){var f=window.location.hash;if(""!==f){var d=0<f.indexOf("&"+b+"=")?f.indexOf("&"+b+"="):f.indexOf("#"+b+"=");if(0<=d)return d+=b.length+2,b=f.indexOf("&",d),b>d?f.substring(d,b):0>b?f.substring(d):""}return!1}})(jQuery);
-(function(b){b.updateHashParam=function(e,f){var d=b.getHashParam(e),a=window.location.hash;if(d!==f)if("string"==typeof d){var g=0<a.indexOf("&"+e+"=")?a.indexOf("&"+e+"="):a.indexOf("#"+e+"="),d=g+e.length+2+d.length,h=0===g?"#":"&";window.location.replace(a.substring(0,g)+h+e+"="+f+a.substring(d))}else 0===a.length?window.location.replace("#"+e+"="+f):window.location.replace(a+"&"+e+"="+f)}})(jQuery);
-(function(b){b.fn.dragscrollable=function(e){var f=b.extend({dragSelector:">:first",acceptPropagatedEvent:!0,preventDefault:!0},e||{}),d={mouseDownHandler:function(a){if(1!=a.which||!a.data.acceptPropagatedEvent&&a.target!=this)return!1;a.data.lastCoord={left:a.clientX,top:a.clientY};b.event.add(document,"mouseup",d.mouseUpHandler,a.data);b.event.add(document,"mousemove",d.mouseMoveHandler,a.data);if(a.data.preventDefault)return a.preventDefault(),!1},mouseMoveHandler:function(a){var b=a.clientX-
-a.data.lastCoord.left,d=a.clientY-a.data.lastCoord.top;a.data.scrollable.scrollLeft(a.data.scrollable.scrollLeft()-b);a.data.scrollable.scrollTop(a.data.scrollable.scrollTop()-d);a.data.lastCoord={left:a.clientX,top:a.clientY};if(a.data.preventDefault)return a.preventDefault(),!1},mouseUpHandler:function(a){b.event.remove(document,"mousemove",d.mouseMoveHandler);b.event.remove(document,"mouseup",d.mouseUpHandler);if(a.data.preventDefault)return a.preventDefault(),!1}};this.each(function(){var a={scrollable:b(this),
-acceptPropagatedEvent:f.acceptPropagatedEvent,preventDefault:f.preventDefault};b(this).find(f.dragSelector).bind("mousedown",a,d.mouseDownHandler)})}})(jQuery);
-(function(b){var e={cursor:"move",decelerate:!0,triggerHardware:!1,y:!0,x:!0,slowdown:.9,maxvelocity:40,throttleFPS:60,movingClass:{up:"kinetic-moving-up",down:"kinetic-moving-down",left:"kinetic-moving-left",right:"kinetic-moving-right"},deceleratingClass:{up:"kinetic-decelerating-up",down:"kinetic-decelerating-down",left:"kinetic-decelerating-left",right:"kinetic-decelerating-right"}};window.requestAnimationFrame||(window.requestAnimationFrame=function(){return window.webkitRequestAnimationFrame||
-window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a,b){window.setTimeout(a,1E3/60)}}());b.support=b.support||{};b.extend(b.support,{touch:"ontouchend"in document});var f=function(){return!1},d=function(a,b){return 0===Math.floor(Math.abs(a))?0:a*b},a=function(a,b){var d=a;0<a?a>b&&(d=b):a<0-b&&(d=0-b);return d},g=function(a,b){this.removeClass(a.movingClass.up).removeClass(a.movingClass.down).removeClass(a.movingClass.left).removeClass(a.movingClass.right).removeClass(a.deceleratingClass.up).removeClass(a.deceleratingClass.down).removeClass(a.deceleratingClass.left).removeClass(a.deceleratingClass.right);
-0<a.velocity&&this.addClass(b.right);0>a.velocity&&this.addClass(b.left);0<a.velocityY&&this.addClass(b.down);0>a.velocityY&&this.addClass(b.up)},h=function(a,b){b.velocity=0;b.velocityY=0;b.decelerate=!0;"function"===typeof b.stopped&&b.stopped.call(a,b)},l=function(a,b){var e=a[0];b.x&&0<e.scrollWidth?(e.scrollLeft=b.scrollLeft=e.scrollLeft+b.velocity,0<Math.abs(b.velocity)&&(b.velocity=b.decelerate?d(b.velocity,b.slowdown):b.velocity)):b.velocity=0;b.y&&0<e.scrollHeight?(e.scrollTop=b.scrollTop=
-e.scrollTop+b.velocityY,0<Math.abs(b.velocityY)&&(b.velocityY=b.decelerate?d(b.velocityY,b.slowdown):b.velocityY)):b.velocityY=0;g.call(a,b,b.deceleratingClass);"function"===typeof b.moved&&b.moved.call(a,b);0<Math.abs(b.velocity)||0<Math.abs(b.velocityY)?window.requestAnimationFrame(function(){l(a,b)}):h(a,b)},n=function(a,d){var e=b.kinetic.callMethods[a],f=Array.prototype.slice.call(arguments);e&&this.each(function(){var a=f.slice(1),d=b(this).data("kinetic-settings");a.unshift(d);e.apply(this,
-a)})},t=function(a,d){b.support.touch?a.bind("touchstart",d.events.touchStart).bind("touchend",d.events.inputEnd).bind("touchmove",d.events.touchMove):a.mousedown(d.events.inputDown).mouseup(d.events.inputEnd).mousemove(d.events.inputMove);a.click(d.events.inputClick).scroll(d.events.scroll).bind("selectstart",f).bind("dragstart",d.events.dragStart)},u=function(d){this.addClass("kinetic-active").each(function(){var f=this,h=b(this);if(!h.data("kinetic-settings")){var k=b.extend({},e,d),n,u=!1,y,v=
-!1,A=!1,B=1E3/k.throttleFPS,I,G;k.velocity=0;k.velocityY=0;var M=function(){A=y=n=!1};b(document).mouseup(M).click(M);var m=function(){k.velocity=a(u-n,k.maxvelocity);k.velocityY=a(v-y,k.maxvelocity)},x=function(a){return b.isFunction(k.filterTarget)?!1!==k.filterTarget.call(f,a):!0},F=function(a,d){if(!I||new Date>new Date(I.getTime()+B))I=new Date,A&&(n||y)&&(G&&(b(G).blur(),G=null,h.focus()),k.decelerate=!1,k.velocity=k.velocityY=0,h[0].scrollLeft=k.scrollLeft=k.x?h[0].scrollLeft-(a-n):h[0].scrollLeft,
-h[0].scrollTop=k.scrollTop=k.y?h[0].scrollTop-(d-y):h[0].scrollTop,u=n,v=y,n=a,y=d,m(),g.call(h,k,k.movingClass),"function"===typeof k.moved&&k.moved.call(h,k))};k.events={touchStart:function(a){var b;if(x(a.target)){b=a.originalEvent.touches[0];var d=b.clientX;b=b.clientY;A=!0;k.velocity=u=0;k.velocityY=v=0;n=d;y=b;a.stopPropagation()}},touchMove:function(a){var b;A&&(b=a.originalEvent.touches[0],F(b.clientX,b.clientY),a.preventDefault&&a.preventDefault())},inputDown:function(a){if(x(a.target)){var b=
-a.clientX,d=a.clientY;A=!0;k.velocity=u=0;k.velocityY=v=0;n=b;y=d;G=a.target;"IMG"===a.target.nodeName&&a.preventDefault();a.stopPropagation()}},inputEnd:function(a){n&&u&&!1===k.decelerate&&(k.decelerate=!0,m(),n=u=A=!1,l(h,k));G=null;a.preventDefault&&a.preventDefault()},inputMove:function(a){A&&(F(a.clientX,a.clientY),a.preventDefault&&a.preventDefault())},scroll:function(a){"function"===typeof k.moved&&k.moved.call(h,k);a.preventDefault&&a.preventDefault()},inputClick:function(a){if(0<Math.abs(k.velocity))return a.preventDefault(),
-!1},dragStart:function(a){if(G)return!1}};t(h,k);h.data("kinetic-settings",k).css("cursor",k.cursor);k.triggerHardware&&h.css({"-webkit-transform":"translate3d(0,0,0)","-webkit-perspective":"1000","-webkit-backface-visibility":"hidden"})}})};b.kinetic={settingsKey:"kinetic-settings",callMethods:{start:function(a,d){var e=b(this);if(a=b.extend(a,d))a.decelerate=!1,l(e,a)},end:function(a,d){b(this);a&&(a.decelerate=!0)},stop:function(a,d){var e=b(this);h(e,a)},detach:function(a,d){var e=b(this);b.support.touch?
-e.unbind("touchstart",a.events.touchStart).unbind("touchend",a.events.inputEnd).unbind("touchmove",a.events.touchMove):e.unbind("mousedown",a.events.inputDown).unbind("mouseup",a.events.inputEnd).unbind("mousemove",a.events.inputMove).unbind("scroll",a.events.scroll);e.unbind("click",a.events.inputClick).unbind("selectstart",f);e.unbind("dragstart",a.events.dragStart);e.removeClass("kinetic-active").css("cursor","")},attach:function(a,d){var e=b(this);t(e,a);e.addClass("kinetic-active").css("cursor",
-"move")}}};b.fn.kinetic=function(a){"string"===typeof a?n.apply(this,arguments):u.call(this,a);return this}})(window.jQuery||window.Zepto);
-var diva=function(){var b={};return{Events:{publish:function(e,f,d){if(b[e]){e=b[e];for(var a=e.length;a--;)e[a].apply(d||this,f||[])}},subscribe:function(e,f){b[e]||(b[e]=[]);b[e].push(f);return[e,f]},unsubscribe:function(e,f){var d=e[0];if(b[d])for(var a=b[d].length;a--;)if(b[d][a]===e[1])return b[d].splice(a,1),f&&delete b[d],!0;return!1},unsubscribeAll:function(){b={}}}}}(),activeDivaController=function(){var b;$(document).on("click",function(e){a:{var f=$(e.target);e=f.find(".diva-outer");var f=
-f.closest(".diva-outer"),d;if(!(0<e.length))if(0<f.length)e=f;else{d=document.getElementsByClassName("diva-outer");for(f=0;f<d.length;f++)$(d[f].parentElement).data("diva").deactivate();break a}e.parent().data("diva").activate();b=e.parent();d=document.getElementsByClassName("diva-outer");for(f=0;f<d.length;f++)d[f].getAttribute("id")!=e.attr("id")&&$(d[f].parentElement).data("diva").deactivate()}});this.getActive=function(){return b}},activeDiva=new activeDivaController;window.divaPlugins=[];
-(function(b){var e=function(e,d){var a=b.extend({},{adaptivePadding:.05,arrowScrollAmount:40,blockMobileMove:!0,objectData:"",enableAutoTitle:!0,enableFilename:!0,enableFullscreen:!0,enableGotoPage:!0,enableGridIcon:!0,enableGridControls:"buttons",enableKeyScroll:!0,enableLinkIcon:!0,enableSpaceScroll:!1,enableToolbar:!0,enableZoomControls:"buttons",fixedPadding:10,fixedHeightGrid:!0,goDirectlyTo:0,iipServerURL:"",inFullscreen:!1,inGrid:!1,imageDir:"",maxPagesPerRow:8,maxZoomLevel:-1,minPagesPerRow:2,
-minZoomLevel:0,onDocumentLoaded:null,onModeToggle:null,onViewToggle:null,onJump:null,onPageLoad:null,onPageLoaded:null,onReady:null,onScroll:null,onScrollDown:null,onScrollUp:null,onSetCurrentPage:null,onZoom:null,onZoomIn:null,onZoomOut:null,pageLoadTimeout:200,pagesPerRow:5,rowLoadTimeout:50,throbberTimeout:100,tileHeight:256,tileWidth:256,toolbarParentObject:d.parentObject,verticallyOriented:!0,viewportMargin:200,zoomLevel:2},d);b.extend(a,{allTilesLoaded:[],averageHeights:[],averageWidths:[],
-currentPageIndex:0,divaIsFullWindow:!1,doubleClickZoom:!1,firstPageLoaded:-1,firstRowLoaded:-1,gridPageWidth:0,hashParamSuffix:"",horizontalOffset:0,horizontalPadding:0,ID:null,initialKeyScroll:!1,initialSpaceScroll:!1,innerObject:"",isActiveDiva:!0,isScrollable:!0,itemTitle:"",lastPageLoaded:-1,lastRowLoaded:-1,loaded:!1,maxWidths:[],maxHeights:[],maxRatio:0,minRatio:0,mobileWebkit:!1,numPages:0,numRows:0,oldZoomLevel:-1,outerObject:"",pages:[],pageLeftOffsets:[],pageTopOffsets:[],pageTimeouts:[],
-pageTools:"",panelHeight:0,panelWidth:0,plugins:[],previousLeftScroll:0,previousTopScroll:0,realMaxZoom:-1,resizeTimer:-1,rowHeight:0,scaleWait:!1,scrollbarWidth:0,selector:"",singleClick:!1,singleTap:!1,throbberTimeoutID:-1,toolbar:null,totalHeights:[],totalHeight:0,totalWidths:[],totalWidth:0,verticalOffset:0,verticalPadding:0});var g=this,h=function(a){var b=!0;return function(a){var c,d,e;if("function"===typeof a){c=[];d=1;for(e=arguments.length;d<e;d++)c.push(arguments[d]);b&&(console.warn('The use of callback functions is deprecated. Use diva.Events.subscribe("Event", function) instead.'),
-b=!1);a.apply(g,c);return!0}return!1}}(),l=function(c,b){return a.pages[c].d[a.zoomLevel][b]},n=function(c){var b,d=a.numPages;for(b=0;b<d;b++)if(a.pages[b].f===c)return b;return-1},t=function(c,d){var e=b("#"+a.ID+"outer").scrollLeft()-a.viewportMargin,f=e+a.panelWidth+2*a.viewportMargin;return c>=e&&c<=f||c<=e&&d>=f||d>=e&&d<=f},u=function(c,d){var e=b("#"+a.ID+"outer").scrollTop()-a.viewportMargin,f=e+a.panelHeight+2*a.viewportMargin;return c>=e&&c<=f||c<=e&&d>=f||d>=e&&d<=f},p=function(c){return 0<=
-c&&c<a.numPages},r=function(c){var b=a.pageTopOffsets[c],d=b+l(c,"h")+a.verticalPadding,e=a.pageLeftOffsets[c];c=e+l(c,"w")+a.horizontalPadding;return u(b,d)&&t(e,c)},q=function(c){return!!document.getElementById(a.ID+"page-"+c)},k=function(c){if(!q(c)||!a.allTilesLoaded[c]){var b=a.pages[c].f,d=l(c,"w"),e=l(c,"h"),f=a.pageTopOffsets[c]+a.verticalPadding,m=a.pageLeftOffsets[c]+a.horizontalPadding,U=a.selector+"page-"+c,x;if(!q(c)){var H=document.getElementById(a.ID+"inner"),k=document.createElement("div");
-k.id=a.ID+"page-"+c;k.classList.add("diva-document-page");k.setAttribute("data-index",c);k.setAttribute("data-filename",b);k.title="Page "+(c+1);k.innerHTML=a.pageTools;k.style.width=d+"px";k.style.height=e+"px";a.verticallyOriented?(k.style.top=f+"px",k.classList.add("diva-page-vertical")):(k.style.left=m+"px",k.classList.add("diva-page-horizontal"));H.appendChild(k);h(a.onPageLoad,c,b,U);diva.Events.publish("PageWillLoad",[c,b,U],g);for(x in a.plugins)h(a.plugins[x].onPageLoad,c,b,U)}a.pageTimeouts.push(setTimeout(function(c){var f=
-document.getElementById(a.ID+"page-"+c);if(r(c)){var m=a.imageDir+"/",k=l(c,"r"),x=l(c,"c"),H=!0,Y=0,F=e-(k-1)*a.tileHeight,z=d-(x-1)*a.tileWidth,n,p,X,fa,ga,K;baseImageURL=a.iipServerURL+"?FIF="+m+b+"&JTL="+(a.zoomLevel+a.pages[c].m-a.realMaxZoom)+",";for(m=0;m<k;){for(n=0;n<x;){fa=m*a.tileHeight;ga=n*a.tileWidth;p=m===k-1?F:a.tileHeight;X=n===x-1?z:a.tileWidth;K=baseImageURL+Y;if(!document.getElementById(a.ID+"tile-"+c+"-"+Y)){var w=void 0,q=void 0;a.verticallyOriented?(w=a.pageTopOffsets[c]+m*
-a.tileHeight+a.verticalPadding,q=a.pageLeftOffsets[c]+n*a.tileWidth):(w=a.pageTopOffsets[c]+m*a.tileHeight,q=a.pageLeftOffsets[c]+n*a.tileWidth+a.horizontalPadding);var ra=q+a.tileWidth;u(w,w+a.tileHeight)&&t(q,ra)?(w=document.createElement("div"),w.id=a.ID+"tile-"+c+"-"+Y,w.classList.add("diva-document-tile"),w.style.display="inline",w.style.position="absolute",w.style.top=fa+"px",w.style.left=ga+"px",w.style.backgroundImage="url('"+K+"')",w.style.height=p+"px",w.style.width=X+"px",f.appendChild(w)):
-H=!1}Y++;n++}m++}a.allTilesLoaded[c]=H;h(a.onPageLoaded,c,b,U);diva.Events.publish("PageDidLoad",[c,b,U],g)}},a.pageLoadTimeout,c))}},T=function(c){c=document.getElementById(a.ID+"page-"+c);if(null!==c){for(;c.firstChild;)c.removeChild(c.firstChild);c.parentNode.removeChild(c)}},L=function(c){if(a.verticallyOriented){c=a.pageTopOffsets[c]+l(c,"h")+a.verticalPadding;var b=document.getElementById(a.ID+"outer").scrollTop}else c=a.pageLeftOffsets[c]+l(c,"w")+a.horizontalPadding,b=document.getElementById(a.ID+
-"outer").scrollLeft;return c=c<b},y=function(c){if(a.verticallyOriented){c=a.pageTopOffsets[c];var b=document.getElementById(a.ID+"outer").scrollTop+a.panelHeight}else c=a.pageLeftOffsets[c],b=document.getElementById(a.ID+"outer").scrollLeft+a.panelWidth;return c=c>b},v=function(c,b){0<b?p(c)&&(r(c)?(k(c),a.lastPageLoaded=c,v(a.lastPageLoaded+1,b)):L(c)&&v(c+1,b)):p(c)&&(r(c)?(k(c),a.firstPageLoaded=c,v(a.firstPageLoaded-1,b)):y(c)&&v(c-1,b))},A=function(c,b){0<b?p(c)&&L(c)&&(T(c),a.firstPageLoaded=
-c+1,A(a.firstPageLoaded,b)):p(c)&&y(c)&&(T(c),a.lastPageLoaded=c-1,A(a.lastPageLoaded,b))},B=function(c){return 0<=c&&c<a.numRows},I=function(c){c*=a.rowHeight;return u(c,c+a.rowHeight+a.fixedPadding)},G=function(c){if(!document.getElementById(a.ID+"row-"+c)){var b=a.rowHeight*c+a.fixedPadding,d=document.getElementById(a.ID+"inner"),e=document.createElement("div");e.id=a.ID+"row-"+c;e.classList.add("diva-row");e.style.height=a.rowHeight+"px";e.style.top=b+"px";d.appendChild(e);for(var f,m,h,k,x,H,
-F=a.imageDir+"/",n=a.pagesPerRow,d=0;d<n;d++){f=c*a.pagesPerRow+d;if(!p(f))break;m=a.pages[f].f;h=l(f,"w");k=l(f,"h");x=a.fixedHeightGrid?(a.rowHeight-a.fixedPadding)*h/k:a.gridPageWidth;h=a.fixedHeightGrid?a.rowHeight-a.fixedPadding:x/h*k;k=parseInt(d*(a.fixedPadding+a.gridPageWidth)+a.fixedPadding,10);x=parseInt(x,10);h=parseInt(h,10);k+=a.fixedHeightGrid?(a.gridPageWidth-x)/2:0;H=encodeURI(a.iipServerURL+"?FIF="+F+m+"&HEI="+(h+2)+"&CVT=JPEG");a.pageTopOffsets[f]=b;a.pageLeftOffsets[f]=k;var z=
-document.createElement("div");z.id=a.ID+"page-"+f;var w=a.selector+"page-"+f;z.classList.add("diva-page");z.style.width=x+"px";z.style.height=h+"px";z.style.left=k+"px";z.setAttribute("data-index",f);z.setAttribute("data-filename",m);z.title="Page "+(f+1);e.appendChild(z);diva.Events.publish("PageWillLoad",[f,m,w],g);X(c,f,H,x,h)}}},M=function(c){c=document.getElementById(a.ID+"row-"+c);if(null!==c){for(;c.firstChild;)c.removeChild(c.firstChild);c.parentNode.removeChild(c)}},m=function(c){c=a.rowHeight*
-(c+1);var b=document.getElementById(a.ID+"outer").scrollTop;return c<b},x=function(c){c*=a.rowHeight;var b=document.getElementById(a.ID+"outer").scrollTop+a.panelHeight;return c>b},F=function(c,b){0<b?B(c)&&(I(c)?(G(c),a.lastRowLoaded=c,F(a.lastRowLoaded+1,b)):m(c)&&F(c+1,b)):B(c)&&(I(c)?(G(c),a.firstRowLoaded=c,F(a.firstRowLoaded-1,b)):x(c)&&F(c-1,b))},H=function(c,b){0<b?B(c)&&m(c)&&(M(c),a.firstRowLoaded++,H(a.firstRowLoaded,b)):B(c)&&x(c)&&(M(c),a.lastRowLoaded--,H(a.lastRowLoaded,b))},X=function(c,
-b,d,e,f){a.pageTimeouts.push(window.setTimeout(function(c,b,d,e,f){I(c)&&(c=document.createElement("img"),c.src=d,c.style.width=e+"px",c.style.height=f+"px",document.getElementById(a.ID+"page-"+b).appendChild(c))},a.rowLoadTimeout,c,b,d,e,f))},K=function(c){var b=a.currentPageIndex,d=b+c;if(!p(d))return!1;var e=a.verticallyOriented?document.getElementById(a.ID+"outer").scrollTop+a.panelHeight/2:document.getElementById(a.ID+"outer").scrollLeft+a.panelWidth/2,f=!1;0>c?a.verticallyOriented?0<=d&&a.pageTopOffsets[d]+
-l(d,"h")+a.verticalPadding>=e&&(f=!0):0<=d&&a.pageLeftOffsets[d]+l(d,"w")+a.horizontalPadding>=e&&(f=!0):0<c&&(a.verticallyOriented?a.pageTopOffsets[b]+l(b,"h")+a.verticalPadding<e&&(f=!0):a.pageLeftOffsets[b]+l(b,"w")+a.horizontalPadding<e&&(f=!0));return f?(a.currentPageIndex=d,0===c||K(c)||(c=a.pages[d].f,h(a.onSetCurrentPage,d,c),diva.Events.publish("VisiblePageDidChange",[d,c],g)),!0):!1},O=function(c){var b=Math.floor(a.currentPageIndex/a.pagesPerRow),d=b+parseInt(c,10),e=document.getElementById(a.ID+
-"outer").scrollTop,f=e+a.panelHeight/2,m=!1;0>c?0<=d&&(a.rowHeight*b>=f||a.rowHeight*d>=e)&&(m=!0):0<c&&a.rowHeight*(b+1)<e&&B(d)&&(m=!0);return m?(a.currentPageIndex=d*a.pagesPerRow,0===c||O(c)||(c=a.currentPageIndex,diva.Events.publish("VisiblePageDidChange",[c,a.pages[c].f],g)),!0):!1},J=function(c,b,d){d="undefined"!==typeof d?d:0;b=a.pageTopOffsets[c]+("undefined"!==typeof b?b:0)-parseInt(a.panelHeight/2,10);d=a.pageLeftOffsets[c]+d-parseInt(a.panelWidth/2,10);a.outerObject.scrollTop(b);a.outerObject.scrollLeft(d);
-c!==a.currentPageIndex&&(a.currentPageIndex=c,d=a.pages[c].f,h(a.onSetCurrentPage,c,d),diva.Events.publish("VisiblePageDidChange",[c,d],g));h(a.onJump,c);diva.Events.publish("ViewerDidJump",[c],g)},z=function(c){a.outerObject.scrollTop(Math.floor(c/a.pagesPerRow)*a.rowHeight);a.currentPageIndex=c;diva.Events.publish("VisiblePageDidChange",[c,a.pages[c].f],g)},w=function(c){return c>=a.minZoomLevel&&c<=a.maxZoomLevel?c:a.minZoomLevel},ha=function(c){return c>=a.minPagesPerRow&&c<=a.maxPagesPerRow?
-c:a.maxPagesPerRow},ia=function(){a.allTilesLoaded=[];a.outerObject.scrollTop(0);a.innerObject.empty();a.firstPageLoaded=0;a.firstRowLoaded=-1;a.previousTopScroll=0;a.previousLeftScroll=0;for(clearTimeout(a.resizeTimer);a.pageTimeouts.length;)clearTimeout(a.pageTimeouts.pop())},P=function(){a.inGrid?ja():aa()},aa=function(){ia();a.zoomLevel=w(a.zoomLevel);var c=a.zoomLevel;a.totalHeight=a.totalHeights[c]+a.verticalPadding*(a.numPages+1);a.totalWidth=a.totalWidths[c]+a.horizontalPadding*(a.numPages+
-1);var b=a.maxHeights[c]+2*a.verticalPadding,d=Math.max(a.maxWidths[c]+2*a.horizontalPadding,a.panelWidth),b=Math.max(b,a.panelHeight),e=document.getElementById(a.ID+"inner");a.verticallyOriented?(e.style.height=Math.round(a.totalHeight)+"px",e.style.width=Math.round(d)+"px"):(e.style.height=Math.round(b)+"px",e.style.width=Math.round(a.totalWidth)+"px");var f=0,m=0;a.pageTopOffsets=[];a.pageLeftOffsets=[];for(e=0;e<a.numPages;e++)a.pageTopOffsets[e]=parseInt(a.verticallyOriented?f:(b-l(e,"h"))/2,
-10),a.pageLeftOffsets[e]=parseInt(a.verticallyOriented?(d-l(e,"w"))/2:m,10),f=a.pageTopOffsets[e]+l(e,"h")+a.verticalPadding,m=a.pageLeftOffsets[e]+l(e,"w")+a.horizontalPadding;p(a.goDirectlyTo)||(a.goDirectlyTo=0);J(a.goDirectlyTo,a.verticalOffset,a.horizontalOffset);d=!1;for(e=0;e<a.numPages;e++)if(r(e))k(e),a.lastPageLoaded=e,d=!0;else if(d)break;0<=a.oldZoomLevel?(a.oldZoomLevel<a.zoomLevel?(h(a.onZoomIn,c),diva.Events.publish("ViewerDidZoomIn",[c],g)):(h(a.onZoomOut,c),diva.Events.publish("ViewerDidZoomOut",
-[c],g)),h(a.onZoom,c)):a.oldZoomLevel=a.zoomLevel;a.scaleWait&&(a.scaleWait=!1);c=a.pages[a.currentPageIndex].f;h(a.onDocumentLoaded,a.currentPageIndex,c);diva.Events.publish("DocumentDidLoad",[a.currentPageIndex,c],g)},ja=function(){var c=a.currentPageIndex;a.verticalOffset=a.verticallyOriented?a.panelHeight/2:l(c,"h")/2;a.horizontalOffset=a.verticallyOriented?l(c,"w")/2:a.panelWidth/2;ia();a.pagesPerRow=ha(a.pagesPerRow);c=(a.panelWidth-a.fixedPadding*(a.pagesPerRow+1))/a.pagesPerRow;a.gridPageWidth=
-c;a.rowHeight=a.fixedHeightGrid?a.fixedPadding+a.minRatio*c:a.fixedPadding+a.maxRatio*c;a.numRows=Math.ceil(a.numPages/a.pagesPerRow);a.totalHeight=a.numRows*a.rowHeight+a.fixedPadding;c=document.getElementById(a.ID+"inner");c.style.height=Math.round(a.totalHeight)+"px";c.style.width=Math.round(a.panelWidth)+"px";z(a.goDirectlyTo);var b;a.pageTopOffsets=[];a.pageLeftOffsets=[];for(var d=a.numPages,c=0;c<d;c+=a.pagesPerRow)b=Math.floor(c/a.pagesPerRow),I(b)&&(a.firstRowLoaded=0>a.firstRowLoaded?b:
-a.firstRowLoaded,G(b),a.lastRowLoaded=b)},ka=function(a){27==a.keyCode&&C()},ba=function(c){a.outerObject.toggleClass("diva-fullscreen");b("body").toggleClass("diva-hide-scrollbar");a.parentObject.toggleClass("diva-full-width");if(a.mobileWebkit){var d=parseInt(a.outerObject.css("margin-left"),10)-parseInt(b("body").css("margin-left"),10);a.outerObject.css("margin-left",d)}var d=a.panelHeight,e=a.panelWidth;Q();if(0<=a.oldZoomLevel&&!a.inGrid){var f=a.panelHeight,m=a.panelWidth;a.inFullscreen?(a.verticalOffset-=
-(f-d)/2,a.horizontalOffset-=(m-e)/2):(a.verticalOffset+=(d-f)/2,a.horizontalOffset+=(e-m)/2)}c?(a.inGrid=!a.inGrid,D()):P();if(a.inFullscreen)b(document).on("keyup",ka);else b(document).off("keyup",ka);h(a.onModeToggle,a.inFullscreen);diva.Events.publish("ModeDidSwitch",[a.inFullscreen],g)},D=function(){P();h(a.onViewToggle,a.inGrid);diva.Events.publish("ViewDidSwitch",[a.inGrid],g)},C=function(){a.goDirectlyTo=a.currentPageIndex;a.inFullscreen=!a.inFullscreen;ba(!1)},E=function(){a.goDirectlyTo=
-a.currentPageIndex;a.inGrid=!a.inGrid;D()},ca=function(c){var d=b(this).offset();a.doubleClickZoom=!0;a.horizontalOffset=c.pageX-d.left;a.verticalOffset=c.pageY-d.top;a.goDirectlyTo=parseInt(b(this).attr("data-index"),10);N(c.ctrlKey?a.zoomLevel-1:a.zoomLevel+1)},la=function(c){var d=parseInt(b(this).attr("data-index"),10);a.goDirectlyTo=d;var e=b(this).offset(),d=l(d,"w")/b(this).width();a.horizontalOffset=(c.pageX-e.left)*d;a.verticalOffset=(c.pageY-e.top)*d;a.inGrid=!1;D()},N=function(c){var b=
-w(c);if(b!==c)return!1;c=Math.pow(2,b-a.zoomLevel);a.doubleClickZoom?(a.verticalOffset*=c,a.horizontalOffset*=c,a.doubleClickZoom=!1):(a.goDirectlyTo=a.currentPageIndex,a.verticalOffset=c*V(),a.horizontalOffset=c*W());a.oldZoomLevel=a.zoomLevel;a.zoomLevel=b;diva.Events.publish("ZoomLevelDidChange",[b],g);aa();return!0},Z=function(c){var b=ha(c);if(b!==c)return!1;a.pagesPerRow=b;diva.Events.publish("GridRowNumberDidChange",[b],g);a.goDirectlyTo=a.currentPageIndex;ja();return!0},R=function(c,b){c=
-"undefined"===typeof c?a.currentPageIndex:c;return"center"===b||"centre"===b?parseInt(l(c,"h")/2,10):"bottom"===b?parseInt(l(c,"h")-a.panelHeight/2,10):parseInt(a.panelHeight/2,10)},S=function(c,b){c="undefined"===typeof c?a.currentPageIndex:c;return"left"===b?parseInt(a.panelWidth/2,10):"right"===b?parseInt(l(c,"w")-a.panelWidth/2,10):parseInt(l(c,"w")/2,10)},V=function(){return document.getElementById(a.ID+"outer").scrollTop-a.pageTopOffsets[a.currentPageIndex]+parseInt(a.panelHeight/2,10)},W=function(){return document.getElementById(a.ID+
-"outer").scrollLeft-a.pageLeftOffsets[a.currentPageIndex]+parseInt(a.panelWidth/2,10)},ma=function(){return{f:a.inFullscreen,g:a.inGrid,z:a.zoomLevel,n:a.pagesPerRow,i:a.enableFilename?a.pages[a.currentPageIndex].f:!1,p:a.enableFilename?!1:a.currentPageIndex+1,y:a.inGrid?!1:V(),x:a.inGrid?!1:W()}},na=function(){var c=ma(),b=[],d;for(d in c)!1!==c[d]&&b.push(d+a.hashParamSuffix+"="+c[d]);return b.join("&")},oa=function(){return location.protocol+"//"+location.host+location.pathname+"#"+na()},Q=function(){var c=
-document.getElementById(a.ID+"outer");a.panelHeight=c.clientHeight-(c.scrollWidth>c.clientWidth?a.scrollbarWidth:0);a.panelWidth=c.clientWidth-(c.scrollHeight>c.clientHeight?a.scrollbarWidth:0);a.horizontalOffset=W();a.verticalOffset=V();J(a.currentPageIndex,a.verticalOffset,a.horizontalOffset);return!0},pa=function(){a.mobileWebkit||(a.outerObject.dragscrollable({dragSelector:".diva-dragger",acceptPropagatedEvent:!0}),a.innerObject.dragscrollable({dragSelector:".diva-dragger",acceptPropagatedEvent:!0}));
-a.outerObject.on("dblclick",".diva-document-page",function(a){ca.call(this,a)});a.outerObject.on("contextmenu",".diva-document-page",function(c){if(c.ctrlKey)return clearTimeout(a.singleClickTimeout),a.singleClick?(ca.call(this,c),a.singleClick=!1):(a.singleClick=!0,a.singleClickTimeout=setTimeout(function(){a.singleClick=!1},500)),!1});a.outerObject.on("dblclick",".diva-row",function(a){la.call(b(a.target).parent(),a)})},da=function(a,b,d,e){return Math.sqrt((a-b)*(a-b)+(d-e)*(d-e))},sa=function(){a.innerObject.mouseover(function(){b(this).removeClass("diva-grabbing").addClass("diva-grab")});
-a.innerObject.mouseout(function(){b(this).removeClass("diva-grab")});a.innerObject.mousedown(function(){b(this).removeClass("diva-grab").addClass("diva-grabbing")});a.innerObject.mouseup(function(){b(this).removeClass("diva-grabbing").addClass("diva-grab")});pa();a.outerObject.scroll(function(){var c,b=document.getElementById(a.ID+"outer").scrollTop,d=document.getElementById(a.ID+"outer").scrollLeft;c=a.verticallyOriented||a.inGrid?b-a.previousTopScroll:d-a.previousLeftScroll;if(a.inGrid){0>c?(F(a.firstRowLoaded,
--1),O(-1),H(a.lastRowLoaded,-1)):0<c&&(F(a.lastRowLoaded,1),O(1),H(a.firstRowLoaded,1));var e=document.getElementById(a.ID+"outer").scrollTop}else{if(0>c)v(a.firstPageLoaded,c),K(-1),A(a.lastPageLoaded,c);else if(0<c)v(a.lastPageLoaded,c),K(1),A(a.firstPageLoaded,c);else for(var f=a.lastPageLoaded,e=Math.max(a.firstPageLoaded,0);e<=f;e++)r(e)&&k(e);e=a.verticallyOriented?document.getElementById(a.ID+"outer").scrollTop:document.getElementById(a.ID+"outer").scrollLeft}h(a.onScroll,e);diva.Events.publish("ViewerDidScroll",
-[e],g);0<c?(h(a.onScrollDown,e),diva.Events.publish("ViewerDidScrollDown",[e],g)):0>c&&(h(a.onScrollUp,e),diva.Events.publish("ViewerDidScrollUp",[e],g));a.previousTopScroll=b;a.previousLeftScroll=d;a.horizontalOffset=W();a.verticalOffset=V()});b(document).keydown(function(c){if(!a.isActiveDiva)return!0;if(a.enableSpaceScroll&&!c.shiftKey&&32===c.keyCode||a.enableKeyScroll&&34===c.keyCode)return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop+a.panelHeight),!1;a.enableSpaceScroll||
-32!==c.keyCode||c.preventDefault();if(a.enableKeyScroll)switch(c.keyCode){case 33:return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop-a.panelHeight),!1;case 38:return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop-a.arrowScrollAmount),!1;case 40:return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop+a.arrowScrollAmount),!1;case 37:return a.outerObject.scrollLeft(document.getElementById(a.ID+"outer").scrollLeft-a.arrowScrollAmount),
-!1;case 39:return a.outerObject.scrollLeft(document.getElementById(a.ID+"outer").scrollLeft+a.arrowScrollAmount),!1;case 36:return a.outerObject.scrollTop(0),!1;case 35:return a.outerObject.scrollTop(a.totalHeight),!1}return!0});if(a.mobileWebkit){var c=[];c.push('<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" />');c.push('<meta name="apple-mobile-web-app-capable" content="yes" />');c.push('<meta name="apple-mobile-web-app-status-bar-style" content="black" />');
-b("head").append(c.join("\n"));a.blockMobileMove&&b("body").bind("touchmove",function(a){a.originalEvent.preventDefault();return!1});a.outerObject.kinetic({triggerHardware:!0});var d=[],e=[],f=0;a.outerObject.on("touchstart",".diva-document-page",function(a){2===a.originalEvent.touches.length&&(d=[a.originalEvent.touches[0].clientX,a.originalEvent.touches[0].clientY,a.originalEvent.touches[1].clientX,a.originalEvent.touches[1].clientY],f=da(d[2],d[0],d[3],d[1]))});a.outerObject.on("touchmove",".diva-document-page",
-function(c){if(2===c.originalEvent.touches.length){e=[c.originalEvent.touches[0].clientX,c.originalEvent.touches[0].clientY,c.originalEvent.touches[1].clientX,c.originalEvent.touches[1].clientY];var d=da(e[2],e[0],e[3],e[1])-f;if(!a.scaleWait)if(a.goDirectlyTo=a.currentPageIndex,a.inGrid)a.inGrid=!1,D();else a:{var m=a.zoomLevel;if(100<d&&m<a.maxZoomLevel)m++;else if(-100>d&&m>a.minZoomLevel)m--;else break a;a.scaleWait=!0;d=b(this).offset();a.horizontalOffset=c.pageX-d.left;a.verticalOffset=c.pageY-
-d.top;a.goDirectlyTo=parseInt(b(this).attr("data-index"),10);N(m)}}});var m={},x=0,c=function(c){if(a.singleTap){var d={pageX:c.originalEvent.changedTouches[0].clientX,pageY:c.originalEvent.changedTouches[0].clientY};x=da(m.pageX,d.pageX,m.pageY,d.pageY);50>x&&a.zoomLevel<a.maxZoomLevel&&(a.inGrid?la.call(b(c.target).parent(),d):ca.call(this,d));a.singleTap=!1;m={}}else a.singleTap=!0,m.pageX=c.originalEvent.changedTouches[0].clientX,m.pageY=c.originalEvent.changedTouches[0].clientY,a.singleTapTimeout=
-setTimeout(function(){a.singleTap=!1;m={}},250)};a.outerObject.on("touchend",".diva-document-page",c);a.outerObject.on("touchend",".diva-page",c);c="onorientationchange"in window?"orientationchange":"resize";b(window).bind(c,function(c){c=a.panelWidth;var b=a.panelHeight;Q();a.horizontalOffset-=(a.panelWidth-c)/2;a.verticalOffset-=(a.panelHeight-b)/2;a.goDirectlyTo=a.currentPageIndex;P()})}else b(window).resize(function(){Q();clearTimeout(a.resizeTimer);a.resizeTimer=setTimeout(function(){a.goDirectlyTo=
-a.currentPageIndex;a.verticalOffset=V();a.horizontalOffset=W();P()},200)});diva.Events.subscribe("PanelSizeDidChange",Q)},ta=function(){a.toolbarParentObject.prepend('<div id="'+a.ID+'tools" class="diva-tools">'+('<div id="'+a.ID+'tools-left" class="diva-tools-left">'+("slider"===a.enableZoomControls?'<input type="range" id="'+a.ID+'zoom-slider" class="zoom-slider" value="'+a.zoomLevel+'" min="'+a.minZoomLevel+'" max="'+a.maxZoomLevel+'">':"")+("buttons"===a.enableZoomControls?'<div id="'+a.ID+'zoom-out-button" class="diva-zoom-out-button button" title="Zoom Out"></div><div id="'+
-a.ID+'zoom-in-button" class="diva-zoom-in-button button" title="Zoom In"></div>':"")+("slider"===a.enableGridControls?'<input type="range" id="'+a.ID+'grid-slider" class="grid-slider" value="'+a.pagesPerRow+'" min="'+a.minPagesPerRow+'" max="'+a.maxPagesPerRow+'">':"")+("buttons"===a.enableGridControls?'<div id="'+a.ID+'grid-out-button" class="diva-grid-out-button button" title="Zoom Out"></div><div id="'+a.ID+'grid-in-button" class="diva-grid-in-button button" title="Zoom In"></div>':"")+("slider"===
-a.enableZoomControls?'<div id="'+a.ID+'zoom-slider-label" class="diva-slider-label">Zoom level: <span id="'+a.ID+'zoom-level">'+a.zoomLevel+"</span></div>":"")+("buttons"===a.enableZoomControls?'<div id="'+a.ID+'zoom-buttons-label" class="diva-buttons-label">Zoom level: <span id="'+a.ID+'zoom-level">'+a.zoomLevel+"</span></div>":"")+("slider"===a.enableGridControls?'<div id="'+a.ID+'grid-slider-label" class="diva-slider-label">Pages per row: <span id="'+a.ID+'pages-per-row">'+a.pagesPerRow+"</span></div>":
-"")+("buttons"===a.enableGridControls?'<div id="'+a.ID+'grid-buttons-label" class="diva-buttons-label">Pages per row: <span id="'+a.ID+'pages-per-row">'+a.pagesPerRow+"</span></div>":"")+'</div><div id="'+a.ID+'tools-right" class="diva-tools-right">'+(a.enableFullscreen?'<div id="'+a.ID+'fullscreen" class="diva-fullscreen-icon button" title="Toggle fullscreen mode"></div>':"")+(a.enableLinkIcon?'<div class="diva-link-icon button" id="'+a.ID+'link-icon" style="'+(a.enableGridIcon?"border-left: 0px":
-"")+'" title="Link to this page"></div>':"")+(a.enableGridIcon?'<div class="diva-grid-icon button'+(a.inGrid?" diva-in-grid":"")+'" id="'+a.ID+'grid-icon" title="Toggle grid view"></div>':"")+'<div id="'+a.ID+'page-nav" class="diva-page-nav">'+(a.enableGotoPage?'<form id="'+a.ID+'goto-page" class="diva-goto-form"><input type="text" id="'+a.ID+'goto-page-input" / class="diva-input"> <input type="submit" value="Go" style="margin-top: 0px;" /></form>':"")+('<div class="diva-page-label">Page <span id="'+
-a.ID+'current-page">1</span> of <span id="'+a.ID+'num-pages">'+a.numPages+"</span></div>")+"</div></div>")+"</div>");b(a.selector+"zoom-slider").on("input",function(a){a=parseInt(this.value,10);N(a)});b(a.selector+"zoom-slider").on("change",function(c){c=parseInt(this.value,10);c!==a.zoomLevel&&N(c)});b(a.selector+"zoom-out-button").click(function(){N(a.zoomLevel+-1)});b(a.selector+"zoom-in-button").click(function(){N(a.zoomLevel+1)});b(a.selector+"grid-slider").on("input",function(a){a=parseInt(this.value,
-10);Z(a)});b(a.selector+"grid-slider").on("change",function(c){c=parseInt(this.value,10);c!==a.zoomLevel&&Z(c)});b(a.selector+"fullscreen").click(function(){C()});b(a.selector+"grid-out-button").click(function(){Z(a.pagesPerRow-1)});b(a.selector+"grid-in-button").click(function(){Z(a.pagesPerRow+1)});b(a.selector+"grid-icon").click(function(){E()});b(a.selector+"goto-page").submit(function(){var c=parseInt(b(a.selector+"goto-page-input").val(),10)-1;if(p(c))if(a.inGrid)z(c);else{var d=R(c,"top"),
-e=S(c,"center");J(c,d,e)}else alert("Invalid page number");return!1});b(a.selector+"link-icon").click(function(){b("body").prepend('<div id="'+a.ID+'link-popup" class="diva-popup diva-link-popup"><input id="'+a.ID+'link-popup-input" class="diva-input" type="text" value="'+oa()+'"/></div>');if(a.inFullscreen)b(a.selector+"link-popup").addClass("in-fullscreen");else{var c=a.outerObject.offset().left+a.panelWidth,c=c+(a.scrollbarWidth-240-1),d=a.outerObject.offset().top+1;b(a.selector+"link-popup").removeClass("in-fullscreen").css({top:d+
-"px",left:c+"px"})}b("body").mouseup(function(c){c=c.target.id;c!==a.ID+"link-popup"&&c!==a.ID+"link-popup-input"&&b(a.selector+"link-popup").remove()});a.outerObject.scroll(function(){b(a.selector+"link-popup").remove()});b(a.selector+"link-popup input").click(function(){b(this).focus().select()});return!1});var c=a.inGrid?"grid":"zoom";b(a.selector+c+"-slider").show();b(a.selector+c+"-out-button").show();b(a.selector+c+"-in-button").show();b(a.selector+c+"-slider-label").show();b(a.selector+c+"-buttons-label").show();
-return{updateCurrentPage:function(){document.getElementById(a.ID+"current-page").textContent=a.currentPageIndex+1},setNumPages:function(c){document.getElementById(a.ID+"num-pages").textContent=c},updateZoomSlider:function(){a.zoomLevel!==b(a.selector+"zoom-slider").val()&&b(a.selector+"zoom-slider").val(a.zoomLevel);document.getElementById(a.ID+"zoom-level").textContent=a.zoomLevel},updateZoomButtons:function(){document.getElementById(a.ID+"zoom-level").textContent=a.zoomLevel},updateGridSlider:function(){a.pagesPerRow!==
-b(a.selector+"grid-slider").val()&&b(a.selector+"grid-slider").val(a.pagesPerRow);document.getElementById(a.ID+"pages-per-row").textContent=a.pagesPerRow},updateGridButtons:function(){document.getElementById(a.ID+"pages-per-row").textContent=a.pagesPerRow},closePopups:function(){b(".diva-popup").css("display","none")},switchView:function(){b(a.selector+c+"-slider").hide();b(a.selector+c+"-out-button").hide();b(a.selector+c+"-in-button").hide();b(a.selector+c+"-slider-label").hide();b(a.selector+c+
-"-buttons-label").hide();c=a.inGrid?"grid":"zoom";b(a.selector+c+"-slider").show();b(a.selector+c+"-out-button").show();b(a.selector+c+"-in-button").show();b(a.selector+c+"-slider-label").show();b(a.selector+c+"-buttons-label").show();b(a.selector+"grid-icon").toggleClass("diva-in-grid")},switchMode:function(){b(a.selector+"tools").toggleClass("diva-fullscreen-tools");a.inFullscreen?b(a.selector+"tools-left").addClass("in-fullscreen"):b(a.selector+"tools-left").removeClass("in-fullscreen")}}},ua=
-function(){if(window.divaPlugins){var c=[];b.each(window.divaPlugins,function(b,d){var e=d.pluginName[0].toUpperCase()+d.pluginName.substring(1);a["enable"+e]&&d.init(a,g)&&(e=d.titleText||e+" plugin","function"===typeof d.handleClick&&(c.push('<div class="diva-'+d.pluginName+'-icon" title="'+e+'"></div>'),a.outerObject.on(a.mobileWebkit?"touchend":"click",".diva-"+d.pluginName+"-icon",function(c){d.handleClick.call(this,c,a,g)})),a.plugins.push(d))});c.length&&(a.pageTools='<div class="diva-page-tools">'+
-c.join("")+"</div>")}},qa=function(){clearTimeout(a.throbberTimeoutID);b(a.selector+"throbber").hide()},va=function(){a.outerObject.append('<div id="'+a.ID+'throbber" class="diva-throbber"></div>');a.throbberTimeoutID=setTimeout(function(){b(a.selector+"throbber").show()},a.throbberTimeout);b.ajax({url:a.objectData,cache:!0,dataType:"json",error:function(c,b,d){qa();c='<div id="'+a.ID+'error" class="diva-error"><p><strong>Error</strong></p><p>Invalid objectData. Error code: '+b+" "+d+"</p>";0===a.objectData.lastIndexOf("http",
-0)&&""===d&&(d=a.objectData.replace(/https?:\/\//i,"").split(/[/?#]/)[0],location.hostname!==d&&(c+='<p>Attempted to access cross-origin data without CORS.</p><p>You may need to update your server configuration to support CORS. For help, see the <a href="https://github.com/DDMAL/diva.js/wiki/Installation#a-note-about-cross-site-requests" target="_blank">cross-site request documentation.</a></p>'));a.outerObject.append(c+"</div>")},success:function(c,d,e){qa();a.pages=c.pgs;a.maxRatio=c.dims.max_ratio;
-a.minRatio=c.dims.min_ratio;a.itemTitle=c.item_title;a.numPages=c.pgs.length;a.maxWidths=c.dims.max_w;a.maxHeights=c.dims.max_h;a.averageWidths=c.dims.a_wid;a.averageHeights=c.dims.a_hei;a.totalHeights=c.dims.t_hei;a.totalWidths=c.dims.t_wid;a.realMaxZoom=c.max_zoom;a.maxZoomLevel=0<=a.maxZoomLevel&&a.maxZoomLevel<=c.max_zoom?a.maxZoomLevel:c.max_zoom;a.minZoomLevel=0<=a.minZoomLevel&&a.minZoomLevel<=a.maxZoomLevel?a.minZoomLevel:0;a.zoomLevel=w(a.zoomLevel);a.minPagesPerRow=Math.max(2,a.minPagesPerRow);
-a.maxPagesPerRow=Math.max(a.minPagesPerRow,a.maxPagesPerRow);a.enableFilename?(c=b.getHashParam("i"+a.hashParamSuffix),c=n(c)):c=parseInt(b.getHashParam("p"+a.hashParamSuffix),10)-1;p(c)&&(a.goDirectlyTo=c,a.currentPageIndex=c);b.each(a.plugins,function(c,b){h(b.setupHook,a)});a.enableToolbar&&(a.toolbar=ta(),diva.Events.subscribe("VisiblePageDidChange",a.toolbar.updateCurrentPage),diva.Events.subscribe("ModeDidSwitch",a.toolbar.switchMode),diva.Events.subscribe("ViewDidSwitch",a.toolbar.switchView),
-diva.Events.subscribe("ZoomLevelDidChange",a.toolbar.updateZoomSlider),diva.Events.subscribe("ZoomLevelDidChange",a.toolbar.updateZoomButtons),diva.Events.subscribe("GridRowNumberDidChange",a.toolbar.updateGridSlider),diva.Events.subscribe("ZoomLevelDidChange",a.toolbar.updateGridButtons),diva.Events.subscribe("ClosePopups",a.toolbar.closePopups));b(a.selector+"current label").text(a.numPages);a.enableAutoTitle&&a.parentObject.prepend('<div id="'+a.ID+'title" class="diva-title">'+a.itemTitle+"</div>");
-a.parentObject.parent()[0]!==document.body||a.parentObject.siblings().not("#diva-canvas-backdrop")[0]||(a.divaIsFullWindow=!0);Q();p(parseInt(a.goDirectlyTo),10)||(a.goDirectlyTo=0);0<a.adaptivePadding?(c=a.zoomLevel,a.horizontalPadding=parseInt(a.averageWidths[c]*a.adaptivePadding,10),a.verticalPadding=parseInt(a.averageHeights[c]*a.adaptivePadding,10)):(a.horizontalPadding=a.fixedPadding,a.verticalPadding=a.fixedPadding);a.pageTools.length&&(a.verticalPadding=Math.max(40,a.verticalPadding));c=parseInt(b.getHashParam("y"+
-a.hashParamSuffix),10);isNaN(c)?a.verticalOffset=R(a.currentPageIndex,"top"):a.verticalOffset=c;c=parseInt(b.getHashParam("x"+a.hashParamSuffix),10);isNaN(c)?a.horizontalOffset=S(a.currentPageIndex,"center"):a.horizontalOffset=c;a.inFullscreen?ba(!1):P();Q();h(a.onReady,a);diva.Events.publish("ViewerDidLoad",[a],g);a.loaded=!0}})},ea=function(){return a.loaded?!0:(console.warn("The viewer is not completely initialized. This is likely because it is still downloading data. To fix this, only call this function if the isReady() method returns true."),
-!1)};(function(){a.scrollbarWidth=b.getScrollbarWidth();a.mobileWebkit=void 0!==window.orientation;a.ID=b.generateId("diva-");a.selector="#"+a.ID;var c=parseInt(a.ID,10);1<c&&(a.hashParamSuffix=c);a.parentObject.append('<div id="'+a.ID+'outer" class="diva-outer"></div>');a.outerObject=b(a.selector+"outer");a.outerObject.append('<div id="'+a.ID+'inner" class="diva-inner diva-dragger"></div>');a.innerObject=b(a.selector+"inner");c=parseInt(b.getHashParam("n"+a.hashParamSuffix),10);c>=a.minPagesPerRow&&
-c<=a.maxPagesPerRow&&(a.pagesPerRow=c);c=b.getHashParam("z"+a.hashParamSuffix);""!==c&&(c=parseInt(c,10),c>=a.minZoomLevel&&(a.zoomLevel=c));var c=b.getHashParam("g"+a.hashParamSuffix),d="true"===c,e=b.getHashParam("f"+a.hashParamSuffix);a.inGrid=a.inGrid&&"false"!==c||d;a.inFullscreen=a.inFullscreen&&"false"!==e||"true"===e;va();ua();sa()})();this.getItemTitle=function(){return a.itemTitle};this.gotoPageByNumber=function(a,b,d){--a;return p(a)?(J(a,R(a,d),S(a,b)),!0):!1};this.gotoPageByIndex=function(a,
-b,d){return p(a)?(J(a,R(a,d),S(a,b)),!0):!1};this.getCurrentPage=function(){console.warn("The call to getCurrentPage is deprecated. Use getCurrentPageIndex instead.");return a.currentPageIndex};this.getNumberOfPages=function(){return ea()?a.numPages:!1};this.getPageDimensionsAtZoomLevel=function(c,b){if(!ea())return!1;b>a.maxZoomLevel&&(b=a.maxZoomLevel);var d=a.pages[c].d[parseInt(b,10)];return{width:d.w,height:d.h}};this.getCurrentPageDimensionsAtCurrentZoomLevel=function(){return this.getPageDimensionsAtZoomLevel(a.currentPageIndex,
-a.zoomLevel)};this.isReady=function(){return a.loaded};this.getCurrentPageIndex=function(){return a.currentPageIndex};this.getCurrentPageFilename=function(){return a.pages[a.currentPageIndex].f};this.getCurrentPageNumber=function(){return a.currentPageIndex+1};this.getFilenames=function(){for(var c=[],b=0;b<a.numPages;b++)c[b]=a.pages[b].f;return c};this.getZoomLevel=function(){return a.zoomLevel};this.getMaxZoomLevel=function(){return a.maxZoomLevel};this.getMaxZoomLevelForPage=function(c){return ea?
-a.pages[c].m:!1};this.getMinZoomLevel=function(){return a.minZoomLevel};this.setZoomLevel=function(c){a.inGrid&&E();return N(c)};this.zoomIn=function(){return this.setZoomLevel(a.zoomLevel+1)};this.zoomOut=function(){return this.setZoomLevel(a.zoomLevel-1)};this.inViewport=function(c,b,d,e,f){--c;d=a.pageTopOffsets[c]+d;b=a.pageLeftOffsets[c]+b;e=b+e;return u(d,d+f)&&t(b,e)};this.isPageInViewport=function(a){return r(a)};this.isPageInDOM=function(a){return q(a)};this.toggleFullscreenMode=function(){C()};
-this.enterFullscreenMode=function(){return a.inFullscreen?!1:(C(),!0)};this.leaveFullscreenMode=function(){return a.inFullscreen?(C(),!0):!1};this.toggleGridView=function(){E()};this.enterGridView=function(){return a.inGrid?!1:(E(),!0)};this.leaveGridView=function(){return a.inGrid?(E(),!0):!1};this.gotoPageByName=function(a,b,d){a=n(a);return p(a)?(J(a,R(a,d),S(a,b)),!0):!1};this.getPageIndex=function(a){return n(a)};this.getCurrentURL=function(){return oa()};this.getURLHash=function(){return na()};
-this.getState=function(){return ma()};this.getInstanceSelector=function(){return a.selector};this.getInstanceId=function(){return a.ID};this.getSettings=function(){return a};this.translateFromMaxZoomLevel=function(c){return c/Math.pow(2,a.maxZoomLevel-a.zoomLevel)};this.translateToMaxZoomLevel=function(c){var b=a.maxZoomLevel-a.zoomLevel;return 0===b?c:c*Math.pow(2,b)};this.setState=function(c){var b;b=n(c.i);p(b)?a.goDirectlyTo=b:p(c.p)&&(a.goDirectlyTo=c.p);horizontalOffset=parseInt(c.x,10);verticalOffset=
-parseInt(c.y,10);c.z>=a.minZoomLevel&&c.z<=a.maxZoomLevel&&(a.zoomLevel=c.z);c.n>=a.minPagesPerRow&&c.n<=a.maxPagesPerRow&&(a.pagesPerRow=c.n);a.inFullscreen!==c.f?(a.inFullscreen=c.f,ba(a.inGrid!==c.g),a.horizontalOffset=horizontalOffset,a.verticalOffset=verticalOffset,J(b,a.verticalOffset,a.horizontalOffset)):(a.horizontalOffset=horizontalOffset,a.verticalOffset=verticalOffset,a.inGrid!==c.g?(a.inGrid=c.g,D()):P())};this.enableScrollable=function(){a.isScrollable||(pa(),a.enableKeyScroll=a.initialKeyScroll,
-a.enableSpaceScroll=a.initialSpaceScroll,a.outerObject.css("overflow","auto"),a.isScrollable=!0)};this.disableScrollable=function(){a.isScrollable&&(a.innerObject.hasClass("diva-dragger")&&a.innerObject.unbind("mousedown"),a.outerObject.unbind("dblclick"),a.outerObject.unbind("contextmenu"),a.outerObject.css("overflow","hidden"),a.initialKeyScroll=a.enableKeyScroll,a.initialSpaceScroll=a.enableSpaceScroll,a.enableKeyScroll=!1,a.enableSpaceScroll=!1,a.isScrollable=!1)};this.toggleOrientation=function(){a.verticallyOriented=
-!a.verticallyOriented;a.verticalOffset=R();a.horizontalOffset=S();a.goDirectlyTo=a.currentPageIndex;aa();return a.verticallyOriented};this.getPageOffset=function(c){return{top:parseInt(a.pageTopOffsets[c]),left:parseInt(a.pageLeftOffsets[c])}};this.getCurrentPageOffset=function(){return this.getPageOffset(a.currentPageIndex)};this.getPageDimensionsAtCurrentGridLevel=function(c){c=p(c)?c:a.currentPageIndex;var b=a.rowHeight-a.fixedPadding;c=a.fixedHeightGrid?(a.rowHeight-a.fixedPadding)*l(c,"w")/l(c,
-"h"):a.gridPageWidth;return{height:parseInt(b,10),width:parseInt(c,10)}};this.getPageIndexForPageXYValues=function(c,b){var d=document.getElementById(a.ID+"outer").getBoundingClientRect(),e=d.bottom,f=d.right;if(c<d.left||c>f||b<d.top||b>e)return!1;d=document.getElementsByClassName("diva-document-page");for(e=d.length;e--;){var f=d[e],m=f.getBoundingClientRect();if(!(c<m.left||c>m.right||b<m.top||b>m.bottom))return f.getAttribute("data-index")}return!1};this.isVerticallyOriented=function(){return a.verticallyOriented};
-this.activate=function(){a.isActiveDiva=!0};this.deactivate=function(){a.isActiveDiva=!1};this.destroy=function(){b("body").removeClass("diva-hide-scrollbar");a.parentObject.empty().removeData("diva");b.each(a.plugins,function(c,b){h(b.destroy,a,g)});a.parentObject.removeAttr("style").removeAttr("class");diva.Events.unsubscribeAll()}};b.fn.diva=function(f){return this.each(function(){f.parentObject=b(this);if(!f.parentObject.data("diva")){var d=new e(this,f);f.parentObject.data("diva",d)}})}})(jQuery);function log10(b){return Math.log(b)/Math.log(10)}
-(function(b){window.divaPlugins.push(function(){return{init:function(e,f){var d,a,g,h,l;f.startScrolling=function(){e.currentlyAutoScrolling?console.warn("Diva is already autoscrolling!"):(b("#"+e.ID+"autoscroll-toggle").text("Turn off"),a&&f.disableScrollable(),e.currentlyAutoScrolling=!0,restartScrollingInterval())};restartScrollingInterval=function(){clearInterval(e.autoScrollInterval);e.autoScrollInterval=e.verticallyOriented?setInterval(function(){e.outerObject.scrollTop(e.outerObject.scrollTop()+d)},
-g):setInterval(function(){e.outerObject.scrollLeft(e.outerObject.scrollLeft()+d)},g)};f.stopScrolling=function(){e.currentlyAutoScrolling?(b("#"+e.ID+"autoscroll-toggle").text("Turn on"),a&&f.enableScrollable(),e.currentlyAutoScrolling=!1,clearInterval(e.autoScrollInterval)):console.warn("Diva isn't autoscrolling!")};f.toggleScrolling=function(){e.currentlyAutoScrolling?f.stopScrolling():f.startScrolling()};f.changeRefresh=function(a){g=a;n()};f.changeScrollSpeed=function(a){l=a;n();b("#"+e.ID+"autoscroll-pps").val(log10(l));
-e.currentlyAutoScrolling&&restartScrollingInterval()};var n=function(){g=h;d=l/(1E3/g);1>d&&(g*=1/d,d=l/(1E3/g))};f.disableManualScroll=function(){a=!0;e.currentlyAutoScrolling&&f.disableScrollable()};f.enableManualScroll=function(){a=!1;e.currentlyAutoScrolling&&f.enableScrollable()};e.currentlyAutoScrolling=!1;e.autoScrollInterval="";a=e.disableManualScroll||!1;h=g=e.autoScrollRefresh||50;f.changeScrollSpeed(e.scrollSpeed||10);b(window).on("keyup",function(a){a.shiftKey&&32==a.keyCode&&f.toggleScrolling()});
-e.disableAutoscrollPrefs||diva.Events.subscribe("ViewerDidLoad",function(a){a="<div id='"+e.ID+"autoscroll-prefs' class='diva-autoscroll-prefs diva-popup'><b>Autoscrolling options:</b><br><span class='diva-autoscroll-prefs-text'>Pixels per second:</span><input type='range' id='"+e.ID+"autoscroll-pps' class='diva-autoscroll-pps diva-autoscroll-prefs-input' value='"+log10(l)+"' min='0' max='3' step='0.1'><br><span class='diva-autoscroll-prefs-text'>Allow manual scroll:</span><input type='checkbox' id='"+
-e.ID+"autoscroll-manual' class='diva-autoscroll-manual diva-autoscroll-prefs-input' checked='checked'><br><button id='"+e.ID+"autoscroll-toggle' class='diva-autoscroll-prefs-toggle diva-autoscroll-prefs-input'> Turn on </button></div>";b("#"+e.ID+"page-nav").before("<div id='"+e.ID+"autoscroll-icon' class='button diva-autoscroll-icon' title='Expand autoscroll options'></div>");b("body").prepend(a);b("#"+e.ID+"autoscroll-pps").on("change",function(a){f.changeScrollSpeed(Math.pow(10,a.target.value))});
-b("#"+e.ID+"autoscroll-manual").on("change",function(a){a.target.checked?f.enableManualScroll():f.disableManualScroll()});b("#"+e.ID+"autoscroll-toggle").on("click",f.toggleScrolling);b("#"+e.ID+"autoscroll-icon").on("click",function(a){a=b("#"+e.ID+"autoscroll-prefs");"none"==a.css("display")?(a.css({display:"block",right:b(window).width()-(e.outerObject.offset().left+e.outerObject.outerWidth())+e.scrollbarWidth}),a.offset({top:e.outerObject.offset().top+1})):a.css("display","none")})})},pluginName:"autoscroll",
-titleText:"Automatically scrolls page along primary axis"}}())})(jQuery);(function(b){window.divaPlugins.push(function(){var e={},f={},d={},a,g,h,l={brightnessMax:150,brightnessMin:-100,brightnessStep:1,contrastMax:3,contrastMin:-1,contrastStep:.05,localStoragePrefix:"canvas-",mobileWebkitMaxZoom:2,onInit:null,rgbMax:50,rgbMin:-50,throbberFadeSpeed:200,throbberTimeout:100,buttons:["contrast","brightness","rotation","zoom"]},n=function(b,d){var e=b.context,f=b.size/2,g=-(b.width/2),h=-(b.height/2);e.clearRect(0,0,b.size,b.size);e.save();e.translate(f,f);e.rotate(d*Math.PI/
-180);e.drawImage(a,g,h,b.width,b.height);e.restore();b.data=e.getImageData(0,0,b.size,b.size)},t=function(){for(var a in g)if(g[a].current!==g[a].previous)return!0;return!1},u=function(){n(f,g.rotation.current);q(f)},p=function(){var a=g.rotation.current,f=g.zoom.current,h=g.zoom.previous;if(a!==g.rotation.previous||f!==h){var k=b("#diva-canvas-wrapper").scrollLeft(),l=b("#diva-canvas-wrapper").scrollTop(),p=d.viewport.width/2,r=d.viewport.height/2,k=k+p-e.centerX,u=-(l+r-e.centerY),z=(g.rotation.previous-
-a)*Math.PI/180,l=Math.cos(z)*k-Math.sin(z)*u+e.centerX,k=-(Math.sin(z)*k+Math.cos(z)*u)+e.centerY,f=Math.pow(2,f-h),p=f*l-p,r=f*k-r;n(e,a);b("#diva-canvas-wrapper").scrollLeft(p);b("#diva-canvas-wrapper").scrollTop(r)}if(t()){q(e);for(var w in g)g[w].previous=g[w].current}},r=function(a){var b=g[a].current!==g[a].initial;return g[a].current!==g[a].previous||b},q=function(a){var b=a.data,e=a.context.createImageData(b),f=e.data,h,k;h=0;for(k=f.length;h<k;h++)f[h]=b.data[h];b=e.data;h=g.contrast.current;
-f=(1+Math.min(d.brightnessMax,Math.max(d.brightnessMin,g.brightness.current))/d.brightnessMax)*h;h=128-128*h;k=g.red.current;var l=g.green.current,n=g.blue.current,z=r("red"),p=r("green"),q=r("blue"),u=r("brightness"),t=r("contrast"),u=u||t,y,A,v,B,D,C,E,t=0;for(A=e.width;t<A;t++)for(y=0,v=e.height;y<v;y++)B=4*(y*A+t),D=b[B],C=b[B+1],E=b[B+2],0<D+C+E&&(z&&D&&(D+=k),p&&C&&(C+=l),q&&E&&(E+=n),u&&(D&&(D=D*f+h),C&&(C=C*f+h),E&&(E=E*f+h)),b[B]=D,b[B+1]=C,b[B+2]=E);a.context.clearRect(0,0,A,v);a.context.putImageData(e,
-0,0)},k=function(){var a=b("#diva-canvas-wrapper").scrollLeft()*f.scaleFactor,e=b("#diva-canvas-wrapper").scrollTop()*f.scaleFactor,g=Math.min(Math.round(d.viewport.height*f.scaleFactor),d.mapSize)-4,h=Math.min(Math.round(d.viewport.width*f.scaleFactor),d.mapSize)-4;b("#diva-map-viewbox").height(g).width(h).css({top:e,left:a})},T=function(g,h){a=new Image;a.src=g;a.crossOrigin="Anonymous";a.onload=function(){e.size=Math.sqrt(a.width*a.width+a.height*a.height);e.canvas=document.getElementById("diva-canvas");
-e.canvas.width=e.size;e.canvas.height=e.size;e.cornerX=(e.size-a.width)/2;e.cornerY=(e.size-a.height)/2;e.width=a.width;e.height=a.height;e.centerX=e.size/2;e.centerY=e.size/2;e.context=e.canvas.getContext("2d");e.context.drawImage(a,e.cornerX,e.cornerY,e.width,e.height);try{e.data=e.context.getImageData(0,0,e.size,e.size)}catch(g){var m='<div id="diva-error" class="diva-error"><p><strong>Error</strong></p><p>'+g.message+"</p>";if("SecurityError"!==g.name)throw g;m+='<p>You may need to update your server configuration in order to use the image manipulation tools. For help, see the <a href="https://github.com/DDMAL/diva.js/wiki/The-API-and-Plugins#a-note-about-canvas-and-cross-site-data" target="_blank">canvas cross-site data documentation</a>.</p></div></div>';
-b("#diva-canvas-backdrop").append(m);B()}void 0===h&&(m=a,f.canvas=document.getElementById("diva-canvas-minimap"),f.size=d.mapSize,f.canvas.width=f.size,f.canvas.height=f.size,f.context=f.canvas.getContext("2d"),f.context.fillRect(0,0,f.size,f.size),f.scaleFactor=d.mapSize/e.size,f.cornerX=e.cornerX*f.scaleFactor,f.cornerY=e.cornerY*f.scaleFactor,f.width=m.width*f.scaleFactor,f.height=m.height*f.scaleFactor,f.context.drawImage(m,f.cornerX,f.cornerY,f.width,f.height),f.data=f.context.getImageData(0,
-0,d.mapSize,d.mapSize),b("#diva-map-viewbox").show(),k());u();p(e);B();"function"===typeof h&&h.call(h)}},L=function(){var a=g[h],d=a.current,a=a.transform?a.transform(d):d;b("#diva-canvas-value").html(a)},y=function(){b("#diva-canvas-slider").val(g[h].current)},v=function(a){a=d.zoomWidthRatio*Math.pow(2,a);return d.proxyURL?d.proxyURL+"?f="+d.filename+"&w="+a:d.iipServerURL+"?FIF="+(d.imageDir+"/")+d.filename+"&WID="+a+"&CVT=JPEG"},A=function(){(0<g.zoom.current||d.mobileWebkit)&&b(d.selector+"throbber").addClass("canvas-throbber").show()},
-B=function(){b(d.selector+"throbber").removeClass("canvas-throbber").hide()},I=function(){var a={},b=!1,e=d.localStoragePrefix+d.filename,f;for(f in g)g[f].previous!==g[f].initial&&(a[f]=g[f].previous,b=!0);b?(d.pluginIcon.addClass("new"),localStorage.setObject(e,a)):(d.pluginIcon.removeClass("new"),localStorage.removeItem(e))},G=function(a,b){d.zoomLevel=a;var g=v(a);T(g,function(){f.scaleFactor=f.size/e.size;k();I()})},M=function(a){switch(a.keyCode){case 38:return b("#diva-canvas-wrapper").scrollTop(document.getElementById("diva-canvas-wrapper").scrollTop-
-d.arrowScrollAmount),!1;case 40:return b("#diva-canvas-wrapper").scrollTop(document.getElementById("diva-canvas-wrapper").scrollTop+d.arrowScrollAmount),!1;case 37:return b("#diva-canvas-wrapper").scrollLeft(document.getElementById("diva-canvas-wrapper").scrollLeft-d.arrowScrollAmount),!1;case 39:return b("#diva-canvas-wrapper").scrollLeft(document.getElementById("diva-canvas-wrapper").scrollLeft+d.arrowScrollAmount),!1}};return{init:function(a,n){if(!window.HTMLCanvasElement)return!1;b.extend(d,
-l,a.canvasPlugin);d.inCanvas=!1;d.iipServerURL=a.iipServerURL;d.imageDir=a.imageDir;d.selector=a.selector;d.mobileWebkit=a.mobileWebkit;d.arrowScrollAmount=a.arrowScrollAmount;g={contrast:{initial:1,min:d.contrastMin,max:d.contrastMax,step:d.contrastStep,transform:function(a){return a.toFixed(2)},title:"Change the contrast"},brightness:{initial:0,min:d.brightnessMin,max:d.brightnessMax,step:d.brightnessStep,title:"Adjust the brightness"},rotation:{initial:0,min:0,max:359,step:1,transform:function(a){return a+
-"&deg;"},title:"Rotate the image"},zoom:{initial:0,min:0,max:0,step:1,title:"Adjust the zoom level"},red:{initial:0,min:d.rgbMin,max:d.rgbMax,step:1,title:"Adjust the red channel"},green:{initial:0,min:d.rgbMin,max:d.rgbMax,step:1,title:"Adjust the green channel"},blue:{initial:0,min:d.rgbMin,max:d.rgbMax,step:1,title:"Adjust the blue channel"}};var r=function(){var a,b,d;for(d in g)b=g[d],a=b.initial,b.current=a,b.previous=a};r();if(b("#diva-canvas-backdrop").length)return!0;var q=[],v,K,O;for(O in d.buttons)v=
-d.buttons[O],K=g[v].title,v='<div class="'+v+'" title="'+K+'"></div>',q.push(v);q='<div id="diva-canvas-backdrop">'+('<div id="diva-canvas-tools"><div id="diva-canvas-toolbar"><div id="diva-canvas-close" title="Return to the document viewer"></div><div id="diva-canvas-minimise" title="Minimise the toolbar"></div><span id="diva-canvas-info">Test</span></div><div id="diva-canvas-toolwindow"><div id="diva-map-viewbox"></div><canvas id="diva-canvas-minimap"></canvas><div id="diva-canvas-buttons">'+q.join("")+
-'</div><div id="diva-canvas-pane"><p id="diva-canvas-tooltip"><span id="diva-canvas-mode">contrast</span>: <span id="diva-canvas-value">0</span> <span id="diva-canvas-reset" class="link">(Reset)</span></p><input type="range" id="diva-canvas-slider"></input></div><br /><div class="action-buttons"><a href="#" id="diva-canvas-reset-all">Reset all</a><a href="#" id="diva-canvas-apply">Apply</a></div></div></div>')+'<div id="diva-canvas-wrapper"><canvas id="diva-canvas"></canvas></div></div>';b("body").append(q);
-d.mapSize=b("#diva-canvas-minimap").width();b("#diva-canvas-buttons div").click(function(){b("#diva-canvas-buttons .clicked").removeClass("clicked");J(b(this).attr("class"))});var J=function(a){h=a;a=g[h];b("#diva-canvas-buttons ."+h).addClass("clicked");b("#diva-canvas-mode").text(h);var d=a.current,e=a.transform?a.transform(d):d,f=document.getElementById("diva-canvas-slider");f.min=a.min;f.max=a.max;f.step=a.step;b("#diva-canvas-slider").val(d);b("#diva-canvas-value").html(e)};J("contrast");b("#diva-canvas-slider").on("input",
-function(a){g[h].current=parseFloat(this.value);L();u()});b("#diva-canvas-reset-all").click(function(){for(var a in g)g[a].current=g[a].initial;L();y();u()});b("#diva-canvas-reset").click(function(){g[h].current=g[h].initial;L();y();u()});b("#diva-canvas-apply").click(function(){t()&&(A(),setTimeout(function(){g.zoom.current!==g.zoom.previous?G(g.zoom.current):(p(),B(),I())},d.throbberTimeout))});b("#diva-canvas-close").click(function(){b("body").removeClass("overflow-hidden");e.context.clearRect(0,
-0,e.size,e.size);f.context.clearRect(0,0,f.size,f.size);b("#diva-canvas-wrapper").scrollTop(0).scrollLeft(0);b("#diva-canvas-backdrop").hide();b("#diva-map-viewbox").hide();B();n.enableScrollable();b(document).off("keydown",M);r();L();y();b("#diva-canvas-buttons .clicked").removeClass("clicked");J("contrast");diva.Events.publish("CanvasViewDidHide")});b("#diva-canvas-minimise").click(function(){b("#diva-canvas-toolwindow").slideToggle("fast")});b(window).resize(function(){d.viewport={height:window.innerHeight-
-a.scrollbarWidth,width:window.innerWidth-a.scrollbarWidth};d.inCanvas&&k()});b("#diva-canvas-wrapper").scroll(function(){d.inCanvas&&k()});b("#diva-canvas-minimap, #diva-map-viewbox").mouseup(function(a){var e=b("#diva-canvas-minimap").offset(),g=(a.pageX-e.left)/f.scaleFactor;a=(a.pageY-e.top)/f.scaleFactor;b("#diva-canvas-wrapper").scrollTop(a-d.viewport.height/2);b("#diva-canvas-wrapper").scrollLeft(g-d.viewport.width/2)});b("#diva-canvas").mousedown(function(){b(this).addClass("grabbing")}).mouseup(function(){b(this).removeClass("grabbing")});
-d.mobileWebkit?b("#diva-canvas-wrapper").kinetic():b("#diva-canvas-wrapper").dragscrollable({acceptPropagatedEvent:!0});"function"===typeof d.onInit&&d.onInit.call(this,d);return!0},pluginName:"canvas",titleText:"View the image on a canvas and adjust various settings",setupHook:function(a){d.viewport={height:window.innerHeight-a.scrollbarWidth,width:window.innerWidth-a.scrollbarWidth};d.minZoomLevel=a.minZoomLevel;d.maxZoomLevel=a.maxZoomLevel;d.mobileWebkit&&(d.maxZoomLevel=Math.min(d.maxZoomLevel,
-d.mobileWebkitMaxZoom));g.zoom.min=d.minZoomLevel;g.zoom.max=d.maxZoomLevel},handleClick:function(a,e,f){a=b(this).parent().parent();var k=b(a).attr("data-filename"),l=b(a).width()-1;e=e.zoomLevel;var n;d.zoomWidthRatio=l/Math.pow(2,e);d.pluginIcon=b(this);d.mobileWebkit&&(e=Math.min(d.maxZoomLevel,e));d.filename=k;g.zoom.initial=e;g.zoom.current=e;if(k=localStorage.getObject(d.localStoragePrefix+d.filename))for(n in k)g[n].current=k[n],n===h&&(L(),y()),"zoom"===n&&(e=k[n]);g.zoom.previous=e;b("body").addClass("overflow-hidden");
-b("#diva-canvas-backdrop").show();f.disableScrollable();b(document).keydown(M);d.inCanvas=!0;f=v(e);b("#diva-canvas-info").text(b(a).attr("title"));A();diva.Events.publish("CanvasViewDidActivate",[a]);T(f)},onPageLoad:function(a,e,f){null!==localStorage.getItem(d.localStoragePrefix+e)&&b(f).find(".diva-canvas-icon").addClass("new")},destroy:function(a,d){b("#diva-canvas-backdrop").remove()}}}())})(jQuery);(function(b){window.divaPlugins.push(function(){var e,f;return{init:function(b,a){e=b.iipServerURL;f=b.imageDir;return!0},pluginName:"download",titleText:"Download image at the given zoom level",handleClick:function(d){var a=b(this).parent().parent();d=b(a).attr("data-filename");a=b(a).width()-1;window.open(e+"?FIF="+(f+"/")+d+"&WID="+a+"&CVT=JPEG")}}}())})(jQuery);(function(b){window.divaPlugins.push(function(){return{init:function(b,f){function d(a,d,h){var l=b.parentObject.data("highlights");if("undefined"!==typeof l){if(l.hasOwnProperty(a)){var n=f.getInstanceId()+"page-"+a,n=document.getElementById(n),t=l[a].regions,u=l[a].colour,l=l[a].divClass,p=f.getMaxZoomLevel();b.inGrid?(p=f.getPageDimensionsAtZoomLevel(a,p).width,p=Math.log(p/n.clientWidth)/Math.log(2)):p-=f.getZoomLevel();for(var r=t.length;r--;){var q=document.createElement("div");q.style.width=
-t[r].width/Math.pow(2,p)+"px";q.style.height=t[r].height/Math.pow(2,p)+"px";q.style.top=t[r].uly/Math.pow(2,p)+"px";q.style.left=t[r].ulx/Math.pow(2,p)+"px";q.style.background=u;q.style.border="1px solid #555";q.style.position="absolute";q.style.zIndex=100;q.className=l;"undefined"!==typeof t[r].divID&&(q.id=t[r].divID);n.appendChild(q)}}diva.Events.publish("HighlightCompleted",[a,d,h])}}b.parentObject.data("highlights",{});diva.Events.subscribe("PageWillLoad",d);f.resetHighlights=function(){for(var a=
-document.getElementById(b.ID+"inner").getElementsByClassName(b.ID+"highlight"),d=a.length;d--;)a[d].parentNode.removeChild(a[d]);b.parentObject.data("highlights",{})};f.removeHighlightsOnPage=function(a){var d=b.parentObject.data("highlights");if(d.hasOwnProperty(a)){for(var h=f.getInstanceId()+"page-"+a,h=document.getElementById(h),l=h.getElementsByTagName("div"),n=d[a].divClass,t=l.length;t--;)l[t].className===n&&h.removeChild(l[t]);delete d[a]}};f.highlightOnPages=function(a,b,d,e){for(var n=a.length;n--;)f.highlightOnPage(a[n],
-b[n],d,e)};f.highlightOnPage=function(a,g,h,l){"undefined"===typeof h&&(h="rgba(255, 0, 0, 0.2)");l="undefined"===typeof l?b.ID+"highlight":b.ID+"highlight "+l;f.getMaxZoomLevel();b.parentObject.data("highlights")[a]={regions:g,colour:h,divClass:l};f.isPageInDOM(a)&&d(a,null,null);return!0};return!0},destroy:function(b,f){b.parentObject.removeData("highlights")},pluginName:"highlight",titleText:"Highlight regions of pages"}}())})(jQuery);(function(b){window.divaPlugins.push(function(){return{init:function(b,f){void 0===b.pageAliases&&(b.pageAliases={});void 0===b.pageAliasFunction&&(b.pageAliasFunction=function(){return!1});f.getAliasForPageIndex=function(d){return b.pageAliases[d]||b.pageAliasFunction(d)||d+1};f.getPageIndexForAlias=function(d){for(var a=0;a<b.numPages;a++)if(f.getAliasForPageIndex(a)==d)return a;return!1};f.getPageIndicesForAlias=function(d){for(var a=[],g=0;g<b.numPages;g++)f.getAliasForPageIndex(g)==d&&a.push(g);
-return a};f.getCurrentAliasedPageIndex=function(){return f.getAliasForPageIndex(b.currentPageIndex)};f.gotoPageByAliasedNumber=function(b,a,e){return f.gotoPageByIndex(f.getPageIndexForAlias(b),a,e)};updateCurrentAliasedPage=function(){document.getElementById(this.getSettings().ID+"current-page").textContent=this.getCurrentAliasedPageIndex()};initialChanges=function(){var b=this.getSettings(),a=b.numPages;void 0!==b.newTotalPages?a=b.newTotalPages:void 0!==b.totalPageOffset&&(a+=b.totalPageOffset);
-document.getElementById(this.getSettings().ID+"num-pages").textContent=a;document.getElementById(this.getSettings().ID+"current-page").textContent=this.getCurrentAliasedPageIndex();diva.Events.unsubscribe(["VisiblePageDidChange",b.toolbar.updateCurrentPage]);diva.Events.subscribe("VisiblePageDidChange",updateCurrentAliasedPage)};diva.Events.subscribe("ViewerDidLoad",initialChanges)},pluginName:"pagealias",titleText:"Re-aliases page indexes"}}())})(jQuery);
Binary file src/main/webapp/imageServer/resources/js/jquery-ui-1.10.4.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/imageServer/resources/js/vendor/diva-old.js	Fri Jul 05 16:05:57 2019 +0200
@@ -0,0 +1,2592 @@
+window.divaPlugins = [];
+
+// this pattern was taken from http://www.virgentech.com/blog/2009/10/building-object-oriented-jquery-plugin.html
+(function ($)
+{
+    var Diva = function (element, options)
+    {
+        // These are elements that can be overridden upon instantiation
+        // See https://github.com/DDMAL/diva.js/wiki/Code-documentation for more details
+        var defaults = {
+            adaptivePadding: 0.05, // The ratio of padding to the page dimension
+            blockMobileMove: true, // Prevent moving or scrolling the page on mobile devices
+            contained: false, // Determines the location of the fullscreen icon
+            objectData: '', // URL to the JSON file that provides the object dimension data - *MANDATORY*
+            enableAutoHeight: false, // Automatically adjust height based on the window size
+            enableAutoTitle: true, // Shows the title within a div of id diva-title
+            enableAutoWidth: true, // Automatically adjust width based on the window size
+            enableCanvas: true, // Used for the canvas plugin
+            enableDownload: true, // Used for the download plugin
+            enableFilename: true, // Uses filenames and not page numbers for links (i=bm_001.tif, not p=1)
+            enableFullscreen: true, // Enable or disable fullscreen icon (mode still available)
+            enableGotoPage: true, // A "go to page" jump box
+            enableGridIcon: true, // A grid view of all the pages
+            enableGridSlider: true, // Slider to control the pages per grid row
+            enableKeyScroll: true, // Scrolling using the page up/down keys
+            enableLinkIcon: true, // Controls the visibility of the link icon
+            enableSpaceScroll: false, // Scrolling down by pressing the space key
+            enableToolbar: true, // Enables the toolbar. Note that disabling this means you have to handle all controls yourself.
+            enableZoomSlider: true, // Enable or disable the zoom slider (for zooming in and out)
+            fixedPadding: 10, // Fallback if adaptive padding is set to 0
+            fixedHeightGrid: true, // So each page in grid view has the same height (only widths differ)
+            goDirectlyTo: 0, // Default initial page to show (0-indexed)
+            iipServerURL: '', // The URL to the IIPImage installation, including the `?FIF=` - *MANDATORY*
+            inFullscreen: false, // Set to true to load fullscreen mode initially
+            inGrid: false, // Set to true to load grid view initially
+            imageDir: '', // Image directory, either absolute path or relative to IIP's FILESYSTEM_PREFIX - *MANDATORY*
+            maxPagesPerRow: 8, // Maximum number of pages per row, grid view
+            maxZoomLevel: -1, // Optional; defaults to the max zoom returned in the JSON response
+            minPagesPerRow: 2, // 2 for the spread view. Recommended to leave it
+            minZoomLevel: 0, // Defaults to 0 (the minimum zoom)
+            onDocumentLoaded: null, // Callback function for when the document is fully loaded
+            onModeToggle: null, // Callback for toggling fullscreen mode
+            onViewToggle: null, // Callback for switching between grid and document view
+            onJump: null, // Callback function for jumping to a specific page (using the gotoPage feature)
+            onPageLoad: null, // Callback function for loading pages
+            onPageLoaded: null, // Callback function for after the page has been loaded
+            onReady: null, // Callback function for initial load
+            onScroll: null, // Callback function for scrolling
+            onScrollDown: null, // Callback function for scrolling down, only
+            onScrollUp: null, // Callback function for scrolling up only
+            onSetCurrentPage: null, // Callback function for when the current page is set
+            onZoom: null, // Callback function for zooming in general
+            onZoomIn: null, // Callback function for zooming in only
+            onZoomOut: null, // Callback function for zooming out only
+            pageLoadTimeout: 200, // Number of milliseconds to wait before loading pages
+            pagesPerRow: 5, // The default number of pages per row in grid view
+            rowLoadTimeout: 50, // Number of milliseconds to wait before loading a row
+            throbberTimeout: 100, // Number of milliseconds to wait before showing throbber
+            tileHeight: 256, // The height of each tile, in pixels; usually 256
+            tileWidth: 256, // The width of each tile, in pixels; usually 256
+            toolbarParentSelector: null, // The toolbar parent selector. If null, it defaults to the primary diva element. Must be a jQuery selector (leading '#')
+            viewerHeightPadding: 15, // Vertical padding when resizing the viewer, if enableAutoHeight is set
+            viewerWidthPadding: 30, // Horizontal padding when resizing the viewer, if enableAutoHeight is set
+            viewportMargin: 200, // Pretend tiles +/- 200px away from viewport are in
+            zoomLevel: 2 // The initial zoom level (used to store the current zoom level)
+        };
+
+        // Apply the defaults, or override them with passed-in options.
+        var settings = $.extend({}, defaults, options);
+
+        // Things that cannot be changed because of the way they are used by the script
+        // Many of these are declared with arbitrary values that are changed later on
+        var globals = {
+            allTilesLoaded: [], // A boolean for each page, indicating if all tiles have been loaded
+            averageHeights: [], // The average page height for each zoom level
+            averageWidths: [], // The average page width for each zoom level
+            currentPageIndex: 0, // The current page in the viewport (center-most page)
+            dimAfterZoom: 0, // Used for storing the item dimensions after zooming
+            firstPageLoaded: -1, // The ID of the first page loaded (value set later)
+            firstRowLoaded: -1, // The index of the first row loaded
+            gridPageWidth: 0, // Holds the max width of each row in grid view. Calculated in loadGrid()
+            hashParamSuffix: '', // Used when there are multiple document viewers on a page
+            heightAbovePages: [], // The height above each page at the current zoom level
+            horizontalOffset: 0, // Used in documentScroll for scrolling more precisely
+            horizontalPadding: 0, // Either the fixed padding or adaptive padding
+            ID: null, // The prefix of the IDs of the elements (usually 1-diva-)
+            innerSelector: '', // settings.selector + 'inner', for selecting the .diva-inner element
+            itemTitle: '', // The title of the document
+            lastPageLoaded: -1, // The ID of the last page loaded (value set later)
+            lastRowLoaded: -1, // The index of the last row loaded
+            leftScrollSoFar: 0, // Current scroll from the left edge of the pane
+            loaded: false, // A flag for when everything is loaded and ready to go.
+            maxWidths: [], // The width of the widest page for each zoom level
+            maxRatio: 0, // The max height/width ratio (for grid view)
+            minHeight: 0, // Minimum height of the .diva-outer element, as defined in the CSS
+            minRatio: 0, // The minimum height/width ratio for a page
+            minWidth: 0, // Minimum width of the .diva-outer element, as defined in the CSS
+            mobileWebkit: false, // Checks if the user is on a touch device (iPad/iPod/iPhone/Android)
+            numPages: 0, // Number of pages in the array
+            numRows: 0, // Number of rows
+            oldPagesPerRow: 0, // Holds the previous number of pages per row after it is changed
+            oldZoomLevel: -1, // Holds the previous zoom level after zooming in or out
+            orientationChange: false, // For handling device orientation changes for touch devices
+            originalHeight: 0, // Stores the original height of the .diva-outer element
+            originalWidth: 0, // Stores the original width of the .diva-outer element
+            outerSelector: '', // settings.selector + 'outer', for selecting the .diva-outer element
+            pages: [], // An array containing the data for all the pages
+            pageLeftOffsets: [], // Offset from the left side of the pane to the edge of the page
+            pageTimeouts: [], // Stack to hold the loadPage timeouts
+            pageTools: '', // The string for page tools
+            panelHeight: 0, // Height of the document viewer pane
+            panelWidth: 0, // Width of the document viewer pane
+            plugins: [], // Filled with the enabled plugins from window.divaPlugins
+            previousTopScroll: 0, // Used to determine vertical scroll direction
+            preZoomOffset: null, // Holds the offset prior to zooming when double-clicking
+            realMaxZoom: -1, // To hold the true max zoom level of the document (needed for calculations)
+            resizeTimer: -1, // Holds the ID of the timeout used when resizing the window (for clearing)
+            rowHeight: 0, // Holds the max height of each row in grid view. Calculated in loadGrid()
+            scaleWait: false, // For preventing double-zoom on touch devices (iPad, etc)
+            selector: '', // Uses the generated ID prefix to easily select elements
+            singleClick: false, // Used for catching ctrl+double-click events in Firefox in Mac OS
+            scrollbarWidth: 0, // Set to the actual scrollbar width in init()
+            throbberTimeoutID: -1, // Holds the ID of the throbber loading timeout
+            toolbar: null, // Holds an object with some toolbar-related functions
+            topScrollSoFar: 0, // Holds the number of pixels of vertical scroll
+            totalHeights: [], // The total height of all pages (stacked together) for each zoom level
+            totalHeight: 0, // The total height for the current zoom level (including padding)
+            verticalOffset: 0, // See horizontalOffset
+            verticalPadding: 0, // Either the fixed padding or adaptive padding
+            viewerXOffset: 0, // Distance between left edge of viewer and document left edge
+            viewerYOffset: 0 // Like viewerXOffset but for the top edges
+        };
+
+        $.extend(settings, globals);
+
+        // Executes a callback function with the diva instance set as the context
+        // Can take an unlimited number to arguments to pass to the callback function
+        var self = this;
+
+        var executeCallback = function (callback)
+        {
+            var args, i, length;
+
+            if (typeof callback === "function")
+            {
+                args = [];
+                for (i = 1, length = arguments.length; i < length; i++)
+                {
+                    args.push(arguments[i]);
+                }
+
+                callback.apply(self, args);
+
+                return true;
+            }
+
+            return false;
+        };
+
+        var getPageData = function (pageIndex, attribute)
+        {
+            return settings.pages[pageIndex].d[settings.zoomLevel][attribute];
+        };
+
+        // Returns the page index associated with the given filename; must called after settings settings.pages
+        var getPageIndex = function (filename)
+        {
+            var i,
+                np = settings.numPages;
+
+            for (i = 0; i < np; i++)
+            {
+                if (settings.pages[i].f === filename)
+                {
+                    return i;
+                }
+            }
+
+            return -1;
+        };
+
+        // Checks if a tile is within the viewport horizontally
+        var isHorizontallyInViewport = function (left, right)
+        {
+            var panelWidth = settings.panelWidth;
+            var leftOfViewport = settings.leftScrollSoFar - settings.viewportMargin;
+            var rightOfViewport = leftOfViewport + panelWidth + settings.viewportMargin * 2;
+
+            var leftVisible = left >= leftOfViewport && left <= rightOfViewport;
+            var rightVisible = right >= leftOfViewport && right <= rightOfViewport;
+            var middleVisible = left <= leftOfViewport && right >= rightOfViewport;
+
+            return (leftVisible || middleVisible || rightVisible);
+        };
+
+        // Checks if a page or tile is within the viewport vertically
+        var isVerticallyInViewport = function (top, bottom)
+        {
+            var panelHeight = settings.panelHeight;
+            var topOfViewport = settings.topScrollSoFar - settings.viewportMargin;
+            var bottomOfViewport = topOfViewport + panelHeight + settings.viewportMargin * 2;
+
+            var topVisible = top >= topOfViewport && top <= bottomOfViewport;
+            var middleVisible = top <= topOfViewport && bottom >= bottomOfViewport;
+            var bottomVisible = bottom >= topOfViewport && bottom <= bottomOfViewport;
+
+            return (topVisible || middleVisible || bottomVisible);
+        };
+
+        // Check if a tile is near the viewport and thus should be loaded
+        var isTileVisible = function (pageIndex, tileRow, tileCol)
+        {
+            var tileTop = settings.heightAbovePages[pageIndex] + (tileRow * settings.tileHeight) + settings.verticalPadding;
+            var tileBottom = tileTop + settings.tileHeight;
+            var tileLeft = settings.pageLeftOffsets[pageIndex] + (tileCol * settings.tileWidth);
+            var tileRight = tileLeft + settings.tileWidth;
+
+            return isVerticallyInViewport(tileTop, tileBottom) && isHorizontallyInViewport(tileLeft, tileRight);
+        };
+
+        // Check if a tile has been appended to the DOM
+        var isTileLoaded = function (pageIndex, tileIndex)
+        {
+            return document.getElementById(settings.ID + 'tile-' + pageIndex + '-' + tileIndex) === false;
+        };
+
+        // Check if a page index is valid
+        var isPageValid = function (pageIndex)
+        {
+            return pageIndex >= 0 && pageIndex < settings.numPages;
+        };
+
+        // Check if a page is in or near the viewport and thus should be loaded
+        var isPageVisible = function (pageIndex)
+        {
+            var topOfPage = settings.heightAbovePages[pageIndex];
+            var bottomOfPage = topOfPage + getPageData(pageIndex, 'h') + settings.verticalPadding;
+
+            return isVerticallyInViewport(topOfPage, bottomOfPage);
+        };
+
+        // Check if a page has been appended to the DOM
+        var isPageLoaded = function (pageIndex)
+        {
+            return $(document.getElementById(settings.ID + 'page-' + pageIndex)).length > 0;
+        };
+
+        // Appends the page directly into the document body, or loads the relevant tiles
+        var loadPage = function (pageIndex)
+        {
+            // If the page and all of its tiles have been loaded, exit
+            if (isPageLoaded(pageIndex) && settings.allTilesLoaded[pageIndex])
+            {
+                return;
+            }
+
+            // Load some data for this page
+            var filename = settings.pages[pageIndex].f;
+            var width = getPageData(pageIndex, 'w');
+            var height = getPageData(pageIndex, 'h');
+            var heightFromTop = settings.heightAbovePages[pageIndex] + settings.verticalPadding;
+            var pageSelector = settings.selector + 'page-' + pageIndex;
+            var plugin;
+
+            // If the page has not been loaded yet, append the div to the DOM
+            if (!isPageLoaded(pageIndex))
+            {
+                $(document.getElementById(settings.ID + "inner")).append('<div id="' + settings.ID + 'page-' + pageIndex + '" style="top: ' + heightFromTop + 'px; width: ' + width + 'px; height: ' + height + 'px;" class="diva-document-page" title="Page ' + (pageIndex + 1) + '" data-index="' + pageIndex + '" data-filename="' + filename + '">' + settings.pageTools + '</div>');
+
+                // Call the callback function
+                executeCallback(settings.onPageLoad, pageIndex, filename, pageSelector);
+                Events.publish("PageHasLoaded", [pageIndex, filename, pageSelector]);
+
+                // @TODO: Replace this with a notification.
+                // Execute the callback functions for any of the enabled plugins
+                for (plugin in settings.plugins) {
+                    executeCallback(settings.plugins[plugin].onPageLoad, pageIndex, filename, pageSelector);
+                }
+            }
+
+            // There are still tiles to load, so try to load those (after a delay)
+            settings.pageTimeouts.push(setTimeout(function ()
+            {
+                // If the page is no longer in the viewport, don't load any tiles
+                if (!isPageVisible(pageIndex))
+                {
+                    return;
+                }
+
+                var imdir = settings.imageDir + "/";
+                // Load some more data and initialise some variables
+                var rows = getPageData(pageIndex, 'r');
+                var cols = getPageData(pageIndex, 'c');
+                var maxZoom = settings.pages[pageIndex].m;
+                var baseURL = settings.iipServerURL + "?FIF=" + imdir + filename + '&JTL=';
+                var content = [];
+                var allTilesLoaded = true;
+                var tileIndex = 0;
+                var i;
+
+                // Calculate the width and height of outer tiles (non-standard dimensions)
+                var lastHeight = height - (rows - 1) * settings.tileHeight;
+                var lastWidth = width - (cols - 1) * settings.tileWidth;
+
+                // Declare variables used within the loops
+                var row, col, tileHeight, tileWidth, top, left, displayStyle, zoomLevel, imageURL;
+
+                // Adjust the zoom level based on the max zoom level of the page
+                zoomLevel = settings.zoomLevel + maxZoom - settings.realMaxZoom;
+                baseImageURL = baseURL + zoomLevel + ',';
+
+                // Loop through all the tiles in this page
+                row = 0;
+                while (row < rows)
+                {
+                    col = 0;
+                    while (col < cols)
+                    {
+                        top = row * settings.tileHeight;
+                        left = col * settings.tileWidth;
+
+                        // If the tile is in the last row or column, its dimensions will be different
+                        tileHeight = (row === rows - 1) ? lastHeight : settings.tileHeight;
+                        tileWidth = (col === cols - 1) ? lastWidth : settings.tileWidth;
+
+                        imageURL = baseImageURL + tileIndex;
+
+                        // this check looks to see if the tile is already loaded, and then if
+                        // it isn't, if it should be visible.
+                        if (!isTileLoaded(pageIndex, tileIndex)) {
+                            if (isTileVisible(pageIndex, row, col)) {
+                                content.push('<div id="' + settings.ID + 'tile-' + pageIndex + '-' + tileIndex + '" style="display:inline; position: absolute; top: ' + top + 'px; left: ' + left + 'px; background-image: url(\'' + imageURL + '\'); height: ' + tileHeight + 'px; width: ' + tileWidth + 'px;"></div>');
+                            } else {
+                                // The tile does not need to be loaded - not all have been loaded
+                                allTilesLoaded = false;
+                            }
+                        }
+                        tileIndex++;
+                        col++;
+                    }
+                    row++;
+                }
+
+                settings.allTilesLoaded[pageIndex] = allTilesLoaded;
+                $(document.getElementById(settings.ID + 'page-' + pageIndex)).append(content.join(''));
+
+                executeCallback(settings.onPageLoaded, pageIndex, filename, pageSelector);
+
+            }, settings.pageLoadTimeout));
+        };
+
+        // Delete a page from the DOM; will occur when a page is scrolled out of the viewport
+        var deletePage = function (pageIndex)
+        {
+            $(document.getElementById(settings.ID + 'page-' + pageIndex)).empty().remove();
+        };
+
+        // Check if the bottom of a page is above the top of a viewport (scrolling down)
+        // For when you want to keep looping but don't want to load a specific page
+        var pageAboveViewport = function (pageIndex)
+        {
+            var bottomOfPage = settings.heightAbovePages[pageIndex] + getPageData(pageIndex, 'h') + settings.verticalPadding;
+            var topOfViewport = settings.topScrollSoFar;
+
+            return bottomOfPage < topOfViewport;
+        };
+
+        // Check if the top of a page is below the bottom of a viewport (scrolling up)
+        var pageBelowViewport = function (pageIndex)
+        {
+            var topOfPage = settings.heightAbovePages[pageIndex];
+            var bottomOfViewport = settings.topScrollSoFar + settings.panelHeight;
+
+            return topOfPage > bottomOfViewport;
+        };
+
+        // Called by adjust pages - determine what pages should be visible, and show them
+        var attemptPageShow = function (pageIndex, direction)
+        {
+            if (direction > 0)
+            {
+                // Direction is positive - we're scrolling down
+                if (isPageValid(pageIndex))
+                {
+                    // If the page should be visible, then yes, add it
+                    if (isPageVisible(pageIndex))
+                    {
+                        loadPage(pageIndex);
+
+                        settings.lastPageLoaded = pageIndex;
+
+                        // Recursively call this function until there's nothing to add
+                        attemptPageShow(settings.lastPageLoaded + 1, direction);
+                    }
+                    else if (pageAboveViewport(pageIndex))
+                    {
+                        // If the page is below the viewport. try to load the next one
+                        attemptPageShow(pageIndex + 1, direction);
+                    }
+                }
+            }
+            else
+            {
+                // Direction is negative - we're scrolling up
+                if (isPageValid(pageIndex))
+                {
+                    // If it's near the viewport, yes, add it
+                    if (isPageVisible(pageIndex))
+                    {
+                        loadPage(pageIndex);
+
+                        // Reset the first page loaded to this one
+                        settings.firstPageLoaded = pageIndex;
+
+                        // Recursively call this function until there's nothing to add
+                        attemptPageShow(settings.firstPageLoaded - 1, direction);
+                    }
+                    else if (pageBelowViewport(pageIndex))
+                    {
+                        // Attempt to call this on the next page, do not increment anything
+                        attemptPageShow(pageIndex - 1, direction);
+                    }
+                }
+            }
+        };
+
+        // Called by adjustPages - see what pages need to be hidden, and hide them
+        var attemptPageHide = function (pageIndex, direction)
+        {
+            if (direction > 0)
+            {
+                // Scrolling down - see if this page needs to be deleted from the DOM
+                if (isPageValid(pageIndex) && pageAboveViewport(pageIndex))
+                {
+                    // Yes, delete it, reset the first page loaded
+                    deletePage(pageIndex);
+                    settings.firstPageLoaded = pageIndex + 1;
+
+                    // Try to call this function recursively until there's nothing to delete
+                    attemptPageHide(settings.firstPageLoaded, direction);
+                }
+            }
+            else
+            {
+                // Direction must be negative (not 0 - see adjustPages), we're scrolling up
+                if (isPageValid(pageIndex) && pageBelowViewport(pageIndex))
+                {
+                    // Yes, delete it, reset the last page loaded
+                    deletePage(pageIndex);
+                    settings.lastPageLoaded = pageIndex - 1;
+
+                    // Try to call this function recursively until there's nothing to delete
+                    attemptPageHide(settings.lastPageLoaded, direction);
+                }
+            }
+        };
+
+        // Handles showing and hiding pages when the user scrolls
+        var adjustPages = function (direction)
+        {
+            var i;
+
+            // Direction is negative, so we're scrolling up
+            if (direction < 0)
+            {
+                attemptPageShow(settings.firstPageLoaded, direction);
+                setCurrentPage(-1);
+                attemptPageHide(settings.lastPageLoaded, direction);
+            }
+            else if (direction > 0)
+            {
+                // Direction is positive so we're scrolling down
+                attemptPageShow(settings.lastPageLoaded, direction);
+                setCurrentPage(1);
+                attemptPageHide(settings.firstPageLoaded, direction);
+            }
+            else
+            {
+                // Horizontal scroll, check if we need to reveal any tiles
+                var lpl = settings.lastPageLoaded;
+                for (i = Math.max(settings.firstPageLoaded, 0); i <= lpl; i++)
+                {
+                    if (isPageVisible(i))
+                    {
+                        loadPage(i);
+                    }
+                }
+            }
+
+            executeCallback(settings.onScroll, settings.topScrollSoFar);
+
+            // If we're scrolling down
+            if (direction > 0)
+            {
+                executeCallback(settings.onScrollDown, settings.topScrollSoFar);
+            }
+            else if (direction < 0)
+            {
+                // We're scrolling up
+                executeCallback(settings.onScrollUp, settings.topScrollSoFar);
+            }
+        };
+
+        // Check if a row index is valid
+        var isRowValid = function (rowIndex)
+        {
+            return rowIndex >= 0 && rowIndex < settings.numRows;
+        };
+
+        // Check if a row should be visible in the viewport
+        var isRowVisible = function (rowIndex)
+        {
+            var topOfRow = settings.rowHeight * rowIndex;
+            var bottomOfRow = topOfRow + settings.rowHeight + settings.fixedPadding;
+
+            return isVerticallyInViewport(topOfRow, bottomOfRow);
+        };
+
+        // Check if a row (in grid view) is present in the DOM
+        var isRowLoaded = function (rowIndex)
+        {
+            return $(settings.selector + 'row-' + rowIndex).length > 0;
+        };
+
+        var loadRow = function (rowIndex)
+        {
+            // If the row has already been loaded, don't attempt to load it again
+            if (isRowLoaded(rowIndex))
+            {
+                return;
+            }
+
+            // Load some data for this and initialise some variables
+            var heightFromTop = (settings.rowHeight * rowIndex) + settings.fixedPadding;
+            var content = [];
+
+            // Create the opening tag for the row div
+            content.push('<div class="diva-row" id="' + settings.ID + 'row-' + rowIndex + '" style="height: ' + settings.rowHeight + '; top: ' + heightFromTop + 'px;">');
+
+            // Declare variables used in the loop
+            var i, pageIndex, filename, realWidth, realHeight, pageWidth, pageHeight, leftOffset, imageURL;
+            var imdir = settings.imageDir + "/";
+
+            // Load each page within that row
+            var ppr = settings.pagesPerRow;
+            for (i = 0; i < ppr; i++)
+            {
+                pageIndex = rowIndex * settings.pagesPerRow + i;
+
+                // If this page is the last row, don't try to load a nonexistent page
+                if (!isPageValid(pageIndex))
+                {
+                    break;
+                }
+
+                // Calculate the width, height and horizontal placement of this page
+                filename = settings.pages[pageIndex].f;
+                realWidth = getPageData(pageIndex, 'w');
+                realHeight = getPageData(pageIndex, 'h');
+                pageWidth = (settings.fixedHeightGrid) ? (settings.rowHeight - settings.fixedPadding) * realWidth / realHeight : settings.gridPageWidth;
+                pageHeight = (settings.fixedHeightGrid) ? settings.rowHeight - settings.fixedPadding : pageWidth / realWidth * realHeight;
+                leftOffset = parseInt(i * (settings.fixedPadding + settings.gridPageWidth) + settings.fixedPadding, 10);
+
+                // Make sure they're all integers for nice, round numbers
+                pageWidth = parseInt(pageWidth, 10);
+                pageHeight = parseInt(pageHeight, 10);
+
+                // Center the page if the height is fixed (otherwise, there is no horizontal padding)
+                leftOffset += (settings.fixedHeightGrid) ? (settings.gridPageWidth - pageWidth) / 2 : 0;
+                imageURL = settings.iipServerURL + "?FIF=" + imdir + filename + '&amp;HEI=' + (pageHeight + 2) + '&amp;CVT=JPEG';
+
+                // Append the HTML for this page to the string builder array
+                content.push('<div id="' + settings.ID + 'page-' + pageIndex + '" class="diva-page" style="width: ' + pageWidth + 'px; height: ' + pageHeight + 'px; left: ' + leftOffset + 'px;" title="Page ' + (pageIndex + 1) + '"></div>');
+
+                // Add each image to a queue so that images aren't loaded unnecessarily
+                addPageToQueue(rowIndex, pageIndex, imageURL, pageWidth, pageHeight);
+            }
+
+            // Append this row to the DOM
+            content.push('</div>');
+            $(document.getElementById(settings.ID + "inner")).append(content.join(''));
+        };
+
+        var deleteRow = function (rowIndex)
+        {
+            $(document.getElementById(settings.ID + 'row-' + rowIndex)).empty().remove();
+        };
+
+        // Check if the bottom of a row is above the top of the viewport (scrolling down)
+        var rowAboveViewport = function (rowIndex)
+        {
+            var bottomOfRow = settings.rowHeight * (rowIndex + 1);
+            var topOfViewport = settings.topScrollSoFar;
+
+            return (bottomOfRow < topOfViewport);
+        };
+
+        // Check if the top of a row is below the bottom of the viewport (scrolling up)
+        var rowBelowViewport = function (rowIndex)
+        {
+            var topOfRow = settings.rowHeight * rowIndex;
+            var bottomOfViewport = settings.topScrollSoFar + settings.panelHeight;
+
+            return (topOfRow > bottomOfViewport);
+        };
+
+        // Same thing as attemptPageShow only with rows
+        var attemptRowShow = function (rowIndex, direction)
+        {
+            if (direction > 0)
+            {
+                if (isRowValid(rowIndex))
+                {
+                    if (isRowVisible(rowIndex))
+                    {
+                        loadRow(rowIndex);
+                        settings.lastRowLoaded = rowIndex;
+
+                        attemptRowShow(settings.lastRowLoaded + 1, direction);
+                    }
+                    else if (rowAboveViewport(rowIndex))
+                    {
+                        attemptRowShow(rowIndex + 1, direction);
+                    }
+                }
+            }
+            else
+            {
+                if (isRowValid(rowIndex))
+                {
+                    if (isRowVisible(rowIndex))
+                    {
+                        loadRow(rowIndex);
+                        settings.firstRowLoaded = rowIndex;
+
+                        attemptRowShow(settings.firstRowLoaded - 1, direction);
+                    }
+                    else if (rowBelowViewport(rowIndex))
+                    {
+                        attemptRowShow(rowIndex - 1, direction);
+                    }
+                }
+            }
+        };
+
+        var attemptRowHide = function (rowIndex, direction)
+        {
+            if (direction > 0)
+            {
+                if (isRowValid(rowIndex) && rowAboveViewport(rowIndex))
+                {
+                    deleteRow(rowIndex);
+                    settings.firstRowLoaded++;
+
+                    attemptRowHide(settings.firstRowLoaded, direction);
+                }
+            }
+            else
+            {
+                if (isRowValid(rowIndex) && rowBelowViewport(rowIndex))
+                {
+                    deleteRow(rowIndex);
+                    settings.lastRowLoaded--;
+
+                    attemptRowHide(settings.lastRowLoaded, direction);
+                }
+            }
+        };
+
+        var adjustRows = function (direction)
+        {
+            if (direction < 0)
+            {
+                attemptRowShow(settings.firstRowLoaded, -1);
+                setCurrentRow(-1);
+                attemptRowHide(settings.lastRowLoaded, -1);
+            }
+            else if (direction > 0)
+            {
+                attemptRowShow(settings.lastRowLoaded, 1);
+                setCurrentRow(1);
+                attemptRowHide(settings.firstRowLoaded, 1);
+            }
+
+            executeCallback(settings.onScroll, settings.topScrollSoFar);
+
+            // If we're scrolling down
+            if (direction > 0)
+            {
+                executeCallback(settings.onScrollDown, settings.topScrollSoFar);
+            }
+            else if (direction < 0)
+            {
+                // We're scrolling up
+                executeCallback(settings.onScrollUp, settings.topScrollSoFar);
+            }
+        };
+
+        // Used to delay loading of page images in grid view to prevent unnecessary loads
+        var addPageToQueue = function (rowIndex, pageIndex, imageURL, pageWidth, pageHeight)
+        {
+            settings.pageTimeouts.push(setTimeout(function ()
+            {
+                if (isRowVisible(rowIndex))
+                {
+                    $(settings.selector + 'page-' + pageIndex).html('<img src="' + imageURL + '" style="width: ' + pageWidth + 'px; height: ' + pageHeight + 'px;" />');
+                }
+            }, settings.rowLoadTimeout));
+        };
+
+        // Determines and sets the "current page" (settings.currentPageIndex); called within adjustPages
+        // The "direction" is either 1 (downward scroll) or -1 (upward scroll)
+        var setCurrentPage = function (direction)
+        {
+            var middleOfViewport = settings.topScrollSoFar + (settings.panelHeight / 2);
+            var currentPage = settings.currentPageIndex;
+            var pageToConsider = settings.currentPageIndex + direction;
+            var changeCurrentPage = false;
+            var pageSelector = settings.selector + 'page-' + pageToConsider;
+
+            // When scrolling up:
+            if (direction < 0)
+            {
+                // If the previous page > middle of viewport
+                if (pageToConsider >= 0 && (settings.heightAbovePages[pageToConsider] + getPageData(pageToConsider, 'h') + (settings.verticalPadding) >= middleOfViewport))
+                {
+                    changeCurrentPage = true;
+                }
+            }
+            else if (direction > 0)
+            {
+                // When scrolling down:
+                // If this page < middle of viewport
+                if (settings.heightAbovePages[currentPage] + getPageData(currentPage, 'h') + settings.verticalPadding < middleOfViewport)
+                {
+                    changeCurrentPage = true;
+                }
+            }
+
+            if (changeCurrentPage)
+            {
+                // Set this to the current page
+                settings.currentPageIndex = pageToConsider;
+                // Now try to change the next page, given that we're not going to a specific page
+                // Calls itself recursively - this way we accurately obtain the current page
+                if (direction !== 0)
+                {
+                    if (!setCurrentPage(direction))
+                    {
+                        var filename = settings.pages[pageToConsider].f;
+                        executeCallback(settings.onSetCurrentPage, pageToConsider, filename);
+                        Events.publish("VisiblePageDidChange", [pageToConsider, filename]);
+                    }
+                }
+                return true;
+            }
+
+            return false;
+        };
+
+        // Sets the current page in grid view
+        var setCurrentRow = function (direction)
+        {
+            var currentRow = Math.floor(settings.currentPageIndex / settings.pagesPerRow);
+            var rowToConsider = currentRow + parseInt(direction, 10);
+            var middleOfViewport = settings.topScrollSoFar + (settings.panelHeight / 2);
+            var changeCurrentRow = false;
+
+            if (direction < 0)
+            {
+                if (rowToConsider >= 0 && (settings.rowHeight * currentRow >= middleOfViewport || settings.rowHeight * rowToConsider >= settings.topScrollSoFar))
+                {
+                    changeCurrentRow = true;
+                }
+            }
+            else if (direction > 0)
+            {
+                if ((settings.rowHeight * (currentRow + 1)) < settings.topScrollSoFar && isRowValid(rowToConsider))
+                {
+                    changeCurrentRow = true;
+                }
+            }
+
+            if (changeCurrentRow)
+            {
+                settings.currentPageIndex = rowToConsider * settings.pagesPerRow;
+
+                if (direction !== 0)
+                {
+                    if (!setCurrentRow(direction))
+                    {
+                        var pageIndex = settings.currentPageIndex;
+                        var filename = settings.pages[pageIndex].f;
+                        Events.publish("VisiblePageDidChange", [pageIndex, filename]);
+                    }
+                }
+
+                return true;
+            }
+
+            return false;
+        };
+
+        // Helper function for going to a particular page
+        // Vertical offset: from the top of the page (including the top padding)
+        // Horizontal offset: from the center of the page; can be negative if to the left
+        var gotoPage = function (pageIndex, verticalOffset, horizontalOffset)
+        {
+            verticalOffset = (typeof verticalOffset !== 'undefined') ? verticalOffset : 0;
+            horizontalOffset = (typeof horizontalOffset !== 'undefined') ? horizontalOffset: 0;
+            var desiredTop = settings.heightAbovePages[pageIndex] + verticalOffset;
+            var desiredLeft = (settings.maxWidths[settings.zoomLevel] - settings.panelWidth) / 2 + settings.horizontalPadding + horizontalOffset;
+
+            $(settings.outerSelector).scrollTop(desiredTop);
+            $(settings.outerSelector).scrollLeft(desiredLeft);
+
+            // Pretend that this is the current page
+            settings.currentPageIndex = pageIndex;
+            //settings.toolbar.updateCurrentPage();
+            var filename = settings.pages[pageIndex].f;
+
+            Events.publish("VisiblePageDidChange", [pageIndex, filename]);
+            executeCallback(settings.onSetCurrentPage, pageIndex, filename);
+
+            // Execute the onJump callback
+            executeCallback(settings.onJump, pageIndex);
+        };
+
+        // Calculates the desired row, then scrolls there
+        var gotoRow = function (pageIndex)
+        {
+            var desiredRow = Math.floor(pageIndex / settings.pagesPerRow);
+            var desiredTop = desiredRow * settings.rowHeight;
+            $(settings.outerSelector).scrollTop(desiredTop);
+
+            // Pretend that this is the current page (it probably isn't)
+            settings.currentPageIndex = pageIndex;
+            var filename = settings.pages[pageIndex].f;
+            Events.publish("VisiblePageDidChange", [pageIndex, filename]);
+        };
+
+        // Helper function called by loadDocument to scroll to the desired place
+        var documentScroll = function ()
+        {
+            // If settings.preZoomOffset is defined, the zoom was trigged by double-clicking
+            // We then zoom in on a specific region
+            if (settings.preZoomOffset)
+            {
+                var clickedPage = settings.preZoomOffset.i;
+                var heightAbovePage = settings.heightAbovePages[clickedPage] + settings.verticalPadding;
+                var pageLeftOffset = settings.pageLeftOffsets[clickedPage];
+                var zoomRatio = Math.pow(2, settings.zoomLevel - settings.oldZoomLevel);
+
+                var distanceFromViewport = {
+                    x: settings.preZoomOffset.originalX - settings.viewerXOffset,
+                    y: settings.preZoomOffset.originalY - settings.viewerYOffset
+                };
+
+                var newDistanceToEdge = {
+                    x: settings.preZoomOffset.x * zoomRatio,
+                    y: settings.preZoomOffset.y * zoomRatio
+                };
+
+                var newScroll = {
+                    x: newDistanceToEdge.x - distanceFromViewport.x + pageLeftOffset,
+                    y: newDistanceToEdge.y - distanceFromViewport.y + heightAbovePage
+                };
+
+                $(settings.outerSelector).scrollTop(newScroll.y).scrollLeft(newScroll.x);
+
+                settings.preZoomOffset = undefined;
+            }
+            else
+            {
+                // Otherwise, we just scroll to the page saved in settings.goDirectlyTo (must be valid)
+                // Make sure the value for settings.goDirectlyTo is valid
+                if (!isPageValid(settings.goDirectlyTo))
+                {
+                    settings.goDirectlyTo = 0;
+                }
+
+                // We use the stored y/x offsets (relative to the top of the page and the center, respectively)
+                gotoPage(settings.goDirectlyTo, settings.verticalOffset, settings.horizontalOffset);
+                settings.horizontalOffset = 0;
+                settings.verticalOffset = 0;
+            }
+        };
+
+        // Don't call this when not in grid mode please
+        // Scrolls to the relevant place when in grid view
+        var gridScroll = function ()
+        {
+            // Figure out and scroll to the row containing the current page
+            gotoRow(settings.goDirectlyTo);
+        };
+
+        // If the given zoom level is valid, returns it; else, returns the min
+        var getValidZoomLevel = function (zoomLevel)
+        {
+            return (zoomLevel >= settings.minZoomLevel && zoomLevel <= settings.maxZoomLevel) ? zoomLevel : settings.minZoomLevel;
+        };
+
+        var getValidPagesPerRow = function (pagesPerRow)
+        {
+            return (pagesPerRow >= settings.minPagesPerRow && pagesPerRow <= settings.maxPagesPerRow) ? pagesPerRow : settings.maxPagesPerRow;
+        };
+
+        // Reset some settings and empty the viewport
+        var clearViewer = function ()
+        {
+            settings.allTilesLoaded = [];
+            $(settings.outerSelector).scrollTop(0);
+            settings.topScrollSoFar = 0;
+            $(settings.innerSelector).empty();
+            settings.firstPageLoaded = 0;
+            settings.firstRowLoaded = -1;
+            settings.previousTopScroll = 0;
+
+            // Clear all the timeouts to prevent undesired pages from loading
+            clearTimeout(settings.resizeTimer);
+
+            while (settings.pageTimeouts.length)
+            {
+                clearTimeout(settings.pageTimeouts.pop());
+            }
+        };
+
+        // Called when we don't necessarily know which view to go into
+        var loadViewer = function ()
+        {
+            if (settings.inGrid)
+            {
+                loadGrid();
+            }
+            else
+            {
+                loadDocument();
+            }
+        };
+
+        // Called every time we need to load document view (after zooming, fullscreen, etc)
+        var loadDocument = function ()
+        {
+            clearViewer();
+
+            // Make sure the zoom level we've been given is valid
+            settings.zoomLevel = getValidZoomLevel(settings.zoomLevel);
+            var z = settings.zoomLevel;
+
+            // Calculate the horizontal and vertical inter-page padding
+            if (settings.adaptivePadding > 0)
+            {
+                settings.horizontalPadding = settings.averageWidths[z] * settings.adaptivePadding;
+                settings.verticalPadding = settings.averageHeights[z] * settings.adaptivePadding;
+            }
+            else
+            {
+                // It's less than or equal to 0; use fixedPadding instead
+                settings.horizontalPadding = settings.fixedPadding;
+                settings.verticalPadding = settings.fixedPadding;
+            }
+
+            // Make sure the vertical padding is at least 40, if plugin icons are enabled
+            if (settings.pageTools.length)
+            {
+                settings.verticalPadding = Math.max(40, settings.horizontalPadding);
+            }
+
+            // Now reset some things that need to be changed after each zoom
+            settings.totalHeight = settings.totalHeights[z] + settings.verticalPadding * (settings.numPages + 1);
+            settings.dimAfterZoom = settings.totalHeight;
+
+            // Determine the width of the inner element (based on the max width)
+            var maxWidthToSet = settings.maxWidths[z] + settings.horizontalPadding * 2;
+            var widthToSet = Math.max(maxWidthToSet, settings.panelWidth);
+
+            // Needed to set settings.heightAbovePages - initially just the top padding
+            var heightSoFar = 0;
+            var i;
+
+            for (i = 0; i < settings.numPages; i++)
+            {
+                // First set the height above that page by adding this height to the previous total
+                // A page includes the padding above it
+                settings.heightAbovePages[i] = heightSoFar;
+
+                // Has to be done this way otherwise you get the height of the page included too
+                heightSoFar = settings.heightAbovePages[i] + getPageData(i, 'h') + settings.verticalPadding;
+
+                // Figure out the pageLeftOffset stuff
+                settings.pageLeftOffsets[i] = (widthToSet - getPageData(i, 'w')) / 2;
+
+                // Now try to load the page ONLY if the page needs to be loaded
+                // Take scrolling into account later, just try this for now
+                if (isPageVisible(i))
+                {
+                    loadPage(i);
+                    settings.lastPageLoaded = i;
+                }
+            }
+
+            // If this is not the initial load, execute the zoom callbacks
+            if (settings.oldZoomLevel >= 0)
+            {
+                if (settings.oldZoomLevel < settings.zoomLevel)
+                {
+                    executeCallback(settings.onZoomIn, z);
+                }
+                else
+                {
+                    executeCallback(settings.onZoomOut, z);
+                }
+
+                executeCallback(settings.onZoom, z);
+            }
+
+            // Set the height and width of documentpane (necessary for dragscrollable)
+            $(settings.innerSelector).height(Math.round(settings.totalHeight));
+            $(settings.innerSelector).width(Math.round(widthToSet));
+
+            // Scroll to the proper place
+            documentScroll();
+
+            // For the iPad - wait until this request finishes before accepting others
+            if (settings.scaleWait)
+            {
+                settings.scaleWait = false;
+            }
+
+            var fileName = settings.pages[settings.currentPageIndex].f;
+            executeCallback(settings.onDocumentLoaded, settings.lastPageLoaded, fileName);
+            Events.publish("DocumentHasFinishedLoading", [settings.lastPageLoaded, fileName]);
+        };
+
+        var loadGrid = function ()
+        {
+            clearViewer();
+
+            // Make sure the pages per row setting is valid
+            settings.pagesPerRow = getValidPagesPerRow(settings.pagesPerRow);
+
+            var horizontalPadding = settings.fixedPadding * (settings.pagesPerRow + 1);
+            var pageWidth = (settings.panelWidth - horizontalPadding) / settings.pagesPerRow;
+            settings.gridPageWidth = pageWidth;
+
+            // Calculate the row height depending on whether we want to fix the width or the height
+            settings.rowHeight = (settings.fixedHeightGrid) ? settings.fixedPadding + settings.minRatio * pageWidth : settings.fixedPadding + settings.maxRatio * pageWidth;
+            settings.numRows = Math.ceil(settings.numPages / settings.pagesPerRow);
+            settings.totalHeight = settings.numRows * settings.rowHeight + settings.fixedPadding;
+
+            $(settings.innerSelector).height(Math.round(settings.totalHeight));
+            $(settings.innerSelector).width(Math.round(settings.panelWidth));
+
+            // First scroll directly to the row containing the current page
+            gridScroll();
+
+            var i, rowIndex;
+
+            // Figure out the row each page is in
+            var np = settings.numPages;
+            for (i = 0; i < np; i += settings.pagesPerRow)
+            {
+                rowIndex = Math.floor(i / settings.pagesPerRow);
+
+                if (isRowVisible(rowIndex))
+                {
+                    settings.firstRowLoaded = (settings.firstRowLoaded < 0) ? rowIndex : settings.firstRowLoaded;
+                    loadRow(rowIndex);
+                    settings.lastRowLoaded = rowIndex;
+                }
+            }
+        };
+
+        // Handles switching in and out of fullscreen mode
+        // Should only be called after changing settings.inFullscreen
+        var handleModeChange = function (changeView)
+        {
+            // Save some offsets (required for scrolling properly), if it's not the initial load
+            if (settings.oldZoomLevel >= 0)
+            {
+                if (!settings.inGrid)
+                {
+                    var pageOffset = $(settings.selector + 'page-' + settings.currentPageIndex).offset();
+                    var topOffset = -(pageOffset.top - settings.verticalPadding - settings.viewerYOffset);
+                    var expectedLeft = (settings.panelWidth - getPageData(settings.currentPageIndex, 'w')) / 2;
+                    var leftOffset = -(pageOffset.left - settings.viewerXOffset - expectedLeft);
+                    settings.verticalOffset = topOffset;
+                    settings.horizontalOffset = leftOffset;
+                }
+            }
+
+            // Change the look of the toolbar
+            Events.publish("ModeDidSwitch", null);
+
+            // Toggle the classes
+            $(settings.selector + 'fullscreen').toggleClass('diva-in-fullscreen');
+            $(settings.outerSelector).toggleClass('diva-fullscreen');
+            $('body').toggleClass('diva-hide-scrollbar');
+            $(settings.parentSelector).toggleClass('diva-full-width');
+
+            // Reset the panel dimensions
+            settings.panelHeight = $(settings.outerSelector).height();
+            settings.panelWidth = $(settings.outerSelector).width() - settings.scrollbarWidth;
+            $(settings.innerSelector).width(settings.panelWidth);
+
+            // Recalculate the viewer offsets
+            settings.viewerXOffset = $(settings.outerSelector).offset().left;
+            settings.viewerYOffset = $(settings.outerSelector).offset().top;
+
+            // Used by setState when we need to change the view and the mode
+            if (changeView)
+            {
+                settings.inGrid = !settings.inGrid;
+                handleViewChange();
+            }
+            else
+            {
+                loadViewer();
+            }
+
+            // Execute callbacks
+            executeCallback(settings.onModeToggle, settings.inFullscreen);
+            Events.publish("ModeHasChanged", [settings.inFullScreen]);
+        };
+
+        // Handles switching in and out of grid view
+        // Should only be called after changing settings.inGrid
+        var handleViewChange = function ()
+        {
+            // Switch the slider
+            // Events.publish("ViewDidSwitch", null);
+
+            loadViewer();
+            executeCallback(settings.onViewToggle, settings.inGrid);
+            Events.publish("ViewDidSwitch", [settings.inGrid]);
+        };
+
+        // Called when the fullscreen icon is clicked
+        var toggleFullscreen = function ()
+        {
+            settings.goDirectlyTo = settings.currentPageIndex;
+            settings.inFullscreen = !settings.inFullscreen;
+            handleModeChange(false);
+        };
+
+        // Called when the grid icon is clicked
+        var toggleGrid = function ()
+        {
+            settings.goDirectlyTo = settings.currentPageIndex;
+            settings.inGrid = !settings.inGrid;
+            handleViewChange();
+        };
+
+        // Called after double-click or ctrl+double-click events on pages in document view
+        var handleDocumentDoubleClick = function (event)
+        {
+            var pageOffset = $(this).offset();
+            var offsetX = event.pageX - pageOffset.left;
+            var offsetY = event.pageY - pageOffset.top;
+
+            // Store the offset information so that it can be used in documentScroll()
+            settings.preZoomOffset = {
+                x: offsetX,
+                y: offsetY,
+                originalX: event.pageX,
+                originalY: event.pageY,
+                i: $(this).attr('data-index')
+            };
+
+            // Hold control to zoom out, otherwise, zoom in
+            var newZoomLevel = (event.ctrlKey) ? settings.zoomLevel - 1 : settings.zoomLevel + 1;
+
+            handleZoom(newZoomLevel);
+        };
+
+        // Called after double-clicking on a page in grid view
+        var handleGridDoubleClick = function (event)
+        {
+            // Figure out the page that was clicked, scroll to that page
+            var sel = document.getElementById(settings.ID + "outer");
+            var centerX = (event.pageX - settings.viewerXOffset) + sel.scrollLeft;
+            var centerY = (event.pageY - settings.viewerYOffset) + sel.scrollTop;
+            var rowIndex = Math.floor(centerY / settings.rowHeight);
+            var colIndex = Math.floor(centerX / (settings.panelWidth / settings.pagesPerRow));
+            var pageIndex = rowIndex * settings.pagesPerRow + colIndex;
+            settings.goDirectlyTo = pageIndex;
+
+            // Leave grid view, jump directly to the desired page
+            settings.inGrid = false;
+            handleViewChange();
+        };
+
+        // Handles pinch-zooming for mobile devices
+        var handlePinchZoom = function (event)
+        {
+            var newZoomLevel = settings.zoomLevel;
+
+            // First figure out the new zoom level:
+            if (event.scale > 1 && newZoomLevel < settings.maxZoomLevel)
+            {
+                newZoomLevel++;
+            }
+            else if (event.scale < 1 && newZoomLevel > settings.minZoomLevel)
+            {
+                newZoomLevel--;
+            }
+            else
+            {
+                return;
+            }
+
+            // Set it to true so we have to wait for this one to finish
+            settings.scaleWait = true;
+
+            // Has to call handleZoomSlide so that the coordinates are kept
+            handleZoom(newZoomLevel);
+        };
+
+        // Called to handle any zoom level
+        var handleZoom = function (newValue)
+        {
+            var newZoomLevel = getValidZoomLevel(newValue);
+
+            // If the zoom level provided is invalid, return false
+            if (newZoomLevel !== newValue)
+            {
+                return false;
+            }
+
+            settings.oldZoomLevel = settings.zoomLevel;
+            settings.zoomLevel = newZoomLevel;
+
+            // Update the slider
+            Events.publish("ZoomLevelDidChange", null);
+
+            loadDocument();
+
+            return true;
+        };
+
+        // Called to handle changing the pages per row slider
+        var handleGrid = function (newValue)
+        {
+            var newPagesPerRow = getValidPagesPerRow(newValue);
+
+            // If the value provided is invalid, return false
+            if (newPagesPerRow !== newValue)
+            {
+                return false;
+            }
+
+            settings.oldPagesPerRow = settings.zoomLevel;
+            settings.pagesPerRow = newPagesPerRow;
+
+            // Update the slider
+            Events.publish("GridRowNumberDidChange", null);
+
+            loadGrid();
+        };
+
+        var getYOffset = function ()
+        {
+            var yScroll = document.getElementById(settings.ID + "outer").scrollTop;
+            var topOfPage = settings.heightAbovePages[settings.currentPageIndex];
+
+            return parseInt(yScroll - topOfPage, 10);
+        };
+
+        var getXOffset = function ()
+        {
+            var innerWidth = settings.maxWidths[settings.zoomLevel] + settings.horizontalPadding * 2;
+            var centerX = (innerWidth - settings.panelWidth) / 2;
+            var xoff = document.getElementById(settings.ID + "outer").scrollLeft - centerX;
+            return parseInt(xoff, 10);
+        };
+
+        var getState = function ()
+        {
+            var state = {
+                'f': settings.inFullscreen,
+                'g': settings.inGrid,
+                'z': settings.zoomLevel,
+                'n': settings.pagesPerRow,
+                'i': (settings.enableFilename) ? settings.pages[settings.currentPageIndex].f : false,
+                'p': (settings.enableFilename) ? false : settings.currentPageIndex + 1,
+                'y': (settings.inGrid) ? false : getYOffset(),
+                'x': (settings.inGrid) ? false : getXOffset(),
+                'h': (settings.inFullscreen) ? false : settings.panelHeight,
+                'w': (settings.inFullscreen) ? false : $(settings.outerSelector).width()
+            };
+
+            return state;
+        };
+
+        var getURLHash = function ()
+        {
+            var hashParams = getState();
+            var hashStringBuilder = [];
+            var param;
+
+            for (param in hashParams)
+            {
+                if (hashParams[param] !== false)
+                {
+                    hashStringBuilder.push(param + settings.hashParamSuffix + '=' + hashParams[param]);
+                }
+            }
+
+            return hashStringBuilder.join('&');
+        };
+
+        // Returns the URL to the current state of the document viewer (so it should be an exact replica)
+        var getCurrentURL = function ()
+        {
+            return location.protocol + '//' + location.host + location.pathname + '#' + getURLHash();
+        };
+
+        // Called in init and when the orientation changes
+        var adjustMobileWebkitDims = function ()
+        {
+            var outerOffset = $(settings.outerSelector).offset().top;
+            settings.panelHeight = window.innerHeight - outerOffset - settings.viewerHeightPadding;
+            settings.panelWidth = window.innerWidth - settings.viewerWidthPadding;
+
+            // $(settings.parentSelector).width(settings.panelWidth);
+            // document.getElementById(settings.parentSelector.substring(1)).style.width = settings.panelWidth + "px";
+            settings.parentSelector.style.width = settings.panelWidth + "px";
+
+            if (settings.enableAutoHeight)
+            {
+                document.getElementById(settings.ID + "outer").style.height = settings.panelHeight + "px";
+            }
+
+            if (settings.enableAutoWidth)
+            {
+                document.getElementById(settings.ID + "outer").style.width = settings.panelWidth + "px";
+            }
+        };
+
+        // Will return true if something has changed, false otherwise
+        var adjustBrowserDims = function ()
+        {
+            // Only resize if the browser viewport is too small
+            var newHeight = $(settings.outerSelector).height();
+            var newWidth = $(settings.parentSelector).width() - settings.scrollbarWidth;
+            var outerOffset = $(settings.outerSelector).offset().top;
+
+            var windowHeight = window.innerHeight || document.documentElement.clientHeight;
+            var windowWidth = window.innerWidth || document.documentElement.clientWidth;
+            // 2 or 1 pixels for the border
+            var desiredWidth = windowWidth - settings.viewerWidthPadding - settings.scrollbarWidth - 2;
+            var desiredHeight = windowHeight - outerOffset - settings.viewerHeightPadding - 1;
+
+            if (settings.enableAutoHeight)
+            {
+                if (newHeight + outerOffset + 16 > window.innerHeight)
+                {
+                    newHeight = desiredHeight;
+                }
+                else if (newHeight <= settings.originalHeight)
+                {
+                    newHeight = Math.min(desiredHeight, settings.originalHeight);
+                }
+            }
+
+            if (settings.enableAutoWidth)
+            {
+                if (newWidth + 32 > window.innerWidth)
+                {
+                    newWidth = desiredWidth;
+                }
+                else if (newWidth <= settings.originalWidth)
+                {
+                    newWidth = Math.min(desiredWidth, settings.originalWidth);
+                }
+
+                settings.parentSelector[0].style.width = newWidth + settings.scrollbarWidth;
+            }
+
+            if (newWidth !== settings.panelWidth || newHeight !== settings.panelHeight)
+            {
+                var el = document.getElementById(settings.ID + "outer");
+                el.style.height = newHeight + "px";
+                el.style.width = newWidth + settings.scrollbarWidth + "px";
+                settings.panelWidth = newWidth;
+                settings.panelHeight = newHeight;
+                return true;
+            }
+
+            return false;
+        };
+
+        // Update the panelHeight and panelWidth based on the window size
+        var adjustFullscreenDims = function ()
+        {
+            settings.panelWidth = window.innerWidth - settings.scrollbarWidth;
+            settings.panelHeight = window.innerHeight;
+
+            return true;
+        };
+
+        var resizeViewer = function (newWidth, newHeight)
+        {
+            if (newWidth >= settings.minWidth)
+            {
+                settings.originalWidth = newWidth;
+                $(settings.outerSelector).width(newWidth);
+                document.getElementById(settings.ID + "outer").style.width = newWidth + "px";
+
+                settings.panelWidth = newWidth - settings.scrollbarWidth;
+
+                // Should also change the width of the container
+                settings.parentSelector[0].style.width = newWidth + "px";
+            }
+
+            if (newHeight >= settings.minHeight)
+            {
+                settings.originalHeight = newHeight;
+                document.getElementById(settings.ID + "outer").style.height = newHeight + "px";
+
+                settings.panelHeight = newHeight;
+            }
+        };
+
+        // Binds most of the event handlers (some more in createToolbar)
+        var handleEvents = function ()
+        {
+            // Create the fullscreen toggle icon if fullscreen is enabled
+            if (settings.enableFullscreen)
+            {
+                // Event handler for fullscreen toggling
+                $(settings.selector + 'fullscreen').click(function ()
+                {
+                    toggleFullscreen();
+                });
+            }
+
+            // Change the cursor for dragging
+            $(settings.innerSelector).mouseover(function ()
+            {
+                $(this).removeClass('diva-grabbing').addClass('diva-grab');
+            });
+
+            $(settings.innerSelector).mouseout(function ()
+            {
+                $(this).removeClass('diva-grab');
+            });
+
+            $(settings.innerSelector).mousedown(function ()
+            {
+                $(this).removeClass('diva-grab').addClass('diva-grabbing');
+            });
+
+            $(settings.innerSelector).mouseup(function ()
+            {
+                $(this).removeClass('diva-grabbing').addClass('diva-grab');
+            });
+
+            // Set drag scroll on first descendant of class dragger on both selected elements
+            $(settings.outerSelector + ', ' + settings.innerSelector).dragscrollable({dragSelector: '.diva-dragger', acceptPropagatedEvent: true});
+
+            // Handle the scroll
+            $(settings.outerSelector).scroll(function ()
+            {
+                settings.topScrollSoFar = document.getElementById(settings.ID + "outer").scrollTop;
+                var direction = settings.topScrollSoFar - settings.previousTopScroll;
+
+                if (settings.inGrid)
+                {
+                    adjustRows(direction);
+                }
+                else
+                {
+                    adjustPages(direction);
+                    settings.leftScrollSoFar = $(this).scrollLeft();
+                }
+
+                settings.previousTopScroll = settings.topScrollSoFar;
+            });
+
+            // Double-click to zoom
+            $(settings.outerSelector).on('dblclick', '.diva-document-page', function (event)
+            {
+                handleDocumentDoubleClick.call(this, event);
+            });
+
+            // Handle the control key for macs (in conjunction with double-clicking)
+            $(settings.outerSelector).on('contextmenu', '.diva-document-page', function (event)
+            {
+                if (event.ctrlKey)
+                {
+                    // In Firefox, this doesn't trigger a double-click, so we apply one manually
+                    clearTimeout(settings.singleClickTimeout);
+
+                    if (settings.singleClick)
+                    {
+                        handleDocumentDoubleClick.call(this, event);
+                        settings.singleClick = false;
+                    }
+                    else
+                    {
+                        settings.singleClick = true;
+
+                        // Set it to false again after 500 milliseconds (standard double-click timeout)
+                        settings.singleClickTimeout = setTimeout(function ()
+                        {
+                            settings.singleClick = false;
+                        }, 500);
+                    }
+
+                    return false;
+                }
+            });
+
+            $(settings.outerSelector).on('dblclick', '.diva-row', function (event)
+            {
+                handleGridDoubleClick.call(this, event);
+            });
+
+            // Check if the user is on a iPhone or iPod touch or iPad
+            if (settings.mobileWebkit)
+            {
+                // Prevent resizing (below from http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/)
+                var toAppend = [];
+                toAppend.push('<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" />');
+
+                // Eliminate URL and button bars if added to home screen
+                toAppend.push('<meta name="apple-mobile-web-app-capable" content="yes" />');
+
+                // Choose how to handle the phone status bar
+                toAppend.push('<meta name="apple-mobile-web-app-status-bar-style" content="black" />');
+                $('head').append(toAppend.join('\n'));
+
+                // Block the user from moving the window only if it's not integrated
+                if (settings.blockMobileMove)
+                {
+                    $('body').bind('touchmove', function (event)
+                    {
+                        var e = event.originalEvent;
+                        e.preventDefault();
+
+                        return false;
+                    });
+                }
+
+                // Allow pinch-zooming
+                $('body').bind('gestureend', function (event)
+                {
+                    var e = event.originalEvent;
+
+                    if (!settings.scaleWait)
+                    {
+                        // Save the page we're currently on so we scroll there
+                        settings.goDirectlyTo = settings.currentPageIndex;
+
+                        if (settings.inGrid)
+                        {
+                            settings.inGrid = false;
+
+                            handleViewChange();
+                        }
+                        else
+                        {
+                            handlePinchZoom(e);
+                        }
+                    }
+                    return false;
+                });
+
+                // Listen to orientation change event
+                $(window).bind('orientationchange', function (event)
+                {
+                    settings.orientationChange = true;
+                    adjustMobileWebkitDims();
+
+                    // Reload the viewer to account for the resized viewport
+                    settings.goDirectlyTo = settings.currentPageIndex;
+                    loadViewer();
+                });
+
+                // Inertial scrolling
+                $(settings.outerSelector).kinetic();
+            }
+
+            // Only check if either scrollBySpace or scrollByKeys is enabled
+            if (settings.enableSpaceScroll || settings.enableKeyScroll)
+            {
+                var spaceKey = $.ui.keyCode.SPACE;
+                var pageUpKey = $.ui.keyCode.PAGE_UP;
+                var pageDownKey = $.ui.keyCode.PAGE_DOWN;
+                var homeKey = $.ui.keyCode.HOME;
+                var endKey = $.ui.keyCode.END;
+
+                // Catch the key presses in document
+                $(document).keydown(function (event)
+                {
+                    // Space or page down - go to the next page
+                    if ((settings.enableSpaceScroll && event.keyCode === spaceKey) || (settings.enableKeyScroll && event.keyCode === pageDownKey))
+                    {
+                        $(settings.outerSelector).scrollTop(settings.topScrollSoFar + settings.panelHeight);
+                        return false;
+                    }
+
+                    // Page up - go to the previous page
+                    if (settings.enableKeyScroll && event.keyCode === pageUpKey)
+                    {
+                        $(settings.outerSelector).scrollTop(settings.topScrollSoFar - settings.panelHeight);
+                        return false;
+                    }
+
+                    // Home key - go to the beginning of the document
+                    if (settings.enableKeyScroll && event.keyCode === homeKey)
+                    {
+                        $(settings.outerSelector).scrollTop(0);
+                        return false;
+                    }
+
+                    // End key - go to the end of the document
+                    if (settings.enableKeyScroll && event.keyCode === endKey)
+                    {
+                        $(settings.outerSelector).scrollTop(settings.totalHeight);
+                        return false;
+                    }
+                });
+
+                // Handle window resizing events
+                if (!settings.mobileWebkit)
+                {
+                    $(window).resize(function ()
+                    {
+                        var adjustSuccess = (settings.inFullscreen) ? adjustFullscreenDims() : adjustBrowserDims();
+
+                        if (adjustSuccess)
+                        {
+                            // Cancel any previously-set resize timeouts
+                            clearTimeout(settings.resizeTimer);
+
+                            settings.resizeTimer = setTimeout(function ()
+                            {
+                                settings.goDirectlyTo = settings.currentPageIndex;
+                                loadViewer();
+                            }, 200);
+                        }
+                    });
+                }
+            }
+        };
+
+        // Handles all status updating etc (both fullscreen and not)
+        var createToolbar = function () {
+            // Prepare the HTML for the various components
+            var gridIconHTML = (settings.enableGridIcon) ? '<div class="diva-grid-icon' + (settings.inGrid ? ' diva-in-grid' : '') + '" id="' + settings.ID + 'grid-icon" title="Toggle grid view"></div>' : '';
+            var linkIconHTML = (settings.enableLinkIcon) ? '<div class="diva-link-icon" id="' + settings.ID + 'link-icon" style="' + (settings.enableGridIcon ? 'border-left: 0px' : '') + '" title="Link to this page"></div>' : '';
+            var zoomSliderHTML = (settings.enableZoomSlider) ? '<div id="' + settings.ID + 'zoom-slider"></div>' : '';
+            var gridSliderHTML = (settings.enableGridSlider) ? '<div id="' + settings.ID + 'grid-slider"></div>' : '';
+            var gotoPageHTML = (settings.enableGotoPage) ? '<form id="' + settings.ID + 'goto-page" class="diva-goto-form"><input type="text" id="' + settings.ID + 'goto-page-input" / class="diva-input"> <input type="submit" value="Go" style="margin-top: 0px;" /></form>' : '';
+            var zoomSliderLabelHTML = (settings.enableZoomSlider) ? '<div id="' + settings.ID + 'zoom-slider-label" class="diva-slider-label">Zoom level: <span id="' + settings.ID + 'zoom-level">' + settings.zoomLevel + '</span></div>' : '';
+            var gridSliderLabelHTML = (settings.enableGridSlider) ? '<div id="' + settings.ID + 'grid-slider-label" class="diva-slider-label">Pages per row: <span id="' + settings.ID + 'pages-per-row">' + settings.pagesPerRow + '</span></div>' : '';
+            var pageNumberHTML = '<div class="diva-page-label">Page <span id="' + settings.ID + 'current-page">1</span> of <span id="' + settings.ID + 'num-pages">' + settings.numPages + '</span></div>';
+
+            // If the viewer is specified to be "contained", we make room for the fullscreen icon
+            var otherToolbarClass = '';
+
+            if (settings.contained)
+            {
+                // Make sure the container element does not have a static position
+                // (Needed for the fullscreen icon to be contained)
+                if ($(settings.parentSelector).css('position') === 'static')
+                {
+                    $(settings.parentSelector).addClass('diva-relative-position');
+                }
+
+                otherToolbarClass = ' diva-fullscreen-space';
+
+                // If enableAutoTitle is set to TRUE, move it down
+                if (settings.enableAutoTitle)
+                {
+                    $(settings.selector + 'fullscreen').addClass('diva-contained');
+                }
+            }
+
+            var toolbarHTML = '<div id="' + settings.ID + 'tools-left" class="diva-tools-left' + otherToolbarClass + '">' + zoomSliderHTML + gridSliderHTML + zoomSliderLabelHTML + gridSliderLabelHTML + '</div><div id="' + settings.ID + 'tools-right" class="diva-tools-right">' + linkIconHTML + gridIconHTML + '<div class="diva-page-nav">' + gotoPageHTML + pageNumberHTML + '</div></div>';
+
+            if (settings.toolbarParentSelector)
+            {
+                $(settings.toolbarParentSelector).prepend('<div id="' + settings.ID + 'tools" class="diva-tools">' + toolbarHTML + '</div>');
+            }
+            else
+            {
+                $(settings.parentSelector).prepend('<div id="' + settings.ID + 'tools" class="diva-tools">' + toolbarHTML + '</div>');
+            }
+
+            // Create the zoom slider
+            $(settings.selector + 'zoom-slider').slider({
+                value: settings.zoomLevel,
+                min: settings.minZoomLevel,
+                max: settings.maxZoomLevel,
+                step: 1,
+                slide: function (event, ui)
+                {
+                    var i = settings.currentPageIndex;
+                    settings.goDirectlyTo = i;
+
+                    // Figure out the horizontal and vertical offsets
+                    // (Try to zoom in on the current center)
+                    var zoomRatio = Math.pow(2, ui.value - settings.zoomLevel);
+                    var innerWidth = settings.maxWidths[settings.zoomLevel] + settings.horizontalPadding * 2;
+                    var centerX = $(settings.outerSelector).scrollLeft() - (innerWidth - settings.panelWidth) / 2;
+                    settings.horizontalOffset = (innerWidth > settings.panelWidth) ? centerX * zoomRatio : 0;
+                    settings.verticalOffset = zoomRatio * ($(settings.outerSelector).scrollTop() - settings.heightAbovePages[i]);
+
+                    handleZoom(ui.value);
+                },
+                change: function (event, ui)
+                {
+                    if (ui.value !== settings.zoomLevel)
+                    {
+                        handleZoom(ui.value);
+                    }
+                }
+            });
+
+            // Create the grid slider
+            $(settings.selector + 'grid-slider').slider(
+            {
+                value: settings.pagesPerRow,
+                min: settings.minPagesPerRow,
+                max: settings.maxPagesPerRow,
+                step: 1,
+                slide: function (event, ui)
+                {
+                    handleGrid(ui.value);
+                },
+                change: function (event, ui)
+                {
+                    if (ui.value !== settings.pagesPerRow)
+                    {
+                        handleGrid(ui.value);
+                    }
+                }
+            });
+
+            // Handle clicking of the grid icon
+            $(settings.selector + 'grid-icon').click(function ()
+            {
+                toggleGrid();
+            });
+
+            // Handle going to a specific page using the input box
+            $(settings.selector + 'goto-page').submit(function ()
+            {
+                var desiredPage = parseInt($(settings.selector + 'goto-page-input').val(), 10);
+                var pageIndex = desiredPage - 1;
+
+                if (!isPageValid(pageIndex))
+                {
+                    alert("Invalid page number");
+                }
+                else
+                {
+                    if (settings.inGrid)
+                    {
+                        gotoRow(pageIndex);
+                    }
+                    else
+                    {
+                        gotoPage(pageIndex, 0, 0);
+                    }
+                }
+
+                // Prevent the default action of reloading the page
+                return false;
+            });
+
+            // Handle the creation of the link popup box
+            $(settings.selector + 'link-icon').click(function ()
+            {
+                $('body').prepend('<div id="' + settings.ID + 'link-popup" class="diva-link-popup"><input id="' + settings.ID + 'link-popup-input" class="diva-input" type="text" value="' + getCurrentURL() + '"/></div>');
+
+                if (settings.inFullscreen)
+                {
+                    $(settings.selector + 'link-popup').addClass('in-fullscreen');
+                }
+                else
+                {
+                    // Calculate the left and top offsets
+                    // Compensate for border, popup width
+                    var leftOffset = $(settings.outerSelector).offset().left + settings.panelWidth;
+                    leftOffset += settings.scrollbarWidth - 240 - 1;
+                    var topOffset = $(settings.outerSelector).offset().top + 1;
+
+                    $(settings.selector + 'link-popup').removeClass('in-fullscreen').css(
+                    {
+                        'top': topOffset + 'px',
+                        'left': leftOffset + 'px'
+                    });
+                }
+
+                // Catch onmouseup events outside of this div
+                $('body').mouseup(function (event)
+                {
+                    var targetID = event.target.id;
+
+                    if (targetID !== settings.ID + 'link-popup' && targetID !== settings.ID + 'link-popup-input')
+                    {
+                        $(settings.selector + 'link-popup').remove();
+                    }
+                });
+
+                // Also delete it upon scroll and page up/down key events
+                $(settings.outerSelector).scroll(function ()
+                {
+                    $(settings.selector + 'link-popup').remove();
+                });
+                $(settings.selector + 'link-popup input').click(function ()
+                {
+                    $(this).focus().select();
+                });
+                return false;
+            });
+
+            // Show the relevant slider
+            var currentSlider = (settings.inGrid) ? 'grid' : 'zoom';
+            $(settings.selector + currentSlider + '-slider').show();
+            $(settings.selector + currentSlider + '-slider-label').show();
+
+            var switchMode = function ()
+            {
+                // Switch from fullscreen to not
+                $(settings.selector + 'tools').toggleClass('diva-fullscreen-tools');
+
+                if (!settings.inFullscreen)
+                {
+                    // Leaving fullscreen
+                    $(settings.selector + 'tools-left').after($(settings.selector + 'tools-right'));
+                    $(settings.selector + 'tools-left').removeClass('in-fullscreen');
+                }
+                else
+                {
+                    // Entering fullscreen
+                    $(settings.selector + 'tools-right').after($(settings.selector + 'tools-left'));
+                    $(settings.selector + 'tools-left').addClass('in-fullscreen');
+                }
+            };
+
+            var switchView = function ()
+            {
+                // Switch from grid to document view etc
+                $(settings.selector + currentSlider + '-slider').hide();
+                $(settings.selector + currentSlider + '-slider-label').hide();
+                currentSlider = (settings.inGrid) ? 'grid' : 'zoom';
+                $(settings.selector + currentSlider + '-slider').show();
+                $(settings.selector + currentSlider + '-slider-label').show();
+
+                // Also change the image for the grid icon
+                $(settings.selector + 'grid-icon').toggleClass('diva-in-grid');
+            };
+
+            var toolbar =
+            {
+                updateCurrentPage: function ()
+                {
+                    $(settings.selector + 'current-page').text(settings.currentPageIndex + 1);
+                },
+                setNumPages: function (newNumber)
+                {
+                    $(settings.selector + 'num-pages').text(newNumber);
+                },
+                updateZoomSlider: function ()
+                {
+                    // Update the position of the handle within the slider
+                    if (settings.zoomLevel !== $(settings.selector + 'zoom-slider').slider('value'))
+                    {
+                        $(settings.selector + 'zoom-slider').slider(
+                        {
+                            value: settings.zoomLevel
+                        });
+                    }
+
+                    // Update the slider label
+                    $(settings.selector + 'zoom-level').text(settings.zoomLevel);
+                },
+                updateGridSlider: function ()
+                {
+                    // Update the position of the handle within the slider
+                    if (settings.pagesPerRow !== $(settings.selector + 'grid-slider').slider('value'))
+                    {
+                        $(settings.selector + 'grid-slider').slider(
+                        {
+                            value: settings.pagesPerRow
+                        });
+                    }
+
+                    // Update the slider label
+                    $(settings.selector + 'pages-per-row').text(settings.pagesPerRow);
+                },
+                switchView: switchView,
+                switchMode: switchMode
+            };
+            return toolbar;
+        };
+
+        var initPlugins = function ()
+        {
+            if (window.divaPlugins)
+            {
+                var pageTools = [];
+
+                // Add all the plugins that have not been explicitly disabled to settings.plugins
+                $.each(window.divaPlugins, function (index, plugin)
+                {
+                    var pluginProperName = plugin.pluginName[0].toUpperCase() + plugin.pluginName.substring(1);
+
+                    if (settings['enable' + pluginProperName])
+                    {
+                        // Call the init function and check return value
+                        var enablePlugin = plugin.init(settings, self);
+
+                        // If int returns false, consider the plugin disabled
+                        if (!enablePlugin)
+                        {
+                            return;
+                        }
+
+                        // If the title text is undefined, use the name of the plugin
+                        var titleText = plugin.titleText || pluginProperName + " plugin";
+
+                        // Create the pageTools bar if handleClick is set to a function
+                        if (typeof plugin.handleClick === 'function')
+                        {
+                            pageTools.push('<div class="diva-' + plugin.pluginName + '-icon" title="' + titleText + '"></div>');
+
+                            // Delegate the click event - pass it the settings
+                            $(settings.outerSelector).delegate('.diva-' + plugin.pluginName + '-icon', 'click', function (event)
+                            {
+                                plugin.handleClick.call(this, event, settings);
+                            });
+                        }
+
+                        // Add it to settings.plugins so it can be used later
+                        settings.plugins.push(plugin);
+                    }
+                });
+
+                // Save the page tools bar so it can be added for each page
+                if (pageTools.length)
+                {
+                    settings.pageTools = '<div class="diva-page-tools">' + pageTools.join('') + '</div>';
+                }
+            }
+        };
+
+        var hideThrobber = function ()
+        {
+            // Clear the timeout, if it hasn't executed yet
+            clearTimeout(settings.throbberTimeoutID);
+
+            // Hide the throbber if it has already executed
+            $(settings.selector + 'throbber').hide();
+        };
+
+        var setupViewer = function ()
+        {
+            // Create the throbber element
+            var throbberHTML = '<div id="' + settings.ID + 'throbber" class="diva-throbber"></div>';
+            $(settings.outerSelector).append(throbberHTML);
+
+            // If the request hasn't completed after a specified time, show it
+            settings.throbberTimeoutID = setTimeout(function ()
+            {
+                $(settings.selector + 'throbber').show();
+            }, settings.throbberTimeout);
+
+            $.ajax({
+                url: settings.objectData,
+                cache: true,
+                dataType: 'json',
+                error: function (jqxhr, status, error)
+                {
+                    hideThrobber();
+
+                    // Show a basic error message within the document viewer pane
+                    $(settings.outerSelector).text("Invalid URL. Error code: " + status + " " + error);
+                },
+                success: function (data, status, jqxhr)
+                {
+                    hideThrobber();
+
+                    // Save all the data we need
+                    settings.pages = data.pgs;
+                    settings.maxRatio = data.dims.max_ratio;
+                    settings.minRatio = data.dims.min_ratio;
+                    settings.itemTitle = data.item_title;
+                    settings.numPages = data.pgs.length;
+
+                    // These are arrays, the index corresponding to the zoom level
+                    settings.maxWidths = data.dims.max_w;
+                    settings.averageWidths = data.dims.a_wid;
+                    settings.averageHeights = data.dims.a_hei;
+                    settings.totalHeights = data.dims.t_hei;
+
+                    // Make sure the set max and min values are valid
+                    settings.realMaxZoom = data.max_zoom;
+                    settings.maxZoomLevel = (settings.maxZoomLevel >= 0 && settings.maxZoomLevel <= data.max_zoom) ? settings.maxZoomLevel : data.max_zoom;
+                    settings.minZoomLevel = (settings.minZoomLevel >= 0 && settings.minZoomLevel <= settings.maxZoomLevel) ? settings.minZoomLevel : 0;
+                    settings.minPagesPerRow = Math.max(2, settings.minPagesPerRow);
+                    settings.maxPagesPerRow = Math.max(settings.minPagesPerRow, settings.maxPagesPerRow);
+
+                    // Check that the desired page is in range
+                    if (settings.enableFilename)
+                    {
+                        var iParam = $.getHashParam('i' + settings.hashParamSuffix);
+                        var iParamPage = getPageIndex(iParam);
+
+                        if (isPageValid(iParamPage))
+                        {
+                            settings.goDirectlyTo = iParamPage;
+                        }
+                    }
+                    else
+                    {
+                        // Not using the i parameter, check the p parameter
+                        // Subtract 1 to get the page index
+                        var pParam = parseInt($.getHashParam('p' + settings.hashParamSuffix), 10) - 1;
+
+                        if (isPageValid(pParam))
+                        {
+                            settings.goDirectlyTo = pParam;
+                        }
+                    }
+
+                    // Execute the setup hook for each plugin (if defined)
+                    $.each(settings.plugins, function (index, plugin)
+                    {
+                        executeCallback(plugin.setupHook, settings);
+                    });
+
+                    // Create the toolbar and display the title + total number of pages
+                    if (settings.enableToolbar)
+                    {
+                        settings.toolbar = createToolbar();
+                        Events.subscribe("VisiblePageDidChange", settings.toolbar.updateCurrentPage);
+                        Events.subscribe("ModeDidSwitch", settings.toolbar.switchMode);
+                        Events.subscribe("ViewDidSwitch", settings.toolbar.switchView);
+                        Events.subscribe("ZoomLevelDidChange", settings.toolbar.updateZoomSlider);
+                        Events.subscribe("GridRowNumberDidChange", settings.toolbar.updateGridSlider);
+                    }
+
+                    $(settings.selector + 'current label').text(settings.numPages);
+
+                    if (settings.enableAutoTitle)
+                    {
+                        $(settings.parentSelector).prepend('<div id="' + settings.ID + 'title" class="diva-title">' + settings.itemTitle + '</div>');
+                    }
+
+                    // Adjust the document panel dimensions for touch devices
+                    if (settings.mobileWebkit)
+                    {
+                        adjustMobileWebkitDims();
+                    }
+                    else
+                    {
+                        settings.originalWidth = $(settings.parentSelector).width() - settings.scrollbarWidth;
+                        settings.originalHeight = $(settings.outerSelector).height();
+                        adjustBrowserDims();
+                    }
+
+                    // Calculate the viewer x and y offsets
+                    var viewerOffset = $(settings.outerSelector).offset();
+                    settings.viewerXOffset = viewerOffset.left;
+                    settings.viewerYOffset = viewerOffset.top;
+
+                    if (settings.inFullscreen)
+                    {
+                        handleModeChange(false);
+                    }
+                    else
+                    {
+                        loadViewer();
+                    }
+
+                    // Execute the callback
+                    executeCallback(settings.onReady, settings);
+                    Events.publish("ViewerHasFinishedLoading", [settings]);
+
+                    // signal that everything should be set up and ready to go.
+                    settings.loaded = true;
+                }
+            });
+        };
+
+        var checkLoaded = function()
+        {
+            if (!settings.loaded)
+            {
+                console.warn("The viewer is not completely initialized. This is likely because it is still downloading data. To fix this, only call this function if the isReady() method returns true.");
+                return false;
+            }
+            return true;
+        };
+
+        var init = function ()
+        {
+            // First figure out the width of the scrollbar in this browser
+            settings.scrollbarWidth = $.getScrollbarWidth();
+
+            // If window.orientation is defined, then it's probably mobileWebkit
+            settings.mobileWebkit = window.orientation !== undefined;
+
+            // Generate an ID that can be used as a prefix for all the other IDs
+            settings.ID = $.generateId('diva-');
+            settings.selector = '#' + settings.ID;
+
+            // Figure out the hashParamSuffix from the ID
+            var divaNumber = parseInt(settings.ID, 10);
+
+            if (divaNumber > 1)
+            {
+                // If this is document viewer #1, don't use a suffix; otherwise, use the document viewer number
+                settings.hashParamSuffix = divaNumber;
+            }
+
+            // Since we need to reference these two a lot
+            settings.outerSelector = settings.selector + 'outer';
+            settings.innerSelector = settings.selector + 'inner';
+
+            // Create the inner and outer panels
+            $(settings.parentSelector).append('<div id="' + settings.ID + 'outer" class="diva-outer"></div>');
+            $(settings.outerSelector).append('<div id="' + settings.ID + 'inner" class="diva-inner diva-dragger"></div>');
+
+            // Create the fullscreen icon
+            if (settings.enableFullscreen)
+            {
+                $(settings.parentSelector).prepend('<div id="' + settings.ID + 'fullscreen" class="diva-fullscreen-icon" title="Toggle fullscreen mode"></div>');
+            }
+
+            // First, n - check if it's in range
+            var nParam = parseInt($.getHashParam('n' + settings.hashParamSuffix), 10);
+
+            if (nParam >= settings.minPagesPerRow && nParam <= settings.maxPagesPerRow)
+            {
+                settings.pagesPerRow = nParam;
+            }
+
+            // Now z - check that it's in range
+            var zParam = $.getHashParam('z' + settings.hashParamSuffix);
+
+            if (zParam !== '')
+            {
+                // If it's empty, we don't want to change the default zoom level
+                zParam = parseInt(zParam, 10);
+
+                // Can't check if it exceeds the max zoom level or not because that data is not available yet ...
+                if (zParam >= settings.minZoomLevel)
+                {
+                    settings.zoomLevel = zParam;
+                }
+            }
+
+            // y - vertical offset from the top of the relevant page
+            var yParam = parseInt($.getHashParam('y' + settings.hashParamSuffix), 10);
+
+            if (!isNaN(yParam))
+            {
+                settings.verticalOffset = yParam;
+            }
+
+            // x - horizontal offset from the center of the page
+            var xParam = parseInt($.getHashParam('x' + settings.hashParamSuffix), 10);
+
+            if (!isNaN(xParam))
+            {
+                settings.horizontalOffset = xParam;
+            }
+
+            // If the "fullscreen" hash param is true, go to fullscreen initially
+            // If the grid hash param is true, go to grid view initially
+            var gridParam = $.getHashParam('g' + settings.hashParamSuffix);
+            var goIntoGrid = gridParam === 'true';
+            var fullscreenParam = $.getHashParam('f' + settings.hashParamSuffix);
+            var goIntoFullscreen = fullscreenParam === 'true';
+
+            settings.inGrid = (settings.inGrid && gridParam !== 'false') || goIntoGrid;
+            settings.inFullscreen = (settings.inFullscreen && fullscreenParam !== 'false') || goIntoFullscreen;
+
+            // Store the height and width of the viewer (the outer div), if present
+            var desiredHeight = parseInt($.getHashParam('h' + settings.hashParamSuffix), 10);
+            var desiredWidth = parseInt($.getHashParam('w' + settings.hashParamSuffix), 10);
+
+            // Store the minimum and maximum height too
+            settings.minHeight = parseInt($(settings.outerSelector).css('min-height'), 10);
+            settings.minWidth = parseInt($(settings.outerSelector).css('min-width'), 10);
+
+            // Just call resize, it'll take care of bounds-checking etc
+            if (desiredHeight > 0 || desiredWidth > 0)
+            {
+                resizeViewer(desiredWidth, desiredHeight);
+            }
+
+            // Do the initial AJAX request and viewer loading
+            setupViewer();
+
+            // Do all the plugin initialisation
+            initPlugins();
+
+            handleEvents();
+        };
+
+        // Call the init function when this object is created.
+        init();
+
+        /* PUBLIC FUNCTIONS
+===============================================
+*/
+
+        // Returns the title of the document, based on the directory name
+        this.getItemTitle = function ()
+        {
+            return settings.itemTitle;
+        };
+
+        // Go to a particular page by its page number (with indexing starting at 1)
+        // returns True if the page number passed is valid; false if it is not.
+        this.gotoPageByNumber = function (pageNumber)
+        {
+            var pageIndex = pageNumber - 1;
+            if (isPageValid(pageIndex))
+            {
+                gotoPage(pageIndex, 0, 0);
+                return true;
+            }
+            return false;
+        };
+
+        // Go to a particular page (with indexing starting at 0)
+        // returns True if the page index is valid; false if it is not.
+        this.gotoPageByIndex = function (pageIndex)
+        {
+            if (isPageValid(pageIndex))
+            {
+                gotoPage(pageIndex, 0, 0);
+                return true;
+            }
+            return false;
+        };
+
+        // Returns the page index (with indexing starting at 0)
+        this.getCurrentPage = function ()
+        {
+            console.warn("Deprecated. Use getCurrentPageIndex instead.");
+            return settings.currentPageIndex;
+        };
+
+        this.getNumberOfPages = function()
+        {
+            if (!checkLoaded())
+            {
+                return false;
+            }
+
+            return settings.numPages;
+        }
+
+        // Returns the dimensions of a given page index at a given zoom level
+        this.getPageDimensionsAtZoomLevel = function(pageIdx, zoomLevel)
+        {
+            if (!checkLoaded())
+            {
+                return false;
+            }
+
+            var zoomLevel = zoomLevel - 1; // zoom levels are 1-based, but our array is 0-based;
+            var pg = settings.pages[pageIdx];
+            var pgAtZoom = pg.d[parseInt(zoomLevel, 10)];
+            return {'width': pgAtZoom.w, 'height': pgAtZoom.h}
+        };
+
+        // Returns the dimensions of the current page at the current zoom level
+        this.getCurrentPageDimensionsAtCurrentZoomLevel = function()
+        {
+            return this.getPageDimensionsAtZoomLevel(settings.currentPageIndex, settings.zoomLevel);
+        };
+
+        this.isReady = function()
+        {
+            return settings.loaded;
+        };
+
+        this.getCurrentPageIndex = function ()
+        {
+            return settings.currentPageIndex;
+        };
+
+        this.getCurrentPageFilename = function ()
+        {
+            return settings.pages[settings.currentPageIndex].f;
+        };
+
+        this.getCurrentPageNumber = function ()
+        {
+            return settings.currentPageIndex + 1;
+        };
+
+        // Returns the current zoom level
+        this.getZoomLevel = function ()
+        {
+            return settings.zoomLevel;
+        };
+
+        // gets the maximum zoom level for the entire document
+        this.getMaxZoomLevel = function ()
+        {
+            return settings.maxZoomLevel;
+        };
+
+        // gets the max zoom level for a given page
+        this.getMaxZoomLevelForPage = function(pageIdx)
+        {
+            if (!checkLoaded)
+            {
+                return false;
+            }
+
+            return settings.pages[pageIdx].m;
+        }
+
+        this.getMinZoomLevel = function ()
+        {
+            return settings.minZoomLevel;
+        };
+
+        // Use the provided zoom level (will check for validity first)
+        // Returns false if the zoom level is invalid, true otherwise
+        this.setZoomLevel = function (zoomLevel)
+        {
+            if (settings.inGrid)
+            {
+                toggleGrid();
+            }
+
+            return handleZoom(zoomLevel);
+        };
+
+        // Zoom in. Will return false if it's at the maximum zoom
+        this.zoomIn = function ()
+        {
+            return this.setZoomLevel(settings.zoomLevel + 1);
+        };
+
+        // Zoom out. Will return false if it's at the minimum zoom
+        this.zoomOut = function ()
+        {
+            return this.setZoomLevel(settings.zoomLevel - 1);
+        };
+
+        // Uses the isVerticallyInViewport() function, but relative to a page
+        // Check if something (e.g. a highlight box on a particular page) is visible
+        this.inViewport = function (pageNumber, topOffset, height)
+        {
+            var pageIndex = pageNumber - 1;
+            var top = settings.heightAbovePages[pageIndex] + topOffset;
+            var bottom = top + height;
+
+            return isVerticallyInViewport(top, bottom);
+        };
+
+        // Toggle fullscreen mode
+        this.toggleFullscreenMode = function ()
+        {
+            toggleFullscreen();
+        };
+
+        // Enter fullscreen mode if currently not in fullscreen mode
+        // Returns false if in fullscreen mode initially, true otherwise
+        // This function will work even if enableFullscreen is set to false
+        this.enterFullscreenMode = function ()
+        {
+            if (!settings.inFullscreen)
+            {
+                toggleFullscreen();
+                return true;
+            }
+
+            return false;
+        };
+
+        // Leave fullscreen mode if currently in fullscreen mode
+        // Returns true if in fullscreen mode intitially, false otherwise
+        this.leaveFullscreenMode = function ()
+        {
+            if (settings.inFullscreen)
+            {
+                toggleFullscreen();
+                return true;
+            }
+
+            return false;
+        };
+
+        // Toggle grid view
+        this.toggleGridView = function ()
+        {
+            toggleGrid();
+        };
+
+        // Enter grid view if currently not in grid view
+        // Returns false if in grid view initially, true otherwise
+        this.enterGridView = function ()
+        {
+            if (!settings.inGrid) {
+                toggleGrid();
+                return true;
+            }
+
+            return false;
+        };
+
+        // Leave grid view if currently in grid view
+        // Returns true if in grid view initially, false otherwise
+        this.leaveGridView = function ()
+        {
+            if (settings.inGrid)
+            {
+                toggleGrid();
+                return true;
+            }
+
+            return false;
+        };
+
+        // Jump to a page based on its filename
+        // Returns true if successful and false if the filename is invalid
+        this.gotoPageByName = function (filename)
+        {
+            var pageIndex = getPageIndex(filename);
+            if (isPageValid(pageIndex))
+            {
+                gotoPage(pageIndex, 0, 0);
+                return true;
+            }
+
+            return false;
+        };
+
+        // Get the page index (0-based) corresponding to a given filename
+        // If the page index doesn't exist, this will return -1
+        this.getPageIndex = function (filename)
+        {
+            return getPageIndex(filename);
+        };
+
+        // Get the current URL (exposes the private method)
+        this.getCurrentURL = function ()
+        {
+            return getCurrentURL();
+        };
+
+        // Get the hash part only of the current URL (without the leading #)
+        this.getURLHash = function ()
+        {
+            return getURLHash();
+        };
+
+        // Get an object representing the state of this diva instance (for setState)
+        this.getState = function ()
+        {
+            return getState();
+        };
+
+        // Get the instance selector for this instance, since it's auto-generated.
+        this.getInstanceSelector = function ()
+        {
+            return settings.selector;
+        };
+
+        // Get the instance ID -- essentially the selector without the leading '#'.
+        this.getInstanceId = function()
+        {
+            return settings.ID;
+        };
+
+        this.getSettings = function()
+        {
+            return settings;
+        };
+
+        // Align this diva instance with a state object (as returned by getState)
+        this.setState = function (state)
+        {
+            var pageIndex;
+
+            // If we need to resize the viewer, do that first
+            resizeViewer(state.w, state.h);
+
+            // Only change settings.goDirectlyTo if state.i or state.p is valid
+            pageIndex = getPageIndex(state.i);
+
+            if (isPageValid(pageIndex))
+            {
+                settings.goDirectlyTo = pageIndex;
+            }
+            else if (isPageValid(state.p))
+            {
+                settings.goDirectlyTo = state.p;
+            }
+
+            settings.horizontalOffset = parseInt(state.x, 10);
+            settings.verticalOffset = parseInt(state.y, 10);
+
+            // Only change the zoom if state.z is valid
+            if (state.z >= settings.minZoomLevel && state.z <= settings.maxZoomLevel)
+            {
+                settings.zoomLevel = state.z;
+            }
+
+            // Only change the pages per row setting if state.n is valid
+            if (state.n >= settings.minPagesPerRow && state.n <= settings.maxPagesPerRow)
+            {
+                settings.pagesPerRow = state.n;
+            }
+
+            if (settings.inFullscreen !== state.f)
+            {
+                // The parameter determines if we need to change the view as well
+                settings.inFullscreen = state.f;
+                handleModeChange(settings.inGrid !== state.g);
+            }
+            else
+            {
+                // Don't need to change the mode, may need to change view
+                if (settings.inGrid !== state.g)
+                {
+                    settings.inGrid = state.g;
+                    handleViewChange();
+                }
+                else
+                {
+                    // Reload the viewer, just in case
+                    loadViewer();
+                }
+            }
+        };
+
+        // Resizes the outer div to the specified width and height
+        this.resize = function (newWidth, newHeight)
+        {
+            resizeViewer(newWidth, newHeight);
+            loadViewer();
+        };
+
+        // Destroys this instance, tells plugins to do the same (for testing)
+        this.destroy = function ()
+        {
+            // Removes the hide-scrollbar class from the body
+            $('body').removeClass('diva-hide-scrollbar');
+
+            // Empty the parent container and remove any diva-related data
+            $(settings.parentSelector).empty().removeData('diva');
+
+            // Call the destroy function for all the enabled plugins (if it exists)
+            $.each(settings.plugins, function (index, plugin)
+            {
+                executeCallback(plugin.destroy);
+            });
+
+            // Remove any additional styling on the parent element
+            $(settings.parentSelector).removeAttr('style').removeAttr('class');
+        };
+    };
+
+    $.fn.diva = function (options)
+    {
+        return this.each(function ()
+        {
+            var element = $(this);
+
+            // Return early if this element already has a plugin instance
+            if (element.data('diva'))
+            {
+                return;
+            }
+
+            // Save the reference to the container element
+            options.parentSelector = element;
+
+            // Otherwise, instantiate the document viewer
+            var diva = new Diva(this, options);
+            element.data('diva', diva);
+        });
+    };
+
+})(jQuery);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/imageServer/resources/js/vendor/diva-old.min.css	Fri Jul 05 16:05:57 2019 +0200
@@ -0,0 +1,1 @@
+.hidden{display:none}.grab{cursor:url("../img/openhand.cur"),pointer}.grabbing{cursor:url("../img/closedhand.cur"),move !important}.loading{background:url("../img/loading.gif") no-repeat center}.full-width{width:100% !important;max-width:100% !important}.full-height{height:100% !important;max-height:100% !important}.prevent-selection{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.button{cursor:pointer;height:32px;width:32px;background-color:#f1f1f1;background-repeat:no-repeat;background-position:center;border:1px solid #99bbe8}@media screen and (min-device-width:769px){.button:hover{background-color:#fdfdfd}}.diva-title{text-align:center;font-weight:bold;font-size:2em}.diva-tools{margin-top:5px}.diva-tools .diva-tools-left{float:left}.diva-tools .diva-tools-left .diva-slider-label{display:none;padding:8px;float:left}.diva-tools .diva-tools-left .diva-zoom-buttons-label{display:none;padding:8px;float:left}.diva-tools .diva-tools-left .diva-zoom-out-button{display:none;float:left;background-image:url("../img/zoomout.png")}.diva-tools .diva-tools-left .diva-zoom-in-button{display:none;float:left;background-image:url("../img/zoomin.png");margin-left:-1px}.diva-tools .diva-tools-left .diva-grid-out-button{display:none;float:left;background-image:url("../img/zoomout.png")}.diva-tools .diva-tools-left .diva-grid-in-button{display:none;float:left;background-image:url("../img/zoomin.png");margin-left:-1px}.diva-tools .diva-tools-left .diva-buttons-label{display:none;padding:8px;float:left}.diva-tools .diva-tools-left.in-fullscreen{float:left;clear:none}.diva-tools .diva-tools-right{float:right;height:42px}.diva-tools .diva-tools-right .diva-grid-icon{float:right;background-image:url("../img/grid.png")}.diva-tools .diva-tools-right .diva-grid-icon.diva-in-grid{background-image:url("../img/document.png")}.diva-tools .diva-tools-right .diva-download-icon{float:right;background-image:url("../img/download.png")}.diva-link-icon{float:right;background-image:url("../img/link.png")}.diva-tools .diva-tools-right .diva-page-nav{float:left;text-align:right;padding-right:4px;white-space:nowrap;line-height:32px}.diva-tools .diva-tools-right .diva-page-nav .diva-page-label{float:left;padding-top:1px;padding-right:.5em;line-height:32px}.diva-tools .diva-tools-right .diva-page-nav .diva-goto-form{float:right}.diva-tools .diva-tools-right .diva-page-nav .diva-goto-form .diva-input{width:30px;outline:none;margin:0;padding-top:0}.diva-tools.diva-fullscreen-tools{position:fixed;top:0;right:30px;z-index:101;width:230px;height:73px;padding:15px;border:1px solid #ddd;background:#fff;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5)}.diva-tools.diva-fullscreen-tools .diva-buttons-label{margin-top:5px;padding:0;clear:both}.diva-tools.diva-fullscreen-tools .diva-page-nav{float:none;line-height:1em}.diva-tools.diva-fullscreen-tools .diva-page-nav .diva-goto-form{margin-top:9px}.diva-tools.diva-fullscreen-tools .diva-page-nav .diva-page-label{float:none;clear:both;line-height:1em}.diva-outer{clear:both;background:#f1f1f1;border:1px solid #99bbe8;position:relative;min-height:100px;min-width:200px;height:700px;overflow:auto}.diva-outer .diva-inner{position:relative;overflow:hidden;margin:0 auto}.diva-outer .diva-inner .diva-page{-webkit-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);background:url("../img/loading.gif") no-repeat center;position:absolute}.diva-outer .diva-inner .diva-document-page{-webkit-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 6px 0 rgba(0,0,0,0.5);background:url("../img/loading.gif") no-repeat center;position:absolute;left:0;right:0}.diva-outer .diva-inner .diva-document-page .diva-page-tools{position:absolute;top:-25px;left:0;height:25px;z-index:3}.diva-outer .diva-inner .diva-document-page .diva-page-tools div{display:inline-block;height:25px;width:25px;cursor:pointer}.diva-outer .diva-inner .diva-page-vertical{margin:0 auto;display:inline-block}.diva-outer .diva-inner .diva-page-horizontal{vertical-align:middle;display:inline-block;top:50%;transform:translate(0, -50%);-webkit-transform:translate(0, -50%);-moz-transform:translate(0, -50%);-ms-transform:translate(0, -50%)}.diva-outer .diva-inner .diva-row{position:absolute;width:100%}.diva-outer .diva-inner.diva-grab{cursor:url("../img/openhand.cur"),pointer}.diva-outer .diva-inner.diva-grabbing{cursor:url("../img/closedhand.cur"),move !important}.diva-outer.diva-fullscreen{width:100% !important;max-width:100% !important;height:100% !important;max-height:100% !important;z-index:100;position:fixed !important;top:0;left:0;margin:0;border:0}.diva-fullscreen-icon{background-image:url("../img/fullscreen.png");border-left:0;float:right}.diva-popup{background:#fff;border:1px solid #99bbe8;padding:.6em;z-index:101;position:absolute;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5)}.diva-link-popup{font-size:10pt}.diva-link-popup input{width:15em}.diva-link-popup input:focus{outline:none}.diva-link-popup.in-fullscreen{top:150px;right:30px}.diva-download-popup{font-size:10pt}.diva-download-popup input{width:15em}.diva-download-popup input:focus{outline:none}.diva-download-popup.in-fullscreen{top:150px;right:30px}.diva-hide-scrollbar{overflow:hidden !important}.diva-relative-position{position:relative}.zoom-slider{position:relative;top:.6em;display:none;float:left}@media (max-width:480px){.zoom-slider{width:100px}}.grid-slider{position:relative;top:.6em;display:none;float:left}@media (max-width:480px){.grid-slider{width:100px}}.diva-throbber{display:none;position:absolute;width:50px;height:50px;background:url("../img/loading.gif") no-repeat center;background-color:#fff;border:1px solid #ddd;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);top:50%;left:50%;margin-left:-25px;margin-top:-25px}.diva-error{position:absolute;width:400px;height:200px;background-color:#fff;border:1px solid #ddd;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);top:50%;left:50%;margin-left:-220px;margin-top:-120px;z-index:120;padding:0 1em}.diva-canvas-icon{background:url('../img/plugins/canvas.png') no-repeat;background-position:left center}.diva-canvas-icon:hover{background-position:-25px center}.diva-canvas-icon.new{background-position:-50px center}.diva-canvas-icon.new:hover{background-position:-75px center}#diva-canvas-backdrop{z-index:105;position:fixed;top:0;left:0;bottom:0;right:0;display:none;background:rgba(50,50,50,0.9)}#diva-canvas-tools{color:#333;position:fixed;top:10px;left:10px;width:230px;z-index:108;background:#fff;padding-bottom:10px;-webkit-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);-moz-box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5);box-shadow:2px 2px 4px 0 rgba(0,0,0,0.5)}#diva-canvas-tools .action-buttons{clear:both;margin-bottom:5px;text-align:right}#diva-canvas-tools .action-buttons a{color:#333;text-decoration:none;background:#f1f1f1;padding:5px;border:1px solid #99bbe8}#diva-canvas-tools .action-buttons a:last-child{border-left:0}#diva-canvas-tools .action-buttons a:hover{background:#fdfdfd}#diva-canvas-toolbar{height:16px;padding:10px;padding-bottom:0}#diva-canvas-toolbar div{height:18px;width:18px;background-repeat:no-repeat;cursor:pointer;z-index:109;display:inline-block;margin-right:5px;background-image:url("../img/actions.png")}#diva-canvas-toolbar span{vertical-align:top;float:right}#diva-canvas-toolwindow{position:relative;margin:10px}#diva-canvas-close:hover{background-position:-20px 0}#diva-canvas-minimise{background-position:-40px 0}#diva-canvas-minimise:hover{background-position:-60px 0}#diva-canvas-buttons div{cursor:pointer;background-image:url("../img/plugins/canvas-buttons.png");background-repeat:no-repeat;width:20px;height:20px;padding:5px;display:inline-block}#diva-canvas-buttons div.clicked{background-color:#ddd}#diva-canvas-buttons .contrast{background-position:5px 5px}#diva-canvas-buttons .contrast:hover,#diva-canvas-buttons .contrast.clicked{background-position:5px -25px}#diva-canvas-buttons .brightness{background-position:-25px 5px}#diva-canvas-buttons .brightness:hover,#diva-canvas-buttons .brightness.clicked{background-position:-25px -25px}#diva-canvas-buttons .rotation{background-position:-55px 5px}#diva-canvas-buttons .rotation:hover,#diva-canvas-buttons .rotation.clicked{background-position:-55px -25px}#diva-canvas-buttons .zoom{background-position:-85px 5px}#diva-canvas-buttons .zoom:hover,#diva-canvas-buttons .zoom.clicked{background-position:-85px -25px}#diva-canvas-buttons .red{background-position:-115px 5px}#diva-canvas-buttons .red:hover,#diva-canvas-buttons .red.clicked{background-position:-115px -25px}#diva-canvas-buttons .green{background-position:-145px 5px}#diva-canvas-buttons .green:hover,#diva-canvas-buttons .green.clicked{background-position:-145px -25px}#diva-canvas-buttons .blue{background-position:-175px 5px}#diva-canvas-buttons .blue:hover,#diva-canvas-buttons .blue.clicked{background-position:-175px -25px}#diva-canvas-pane{background:#ddd;padding-bottom:10px}#diva-canvas-pane p{margin-left:10px;padding-top:10px}#diva-canvas-pane p .link{cursor:pointer}#diva-canvas-pane p .link:hover{text-decoration:underline}#diva-canvas-mode{text-transform:capitalize}#diva-canvas-slider{width:188px;margin:0 auto;display:block}#diva-canvas-slider .handle{margin-left:-6px}#diva-canvas-minimap{height:210px;width:210px;cursor:crosshair;margin-bottom:10px;background:#000}#diva-canvas{position:absolute;left:0;right:0;margin:0 auto;z-index:107;cursor:url("../img/openhand.cur"),pointer}#diva-map-viewbox{border:2px solid #99bbe8;position:absolute;top:10px;left:10px;cursor:crosshair;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:none}.overflow-hidden{overflow:hidden !important}#diva-canvas-wrapper{z-index:106;position:absolute;top:0;left:0;bottom:0;right:0;overflow:scroll}.canvas-throbber{z-index:110;position:fixed}.diva-download-icon{background:url('../img/plugins/download.png') no-repeat;background-position:left center}.diva-download-icon:hover{background-position:-25px center}.diva-autoscroll-icon{float:right;border-right:none;background-image:url("../img/plugins/play.png")}.diva-autoscroll-prefs{display:none;margin-right:.6em}.diva-autoscroll-prefs-text{float:left}.diva-autoscroll-prefs-input{float:right;margin-left:.6em}.diva-autoscroll-pps{width:5em}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/imageServer/resources/js/vendor/diva-old.min.js	Fri Jul 05 16:05:57 2019 +0200
@@ -0,0 +1,125 @@
+Storage.prototype.setObject=function(b,e){this.setItem(b,JSON.stringify(e))};Storage.prototype.getObject=function(b){return(b=this.getItem(b))&&JSON.parse(b)};(function(b){var e=1;b.generateId=function(b){var d;do d=e++ +(b?"-"+b:"");while(document.getElementById(d));return d}})(jQuery);
+(function(b){b.getScrollbarWidth=function(){var b=document.createElement("p");b.style.width="100%";b.style.height="200px";var f=document.createElement("div");f.style.position="absolute";f.style.top="0px";f.style.left="0px";f.style.visibility="hidden";f.style.width="200px";f.style.height="150px";f.style.overflow="hidden";f.appendChild(b);document.body.appendChild(f);var d=b.offsetWidth;f.style.overflow="scroll";b=b.offsetWidth;d==b&&(b=f.clientWidth);document.body.removeChild(f);return d-b}})(jQuery);
+(function(b){b.getHashParam=function(b){var f=window.location.hash;if(""!==f){var d=0<f.indexOf("&"+b+"=")?f.indexOf("&"+b+"="):f.indexOf("#"+b+"=");if(0<=d)return d+=b.length+2,b=f.indexOf("&",d),b>d?f.substring(d,b):0>b?f.substring(d):""}return!1}})(jQuery);
+(function(b){b.updateHashParam=function(e,f){var d=b.getHashParam(e),a=window.location.hash;if(d!==f)if("string"==typeof d){var g=0<a.indexOf("&"+e+"=")?a.indexOf("&"+e+"="):a.indexOf("#"+e+"="),d=g+e.length+2+d.length,h=0===g?"#":"&";window.location.replace(a.substring(0,g)+h+e+"="+f+a.substring(d))}else 0===a.length?window.location.replace("#"+e+"="+f):window.location.replace(a+"&"+e+"="+f)}})(jQuery);
+(function(b){b.fn.dragscrollable=function(e){var f=b.extend({dragSelector:">:first",acceptPropagatedEvent:!0,preventDefault:!0},e||{}),d={mouseDownHandler:function(a){if(1!=a.which||!a.data.acceptPropagatedEvent&&a.target!=this)return!1;a.data.lastCoord={left:a.clientX,top:a.clientY};b.event.add(document,"mouseup",d.mouseUpHandler,a.data);b.event.add(document,"mousemove",d.mouseMoveHandler,a.data);if(a.data.preventDefault)return a.preventDefault(),!1},mouseMoveHandler:function(a){var b=a.clientX-
+a.data.lastCoord.left,d=a.clientY-a.data.lastCoord.top;a.data.scrollable.scrollLeft(a.data.scrollable.scrollLeft()-b);a.data.scrollable.scrollTop(a.data.scrollable.scrollTop()-d);a.data.lastCoord={left:a.clientX,top:a.clientY};if(a.data.preventDefault)return a.preventDefault(),!1},mouseUpHandler:function(a){b.event.remove(document,"mousemove",d.mouseMoveHandler);b.event.remove(document,"mouseup",d.mouseUpHandler);if(a.data.preventDefault)return a.preventDefault(),!1}};this.each(function(){var a={scrollable:b(this),
+acceptPropagatedEvent:f.acceptPropagatedEvent,preventDefault:f.preventDefault};b(this).find(f.dragSelector).bind("mousedown",a,d.mouseDownHandler)})}})(jQuery);
+(function(b){var e={cursor:"move",decelerate:!0,triggerHardware:!1,y:!0,x:!0,slowdown:.9,maxvelocity:40,throttleFPS:60,movingClass:{up:"kinetic-moving-up",down:"kinetic-moving-down",left:"kinetic-moving-left",right:"kinetic-moving-right"},deceleratingClass:{up:"kinetic-decelerating-up",down:"kinetic-decelerating-down",left:"kinetic-decelerating-left",right:"kinetic-decelerating-right"}};window.requestAnimationFrame||(window.requestAnimationFrame=function(){return window.webkitRequestAnimationFrame||
+window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a,b){window.setTimeout(a,1E3/60)}}());b.support=b.support||{};b.extend(b.support,{touch:"ontouchend"in document});var f=function(){return!1},d=function(a,b){return 0===Math.floor(Math.abs(a))?0:a*b},a=function(a,b){var d=a;0<a?a>b&&(d=b):a<0-b&&(d=0-b);return d},g=function(a,b){this.removeClass(a.movingClass.up).removeClass(a.movingClass.down).removeClass(a.movingClass.left).removeClass(a.movingClass.right).removeClass(a.deceleratingClass.up).removeClass(a.deceleratingClass.down).removeClass(a.deceleratingClass.left).removeClass(a.deceleratingClass.right);
+0<a.velocity&&this.addClass(b.right);0>a.velocity&&this.addClass(b.left);0<a.velocityY&&this.addClass(b.down);0>a.velocityY&&this.addClass(b.up)},h=function(a,b){b.velocity=0;b.velocityY=0;b.decelerate=!0;"function"===typeof b.stopped&&b.stopped.call(a,b)},l=function(a,b){var e=a[0];b.x&&0<e.scrollWidth?(e.scrollLeft=b.scrollLeft=e.scrollLeft+b.velocity,0<Math.abs(b.velocity)&&(b.velocity=b.decelerate?d(b.velocity,b.slowdown):b.velocity)):b.velocity=0;b.y&&0<e.scrollHeight?(e.scrollTop=b.scrollTop=
+e.scrollTop+b.velocityY,0<Math.abs(b.velocityY)&&(b.velocityY=b.decelerate?d(b.velocityY,b.slowdown):b.velocityY)):b.velocityY=0;g.call(a,b,b.deceleratingClass);"function"===typeof b.moved&&b.moved.call(a,b);0<Math.abs(b.velocity)||0<Math.abs(b.velocityY)?window.requestAnimationFrame(function(){l(a,b)}):h(a,b)},n=function(a,d){var e=b.kinetic.callMethods[a],f=Array.prototype.slice.call(arguments);e&&this.each(function(){var a=f.slice(1),d=b(this).data("kinetic-settings");a.unshift(d);e.apply(this,
+a)})},t=function(a,d){b.support.touch?a.bind("touchstart",d.events.touchStart).bind("touchend",d.events.inputEnd).bind("touchmove",d.events.touchMove):a.mousedown(d.events.inputDown).mouseup(d.events.inputEnd).mousemove(d.events.inputMove);a.click(d.events.inputClick).scroll(d.events.scroll).bind("selectstart",f).bind("dragstart",d.events.dragStart)},u=function(d){this.addClass("kinetic-active").each(function(){var f=this,h=b(this);if(!h.data("kinetic-settings")){var k=b.extend({},e,d),n,u=!1,y,v=
+!1,A=!1,B=1E3/k.throttleFPS,I,G;k.velocity=0;k.velocityY=0;var M=function(){A=y=n=!1};b(document).mouseup(M).click(M);var m=function(){k.velocity=a(u-n,k.maxvelocity);k.velocityY=a(v-y,k.maxvelocity)},x=function(a){return b.isFunction(k.filterTarget)?!1!==k.filterTarget.call(f,a):!0},F=function(a,d){if(!I||new Date>new Date(I.getTime()+B))I=new Date,A&&(n||y)&&(G&&(b(G).blur(),G=null,h.focus()),k.decelerate=!1,k.velocity=k.velocityY=0,h[0].scrollLeft=k.scrollLeft=k.x?h[0].scrollLeft-(a-n):h[0].scrollLeft,
+h[0].scrollTop=k.scrollTop=k.y?h[0].scrollTop-(d-y):h[0].scrollTop,u=n,v=y,n=a,y=d,m(),g.call(h,k,k.movingClass),"function"===typeof k.moved&&k.moved.call(h,k))};k.events={touchStart:function(a){var b;if(x(a.target)){b=a.originalEvent.touches[0];var d=b.clientX;b=b.clientY;A=!0;k.velocity=u=0;k.velocityY=v=0;n=d;y=b;a.stopPropagation()}},touchMove:function(a){var b;A&&(b=a.originalEvent.touches[0],F(b.clientX,b.clientY),a.preventDefault&&a.preventDefault())},inputDown:function(a){if(x(a.target)){var b=
+a.clientX,d=a.clientY;A=!0;k.velocity=u=0;k.velocityY=v=0;n=b;y=d;G=a.target;"IMG"===a.target.nodeName&&a.preventDefault();a.stopPropagation()}},inputEnd:function(a){n&&u&&!1===k.decelerate&&(k.decelerate=!0,m(),n=u=A=!1,l(h,k));G=null;a.preventDefault&&a.preventDefault()},inputMove:function(a){A&&(F(a.clientX,a.clientY),a.preventDefault&&a.preventDefault())},scroll:function(a){"function"===typeof k.moved&&k.moved.call(h,k);a.preventDefault&&a.preventDefault()},inputClick:function(a){if(0<Math.abs(k.velocity))return a.preventDefault(),
+!1},dragStart:function(a){if(G)return!1}};t(h,k);h.data("kinetic-settings",k).css("cursor",k.cursor);k.triggerHardware&&h.css({"-webkit-transform":"translate3d(0,0,0)","-webkit-perspective":"1000","-webkit-backface-visibility":"hidden"})}})};b.kinetic={settingsKey:"kinetic-settings",callMethods:{start:function(a,d){var e=b(this);if(a=b.extend(a,d))a.decelerate=!1,l(e,a)},end:function(a,d){b(this);a&&(a.decelerate=!0)},stop:function(a,d){var e=b(this);h(e,a)},detach:function(a,d){var e=b(this);b.support.touch?
+e.unbind("touchstart",a.events.touchStart).unbind("touchend",a.events.inputEnd).unbind("touchmove",a.events.touchMove):e.unbind("mousedown",a.events.inputDown).unbind("mouseup",a.events.inputEnd).unbind("mousemove",a.events.inputMove).unbind("scroll",a.events.scroll);e.unbind("click",a.events.inputClick).unbind("selectstart",f);e.unbind("dragstart",a.events.dragStart);e.removeClass("kinetic-active").css("cursor","")},attach:function(a,d){var e=b(this);t(e,a);e.addClass("kinetic-active").css("cursor",
+"move")}}};b.fn.kinetic=function(a){"string"===typeof a?n.apply(this,arguments):u.call(this,a);return this}})(window.jQuery||window.Zepto);
+var diva=function(){var b={};return{Events:{publish:function(e,f,d){if(b[e]){e=b[e];for(var a=e.length;a--;)e[a].apply(d||this,f||[])}},subscribe:function(e,f){b[e]||(b[e]=[]);b[e].push(f);return[e,f]},unsubscribe:function(e,f){var d=e[0];if(b[d])for(var a=b[d].length;a--;)if(b[d][a]===e[1])return b[d].splice(a,1),f&&delete b[d],!0;return!1},unsubscribeAll:function(){b={}}}}}(),activeDivaController=function(){var b;$(document).on("click",function(e){a:{var f=$(e.target);e=f.find(".diva-outer");var f=
+f.closest(".diva-outer"),d;if(!(0<e.length))if(0<f.length)e=f;else{d=document.getElementsByClassName("diva-outer");for(f=0;f<d.length;f++)$(d[f].parentElement).data("diva").deactivate();break a}e.parent().data("diva").activate();b=e.parent();d=document.getElementsByClassName("diva-outer");for(f=0;f<d.length;f++)d[f].getAttribute("id")!=e.attr("id")&&$(d[f].parentElement).data("diva").deactivate()}});this.getActive=function(){return b}},activeDiva=new activeDivaController;window.divaPlugins=[];
+(function(b){var e=function(e,d){var a=b.extend({},{adaptivePadding:.05,arrowScrollAmount:40,blockMobileMove:!0,objectData:"",enableAutoTitle:!0,enableFilename:!0,enableFullscreen:!0,enableGotoPage:!0,enableGridIcon:!0,enableGridControls:"buttons",enableKeyScroll:!0,enableLinkIcon:!0,enableSpaceScroll:!1,enableToolbar:!0,enableZoomControls:"buttons",fixedPadding:10,fixedHeightGrid:!0,goDirectlyTo:0,iipServerURL:"",inFullscreen:!1,inGrid:!1,imageDir:"",maxPagesPerRow:8,maxZoomLevel:-1,minPagesPerRow:2,
+minZoomLevel:0,onDocumentLoaded:null,onModeToggle:null,onViewToggle:null,onJump:null,onPageLoad:null,onPageLoaded:null,onReady:null,onScroll:null,onScrollDown:null,onScrollUp:null,onSetCurrentPage:null,onZoom:null,onZoomIn:null,onZoomOut:null,pageLoadTimeout:200,pagesPerRow:5,rowLoadTimeout:50,throbberTimeout:100,tileHeight:256,tileWidth:256,toolbarParentObject:d.parentObject,verticallyOriented:!0,viewportMargin:200,zoomLevel:2},d);b.extend(a,{allTilesLoaded:[],averageHeights:[],averageWidths:[],
+currentPageIndex:0,divaIsFullWindow:!1,doubleClickZoom:!1,firstPageLoaded:-1,firstRowLoaded:-1,gridPageWidth:0,hashParamSuffix:"",horizontalOffset:0,horizontalPadding:0,ID:null,initialKeyScroll:!1,initialSpaceScroll:!1,innerObject:"",isActiveDiva:!0,isScrollable:!0,itemTitle:"",lastPageLoaded:-1,lastRowLoaded:-1,loaded:!1,maxWidths:[],maxHeights:[],maxRatio:0,minRatio:0,mobileWebkit:!1,numPages:0,numRows:0,oldZoomLevel:-1,outerObject:"",pages:[],pageLeftOffsets:[],pageTopOffsets:[],pageTimeouts:[],
+pageTools:"",panelHeight:0,panelWidth:0,plugins:[],previousLeftScroll:0,previousTopScroll:0,realMaxZoom:-1,resizeTimer:-1,rowHeight:0,scaleWait:!1,scrollbarWidth:0,selector:"",singleClick:!1,singleTap:!1,throbberTimeoutID:-1,toolbar:null,totalHeights:[],totalHeight:0,totalWidths:[],totalWidth:0,verticalOffset:0,verticalPadding:0});var g=this,h=function(a){var b=!0;return function(a){var c,d,e;if("function"===typeof a){c=[];d=1;for(e=arguments.length;d<e;d++)c.push(arguments[d]);b&&(console.warn('The use of callback functions is deprecated. Use diva.Events.subscribe("Event", function) instead.'),
+b=!1);a.apply(g,c);return!0}return!1}}(),l=function(c,b){return a.pages[c].d[a.zoomLevel][b]},n=function(c){var b,d=a.numPages;for(b=0;b<d;b++)if(a.pages[b].f===c)return b;return-1},t=function(c,d){var e=b("#"+a.ID+"outer").scrollLeft()-a.viewportMargin,f=e+a.panelWidth+2*a.viewportMargin;return c>=e&&c<=f||c<=e&&d>=f||d>=e&&d<=f},u=function(c,d){var e=b("#"+a.ID+"outer").scrollTop()-a.viewportMargin,f=e+a.panelHeight+2*a.viewportMargin;return c>=e&&c<=f||c<=e&&d>=f||d>=e&&d<=f},p=function(c){return 0<=
+c&&c<a.numPages},r=function(c){var b=a.pageTopOffsets[c],d=b+l(c,"h")+a.verticalPadding,e=a.pageLeftOffsets[c];c=e+l(c,"w")+a.horizontalPadding;return u(b,d)&&t(e,c)},q=function(c){return!!document.getElementById(a.ID+"page-"+c)},k=function(c){if(!q(c)||!a.allTilesLoaded[c]){var b=a.pages[c].f,d=l(c,"w"),e=l(c,"h"),f=a.pageTopOffsets[c]+a.verticalPadding,m=a.pageLeftOffsets[c]+a.horizontalPadding,U=a.selector+"page-"+c,x;if(!q(c)){var H=document.getElementById(a.ID+"inner"),k=document.createElement("div");
+k.id=a.ID+"page-"+c;k.classList.add("diva-document-page");k.setAttribute("data-index",c);k.setAttribute("data-filename",b);k.title="Page "+(c+1);k.innerHTML=a.pageTools;k.style.width=d+"px";k.style.height=e+"px";a.verticallyOriented?(k.style.top=f+"px",k.classList.add("diva-page-vertical")):(k.style.left=m+"px",k.classList.add("diva-page-horizontal"));H.appendChild(k);h(a.onPageLoad,c,b,U);diva.Events.publish("PageWillLoad",[c,b,U],g);for(x in a.plugins)h(a.plugins[x].onPageLoad,c,b,U)}a.pageTimeouts.push(setTimeout(function(c){var f=
+document.getElementById(a.ID+"page-"+c);if(r(c)){var m=a.imageDir+"/",k=l(c,"r"),x=l(c,"c"),H=!0,Y=0,F=e-(k-1)*a.tileHeight,z=d-(x-1)*a.tileWidth,n,p,X,fa,ga,K;baseImageURL=a.iipServerURL+"?FIF="+m+b+"&JTL="+(a.zoomLevel+a.pages[c].m-a.realMaxZoom)+",";for(m=0;m<k;){for(n=0;n<x;){fa=m*a.tileHeight;ga=n*a.tileWidth;p=m===k-1?F:a.tileHeight;X=n===x-1?z:a.tileWidth;K=baseImageURL+Y;if(!document.getElementById(a.ID+"tile-"+c+"-"+Y)){var w=void 0,q=void 0;a.verticallyOriented?(w=a.pageTopOffsets[c]+m*
+a.tileHeight+a.verticalPadding,q=a.pageLeftOffsets[c]+n*a.tileWidth):(w=a.pageTopOffsets[c]+m*a.tileHeight,q=a.pageLeftOffsets[c]+n*a.tileWidth+a.horizontalPadding);var ra=q+a.tileWidth;u(w,w+a.tileHeight)&&t(q,ra)?(w=document.createElement("div"),w.id=a.ID+"tile-"+c+"-"+Y,w.classList.add("diva-document-tile"),w.style.display="inline",w.style.position="absolute",w.style.top=fa+"px",w.style.left=ga+"px",w.style.backgroundImage="url('"+K+"')",w.style.height=p+"px",w.style.width=X+"px",f.appendChild(w)):
+H=!1}Y++;n++}m++}a.allTilesLoaded[c]=H;h(a.onPageLoaded,c,b,U);diva.Events.publish("PageDidLoad",[c,b,U],g)}},a.pageLoadTimeout,c))}},T=function(c){c=document.getElementById(a.ID+"page-"+c);if(null!==c){for(;c.firstChild;)c.removeChild(c.firstChild);c.parentNode.removeChild(c)}},L=function(c){if(a.verticallyOriented){c=a.pageTopOffsets[c]+l(c,"h")+a.verticalPadding;var b=document.getElementById(a.ID+"outer").scrollTop}else c=a.pageLeftOffsets[c]+l(c,"w")+a.horizontalPadding,b=document.getElementById(a.ID+
+"outer").scrollLeft;return c=c<b},y=function(c){if(a.verticallyOriented){c=a.pageTopOffsets[c];var b=document.getElementById(a.ID+"outer").scrollTop+a.panelHeight}else c=a.pageLeftOffsets[c],b=document.getElementById(a.ID+"outer").scrollLeft+a.panelWidth;return c=c>b},v=function(c,b){0<b?p(c)&&(r(c)?(k(c),a.lastPageLoaded=c,v(a.lastPageLoaded+1,b)):L(c)&&v(c+1,b)):p(c)&&(r(c)?(k(c),a.firstPageLoaded=c,v(a.firstPageLoaded-1,b)):y(c)&&v(c-1,b))},A=function(c,b){0<b?p(c)&&L(c)&&(T(c),a.firstPageLoaded=
+c+1,A(a.firstPageLoaded,b)):p(c)&&y(c)&&(T(c),a.lastPageLoaded=c-1,A(a.lastPageLoaded,b))},B=function(c){return 0<=c&&c<a.numRows},I=function(c){c*=a.rowHeight;return u(c,c+a.rowHeight+a.fixedPadding)},G=function(c){if(!document.getElementById(a.ID+"row-"+c)){var b=a.rowHeight*c+a.fixedPadding,d=document.getElementById(a.ID+"inner"),e=document.createElement("div");e.id=a.ID+"row-"+c;e.classList.add("diva-row");e.style.height=a.rowHeight+"px";e.style.top=b+"px";d.appendChild(e);for(var f,m,h,k,x,H,
+F=a.imageDir+"/",n=a.pagesPerRow,d=0;d<n;d++){f=c*a.pagesPerRow+d;if(!p(f))break;m=a.pages[f].f;h=l(f,"w");k=l(f,"h");x=a.fixedHeightGrid?(a.rowHeight-a.fixedPadding)*h/k:a.gridPageWidth;h=a.fixedHeightGrid?a.rowHeight-a.fixedPadding:x/h*k;k=parseInt(d*(a.fixedPadding+a.gridPageWidth)+a.fixedPadding,10);x=parseInt(x,10);h=parseInt(h,10);k+=a.fixedHeightGrid?(a.gridPageWidth-x)/2:0;H=encodeURI(a.iipServerURL+"?FIF="+F+m+"&HEI="+(h+2)+"&CVT=JPEG");a.pageTopOffsets[f]=b;a.pageLeftOffsets[f]=k;var z=
+document.createElement("div");z.id=a.ID+"page-"+f;var w=a.selector+"page-"+f;z.classList.add("diva-page");z.style.width=x+"px";z.style.height=h+"px";z.style.left=k+"px";z.setAttribute("data-index",f);z.setAttribute("data-filename",m);z.title="Page "+(f+1);e.appendChild(z);diva.Events.publish("PageWillLoad",[f,m,w],g);X(c,f,H,x,h)}}},M=function(c){c=document.getElementById(a.ID+"row-"+c);if(null!==c){for(;c.firstChild;)c.removeChild(c.firstChild);c.parentNode.removeChild(c)}},m=function(c){c=a.rowHeight*
+(c+1);var b=document.getElementById(a.ID+"outer").scrollTop;return c<b},x=function(c){c*=a.rowHeight;var b=document.getElementById(a.ID+"outer").scrollTop+a.panelHeight;return c>b},F=function(c,b){0<b?B(c)&&(I(c)?(G(c),a.lastRowLoaded=c,F(a.lastRowLoaded+1,b)):m(c)&&F(c+1,b)):B(c)&&(I(c)?(G(c),a.firstRowLoaded=c,F(a.firstRowLoaded-1,b)):x(c)&&F(c-1,b))},H=function(c,b){0<b?B(c)&&m(c)&&(M(c),a.firstRowLoaded++,H(a.firstRowLoaded,b)):B(c)&&x(c)&&(M(c),a.lastRowLoaded--,H(a.lastRowLoaded,b))},X=function(c,
+b,d,e,f){a.pageTimeouts.push(window.setTimeout(function(c,b,d,e,f){I(c)&&(c=document.createElement("img"),c.src=d,c.style.width=e+"px",c.style.height=f+"px",document.getElementById(a.ID+"page-"+b).appendChild(c))},a.rowLoadTimeout,c,b,d,e,f))},K=function(c){var b=a.currentPageIndex,d=b+c;if(!p(d))return!1;var e=a.verticallyOriented?document.getElementById(a.ID+"outer").scrollTop+a.panelHeight/2:document.getElementById(a.ID+"outer").scrollLeft+a.panelWidth/2,f=!1;0>c?a.verticallyOriented?0<=d&&a.pageTopOffsets[d]+
+l(d,"h")+a.verticalPadding>=e&&(f=!0):0<=d&&a.pageLeftOffsets[d]+l(d,"w")+a.horizontalPadding>=e&&(f=!0):0<c&&(a.verticallyOriented?a.pageTopOffsets[b]+l(b,"h")+a.verticalPadding<e&&(f=!0):a.pageLeftOffsets[b]+l(b,"w")+a.horizontalPadding<e&&(f=!0));return f?(a.currentPageIndex=d,0===c||K(c)||(c=a.pages[d].f,h(a.onSetCurrentPage,d,c),diva.Events.publish("VisiblePageDidChange",[d,c],g)),!0):!1},O=function(c){var b=Math.floor(a.currentPageIndex/a.pagesPerRow),d=b+parseInt(c,10),e=document.getElementById(a.ID+
+"outer").scrollTop,f=e+a.panelHeight/2,m=!1;0>c?0<=d&&(a.rowHeight*b>=f||a.rowHeight*d>=e)&&(m=!0):0<c&&a.rowHeight*(b+1)<e&&B(d)&&(m=!0);return m?(a.currentPageIndex=d*a.pagesPerRow,0===c||O(c)||(c=a.currentPageIndex,diva.Events.publish("VisiblePageDidChange",[c,a.pages[c].f],g)),!0):!1},J=function(c,b,d){d="undefined"!==typeof d?d:0;b=a.pageTopOffsets[c]+("undefined"!==typeof b?b:0)-parseInt(a.panelHeight/2,10);d=a.pageLeftOffsets[c]+d-parseInt(a.panelWidth/2,10);a.outerObject.scrollTop(b);a.outerObject.scrollLeft(d);
+c!==a.currentPageIndex&&(a.currentPageIndex=c,d=a.pages[c].f,h(a.onSetCurrentPage,c,d),diva.Events.publish("VisiblePageDidChange",[c,d],g));h(a.onJump,c);diva.Events.publish("ViewerDidJump",[c],g)},z=function(c){a.outerObject.scrollTop(Math.floor(c/a.pagesPerRow)*a.rowHeight);a.currentPageIndex=c;diva.Events.publish("VisiblePageDidChange",[c,a.pages[c].f],g)},w=function(c){return c>=a.minZoomLevel&&c<=a.maxZoomLevel?c:a.minZoomLevel},ha=function(c){return c>=a.minPagesPerRow&&c<=a.maxPagesPerRow?
+c:a.maxPagesPerRow},ia=function(){a.allTilesLoaded=[];a.outerObject.scrollTop(0);a.innerObject.empty();a.firstPageLoaded=0;a.firstRowLoaded=-1;a.previousTopScroll=0;a.previousLeftScroll=0;for(clearTimeout(a.resizeTimer);a.pageTimeouts.length;)clearTimeout(a.pageTimeouts.pop())},P=function(){a.inGrid?ja():aa()},aa=function(){ia();a.zoomLevel=w(a.zoomLevel);var c=a.zoomLevel;a.totalHeight=a.totalHeights[c]+a.verticalPadding*(a.numPages+1);a.totalWidth=a.totalWidths[c]+a.horizontalPadding*(a.numPages+
+1);var b=a.maxHeights[c]+2*a.verticalPadding,d=Math.max(a.maxWidths[c]+2*a.horizontalPadding,a.panelWidth),b=Math.max(b,a.panelHeight),e=document.getElementById(a.ID+"inner");a.verticallyOriented?(e.style.height=Math.round(a.totalHeight)+"px",e.style.width=Math.round(d)+"px"):(e.style.height=Math.round(b)+"px",e.style.width=Math.round(a.totalWidth)+"px");var f=0,m=0;a.pageTopOffsets=[];a.pageLeftOffsets=[];for(e=0;e<a.numPages;e++)a.pageTopOffsets[e]=parseInt(a.verticallyOriented?f:(b-l(e,"h"))/2,
+10),a.pageLeftOffsets[e]=parseInt(a.verticallyOriented?(d-l(e,"w"))/2:m,10),f=a.pageTopOffsets[e]+l(e,"h")+a.verticalPadding,m=a.pageLeftOffsets[e]+l(e,"w")+a.horizontalPadding;p(a.goDirectlyTo)||(a.goDirectlyTo=0);J(a.goDirectlyTo,a.verticalOffset,a.horizontalOffset);d=!1;for(e=0;e<a.numPages;e++)if(r(e))k(e),a.lastPageLoaded=e,d=!0;else if(d)break;0<=a.oldZoomLevel?(a.oldZoomLevel<a.zoomLevel?(h(a.onZoomIn,c),diva.Events.publish("ViewerDidZoomIn",[c],g)):(h(a.onZoomOut,c),diva.Events.publish("ViewerDidZoomOut",
+[c],g)),h(a.onZoom,c)):a.oldZoomLevel=a.zoomLevel;a.scaleWait&&(a.scaleWait=!1);c=a.pages[a.currentPageIndex].f;h(a.onDocumentLoaded,a.currentPageIndex,c);diva.Events.publish("DocumentDidLoad",[a.currentPageIndex,c],g)},ja=function(){var c=a.currentPageIndex;a.verticalOffset=a.verticallyOriented?a.panelHeight/2:l(c,"h")/2;a.horizontalOffset=a.verticallyOriented?l(c,"w")/2:a.panelWidth/2;ia();a.pagesPerRow=ha(a.pagesPerRow);c=(a.panelWidth-a.fixedPadding*(a.pagesPerRow+1))/a.pagesPerRow;a.gridPageWidth=
+c;a.rowHeight=a.fixedHeightGrid?a.fixedPadding+a.minRatio*c:a.fixedPadding+a.maxRatio*c;a.numRows=Math.ceil(a.numPages/a.pagesPerRow);a.totalHeight=a.numRows*a.rowHeight+a.fixedPadding;c=document.getElementById(a.ID+"inner");c.style.height=Math.round(a.totalHeight)+"px";c.style.width=Math.round(a.panelWidth)+"px";z(a.goDirectlyTo);var b;a.pageTopOffsets=[];a.pageLeftOffsets=[];for(var d=a.numPages,c=0;c<d;c+=a.pagesPerRow)b=Math.floor(c/a.pagesPerRow),I(b)&&(a.firstRowLoaded=0>a.firstRowLoaded?b:
+a.firstRowLoaded,G(b),a.lastRowLoaded=b)},ka=function(a){27==a.keyCode&&C()},ba=function(c){a.outerObject.toggleClass("diva-fullscreen");b("body").toggleClass("diva-hide-scrollbar");a.parentObject.toggleClass("diva-full-width");if(a.mobileWebkit){var d=parseInt(a.outerObject.css("margin-left"),10)-parseInt(b("body").css("margin-left"),10);a.outerObject.css("margin-left",d)}var d=a.panelHeight,e=a.panelWidth;Q();if(0<=a.oldZoomLevel&&!a.inGrid){var f=a.panelHeight,m=a.panelWidth;a.inFullscreen?(a.verticalOffset-=
+(f-d)/2,a.horizontalOffset-=(m-e)/2):(a.verticalOffset+=(d-f)/2,a.horizontalOffset+=(e-m)/2)}c?(a.inGrid=!a.inGrid,D()):P();if(a.inFullscreen)b(document).on("keyup",ka);else b(document).off("keyup",ka);h(a.onModeToggle,a.inFullscreen);diva.Events.publish("ModeDidSwitch",[a.inFullscreen],g)},D=function(){P();h(a.onViewToggle,a.inGrid);diva.Events.publish("ViewDidSwitch",[a.inGrid],g)},C=function(){a.goDirectlyTo=a.currentPageIndex;a.inFullscreen=!a.inFullscreen;ba(!1)},E=function(){a.goDirectlyTo=
+a.currentPageIndex;a.inGrid=!a.inGrid;D()},ca=function(c){var d=b(this).offset();a.doubleClickZoom=!0;a.horizontalOffset=c.pageX-d.left;a.verticalOffset=c.pageY-d.top;a.goDirectlyTo=parseInt(b(this).attr("data-index"),10);N(c.ctrlKey?a.zoomLevel-1:a.zoomLevel+1)},la=function(c){var d=parseInt(b(this).attr("data-index"),10);a.goDirectlyTo=d;var e=b(this).offset(),d=l(d,"w")/b(this).width();a.horizontalOffset=(c.pageX-e.left)*d;a.verticalOffset=(c.pageY-e.top)*d;a.inGrid=!1;D()},N=function(c){var b=
+w(c);if(b!==c)return!1;c=Math.pow(2,b-a.zoomLevel);a.doubleClickZoom?(a.verticalOffset*=c,a.horizontalOffset*=c,a.doubleClickZoom=!1):(a.goDirectlyTo=a.currentPageIndex,a.verticalOffset=c*V(),a.horizontalOffset=c*W());a.oldZoomLevel=a.zoomLevel;a.zoomLevel=b;diva.Events.publish("ZoomLevelDidChange",[b],g);aa();return!0},Z=function(c){var b=ha(c);if(b!==c)return!1;a.pagesPerRow=b;diva.Events.publish("GridRowNumberDidChange",[b],g);a.goDirectlyTo=a.currentPageIndex;ja();return!0},R=function(c,b){c=
+"undefined"===typeof c?a.currentPageIndex:c;return"center"===b||"centre"===b?parseInt(l(c,"h")/2,10):"bottom"===b?parseInt(l(c,"h")-a.panelHeight/2,10):parseInt(a.panelHeight/2,10)},S=function(c,b){c="undefined"===typeof c?a.currentPageIndex:c;return"left"===b?parseInt(a.panelWidth/2,10):"right"===b?parseInt(l(c,"w")-a.panelWidth/2,10):parseInt(l(c,"w")/2,10)},V=function(){return document.getElementById(a.ID+"outer").scrollTop-a.pageTopOffsets[a.currentPageIndex]+parseInt(a.panelHeight/2,10)},W=function(){return document.getElementById(a.ID+
+"outer").scrollLeft-a.pageLeftOffsets[a.currentPageIndex]+parseInt(a.panelWidth/2,10)},ma=function(){return{f:a.inFullscreen,g:a.inGrid,z:a.zoomLevel,n:a.pagesPerRow,i:a.enableFilename?a.pages[a.currentPageIndex].f:!1,p:a.enableFilename?!1:a.currentPageIndex+1,y:a.inGrid?!1:V(),x:a.inGrid?!1:W()}},na=function(){var c=ma(),b=[],d;for(d in c)!1!==c[d]&&b.push(d+a.hashParamSuffix+"="+c[d]);return b.join("&")},oa=function(){return location.protocol+"//"+location.host+location.pathname+"#"+na()},Q=function(){var c=
+document.getElementById(a.ID+"outer");a.panelHeight=c.clientHeight-(c.scrollWidth>c.clientWidth?a.scrollbarWidth:0);a.panelWidth=c.clientWidth-(c.scrollHeight>c.clientHeight?a.scrollbarWidth:0);a.horizontalOffset=W();a.verticalOffset=V();J(a.currentPageIndex,a.verticalOffset,a.horizontalOffset);return!0},pa=function(){a.mobileWebkit||(a.outerObject.dragscrollable({dragSelector:".diva-dragger",acceptPropagatedEvent:!0}),a.innerObject.dragscrollable({dragSelector:".diva-dragger",acceptPropagatedEvent:!0}));
+a.outerObject.on("dblclick",".diva-document-page",function(a){ca.call(this,a)});a.outerObject.on("contextmenu",".diva-document-page",function(c){if(c.ctrlKey)return clearTimeout(a.singleClickTimeout),a.singleClick?(ca.call(this,c),a.singleClick=!1):(a.singleClick=!0,a.singleClickTimeout=setTimeout(function(){a.singleClick=!1},500)),!1});a.outerObject.on("dblclick",".diva-row",function(a){la.call(b(a.target).parent(),a)})},da=function(a,b,d,e){return Math.sqrt((a-b)*(a-b)+(d-e)*(d-e))},sa=function(){a.innerObject.mouseover(function(){b(this).removeClass("diva-grabbing").addClass("diva-grab")});
+a.innerObject.mouseout(function(){b(this).removeClass("diva-grab")});a.innerObject.mousedown(function(){b(this).removeClass("diva-grab").addClass("diva-grabbing")});a.innerObject.mouseup(function(){b(this).removeClass("diva-grabbing").addClass("diva-grab")});pa();a.outerObject.scroll(function(){var c,b=document.getElementById(a.ID+"outer").scrollTop,d=document.getElementById(a.ID+"outer").scrollLeft;c=a.verticallyOriented||a.inGrid?b-a.previousTopScroll:d-a.previousLeftScroll;if(a.inGrid){0>c?(F(a.firstRowLoaded,
+-1),O(-1),H(a.lastRowLoaded,-1)):0<c&&(F(a.lastRowLoaded,1),O(1),H(a.firstRowLoaded,1));var e=document.getElementById(a.ID+"outer").scrollTop}else{if(0>c)v(a.firstPageLoaded,c),K(-1),A(a.lastPageLoaded,c);else if(0<c)v(a.lastPageLoaded,c),K(1),A(a.firstPageLoaded,c);else for(var f=a.lastPageLoaded,e=Math.max(a.firstPageLoaded,0);e<=f;e++)r(e)&&k(e);e=a.verticallyOriented?document.getElementById(a.ID+"outer").scrollTop:document.getElementById(a.ID+"outer").scrollLeft}h(a.onScroll,e);diva.Events.publish("ViewerDidScroll",
+[e],g);0<c?(h(a.onScrollDown,e),diva.Events.publish("ViewerDidScrollDown",[e],g)):0>c&&(h(a.onScrollUp,e),diva.Events.publish("ViewerDidScrollUp",[e],g));a.previousTopScroll=b;a.previousLeftScroll=d;a.horizontalOffset=W();a.verticalOffset=V()});b(document).keydown(function(c){if(!a.isActiveDiva)return!0;if(a.enableSpaceScroll&&!c.shiftKey&&32===c.keyCode||a.enableKeyScroll&&34===c.keyCode)return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop+a.panelHeight),!1;a.enableSpaceScroll||
+32!==c.keyCode||c.preventDefault();if(a.enableKeyScroll)switch(c.keyCode){case 33:return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop-a.panelHeight),!1;case 38:return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop-a.arrowScrollAmount),!1;case 40:return a.outerObject.scrollTop(document.getElementById(a.ID+"outer").scrollTop+a.arrowScrollAmount),!1;case 37:return a.outerObject.scrollLeft(document.getElementById(a.ID+"outer").scrollLeft-a.arrowScrollAmount),
+!1;case 39:return a.outerObject.scrollLeft(document.getElementById(a.ID+"outer").scrollLeft+a.arrowScrollAmount),!1;case 36:return a.outerObject.scrollTop(0),!1;case 35:return a.outerObject.scrollTop(a.totalHeight),!1}return!0});if(a.mobileWebkit){var c=[];c.push('<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" />');c.push('<meta name="apple-mobile-web-app-capable" content="yes" />');c.push('<meta name="apple-mobile-web-app-status-bar-style" content="black" />');
+b("head").append(c.join("\n"));a.blockMobileMove&&b("body").bind("touchmove",function(a){a.originalEvent.preventDefault();return!1});a.outerObject.kinetic({triggerHardware:!0});var d=[],e=[],f=0;a.outerObject.on("touchstart",".diva-document-page",function(a){2===a.originalEvent.touches.length&&(d=[a.originalEvent.touches[0].clientX,a.originalEvent.touches[0].clientY,a.originalEvent.touches[1].clientX,a.originalEvent.touches[1].clientY],f=da(d[2],d[0],d[3],d[1]))});a.outerObject.on("touchmove",".diva-document-page",
+function(c){if(2===c.originalEvent.touches.length){e=[c.originalEvent.touches[0].clientX,c.originalEvent.touches[0].clientY,c.originalEvent.touches[1].clientX,c.originalEvent.touches[1].clientY];var d=da(e[2],e[0],e[3],e[1])-f;if(!a.scaleWait)if(a.goDirectlyTo=a.currentPageIndex,a.inGrid)a.inGrid=!1,D();else a:{var m=a.zoomLevel;if(100<d&&m<a.maxZoomLevel)m++;else if(-100>d&&m>a.minZoomLevel)m--;else break a;a.scaleWait=!0;d=b(this).offset();a.horizontalOffset=c.pageX-d.left;a.verticalOffset=c.pageY-
+d.top;a.goDirectlyTo=parseInt(b(this).attr("data-index"),10);N(m)}}});var m={},x=0,c=function(c){if(a.singleTap){var d={pageX:c.originalEvent.changedTouches[0].clientX,pageY:c.originalEvent.changedTouches[0].clientY};x=da(m.pageX,d.pageX,m.pageY,d.pageY);50>x&&a.zoomLevel<a.maxZoomLevel&&(a.inGrid?la.call(b(c.target).parent(),d):ca.call(this,d));a.singleTap=!1;m={}}else a.singleTap=!0,m.pageX=c.originalEvent.changedTouches[0].clientX,m.pageY=c.originalEvent.changedTouches[0].clientY,a.singleTapTimeout=
+setTimeout(function(){a.singleTap=!1;m={}},250)};a.outerObject.on("touchend",".diva-document-page",c);a.outerObject.on("touchend",".diva-page",c);c="onorientationchange"in window?"orientationchange":"resize";b(window).bind(c,function(c){c=a.panelWidth;var b=a.panelHeight;Q();a.horizontalOffset-=(a.panelWidth-c)/2;a.verticalOffset-=(a.panelHeight-b)/2;a.goDirectlyTo=a.currentPageIndex;P()})}else b(window).resize(function(){Q();clearTimeout(a.resizeTimer);a.resizeTimer=setTimeout(function(){a.goDirectlyTo=
+a.currentPageIndex;a.verticalOffset=V();a.horizontalOffset=W();P()},200)});diva.Events.subscribe("PanelSizeDidChange",Q)},ta=function(){a.toolbarParentObject.prepend('<div id="'+a.ID+'tools" class="diva-tools">'+('<div id="'+a.ID+'tools-left" class="diva-tools-left">'+("slider"===a.enableZoomControls?'<input type="range" id="'+a.ID+'zoom-slider" class="zoom-slider" value="'+a.zoomLevel+'" min="'+a.minZoomLevel+'" max="'+a.maxZoomLevel+'">':"")+("buttons"===a.enableZoomControls?'<div id="'+a.ID+'zoom-out-button" class="diva-zoom-out-button button" title="Zoom Out"></div><div id="'+
+a.ID+'zoom-in-button" class="diva-zoom-in-button button" title="Zoom In"></div>':"")+("slider"===a.enableGridControls?'<input type="range" id="'+a.ID+'grid-slider" class="grid-slider" value="'+a.pagesPerRow+'" min="'+a.minPagesPerRow+'" max="'+a.maxPagesPerRow+'">':"")+("buttons"===a.enableGridControls?'<div id="'+a.ID+'grid-out-button" class="diva-grid-out-button button" title="Zoom Out"></div><div id="'+a.ID+'grid-in-button" class="diva-grid-in-button button" title="Zoom In"></div>':"")+("slider"===
+a.enableZoomControls?'<div id="'+a.ID+'zoom-slider-label" class="diva-slider-label">Zoom level: <span id="'+a.ID+'zoom-level">'+a.zoomLevel+"</span></div>":"")+("buttons"===a.enableZoomControls?'<div id="'+a.ID+'zoom-buttons-label" class="diva-buttons-label">Zoom level: <span id="'+a.ID+'zoom-level">'+a.zoomLevel+"</span></div>":"")+("slider"===a.enableGridControls?'<div id="'+a.ID+'grid-slider-label" class="diva-slider-label">Pages per row: <span id="'+a.ID+'pages-per-row">'+a.pagesPerRow+"</span></div>":
+"")+("buttons"===a.enableGridControls?'<div id="'+a.ID+'grid-buttons-label" class="diva-buttons-label">Pages per row: <span id="'+a.ID+'pages-per-row">'+a.pagesPerRow+"</span></div>":"")+'</div><div id="'+a.ID+'tools-right" class="diva-tools-right">'+(a.enableFullscreen?'<div id="'+a.ID+'fullscreen" class="diva-fullscreen-icon button" title="Toggle fullscreen mode"></div>':"")+(a.enableLinkIcon?'<div class="diva-link-icon button" id="'+a.ID+'link-icon" style="'+(a.enableGridIcon?"border-left: 0px":
+"")+'" title="Link to this page"></div>':"")+(a.enableGridIcon?'<div class="diva-grid-icon button'+(a.inGrid?" diva-in-grid":"")+'" id="'+a.ID+'grid-icon" title="Toggle grid view"></div>':"")+'<div id="'+a.ID+'page-nav" class="diva-page-nav">'+(a.enableGotoPage?'<form id="'+a.ID+'goto-page" class="diva-goto-form"><input type="text" id="'+a.ID+'goto-page-input" / class="diva-input"> <input type="submit" value="Go" style="margin-top: 0px;" /></form>':"")+('<div class="diva-page-label">Page <span id="'+
+a.ID+'current-page">1</span> of <span id="'+a.ID+'num-pages">'+a.numPages+"</span></div>")+"</div></div>")+"</div>");b(a.selector+"zoom-slider").on("input",function(a){a=parseInt(this.value,10);N(a)});b(a.selector+"zoom-slider").on("change",function(c){c=parseInt(this.value,10);c!==a.zoomLevel&&N(c)});b(a.selector+"zoom-out-button").click(function(){N(a.zoomLevel+-1)});b(a.selector+"zoom-in-button").click(function(){N(a.zoomLevel+1)});b(a.selector+"grid-slider").on("input",function(a){a=parseInt(this.value,
+10);Z(a)});b(a.selector+"grid-slider").on("change",function(c){c=parseInt(this.value,10);c!==a.zoomLevel&&Z(c)});b(a.selector+"fullscreen").click(function(){C()});b(a.selector+"grid-out-button").click(function(){Z(a.pagesPerRow-1)});b(a.selector+"grid-in-button").click(function(){Z(a.pagesPerRow+1)});b(a.selector+"grid-icon").click(function(){E()});b(a.selector+"goto-page").submit(function(){var c=parseInt(b(a.selector+"goto-page-input").val(),10)-1;if(p(c))if(a.inGrid)z(c);else{var d=R(c,"top"),
+e=S(c,"center");J(c,d,e)}else alert("Invalid page number");return!1});b(a.selector+"link-icon").click(function(){b("body").prepend('<div id="'+a.ID+'link-popup" class="diva-popup diva-link-popup"><input id="'+a.ID+'link-popup-input" class="diva-input" type="text" value="'+oa()+'"/></div>');if(a.inFullscreen)b(a.selector+"link-popup").addClass("in-fullscreen");else{var c=a.outerObject.offset().left+a.panelWidth,c=c+(a.scrollbarWidth-240-1),d=a.outerObject.offset().top+1;b(a.selector+"link-popup").removeClass("in-fullscreen").css({top:d+
+"px",left:c+"px"})}b("body").mouseup(function(c){c=c.target.id;c!==a.ID+"link-popup"&&c!==a.ID+"link-popup-input"&&b(a.selector+"link-popup").remove()});a.outerObject.scroll(function(){b(a.selector+"link-popup").remove()});b(a.selector+"link-popup input").click(function(){b(this).focus().select()});return!1});var c=a.inGrid?"grid":"zoom";b(a.selector+c+"-slider").show();b(a.selector+c+"-out-button").show();b(a.selector+c+"-in-button").show();b(a.selector+c+"-slider-label").show();b(a.selector+c+"-buttons-label").show();
+return{updateCurrentPage:function(){document.getElementById(a.ID+"current-page").textContent=a.currentPageIndex+1},setNumPages:function(c){document.getElementById(a.ID+"num-pages").textContent=c},updateZoomSlider:function(){a.zoomLevel!==b(a.selector+"zoom-slider").val()&&b(a.selector+"zoom-slider").val(a.zoomLevel);document.getElementById(a.ID+"zoom-level").textContent=a.zoomLevel},updateZoomButtons:function(){document.getElementById(a.ID+"zoom-level").textContent=a.zoomLevel},updateGridSlider:function(){a.pagesPerRow!==
+b(a.selector+"grid-slider").val()&&b(a.selector+"grid-slider").val(a.pagesPerRow);document.getElementById(a.ID+"pages-per-row").textContent=a.pagesPerRow},updateGridButtons:function(){document.getElementById(a.ID+"pages-per-row").textContent=a.pagesPerRow},closePopups:function(){b(".diva-popup").css("display","none")},switchView:function(){b(a.selector+c+"-slider").hide();b(a.selector+c+"-out-button").hide();b(a.selector+c+"-in-button").hide();b(a.selector+c+"-slider-label").hide();b(a.selector+c+
+"-buttons-label").hide();c=a.inGrid?"grid":"zoom";b(a.selector+c+"-slider").show();b(a.selector+c+"-out-button").show();b(a.selector+c+"-in-button").show();b(a.selector+c+"-slider-label").show();b(a.selector+c+"-buttons-label").show();b(a.selector+"grid-icon").toggleClass("diva-in-grid")},switchMode:function(){b(a.selector+"tools").toggleClass("diva-fullscreen-tools");a.inFullscreen?b(a.selector+"tools-left").addClass("in-fullscreen"):b(a.selector+"tools-left").removeClass("in-fullscreen")}}},ua=
+function(){if(window.divaPlugins){var c=[];b.each(window.divaPlugins,function(b,d){var e=d.pluginName[0].toUpperCase()+d.pluginName.substring(1);a["enable"+e]&&d.init(a,g)&&(e=d.titleText||e+" plugin","function"===typeof d.handleClick&&(c.push('<div class="diva-'+d.pluginName+'-icon" title="'+e+'"></div>'),a.outerObject.on(a.mobileWebkit?"touchend":"click",".diva-"+d.pluginName+"-icon",function(c){d.handleClick.call(this,c,a,g)})),a.plugins.push(d))});c.length&&(a.pageTools='<div class="diva-page-tools">'+
+c.join("")+"</div>")}},qa=function(){clearTimeout(a.throbberTimeoutID);b(a.selector+"throbber").hide()},va=function(){a.outerObject.append('<div id="'+a.ID+'throbber" class="diva-throbber"></div>');a.throbberTimeoutID=setTimeout(function(){b(a.selector+"throbber").show()},a.throbberTimeout);b.ajax({url:a.objectData,cache:!0,dataType:"json",error:function(c,b,d){qa();c='<div id="'+a.ID+'error" class="diva-error"><p><strong>Error</strong></p><p>Invalid objectData. Error code: '+b+" "+d+"</p>";0===a.objectData.lastIndexOf("http",
+0)&&""===d&&(d=a.objectData.replace(/https?:\/\//i,"").split(/[/?#]/)[0],location.hostname!==d&&(c+='<p>Attempted to access cross-origin data without CORS.</p><p>You may need to update your server configuration to support CORS. For help, see the <a href="https://github.com/DDMAL/diva.js/wiki/Installation#a-note-about-cross-site-requests" target="_blank">cross-site request documentation.</a></p>'));a.outerObject.append(c+"</div>")},success:function(c,d,e){qa();a.pages=c.pgs;a.maxRatio=c.dims.max_ratio;
+a.minRatio=c.dims.min_ratio;a.itemTitle=c.item_title;a.numPages=c.pgs.length;a.maxWidths=c.dims.max_w;a.maxHeights=c.dims.max_h;a.averageWidths=c.dims.a_wid;a.averageHeights=c.dims.a_hei;a.totalHeights=c.dims.t_hei;a.totalWidths=c.dims.t_wid;a.realMaxZoom=c.max_zoom;a.maxZoomLevel=0<=a.maxZoomLevel&&a.maxZoomLevel<=c.max_zoom?a.maxZoomLevel:c.max_zoom;a.minZoomLevel=0<=a.minZoomLevel&&a.minZoomLevel<=a.maxZoomLevel?a.minZoomLevel:0;a.zoomLevel=w(a.zoomLevel);a.minPagesPerRow=Math.max(2,a.minPagesPerRow);
+a.maxPagesPerRow=Math.max(a.minPagesPerRow,a.maxPagesPerRow);a.enableFilename?(c=b.getHashParam("i"+a.hashParamSuffix),c=n(c)):c=parseInt(b.getHashParam("p"+a.hashParamSuffix),10)-1;p(c)&&(a.goDirectlyTo=c,a.currentPageIndex=c);b.each(a.plugins,function(c,b){h(b.setupHook,a)});a.enableToolbar&&(a.toolbar=ta(),diva.Events.subscribe("VisiblePageDidChange",a.toolbar.updateCurrentPage),diva.Events.subscribe("ModeDidSwitch",a.toolbar.switchMode),diva.Events.subscribe("ViewDidSwitch",a.toolbar.switchView),
+diva.Events.subscribe("ZoomLevelDidChange",a.toolbar.updateZoomSlider),diva.Events.subscribe("ZoomLevelDidChange",a.toolbar.updateZoomButtons),diva.Events.subscribe("GridRowNumberDidChange",a.toolbar.updateGridSlider),diva.Events.subscribe("ZoomLevelDidChange",a.toolbar.updateGridButtons),diva.Events.subscribe("ClosePopups",a.toolbar.closePopups));b(a.selector+"current label").text(a.numPages);a.enableAutoTitle&&a.parentObject.prepend('<div id="'+a.ID+'title" class="diva-title">'+a.itemTitle+"</div>");
+a.parentObject.parent()[0]!==document.body||a.parentObject.siblings().not("#diva-canvas-backdrop")[0]||(a.divaIsFullWindow=!0);Q();p(parseInt(a.goDirectlyTo),10)||(a.goDirectlyTo=0);0<a.adaptivePadding?(c=a.zoomLevel,a.horizontalPadding=parseInt(a.averageWidths[c]*a.adaptivePadding,10),a.verticalPadding=parseInt(a.averageHeights[c]*a.adaptivePadding,10)):(a.horizontalPadding=a.fixedPadding,a.verticalPadding=a.fixedPadding);a.pageTools.length&&(a.verticalPadding=Math.max(40,a.verticalPadding));c=parseInt(b.getHashParam("y"+
+a.hashParamSuffix),10);isNaN(c)?a.verticalOffset=R(a.currentPageIndex,"top"):a.verticalOffset=c;c=parseInt(b.getHashParam("x"+a.hashParamSuffix),10);isNaN(c)?a.horizontalOffset=S(a.currentPageIndex,"center"):a.horizontalOffset=c;a.inFullscreen?ba(!1):P();Q();h(a.onReady,a);diva.Events.publish("ViewerDidLoad",[a],g);a.loaded=!0}})},ea=function(){return a.loaded?!0:(console.warn("The viewer is not completely initialized. This is likely because it is still downloading data. To fix this, only call this function if the isReady() method returns true."),
+!1)};(function(){a.scrollbarWidth=b.getScrollbarWidth();a.mobileWebkit=void 0!==window.orientation;a.ID=b.generateId("diva-");a.selector="#"+a.ID;var c=parseInt(a.ID,10);1<c&&(a.hashParamSuffix=c);a.parentObject.append('<div id="'+a.ID+'outer" class="diva-outer"></div>');a.outerObject=b(a.selector+"outer");a.outerObject.append('<div id="'+a.ID+'inner" class="diva-inner diva-dragger"></div>');a.innerObject=b(a.selector+"inner");c=parseInt(b.getHashParam("n"+a.hashParamSuffix),10);c>=a.minPagesPerRow&&
+c<=a.maxPagesPerRow&&(a.pagesPerRow=c);c=b.getHashParam("z"+a.hashParamSuffix);""!==c&&(c=parseInt(c,10),c>=a.minZoomLevel&&(a.zoomLevel=c));var c=b.getHashParam("g"+a.hashParamSuffix),d="true"===c,e=b.getHashParam("f"+a.hashParamSuffix);a.inGrid=a.inGrid&&"false"!==c||d;a.inFullscreen=a.inFullscreen&&"false"!==e||"true"===e;va();ua();sa()})();this.getItemTitle=function(){return a.itemTitle};this.gotoPageByNumber=function(a,b,d){--a;return p(a)?(J(a,R(a,d),S(a,b)),!0):!1};this.gotoPageByIndex=function(a,
+b,d){return p(a)?(J(a,R(a,d),S(a,b)),!0):!1};this.getCurrentPage=function(){console.warn("The call to getCurrentPage is deprecated. Use getCurrentPageIndex instead.");return a.currentPageIndex};this.getNumberOfPages=function(){return ea()?a.numPages:!1};this.getPageDimensionsAtZoomLevel=function(c,b){if(!ea())return!1;b>a.maxZoomLevel&&(b=a.maxZoomLevel);var d=a.pages[c].d[parseInt(b,10)];return{width:d.w,height:d.h}};this.getCurrentPageDimensionsAtCurrentZoomLevel=function(){return this.getPageDimensionsAtZoomLevel(a.currentPageIndex,
+a.zoomLevel)};this.isReady=function(){return a.loaded};this.getCurrentPageIndex=function(){return a.currentPageIndex};this.getCurrentPageFilename=function(){return a.pages[a.currentPageIndex].f};this.getCurrentPageNumber=function(){return a.currentPageIndex+1};this.getFilenames=function(){for(var c=[],b=0;b<a.numPages;b++)c[b]=a.pages[b].f;return c};this.getZoomLevel=function(){return a.zoomLevel};this.getMaxZoomLevel=function(){return a.maxZoomLevel};this.getMaxZoomLevelForPage=function(c){return ea?
+a.pages[c].m:!1};this.getMinZoomLevel=function(){return a.minZoomLevel};this.setZoomLevel=function(c){a.inGrid&&E();return N(c)};this.zoomIn=function(){return this.setZoomLevel(a.zoomLevel+1)};this.zoomOut=function(){return this.setZoomLevel(a.zoomLevel-1)};this.inViewport=function(c,b,d,e,f){--c;d=a.pageTopOffsets[c]+d;b=a.pageLeftOffsets[c]+b;e=b+e;return u(d,d+f)&&t(b,e)};this.isPageInViewport=function(a){return r(a)};this.isPageInDOM=function(a){return q(a)};this.toggleFullscreenMode=function(){C()};
+this.enterFullscreenMode=function(){return a.inFullscreen?!1:(C(),!0)};this.leaveFullscreenMode=function(){return a.inFullscreen?(C(),!0):!1};this.toggleGridView=function(){E()};this.enterGridView=function(){return a.inGrid?!1:(E(),!0)};this.leaveGridView=function(){return a.inGrid?(E(),!0):!1};this.gotoPageByName=function(a,b,d){a=n(a);return p(a)?(J(a,R(a,d),S(a,b)),!0):!1};this.getPageIndex=function(a){return n(a)};this.getCurrentURL=function(){return oa()};this.getURLHash=function(){return na()};
+this.getState=function(){return ma()};this.getInstanceSelector=function(){return a.selector};this.getInstanceId=function(){return a.ID};this.getSettings=function(){return a};this.translateFromMaxZoomLevel=function(c){return c/Math.pow(2,a.maxZoomLevel-a.zoomLevel)};this.translateToMaxZoomLevel=function(c){var b=a.maxZoomLevel-a.zoomLevel;return 0===b?c:c*Math.pow(2,b)};this.setState=function(c){var b;b=n(c.i);p(b)?a.goDirectlyTo=b:p(c.p)&&(a.goDirectlyTo=c.p);horizontalOffset=parseInt(c.x,10);verticalOffset=
+parseInt(c.y,10);c.z>=a.minZoomLevel&&c.z<=a.maxZoomLevel&&(a.zoomLevel=c.z);c.n>=a.minPagesPerRow&&c.n<=a.maxPagesPerRow&&(a.pagesPerRow=c.n);a.inFullscreen!==c.f?(a.inFullscreen=c.f,ba(a.inGrid!==c.g),a.horizontalOffset=horizontalOffset,a.verticalOffset=verticalOffset,J(b,a.verticalOffset,a.horizontalOffset)):(a.horizontalOffset=horizontalOffset,a.verticalOffset=verticalOffset,a.inGrid!==c.g?(a.inGrid=c.g,D()):P())};this.enableScrollable=function(){a.isScrollable||(pa(),a.enableKeyScroll=a.initialKeyScroll,
+a.enableSpaceScroll=a.initialSpaceScroll,a.outerObject.css("overflow","auto"),a.isScrollable=!0)};this.disableScrollable=function(){a.isScrollable&&(a.innerObject.hasClass("diva-dragger")&&a.innerObject.unbind("mousedown"),a.outerObject.unbind("dblclick"),a.outerObject.unbind("contextmenu"),a.outerObject.css("overflow","hidden"),a.initialKeyScroll=a.enableKeyScroll,a.initialSpaceScroll=a.enableSpaceScroll,a.enableKeyScroll=!1,a.enableSpaceScroll=!1,a.isScrollable=!1)};this.toggleOrientation=function(){a.verticallyOriented=
+!a.verticallyOriented;a.verticalOffset=R();a.horizontalOffset=S();a.goDirectlyTo=a.currentPageIndex;aa();return a.verticallyOriented};this.getPageOffset=function(c){return{top:parseInt(a.pageTopOffsets[c]),left:parseInt(a.pageLeftOffsets[c])}};this.getCurrentPageOffset=function(){return this.getPageOffset(a.currentPageIndex)};this.getPageDimensionsAtCurrentGridLevel=function(c){c=p(c)?c:a.currentPageIndex;var b=a.rowHeight-a.fixedPadding;c=a.fixedHeightGrid?(a.rowHeight-a.fixedPadding)*l(c,"w")/l(c,
+"h"):a.gridPageWidth;return{height:parseInt(b,10),width:parseInt(c,10)}};this.getPageIndexForPageXYValues=function(c,b){var d=document.getElementById(a.ID+"outer").getBoundingClientRect(),e=d.bottom,f=d.right;if(c<d.left||c>f||b<d.top||b>e)return!1;d=document.getElementsByClassName("diva-document-page");for(e=d.length;e--;){var f=d[e],m=f.getBoundingClientRect();if(!(c<m.left||c>m.right||b<m.top||b>m.bottom))return f.getAttribute("data-index")}return!1};this.isVerticallyOriented=function(){return a.verticallyOriented};
+this.activate=function(){a.isActiveDiva=!0};this.deactivate=function(){a.isActiveDiva=!1};this.destroy=function(){b("body").removeClass("diva-hide-scrollbar");a.parentObject.empty().removeData("diva");b.each(a.plugins,function(c,b){h(b.destroy,a,g)});a.parentObject.removeAttr("style").removeAttr("class");diva.Events.unsubscribeAll()}};b.fn.diva=function(f){return this.each(function(){f.parentObject=b(this);if(!f.parentObject.data("diva")){var d=new e(this,f);f.parentObject.data("diva",d)}})}})(jQuery);function log10(b){return Math.log(b)/Math.log(10)}
+(function(b){window.divaPlugins.push(function(){return{init:function(e,f){var d,a,g,h,l;f.startScrolling=function(){e.currentlyAutoScrolling?console.warn("Diva is already autoscrolling!"):(b("#"+e.ID+"autoscroll-toggle").text("Turn off"),a&&f.disableScrollable(),e.currentlyAutoScrolling=!0,restartScrollingInterval())};restartScrollingInterval=function(){clearInterval(e.autoScrollInterval);e.autoScrollInterval=e.verticallyOriented?setInterval(function(){e.outerObject.scrollTop(e.outerObject.scrollTop()+d)},
+g):setInterval(function(){e.outerObject.scrollLeft(e.outerObject.scrollLeft()+d)},g)};f.stopScrolling=function(){e.currentlyAutoScrolling?(b("#"+e.ID+"autoscroll-toggle").text("Turn on"),a&&f.enableScrollable(),e.currentlyAutoScrolling=!1,clearInterval(e.autoScrollInterval)):console.warn("Diva isn't autoscrolling!")};f.toggleScrolling=function(){e.currentlyAutoScrolling?f.stopScrolling():f.startScrolling()};f.changeRefresh=function(a){g=a;n()};f.changeScrollSpeed=function(a){l=a;n();b("#"+e.ID+"autoscroll-pps").val(log10(l));
+e.currentlyAutoScrolling&&restartScrollingInterval()};var n=function(){g=h;d=l/(1E3/g);1>d&&(g*=1/d,d=l/(1E3/g))};f.disableManualScroll=function(){a=!0;e.currentlyAutoScrolling&&f.disableScrollable()};f.enableManualScroll=function(){a=!1;e.currentlyAutoScrolling&&f.enableScrollable()};e.currentlyAutoScrolling=!1;e.autoScrollInterval="";a=e.disableManualScroll||!1;h=g=e.autoScrollRefresh||50;f.changeScrollSpeed(e.scrollSpeed||10);b(window).on("keyup",function(a){a.shiftKey&&32==a.keyCode&&f.toggleScrolling()});
+e.disableAutoscrollPrefs||diva.Events.subscribe("ViewerDidLoad",function(a){a="<div id='"+e.ID+"autoscroll-prefs' class='diva-autoscroll-prefs diva-popup'><b>Autoscrolling options:</b><br><span class='diva-autoscroll-prefs-text'>Pixels per second:</span><input type='range' id='"+e.ID+"autoscroll-pps' class='diva-autoscroll-pps diva-autoscroll-prefs-input' value='"+log10(l)+"' min='0' max='3' step='0.1'><br><span class='diva-autoscroll-prefs-text'>Allow manual scroll:</span><input type='checkbox' id='"+
+e.ID+"autoscroll-manual' class='diva-autoscroll-manual diva-autoscroll-prefs-input' checked='checked'><br><button id='"+e.ID+"autoscroll-toggle' class='diva-autoscroll-prefs-toggle diva-autoscroll-prefs-input'> Turn on </button></div>";b("#"+e.ID+"page-nav").before("<div id='"+e.ID+"autoscroll-icon' class='button diva-autoscroll-icon' title='Expand autoscroll options'></div>");b("body").prepend(a);b("#"+e.ID+"autoscroll-pps").on("change",function(a){f.changeScrollSpeed(Math.pow(10,a.target.value))});
+b("#"+e.ID+"autoscroll-manual").on("change",function(a){a.target.checked?f.enableManualScroll():f.disableManualScroll()});b("#"+e.ID+"autoscroll-toggle").on("click",f.toggleScrolling);b("#"+e.ID+"autoscroll-icon").on("click",function(a){a=b("#"+e.ID+"autoscroll-prefs");"none"==a.css("display")?(a.css({display:"block",right:b(window).width()-(e.outerObject.offset().left+e.outerObject.outerWidth())+e.scrollbarWidth}),a.offset({top:e.outerObject.offset().top+1})):a.css("display","none")})})},pluginName:"autoscroll",
+titleText:"Automatically scrolls page along primary axis"}}())})(jQuery);(function(b){window.divaPlugins.push(function(){var e={},f={},d={},a,g,h,l={brightnessMax:150,brightnessMin:-100,brightnessStep:1,contrastMax:3,contrastMin:-1,contrastStep:.05,localStoragePrefix:"canvas-",mobileWebkitMaxZoom:2,onInit:null,rgbMax:50,rgbMin:-50,throbberFadeSpeed:200,throbberTimeout:100,buttons:["contrast","brightness","rotation","zoom"]},n=function(b,d){var e=b.context,f=b.size/2,g=-(b.width/2),h=-(b.height/2);e.clearRect(0,0,b.size,b.size);e.save();e.translate(f,f);e.rotate(d*Math.PI/
+180);e.drawImage(a,g,h,b.width,b.height);e.restore();b.data=e.getImageData(0,0,b.size,b.size)},t=function(){for(var a in g)if(g[a].current!==g[a].previous)return!0;return!1},u=function(){n(f,g.rotation.current);q(f)},p=function(){var a=g.rotation.current,f=g.zoom.current,h=g.zoom.previous;if(a!==g.rotation.previous||f!==h){var k=b("#diva-canvas-wrapper").scrollLeft(),l=b("#diva-canvas-wrapper").scrollTop(),p=d.viewport.width/2,r=d.viewport.height/2,k=k+p-e.centerX,u=-(l+r-e.centerY),z=(g.rotation.previous-
+a)*Math.PI/180,l=Math.cos(z)*k-Math.sin(z)*u+e.centerX,k=-(Math.sin(z)*k+Math.cos(z)*u)+e.centerY,f=Math.pow(2,f-h),p=f*l-p,r=f*k-r;n(e,a);b("#diva-canvas-wrapper").scrollLeft(p);b("#diva-canvas-wrapper").scrollTop(r)}if(t()){q(e);for(var w in g)g[w].previous=g[w].current}},r=function(a){var b=g[a].current!==g[a].initial;return g[a].current!==g[a].previous||b},q=function(a){var b=a.data,e=a.context.createImageData(b),f=e.data,h,k;h=0;for(k=f.length;h<k;h++)f[h]=b.data[h];b=e.data;h=g.contrast.current;
+f=(1+Math.min(d.brightnessMax,Math.max(d.brightnessMin,g.brightness.current))/d.brightnessMax)*h;h=128-128*h;k=g.red.current;var l=g.green.current,n=g.blue.current,z=r("red"),p=r("green"),q=r("blue"),u=r("brightness"),t=r("contrast"),u=u||t,y,A,v,B,D,C,E,t=0;for(A=e.width;t<A;t++)for(y=0,v=e.height;y<v;y++)B=4*(y*A+t),D=b[B],C=b[B+1],E=b[B+2],0<D+C+E&&(z&&D&&(D+=k),p&&C&&(C+=l),q&&E&&(E+=n),u&&(D&&(D=D*f+h),C&&(C=C*f+h),E&&(E=E*f+h)),b[B]=D,b[B+1]=C,b[B+2]=E);a.context.clearRect(0,0,A,v);a.context.putImageData(e,
+0,0)},k=function(){var a=b("#diva-canvas-wrapper").scrollLeft()*f.scaleFactor,e=b("#diva-canvas-wrapper").scrollTop()*f.scaleFactor,g=Math.min(Math.round(d.viewport.height*f.scaleFactor),d.mapSize)-4,h=Math.min(Math.round(d.viewport.width*f.scaleFactor),d.mapSize)-4;b("#diva-map-viewbox").height(g).width(h).css({top:e,left:a})},T=function(g,h){a=new Image;a.src=g;a.crossOrigin="Anonymous";a.onload=function(){e.size=Math.sqrt(a.width*a.width+a.height*a.height);e.canvas=document.getElementById("diva-canvas");
+e.canvas.width=e.size;e.canvas.height=e.size;e.cornerX=(e.size-a.width)/2;e.cornerY=(e.size-a.height)/2;e.width=a.width;e.height=a.height;e.centerX=e.size/2;e.centerY=e.size/2;e.context=e.canvas.getContext("2d");e.context.drawImage(a,e.cornerX,e.cornerY,e.width,e.height);try{e.data=e.context.getImageData(0,0,e.size,e.size)}catch(g){var m='<div id="diva-error" class="diva-error"><p><strong>Error</strong></p><p>'+g.message+"</p>";if("SecurityError"!==g.name)throw g;m+='<p>You may need to update your server configuration in order to use the image manipulation tools. For help, see the <a href="https://github.com/DDMAL/diva.js/wiki/The-API-and-Plugins#a-note-about-canvas-and-cross-site-data" target="_blank">canvas cross-site data documentation</a>.</p></div></div>';
+b("#diva-canvas-backdrop").append(m);B()}void 0===h&&(m=a,f.canvas=document.getElementById("diva-canvas-minimap"),f.size=d.mapSize,f.canvas.width=f.size,f.canvas.height=f.size,f.context=f.canvas.getContext("2d"),f.context.fillRect(0,0,f.size,f.size),f.scaleFactor=d.mapSize/e.size,f.cornerX=e.cornerX*f.scaleFactor,f.cornerY=e.cornerY*f.scaleFactor,f.width=m.width*f.scaleFactor,f.height=m.height*f.scaleFactor,f.context.drawImage(m,f.cornerX,f.cornerY,f.width,f.height),f.data=f.context.getImageData(0,
+0,d.mapSize,d.mapSize),b("#diva-map-viewbox").show(),k());u();p(e);B();"function"===typeof h&&h.call(h)}},L=function(){var a=g[h],d=a.current,a=a.transform?a.transform(d):d;b("#diva-canvas-value").html(a)},y=function(){b("#diva-canvas-slider").val(g[h].current)},v=function(a){a=d.zoomWidthRatio*Math.pow(2,a);return d.proxyURL?d.proxyURL+"?f="+d.filename+"&w="+a:d.iipServerURL+"?FIF="+(d.imageDir+"/")+d.filename+"&WID="+a+"&CVT=JPEG"},A=function(){(0<g.zoom.current||d.mobileWebkit)&&b(d.selector+"throbber").addClass("canvas-throbber").show()},
+B=function(){b(d.selector+"throbber").removeClass("canvas-throbber").hide()},I=function(){var a={},b=!1,e=d.localStoragePrefix+d.filename,f;for(f in g)g[f].previous!==g[f].initial&&(a[f]=g[f].previous,b=!0);b?(d.pluginIcon.addClass("new"),localStorage.setObject(e,a)):(d.pluginIcon.removeClass("new"),localStorage.removeItem(e))},G=function(a,b){d.zoomLevel=a;var g=v(a);T(g,function(){f.scaleFactor=f.size/e.size;k();I()})},M=function(a){switch(a.keyCode){case 38:return b("#diva-canvas-wrapper").scrollTop(document.getElementById("diva-canvas-wrapper").scrollTop-
+d.arrowScrollAmount),!1;case 40:return b("#diva-canvas-wrapper").scrollTop(document.getElementById("diva-canvas-wrapper").scrollTop+d.arrowScrollAmount),!1;case 37:return b("#diva-canvas-wrapper").scrollLeft(document.getElementById("diva-canvas-wrapper").scrollLeft-d.arrowScrollAmount),!1;case 39:return b("#diva-canvas-wrapper").scrollLeft(document.getElementById("diva-canvas-wrapper").scrollLeft+d.arrowScrollAmount),!1}};return{init:function(a,n){if(!window.HTMLCanvasElement)return!1;b.extend(d,
+l,a.canvasPlugin);d.inCanvas=!1;d.iipServerURL=a.iipServerURL;d.imageDir=a.imageDir;d.selector=a.selector;d.mobileWebkit=a.mobileWebkit;d.arrowScrollAmount=a.arrowScrollAmount;g={contrast:{initial:1,min:d.contrastMin,max:d.contrastMax,step:d.contrastStep,transform:function(a){return a.toFixed(2)},title:"Change the contrast"},brightness:{initial:0,min:d.brightnessMin,max:d.brightnessMax,step:d.brightnessStep,title:"Adjust the brightness"},rotation:{initial:0,min:0,max:359,step:1,transform:function(a){return a+
+"&deg;"},title:"Rotate the image"},zoom:{initial:0,min:0,max:0,step:1,title:"Adjust the zoom level"},red:{initial:0,min:d.rgbMin,max:d.rgbMax,step:1,title:"Adjust the red channel"},green:{initial:0,min:d.rgbMin,max:d.rgbMax,step:1,title:"Adjust the green channel"},blue:{initial:0,min:d.rgbMin,max:d.rgbMax,step:1,title:"Adjust the blue channel"}};var r=function(){var a,b,d;for(d in g)b=g[d],a=b.initial,b.current=a,b.previous=a};r();if(b("#diva-canvas-backdrop").length)return!0;var q=[],v,K,O;for(O in d.buttons)v=
+d.buttons[O],K=g[v].title,v='<div class="'+v+'" title="'+K+'"></div>',q.push(v);q='<div id="diva-canvas-backdrop">'+('<div id="diva-canvas-tools"><div id="diva-canvas-toolbar"><div id="diva-canvas-close" title="Return to the document viewer"></div><div id="diva-canvas-minimise" title="Minimise the toolbar"></div><span id="diva-canvas-info">Test</span></div><div id="diva-canvas-toolwindow"><div id="diva-map-viewbox"></div><canvas id="diva-canvas-minimap"></canvas><div id="diva-canvas-buttons">'+q.join("")+
+'</div><div id="diva-canvas-pane"><p id="diva-canvas-tooltip"><span id="diva-canvas-mode">contrast</span>: <span id="diva-canvas-value">0</span> <span id="diva-canvas-reset" class="link">(Reset)</span></p><input type="range" id="diva-canvas-slider"></input></div><br /><div class="action-buttons"><a href="#" id="diva-canvas-reset-all">Reset all</a><a href="#" id="diva-canvas-apply">Apply</a></div></div></div>')+'<div id="diva-canvas-wrapper"><canvas id="diva-canvas"></canvas></div></div>';b("body").append(q);
+d.mapSize=b("#diva-canvas-minimap").width();b("#diva-canvas-buttons div").click(function(){b("#diva-canvas-buttons .clicked").removeClass("clicked");J(b(this).attr("class"))});var J=function(a){h=a;a=g[h];b("#diva-canvas-buttons ."+h).addClass("clicked");b("#diva-canvas-mode").text(h);var d=a.current,e=a.transform?a.transform(d):d,f=document.getElementById("diva-canvas-slider");f.min=a.min;f.max=a.max;f.step=a.step;b("#diva-canvas-slider").val(d);b("#diva-canvas-value").html(e)};J("contrast");b("#diva-canvas-slider").on("input",
+function(a){g[h].current=parseFloat(this.value);L();u()});b("#diva-canvas-reset-all").click(function(){for(var a in g)g[a].current=g[a].initial;L();y();u()});b("#diva-canvas-reset").click(function(){g[h].current=g[h].initial;L();y();u()});b("#diva-canvas-apply").click(function(){t()&&(A(),setTimeout(function(){g.zoom.current!==g.zoom.previous?G(g.zoom.current):(p(),B(),I())},d.throbberTimeout))});b("#diva-canvas-close").click(function(){b("body").removeClass("overflow-hidden");e.context.clearRect(0,
+0,e.size,e.size);f.context.clearRect(0,0,f.size,f.size);b("#diva-canvas-wrapper").scrollTop(0).scrollLeft(0);b("#diva-canvas-backdrop").hide();b("#diva-map-viewbox").hide();B();n.enableScrollable();b(document).off("keydown",M);r();L();y();b("#diva-canvas-buttons .clicked").removeClass("clicked");J("contrast");diva.Events.publish("CanvasViewDidHide")});b("#diva-canvas-minimise").click(function(){b("#diva-canvas-toolwindow").slideToggle("fast")});b(window).resize(function(){d.viewport={height:window.innerHeight-
+a.scrollbarWidth,width:window.innerWidth-a.scrollbarWidth};d.inCanvas&&k()});b("#diva-canvas-wrapper").scroll(function(){d.inCanvas&&k()});b("#diva-canvas-minimap, #diva-map-viewbox").mouseup(function(a){var e=b("#diva-canvas-minimap").offset(),g=(a.pageX-e.left)/f.scaleFactor;a=(a.pageY-e.top)/f.scaleFactor;b("#diva-canvas-wrapper").scrollTop(a-d.viewport.height/2);b("#diva-canvas-wrapper").scrollLeft(g-d.viewport.width/2)});b("#diva-canvas").mousedown(function(){b(this).addClass("grabbing")}).mouseup(function(){b(this).removeClass("grabbing")});
+d.mobileWebkit?b("#diva-canvas-wrapper").kinetic():b("#diva-canvas-wrapper").dragscrollable({acceptPropagatedEvent:!0});"function"===typeof d.onInit&&d.onInit.call(this,d);return!0},pluginName:"canvas",titleText:"View the image on a canvas and adjust various settings",setupHook:function(a){d.viewport={height:window.innerHeight-a.scrollbarWidth,width:window.innerWidth-a.scrollbarWidth};d.minZoomLevel=a.minZoomLevel;d.maxZoomLevel=a.maxZoomLevel;d.mobileWebkit&&(d.maxZoomLevel=Math.min(d.maxZoomLevel,
+d.mobileWebkitMaxZoom));g.zoom.min=d.minZoomLevel;g.zoom.max=d.maxZoomLevel},handleClick:function(a,e,f){a=b(this).parent().parent();var k=b(a).attr("data-filename"),l=b(a).width()-1;e=e.zoomLevel;var n;d.zoomWidthRatio=l/Math.pow(2,e);d.pluginIcon=b(this);d.mobileWebkit&&(e=Math.min(d.maxZoomLevel,e));d.filename=k;g.zoom.initial=e;g.zoom.current=e;if(k=localStorage.getObject(d.localStoragePrefix+d.filename))for(n in k)g[n].current=k[n],n===h&&(L(),y()),"zoom"===n&&(e=k[n]);g.zoom.previous=e;b("body").addClass("overflow-hidden");
+b("#diva-canvas-backdrop").show();f.disableScrollable();b(document).keydown(M);d.inCanvas=!0;f=v(e);b("#diva-canvas-info").text(b(a).attr("title"));A();diva.Events.publish("CanvasViewDidActivate",[a]);T(f)},onPageLoad:function(a,e,f){null!==localStorage.getItem(d.localStoragePrefix+e)&&b(f).find(".diva-canvas-icon").addClass("new")},destroy:function(a,d){b("#diva-canvas-backdrop").remove()}}}())})(jQuery);(function(b){window.divaPlugins.push(function(){var e,f;return{init:function(b,a){e=b.iipServerURL;f=b.imageDir;return!0},pluginName:"download",titleText:"Download image at the given zoom level",handleClick:function(d){var a=b(this).parent().parent();d=b(a).attr("data-filename");a=b(a).width()-1;window.open(e+"?FIF="+(f+"/")+d+"&WID="+a+"&CVT=JPEG")}}}())})(jQuery);(function(b){window.divaPlugins.push(function(){return{init:function(b,f){function d(a,d,h){var l=b.parentObject.data("highlights");if("undefined"!==typeof l){if(l.hasOwnProperty(a)){var n=f.getInstanceId()+"page-"+a,n=document.getElementById(n),t=l[a].regions,u=l[a].colour,l=l[a].divClass,p=f.getMaxZoomLevel();b.inGrid?(p=f.getPageDimensionsAtZoomLevel(a,p).width,p=Math.log(p/n.clientWidth)/Math.log(2)):p-=f.getZoomLevel();for(var r=t.length;r--;){var q=document.createElement("div");q.style.width=
+t[r].width/Math.pow(2,p)+"px";q.style.height=t[r].height/Math.pow(2,p)+"px";q.style.top=t[r].uly/Math.pow(2,p)+"px";q.style.left=t[r].ulx/Math.pow(2,p)+"px";q.style.background=u;q.style.border="1px solid #555";q.style.position="absolute";q.style.zIndex=100;q.className=l;"undefined"!==typeof t[r].divID&&(q.id=t[r].divID);n.appendChild(q)}}diva.Events.publish("HighlightCompleted",[a,d,h])}}b.parentObject.data("highlights",{});diva.Events.subscribe("PageWillLoad",d);f.resetHighlights=function(){for(var a=
+document.getElementById(b.ID+"inner").getElementsByClassName(b.ID+"highlight"),d=a.length;d--;)a[d].parentNode.removeChild(a[d]);b.parentObject.data("highlights",{})};f.removeHighlightsOnPage=function(a){var d=b.parentObject.data("highlights");if(d.hasOwnProperty(a)){for(var h=f.getInstanceId()+"page-"+a,h=document.getElementById(h),l=h.getElementsByTagName("div"),n=d[a].divClass,t=l.length;t--;)l[t].className===n&&h.removeChild(l[t]);delete d[a]}};f.highlightOnPages=function(a,b,d,e){for(var n=a.length;n--;)f.highlightOnPage(a[n],
+b[n],d,e)};f.highlightOnPage=function(a,g,h,l){"undefined"===typeof h&&(h="rgba(255, 0, 0, 0.2)");l="undefined"===typeof l?b.ID+"highlight":b.ID+"highlight "+l;f.getMaxZoomLevel();b.parentObject.data("highlights")[a]={regions:g,colour:h,divClass:l};f.isPageInDOM(a)&&d(a,null,null);return!0};return!0},destroy:function(b,f){b.parentObject.removeData("highlights")},pluginName:"highlight",titleText:"Highlight regions of pages"}}())})(jQuery);(function(b){window.divaPlugins.push(function(){return{init:function(b,f){void 0===b.pageAliases&&(b.pageAliases={});void 0===b.pageAliasFunction&&(b.pageAliasFunction=function(){return!1});f.getAliasForPageIndex=function(d){return b.pageAliases[d]||b.pageAliasFunction(d)||d+1};f.getPageIndexForAlias=function(d){for(var a=0;a<b.numPages;a++)if(f.getAliasForPageIndex(a)==d)return a;return!1};f.getPageIndicesForAlias=function(d){for(var a=[],g=0;g<b.numPages;g++)f.getAliasForPageIndex(g)==d&&a.push(g);
+return a};f.getCurrentAliasedPageIndex=function(){return f.getAliasForPageIndex(b.currentPageIndex)};f.gotoPageByAliasedNumber=function(b,a,e){return f.gotoPageByIndex(f.getPageIndexForAlias(b),a,e)};updateCurrentAliasedPage=function(){document.getElementById(this.getSettings().ID+"current-page").textContent=this.getCurrentAliasedPageIndex()};initialChanges=function(){var b=this.getSettings(),a=b.numPages;void 0!==b.newTotalPages?a=b.newTotalPages:void 0!==b.totalPageOffset&&(a+=b.totalPageOffset);
+document.getElementById(this.getSettings().ID+"num-pages").textContent=a;document.getElementById(this.getSettings().ID+"current-page").textContent=this.getCurrentAliasedPageIndex();diva.Events.unsubscribe(["VisiblePageDidChange",b.toolbar.updateCurrentPage]);diva.Events.subscribe("VisiblePageDidChange",updateCurrentAliasedPage)};diva.Events.subscribe("ViewerDidLoad",initialChanges)},pluginName:"pagealias",titleText:"Re-aliases page indexes"}}())})(jQuery);
Binary file src/main/webapp/imageServer/resources/js/vendor/jquery-ui-1.10.4.zip has changed