-
Notifications
You must be signed in to change notification settings - Fork 1
/
openseadragon.min.js
15 lines (13 loc) · 214 KB
/
openseadragon.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! openseadragon 2.3.1
//! Built on 2017-09-19
//! Git commit: v2.3.1-0-08414cd
//! http://openseadragon.github.io
//! License: http://openseadragon.github.io/license/
function OpenSeadragon(a){return new OpenSeadragon.Viewer(a)}!function(a){a.version={versionStr:"2.3.1",major:parseInt("2",10),minor:parseInt("3",10),revision:parseInt("1",10)};var b={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},c=Object.prototype.toString,d=Object.prototype.hasOwnProperty;a.isFunction=function(b){return"function"===a.type(b)};a.isArray=Array.isArray||function(b){return"array"===a.type(b)};a.isWindow=function(a){return a&&"object"==typeof a&&"setInterval"in a};a.type=function(a){return null===a||void 0===a?String(a):b[c.call(a)]||"object"};a.isPlainObject=function(b){if(!b||"object"!==OpenSeadragon.type(b)||b.nodeType||a.isWindow(b))return!1;if(b.constructor&&!d.call(b,"constructor")&&!d.call(b.constructor.prototype,"isPrototypeOf"))return!1;var c;for(var e in b)c=e;return void 0===c||d.call(b,c)};a.isEmptyObject=function(a){for(var b in a)return!1;return!0};a.freezeObject=function(b){Object.freeze?a.freezeObject=Object.freeze:a.freezeObject=function(a){return a};return a.freezeObject(b)};a.supportsCanvas=function(){var b=document.createElement("canvas");return!(!a.isFunction(b.getContext)||!b.getContext("2d"))}();a.isCanvasTainted=function(a){var b=!1;try{a.getContext("2d").getImageData(0,0,1,1)}catch(a){b=!0}return b};a.pixelDensityRatio=function(){if(a.supportsCanvas){var b=document.createElement("canvas").getContext("2d");var c=window.devicePixelRatio||1;var d=b.webkitBackingStorePixelRatio||b.mozBackingStorePixelRatio||b.msBackingStorePixelRatio||b.oBackingStorePixelRatio||b.backingStorePixelRatio||1;return Math.max(c,1)/d}return 1}()}(OpenSeadragon);!function($){function getOffsetParent(a,b){return b&&a!=document.body?document.body:a.offsetParent}$.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=arguments.length,i=!1,j=1;if("boolean"==typeof g){i=g;g=arguments[1]||{};j=2}"object"==typeof g||OpenSeadragon.isFunction(g)||(g={});if(h===j){g=this;--j}for(;j<h;j++){a=arguments[j];if(null!==a||void 0!==a)for(b in a){c=g[b];d=a[b];if(g!==d)if(i&&d&&(OpenSeadragon.isPlainObject(d)||(e=OpenSeadragon.isArray(d)))){if(e){e=!1;f=c&&OpenSeadragon.isArray(c)?c:[]}else f=c&&OpenSeadragon.isPlainObject(c)?c:{};g[b]=OpenSeadragon.extend(i,f,d)}else void 0!==d&&(g[b]=d)}}return g};var isIOSDevice=function(){if("object"!=typeof navigator)return!1;var a=navigator.userAgent;return"string"==typeof a&&(a.indexOf("iPhone")!==-1||a.indexOf("iPad")!==-1||a.indexOf("iPod")!==-1)};$.extend($,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,loadTilesWithAjax:!1,ajaxHeaders:{},panHorizontal:!0,panVertical:!0,constrainDuringPan:!1,wrapHorizontal:!1,wrapVertical:!1,visibilityRatio:.5,minPixelRatio:.5,defaultZoomLevel:0,minZoomLevel:null,maxZoomLevel:null,homeFillsViewer:!1,clickTimeThreshold:300,clickDistThreshold:5,dblClickTimeThreshold:300,dblClickDistThreshold:20,springStiffness:6.5,animationTime:1.2,gestureSettingsMouse:{scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,pinchToZoom:!1,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,pinchToZoom:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,pinchToZoom:!1,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,pinchToZoom:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,smoothTileEdgesMinZoom:1.1,iOSDevice:isIOSDevice(),pixelsPerWheelLine:40,autoResize:!0,preserveImageSizeOnResize:!1,minScrollDeltaTime:50,showSequenceControl:!0,sequenceControlAnchor:null,preserveViewport:!1,preserveOverlays:!1,navPrevNextWrap:!1,showNavigationControl:!0,navigationControlAnchor:null,showZoomControl:!0,showHomeControl:!0,showFullPageControl:!0,showRotationControl:!1,controlsFadeDelay:2e3,controlsFadeLength:1500,mouseNavEnabled:!0,showNavigator:!1,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorAutoFade:!0,navigatorRotate:!0,degrees:0,opacity:1,preload:!1,compositeOperation:null,placeholderFillStyle:null,showReferenceStrip:!1,referenceStripScroll:"horizontal",referenceStripElement:null,referenceStripHeight:null,referenceStripWidth:null,referenceStripPosition:"BOTTOM_LEFT",referenceStripSizeRatio:.2,collectionRows:3,collectionColumns:0,collectionLayout:"horizontal",collectionMode:!1,collectionTileSize:800,collectionTileMargin:80,imageLoaderLimit:0,maxImageCacheCount:200,timeout:3e4,useCanvas:!0,prefixUrl:"/images/",navImages:{zoomIn:{REST:"zoomin_rest.png",GROUP:"zoomin_grouphover.png",HOVER:"zoomin_hover.png",DOWN:"zoomin_pressed.png"},zoomOut:{REST:"zoomout_rest.png",GROUP:"zoomout_grouphover.png",HOVER:"zoomout_hover.png",DOWN:"zoomout_pressed.png"},home:{REST:"home_rest.png",GROUP:"home_grouphover.png",HOVER:"home_hover.png",DOWN:"home_pressed.png"},fullpage:{REST:"fullpage_rest.png",GROUP:"fullpage_grouphover.png",HOVER:"fullpage_hover.png",DOWN:"fullpage_pressed.png"},rotateleft:{REST:"rotateleft_rest.png",GROUP:"rotateleft_grouphover.png",HOVER:"rotateleft_hover.png",DOWN:"rotateleft_pressed.png"},rotateright:{REST:"rotateright_rest.png",GROUP:"rotateright_grouphover.png",HOVER:"rotateright_hover.png",DOWN:"rotateright_pressed.png"},previous:{REST:"previous_rest.png",GROUP:"previous_grouphover.png",HOVER:"previous_hover.png",DOWN:"previous_pressed.png"},next:{REST:"next_rest.png",GROUP:"next_grouphover.png",HOVER:"next_hover.png",DOWN:"next_pressed.png"}},debugMode:!1,debugGridColor:["#437AB2","#1B9E77","#D95F02","#7570B3","#E7298A","#66A61E","#E6AB02","#A6761D","#666666"]},SIGNAL:"----seadragon----",delegate:function(a,b){return function(){var c=arguments;void 0===c&&(c=[]);return b.apply(a,c)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5},getElement:function(a){"string"==typeof a&&(a=document.getElementById(a));return a},getElementPosition:function(a){var b,c,d=new $.Point;a=$.getElement(a);b="fixed"==$.getElementStyle(a).position;c=getOffsetParent(a,b);for(;c;){d.x+=a.offsetLeft;d.y+=a.offsetTop;b&&(d=d.plus($.getPageScroll()));a=c;b="fixed"==$.getElementStyle(a).position;c=getOffsetParent(a,b)}return d},getElementOffset:function(a){a=$.getElement(a);var b,c,d=a&&a.ownerDocument,e={top:0,left:0};if(!d)return new $.Point;b=d.documentElement;"undefined"!=typeof a.getBoundingClientRect&&(e=a.getBoundingClientRect());c=d==d.window?d:9===d.nodeType&&(d.defaultView||d.parentWindow);return new $.Point(e.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0),e.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0))},getElementSize:function(a){a=$.getElement(a);return new $.Point(a.clientWidth,a.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(a){a=$.getElement(a);return a.currentStyle}:function(a){a=$.getElement(a);return window.getComputedStyle(a,"")},getCssPropertyWithVendorPrefix:function(a){var b={};$.getCssPropertyWithVendorPrefix=function(a){if(void 0!==b[a])return b[a];var c=document.createElement("div").style;var d=null;if(void 0!==c[a])d=a;else{var e=["Webkit","Moz","MS","O","webkit","moz","ms","o"];var f=$.capitalizeFirstLetter(a);for(var g=0;g<e.length;g++){var h=e[g]+f;if(void 0!==c[h]){d=h;break}}}b[a]=d;return d};return $.getCssPropertyWithVendorPrefix(a)},capitalizeFirstLetter:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},positiveModulo:function(a,b){var c=a%b;c<0&&(c+=b);return c},pointInElement:function(a,b){a=$.getElement(a);var c=$.getElementOffset(a),d=$.getElementSize(a);return b.x>=c.x&&b.x<c.x+d.x&&b.y<c.y+d.y&&b.y>=c.y},getEvent:function(a){a?$.getEvent=function(a){return a}:$.getEvent=function(){return window.event};return $.getEvent(a)},getMousePosition:function(a){if("number"==typeof a.pageX)$.getMousePosition=function(a){var b=new $.Point;a=$.getEvent(a);b.x=a.pageX;b.y=a.pageY;return b};else{if("number"!=typeof a.clientX)throw new Error("Unknown event mouse position, no known technique.");$.getMousePosition=function(a){var b=new $.Point;a=$.getEvent(a);b.x=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;b.y=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;return b}}return $.getMousePosition(a)},getPageScroll:function(){var a=document.documentElement||{},b=document.body||{};if("number"==typeof window.pageXOffset)$.getPageScroll=function(){return new $.Point(window.pageXOffset,window.pageYOffset)};else if(b.scrollLeft||b.scrollTop)$.getPageScroll=function(){return new $.Point(document.body.scrollLeft,document.body.scrollTop)};else{if(!a.scrollLeft&&!a.scrollTop)return new $.Point(0,0);$.getPageScroll=function(){return new $.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)}}return $.getPageScroll()},setPageScroll:function(a){if("undefined"!=typeof window.scrollTo)$.setPageScroll=function(a){window.scrollTo(a.x,a.y)};else{var b=$.getPageScroll();if(b.x===a.x&&b.y===a.y)return;document.body.scrollLeft=a.x;document.body.scrollTop=a.y;var c=$.getPageScroll();if(c.x!==b.x&&c.y!==b.y){$.setPageScroll=function(a){document.body.scrollLeft=a.x;document.body.scrollTop=a.y};return}document.documentElement.scrollLeft=a.x;document.documentElement.scrollTop=a.y;c=$.getPageScroll();if(c.x!==b.x&&c.y!==b.y){$.setPageScroll=function(a){document.documentElement.scrollLeft=a.x;document.documentElement.scrollTop=a.y};return}$.setPageScroll=function(a){}}return $.setPageScroll(a)},getWindowSize:function(){var a=document.documentElement||{},b=document.body||{};if("number"==typeof window.innerWidth)$.getWindowSize=function(){return new $.Point(window.innerWidth,window.innerHeight)};else if(a.clientWidth||a.clientHeight)$.getWindowSize=function(){return new $.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else{if(!b.clientWidth&&!b.clientHeight)throw new Error("Unknown window size, no known technique.");$.getWindowSize=function(){return new $.Point(document.body.clientWidth,document.body.clientHeight)}}return $.getWindowSize()},makeCenteredNode:function(a){a=$.getElement(a);var b=[$.makeNeutralElement("div"),$.makeNeutralElement("div"),$.makeNeutralElement("div")];$.extend(b[0].style,{display:"table",height:"100%",width:"100%"});$.extend(b[1].style,{display:"table-row"});$.extend(b[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"});b[0].appendChild(b[1]);b[1].appendChild(b[2]);b[2].appendChild(a);return b[0]},makeNeutralElement:function(a){var b=document.createElement(a),c=b.style;c.background="transparent none";c.border="none";c.margin="0px";c.padding="0px";c.position="static";return b},now:function(){Date.now?$.now=Date.now:$.now=function(){return(new Date).getTime()};return $.now()},makeTransparentImage:function(a){$.makeTransparentImage=function(a){var b=$.makeNeutralElement("img");b.src=a;return b};$.Browser.vendor==$.BROWSERS.IE&&$.Browser.version<7&&($.makeTransparentImage=function(a){var b=$.makeNeutralElement("img"),c=null;c=$.makeNeutralElement("span");c.style.display="inline-block";b.onload=function(){c.style.width=c.style.width||b.width+"px";c.style.height=c.style.height||b.height+"px";b.onload=null;b=null};b.src=a;c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a+"', sizingMethod='scale')";return c});return $.makeTransparentImage(a)},setElementOpacity:function(a,b,c){var d,e;a=$.getElement(a);c&&!$.Browser.alpha&&(b=Math.round(b));if($.Browser.opacity)a.style.opacity=b<1?b:"";else if(b<1){d=Math.round(100*b);e="alpha(opacity="+d+")";a.style.filter=e}else a.style.filter=""},setElementTouchActionNone:function(a){a=$.getElement(a);"undefined"!=typeof a.style.touchAction?a.style.touchAction="none":"undefined"!=typeof a.style.msTouchAction&&(a.style.msTouchAction="none")},addClass:function(a,b){a=$.getElement(a);a.className?(" "+a.className+" ").indexOf(" "+b+" ")===-1&&(a.className+=" "+b):a.className=b},indexOf:function(a,b,c){Array.prototype.indexOf?this.indexOf=function(a,b,c){return a.indexOf(b,c)}:this.indexOf=function(a,b,c){var d,e,f=c?c:0;if(!a)throw new TypeError;e=a.length;if(0===e||f>=e)return-1;f<0&&(f=e-Math.abs(f));for(d=f;d<e;d++)if(a[d]===b)return d;return-1};return this.indexOf(a,b,c)},removeClass:function(a,b){var c,d,e=[];a=$.getElement(a);c=a.className.split(/\s+/);for(d=0;d<c.length;d++)c[d]&&c[d]!==b&&e.push(c[d]);a.className=e.join(" ")},addEvent:function(){if(window.addEventListener)return function(a,b,c,d){a=$.getElement(a);a.addEventListener(b,c,d)};if(window.attachEvent)return function(a,b,c,d){a=$.getElement(a);a.attachEvent("on"+b,c)};throw new Error("No known event model.")}(),removeEvent:function(){if(window.removeEventListener)return function(a,b,c,d){a=$.getElement(a);a.removeEventListener(b,c,d)};if(window.detachEvent)return function(a,b,c,d){a=$.getElement(a);a.detachEvent("on"+b,c)};throw new Error("No known event model.")}(),cancelEvent:function(a){a=$.getEvent(a);a.preventDefault?$.cancelEvent=function(a){a.preventDefault()}:$.cancelEvent=function(a){a=$.getEvent(a);a.cancel=!0;a.returnValue=!1};$.cancelEvent(a)},stopEvent:function(a){a=$.getEvent(a);a.stopPropagation?$.stopEvent=function(a){a.stopPropagation()}:$.stopEvent=function(a){a=$.getEvent(a);a.cancelBubble=!0};$.stopEvent(a)},createCallback:function(a,b){var c,d=[];for(c=2;c<arguments.length;c++)d.push(arguments[c]);return function(){var c,e=d.concat([]);for(c=0;c<arguments.length;c++)e.push(arguments[c]);return b.apply(a,e)}},getUrlParameter:function(a){var b=URLPARAMS[a];return b?b:null},getUrlProtocol:function(a){var b=a.match(/^([a-z]+:)\/\//i);return null===b?window.location.protocol:b[1].toLowerCase()},createAjaxRequest:function(a){var b;try{b=!!new ActiveXObject("Microsoft.XMLHTTP")}catch(a){b=!1}if(b)window.XMLHttpRequest?$.createAjaxRequest=function(a){return a?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest}:$.createAjaxRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP")};else{if(!window.XMLHttpRequest)throw new Error("Browser doesn't support XMLHttpRequest.");$.createAjaxRequest=function(){return new XMLHttpRequest}}return $.createAjaxRequest(a)},makeAjaxRequest:function(a,b,c){var d;var e;var f;if($.isPlainObject(a)){b=a.success;c=a.error;d=a.withCredentials;e=a.headers;f=a.responseType||null;a=a.url}var g=$.getUrlProtocol(a);var h=$.createAjaxRequest("file:"===g);if(!$.isFunction(b))throw new Error("makeAjaxRequest requires a success callback");h.onreadystatechange=function(){if(4==h.readyState){h.onreadystatechange=function(){};if(h.status>=200&&h.status<300||0===h.status&&"http:"!==g&&"https:"!==g)b(h);else{$.console.log("AJAX request returned %d: %s",h.status,a);$.isFunction(c)&&c(h)}}};try{h.open("GET",a,!0);f&&(h.responseType=f);if(e)for(var i in e)e.hasOwnProperty(i)&&e[i]&&h.setRequestHeader(i,e[i]);d&&(h.withCredentials=!0);h.send(null)}catch(d){var j=d.message;var k=$.Browser.vendor==$.BROWSERS.IE&&$.Browser.version<10;k&&"undefined"!=typeof d.number&&d.number==-2147024891&&(j+="\nSee http://msdn.microsoft.com/en-us/library/ms537505(v=vs.85).aspx#xdomain");$.console.log("%s while making AJAX request: %s",d.name,j);h.onreadystatechange=function(){};if(window.XDomainRequest){var l=new XDomainRequest;if(l){l.onload=function(a){$.isFunction(b)&&b({responseText:l.responseText,status:200,statusText:"OK"})};l.onerror=function(a){$.isFunction(c)&&c({responseText:l.responseText,status:444,statusText:"An error happened. Due to an XDomainRequest deficiency we can not extract any information about this error. Upgrade your browser."})};try{l.open("GET",a);l.send()}catch(a){$.isFunction(c)&&c(h,d)}}}else $.isFunction(c)&&c(h,d)}return h},jsonp:function(a){var b,c=a.url,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement,e=a.callbackName||"openseadragon"+$.now(),f=window[e],g="$1"+e+"$2",h=a.param||"callback",i=a.callback;c=c.replace(/(\=)\?(&|$)|\?\?/i,g);c+=(/\?/.test(c)?"&":"?")+h+"="+e;window[e]=function(a){if(f)window[e]=f;else try{delete window[e]}catch(a){}i&&$.isFunction(i)&&i(a)};b=document.createElement("script");void 0===a.async&&!1===a.async||(b.async="async");a.scriptCharset&&(b.charset=a.scriptCharset);b.src=c;b.onload=b.onreadystatechange=function(a,c){if(c||!b.readyState||/loaded|complete/.test(b.readyState)){b.onload=b.onreadystatechange=null;d&&b.parentNode&&d.removeChild(b);b=void 0}};d.insertBefore(b,d.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(a){if(window.DOMParser)$.parseXml=function(a){var b,c=null;b=new DOMParser;c=b.parseFromString(a,"text/xml");return c};else{if(!window.ActiveXObject)throw new Error("Browser doesn't support XML DOM.");$.parseXml=function(a){var b=null;b=new ActiveXObject("Microsoft.XMLDOM");b.async=!1;b.loadXML(a);return b}}return $.parseXml(a)},parseJSON:function(string){window.JSON&&window.JSON.parse?$.parseJSON=window.JSON.parse:$.parseJSON=function(string){return eval("("+string+")")};return $.parseJSON(string)},imageFormatSupported:function(a){a=a?a:"";return!!FILEFORMATS[a.toLowerCase()]}});$.Browser={vendor:$.BROWSERS.UNKNOWN,version:0,alpha:!0};var FILEFORMATS={bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1},URLPARAMS={};!function(){var a,b=navigator.appVersion,c=navigator.userAgent;switch(navigator.appName){case"Microsoft Internet Explorer":if(window.attachEvent&&window.ActiveXObject){$.Browser.vendor=$.BROWSERS.IE;$.Browser.version=parseFloat(c.substring(c.indexOf("MSIE")+5,c.indexOf(";",c.indexOf("MSIE"))))}break;case"Netscape":if(window.addEventListener)if(c.indexOf("Firefox")>=0){$.Browser.vendor=$.BROWSERS.FIREFOX;$.Browser.version=parseFloat(c.substring(c.indexOf("Firefox")+8))}else if(c.indexOf("Safari")>=0){$.Browser.vendor=c.indexOf("Chrome")>=0?$.BROWSERS.CHROME:$.BROWSERS.SAFARI;$.Browser.version=parseFloat(c.substring(c.substring(0,c.indexOf("Safari")).lastIndexOf("/")+1,c.indexOf("Safari")))}else{a=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})");if(null!==a.exec(c)){$.Browser.vendor=$.BROWSERS.IE;$.Browser.version=parseFloat(RegExp.$1)}}break;case"Opera":$.Browser.vendor=$.BROWSERS.OPERA;$.Browser.version=parseFloat(b)}var d,e,f,g=window.location.search.substring(1),h=g.split("&");for(f=0;f<h.length;f++){d=h[f];e=d.indexOf("=");e>0&&(URLPARAMS[d.substring(0,e)]=decodeURIComponent(d.substring(e+1)))}$.Browser.alpha=!($.Browser.vendor==$.BROWSERS.IE&&$.Browser.version<9||$.Browser.vendor==$.BROWSERS.CHROME&&$.Browser.version<2);$.Browser.opacity=!($.Browser.vendor==$.BROWSERS.IE&&$.Browser.version<9)}();var nullfunction=function(a){};$.console=window.console||{log:nullfunction,debug:nullfunction,info:nullfunction,warn:nullfunction,error:nullfunction,assert:nullfunction};!function(a){var b=a.requestAnimationFrame||a.mozRequestAnimationFrame||a.webkitRequestAnimationFrame||a.msRequestAnimationFrame;var c=a.cancelAnimationFrame||a.mozCancelAnimationFrame||a.webkitCancelAnimationFrame||a.msCancelAnimationFrame;if(b&&c){$.requestAnimationFrame=function(){return b.apply(a,arguments)};$.cancelAnimationFrame=function(){return c.apply(a,arguments)}}else{var d,e=[],f=[],g=0;$.requestAnimationFrame=function(a){e.push([++g,a]);d||(d=setInterval(function(){if(e.length){var a=$.now();var b=f;f=e;e=b;for(;f.length;)f.shift()[1](a)}else{clearInterval(d);d=void 0}},20));return g};$.cancelAnimationFrame=function(a){var b,c;for(b=0,c=e.length;b<c;b+=1)if(e[b][0]===a){e.splice(b,1);return}for(b=0,c=f.length;b<c;b+=1)if(f[b][0]===a){f.splice(b,1);return}}}}(window)}(OpenSeadragon);!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof module&&module.exports?module.exports=b():a.OpenSeadragon=b()}(this,function(){return OpenSeadragon});!function(a){var b={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};if(document.exitFullscreen){b.supportsFullScreen=!0;b.getFullScreenElement=function(){return document.fullscreenElement};b.requestFullScreen=function(a){return a.requestFullscreen()};b.exitFullScreen=function(){document.exitFullscreen()};b.fullScreenEventName="fullscreenchange";b.fullScreenErrorEventName="fullscreenerror"}else if(document.msExitFullscreen){b.supportsFullScreen=!0;b.getFullScreenElement=function(){return document.msFullscreenElement};b.requestFullScreen=function(a){return a.msRequestFullscreen()};b.exitFullScreen=function(){document.msExitFullscreen()};b.fullScreenEventName="MSFullscreenChange";b.fullScreenErrorEventName="MSFullscreenError"}else if(document.webkitExitFullscreen){b.supportsFullScreen=!0;b.getFullScreenElement=function(){return document.webkitFullscreenElement};b.requestFullScreen=function(a){return a.webkitRequestFullscreen()};b.exitFullScreen=function(){document.webkitExitFullscreen()};b.fullScreenEventName="webkitfullscreenchange";b.fullScreenErrorEventName="webkitfullscreenerror"}else if(document.webkitCancelFullScreen){b.supportsFullScreen=!0;b.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement};b.requestFullScreen=function(a){return a.webkitRequestFullScreen()};b.exitFullScreen=function(){document.webkitCancelFullScreen()};b.fullScreenEventName="webkitfullscreenchange";b.fullScreenErrorEventName="webkitfullscreenerror"}else if(document.mozCancelFullScreen){b.supportsFullScreen=!0;b.getFullScreenElement=function(){return document.mozFullScreenElement};b.requestFullScreen=function(a){return a.mozRequestFullScreen()};b.exitFullScreen=function(){document.mozCancelFullScreen()};b.fullScreenEventName="mozfullscreenchange";b.fullScreenErrorEventName="mozfullscreenerror"}b.isFullScreen=function(){return null!==b.getFullScreenElement()};b.cancelFullScreen=function(){a.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead.");b.exitFullScreen()};a.extend(a,b)}(OpenSeadragon);!function(a){a.EventSource=function(){this.events={}};a.EventSource.prototype={addOnceHandler:function(a,b,c,d){var e=this;d=d||1;var f=0;var g=function(c){f++;f===d&&e.removeHandler(a,g);b(c)};this.addHandler(a,g,c)},addHandler:function(b,c,d){var e=this.events[b];e||(this.events[b]=e=[]);c&&a.isFunction(c)&&(e[e.length]={handler:c,userData:d||null})},removeHandler:function(b,c){var d,e=this.events[b],f=[];if(e&&a.isArray(e)){for(d=0;d<e.length;d++)e[d].handler!==c&&f.push(e[d]);this.events[b]=f}},removeAllHandlers:function(a){if(a)this.events[a]=[];else for(var b in this.events)this.events[b]=[]},getHandler:function(a){var b=this.events[a];if(!b||!b.length)return null;b=1===b.length?[b[0]]:Array.apply(null,b);return function(a,c){var d,e=b.length;for(d=0;d<e;d++)if(b[d]){c.eventSource=a;c.userData=b[d].userData;b[d].handler(c)}}},raiseEvent:function(a,b){var c=this.getHandler(a);if(c){b||(b={});c(this,b)}}}}(OpenSeadragon);!function(a){function b(b){var c,d=pa[b.hash],e=d.activePointersLists.length;for(c=0;c<e;c++)if(d.activePointersLists[c].captureCount>0){a.removeEvent(a.MouseTracker.captureElement,"mousemove",d.mousemovecaptured,!0);a.removeEvent(a.MouseTracker.captureElement,"mouseup",d.mouseupcaptured,!0);a.removeEvent(a.MouseTracker.captureElement,a.MouseTracker.unprefixedPointerEvents?"pointermove":"MSPointerMove",d.pointermovecaptured,!0);a.removeEvent(a.MouseTracker.captureElement,a.MouseTracker.unprefixedPointerEvents?"pointerup":"MSPointerUp",d.pointerupcaptured,!0);a.removeEvent(a.MouseTracker.captureElement,"touchmove",d.touchmovecaptured,!0);a.removeEvent(a.MouseTracker.captureElement,"touchend",d.touchendcaptured,!0);d.activePointersLists[c].captureCount=0}for(c=0;c<e;c++)d.activePointersLists.pop()}function c(c){var d,e,f=pa[c.hash];if(!f.tracking){for(e=0;e<a.MouseTracker.subscribeEvents.length;e++){d=a.MouseTracker.subscribeEvents[e];a.addEvent(c.element,d,f[d],!1)}b(c);f.tracking=!0}}function d(c){var d,e,f=pa[c.hash];if(f.tracking){for(e=0;e<a.MouseTracker.subscribeEvents.length;e++){d=a.MouseTracker.subscribeEvents[e];a.removeEvent(c.element,d,f[d],!1)}b(c);f.tracking=!1}}function e(b,c){var d=pa[b.hash];if("pointerevent"===c)return{upName:a.MouseTracker.unprefixedPointerEvents?"pointerup":"MSPointerUp",upHandler:d.pointerupcaptured,moveName:a.MouseTracker.unprefixedPointerEvents?"pointermove":"MSPointerMove",moveHandler:d.pointermovecaptured};if("mouse"===c)return{upName:"mouseup",upHandler:d.mouseupcaptured,moveName:"mousemove",moveHandler:d.mousemovecaptured};if("touch"===c)return{upName:"touchend",upHandler:d.touchendcaptured,moveName:"touchmove",moveHandler:d.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function f(b,c,d){var f,g=b.getActivePointersListByType(c);g.captureCount+=d||1;if(1===g.captureCount)if(a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9)b.element.setCapture(!0);else{f=e(b,a.MouseTracker.havePointerEvents?"pointerevent":c);qa&&na(window.top)&&a.addEvent(window.top,f.upName,f.upHandler,!0);a.addEvent(a.MouseTracker.captureElement,f.upName,f.upHandler,!0);a.addEvent(a.MouseTracker.captureElement,f.moveName,f.moveHandler,!0)}}function g(b,c,d){var f,g=b.getActivePointersListByType(c);g.captureCount-=d||1;if(0===g.captureCount)if(a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9)b.element.releaseCapture();else{f=e(b,a.MouseTracker.havePointerEvents?"pointerevent":c);qa&&na(window.top)&&a.removeEvent(window.top,f.upName,f.upHandler,!0);a.removeEvent(a.MouseTracker.captureElement,f.moveName,f.moveHandler,!0);a.removeEvent(a.MouseTracker.captureElement,f.upName,f.upHandler,!0)}}function h(b){var c;if(a.MouseTracker.unprefixedPointerEvents)c=b.pointerType;else switch(b.pointerType){case 2:c="touch";break;case 3:c="pen";break;case 4:c="mouse";break;default:c=""}return c}function i(b){return a.getMousePosition(b)}function j(a,b){return k(i(a),b)}function k(b,c){var d=a.getElementOffset(c);return b.minus(d)}function l(b,c){return new a.Point((b.x+c.x)/2,(b.y+c.y)/2)}function m(b,c){b.clickHandler&&a.cancelEvent(c)}function n(b,c){b.dblClickHandler&&a.cancelEvent(c)}function o(b,c){var d;if(b.keyDownHandler){c=a.getEvent(c);d=b.keyDownHandler({eventSource:b,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefaultAction:!1,userData:b.userData});d||a.cancelEvent(c)}}function p(b,c){var d;if(b.keyUpHandler){c=a.getEvent(c);d=b.keyUpHandler({eventSource:b,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefaultAction:!1,userData:b.userData});d||a.cancelEvent(c)}}function q(b,c){var d;if(b.keyHandler){c=a.getEvent(c);d=b.keyHandler({eventSource:b,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefaultAction:!1,userData:b.userData});d||a.cancelEvent(c)}}function r(b,c){var d;if(b.focusHandler){c=a.getEvent(c);d=b.focusHandler({eventSource:b,originalEvent:c,preventDefaultAction:!1,userData:b.userData});d===!1&&a.cancelEvent(c)}}function s(b,c){var d;if(b.blurHandler){c=a.getEvent(c);d=b.blurHandler({eventSource:b,originalEvent:c,preventDefaultAction:!1,userData:b.userData});d===!1&&a.cancelEvent(c)}}function t(a,b){v(a,b,b)}function u(b,c){c=a.getEvent(c);var d={target:c.target||c.srcElement,type:"wheel",shiftKey:c.shiftKey||!1,clientX:c.clientX,clientY:c.clientY,pageX:c.pageX?c.pageX:c.clientX,pageY:c.pageY?c.pageY:c.clientY,deltaMode:"MozMousePixelScroll"==c.type?0:1,deltaX:0,deltaZ:0};"mousewheel"==a.MouseTracker.wheelEventName?d.deltaY=-c.wheelDelta/a.DEFAULT_SETTINGS.pixelsPerWheelLine:d.deltaY=c.detail;v(b,d,c)}function v(b,c,d){var e,f=0;f=c.deltaY<0?1:-1;if(b.scrollHandler){e=b.scrollHandler({eventSource:b,pointerType:"mouse",position:j(c,b.element),scroll:f,shift:c.shiftKey,isTouchEvent:!1,originalEvent:d,preventDefaultAction:!1,userData:b.userData});e===!1&&a.cancelEvent(d)}}function w(a,b){if(a===b)return!1;for(;b&&b!==a;)b=b.parentNode;return b===a}function x(b,c){c=a.getEvent(c);z(b,c)}function y(b,c){c=a.getEvent(c);c.currentTarget===c.relatedTarget||w(c.currentTarget,c.relatedTarget)||z(b,c)}function z(b,c){var d={id:a.MouseTracker.mousePointerId,type:"mouse",isPrimary:!0,currentPos:i(c),currentTime:a.now()};ga(b,c,[d])}function A(b,c){c=a.getEvent(c);C(b,c)}function B(b,c){c=a.getEvent(c);c.currentTarget===c.relatedTarget||w(c.currentTarget,c.relatedTarget)||C(b,c)}function C(b,c){var d={id:a.MouseTracker.mousePointerId,type:"mouse",isPrimary:!0,currentPos:i(c),currentTime:a.now()};ha(b,c,[d])}function D(b){return a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9?1===b?0:2===b?2:4===b?1:-1:b}function E(b,c){var d;c=a.getEvent(c);d={id:a.MouseTracker.mousePointerId,type:"mouse",isPrimary:!0,currentPos:i(c),currentTime:a.now()};if(ia(b,c,[d],D(c.button))){a.stopEvent(c);f(b,"mouse")}(b.clickHandler||b.dblClickHandler||b.pressHandler||b.dragHandler||b.dragEndHandler)&&a.cancelEvent(c)}function F(a,b){H(a,b)}function G(b,c){H(b,c);a.stopEvent(c)}function H(b,c){var d;c=a.getEvent(c);d={id:a.MouseTracker.mousePointerId,type:"mouse",isPrimary:!0,currentPos:i(c),currentTime:a.now()};ja(b,c,[d],D(c.button))&&g(b,"mouse")}function I(a,b){K(a,b)}function J(b,c){K(b,c);a.stopEvent(c)}function K(b,c){var d;c=a.getEvent(c);d={id:a.MouseTracker.mousePointerId,type:"mouse",isPrimary:!0,currentPos:i(c),currentTime:a.now()};ka(b,c,[d])}function L(a,b,c){var d,e=c.getLength(),f=[];if("touch"===c.type||c.contacts>0){for(d=0;d<e;d++)f.push(c.getByIndex(d));if(f.length>0){ja(a,b,f,0);c.captureCount=1;g(a,c.type);ha(a,b,f)}}}function M(b,c){var d,e,g,h,j=c.changedTouches.length,k=[],l=b.getActivePointersListByType("touch");d=a.now();if(l.getLength()>c.touches.length-j){a.console.warn("Tracked touch contact count doesn't match event.touches.length. Removing all tracked touch pointers.");L(b,c,l)}for(e=0;e<j;e++)k.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:i(c.changedTouches[e]),currentTime:d});ga(b,c,k);for(e=0;e<oa.length;e++)if(oa[e]!==b&&oa[e].isTracking()&&w(oa[e].element,b.element)){h=[];for(g=0;g<j;g++)h.push({id:c.changedTouches[g].identifier,type:"touch",currentPos:i(c.changedTouches[g]),currentTime:d});ga(oa[e],c,h)}if(ia(b,c,k,0)){a.stopEvent(c);f(b,"touch",j)}a.cancelEvent(c)}function N(a,b){P(a,b)}function O(b,c){P(b,c);a.stopEvent(c)}function P(b,c){var d,e,f,h,j=c.changedTouches.length,k=[];d=a.now();for(e=0;e<j;e++)k.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:i(c.changedTouches[e]),currentTime:d});ja(b,c,k,0)&&g(b,"touch",j);ha(b,c,k);for(e=0;e<oa.length;e++)if(oa[e]!==b&&oa[e].isTracking()&&w(oa[e].element,b.element)){h=[];for(f=0;f<j;f++)h.push({id:c.changedTouches[f].identifier,type:"touch",currentPos:i(c.changedTouches[f]),currentTime:d});ha(oa[e],c,h)}a.cancelEvent(c)}function Q(a,b){S(a,b)}function R(b,c){S(b,c);a.stopEvent(c)}function S(b,c){var d,e=c.changedTouches.length,f=[];for(d=0;d<e;d++)f.push({id:c.changedTouches[d].identifier,type:"touch",currentPos:i(c.changedTouches[d]),currentTime:a.now()});ka(b,c,f);a.cancelEvent(c)}function T(a,b){var c=a.getActivePointersListByType("touch");L(a,b,c)}function U(a,b){b.stopPropagation();b.preventDefault();return!1}function V(a,b){b.stopPropagation();b.preventDefault();return!1}function W(b,c){var d;if(c.currentTarget!==c.relatedTarget&&!w(c.currentTarget,c.relatedTarget)){d={id:c.pointerId,type:h(c),isPrimary:c.isPrimary,currentPos:i(c),currentTime:a.now()};ga(b,c,[d]);
}}function X(b,c){var d;if(c.currentTarget!==c.relatedTarget&&!w(c.currentTarget,c.relatedTarget)){d={id:c.pointerId,type:h(c),isPrimary:c.isPrimary,currentPos:i(c),currentTime:a.now()};ha(b,c,[d])}}function Y(b,c){var d;d={id:c.pointerId,type:h(c),isPrimary:c.isPrimary,currentPos:i(c),currentTime:a.now()};if(ia(b,c,[d],c.button)){a.stopEvent(c);f(b,d.type)}(b.clickHandler||b.dblClickHandler||b.pressHandler||b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.cancelEvent(c)}function Z(a,b){_(a,b)}function $(b,c){var d=b.getActivePointersListByType(h(c));d.getById(c.pointerId)&&_(b,c);a.stopEvent(c)}function _(b,c){var d;d={id:c.pointerId,type:h(c),isPrimary:c.isPrimary,currentPos:i(c),currentTime:a.now()};ja(b,c,[d],c.button)&&g(b,d.type)}function aa(a,b){ca(a,b)}function ba(b,c){var d=b.getActivePointersListByType(h(c));d.getById(c.pointerId)&&ca(b,c);a.stopEvent(c)}function ca(b,c){var d;d={id:c.pointerId,type:h(c),isPrimary:c.isPrimary,currentPos:i(c),currentTime:a.now()};ka(b,c,[d])}function da(a,b){var c;c={id:b.pointerId,type:h(b)};la(a,b,[c])}function ea(a,b){b.hasOwnProperty("isPrimary")||(0===a.getLength()?b.isPrimary=!0:b.isPrimary=!1);b.speed=0;b.direction=0;b.contactPos=b.currentPos;b.contactTime=b.currentTime;b.lastPos=b.currentPos;b.lastTime=b.currentTime;return a.add(b)}function fa(a,b){var c,d;if(a.getById(b.id)){c=a.removeById(b.id);if(!b.hasOwnProperty("isPrimary")){d=a.getPrimary();if(!d){d=a.getByIndex(0);d&&(d.isPrimary=!0)}}}else c=a.getLength();return c}function ga(b,c,d){var e,f,g,h,i=b.getActivePointersListByType(d[0].type),j=d.length;for(e=0;e<j;e++){f=d[e];g=i.getById(f.id);if(g){g.insideElement=!0;g.lastPos=g.currentPos;g.lastTime=g.currentTime;g.currentPos=f.currentPos;g.currentTime=f.currentTime;f=g}else{f.captured=!1;f.insideElementPressed=!1;f.insideElement=!0;ea(i,f)}if(b.enterHandler){h=b.enterHandler({eventSource:b,pointerType:f.type,position:k(f.currentPos,b.element),buttons:i.buttons,pointers:b.getActivePointerCount(),insideElementPressed:f.insideElementPressed,buttonDownAny:0!==i.buttons,isTouchEvent:"touch"===f.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});h===!1&&a.cancelEvent(c)}}}function ha(b,c,d){var e,f,g,h,i=b.getActivePointersListByType(d[0].type),j=d.length;for(e=0;e<j;e++){f=d[e];g=i.getById(f.id);if(g){if(g.captured){g.insideElement=!1;g.lastPos=g.currentPos;g.lastTime=g.currentTime;g.currentPos=f.currentPos;g.currentTime=f.currentTime}else fa(i,g);f=g}if(b.exitHandler){h=b.exitHandler({eventSource:b,pointerType:f.type,position:k(f.currentPos,b.element),buttons:i.buttons,pointers:b.getActivePointerCount(),insideElementPressed:!!g&&g.insideElementPressed,buttonDownAny:0!==i.buttons,isTouchEvent:"touch"===f.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});h===!1&&a.cancelEvent(c)}}}function ia(b,c,d,e){var f,g,h,i,j=pa[b.hash],m=b.getActivePointersListByType(d[0].type),n=d.length;"undefined"!=typeof c.buttons?m.buttons=c.buttons:a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9?0===e?m.buttons+=1:1===e?m.buttons+=4:2===e?m.buttons+=2:3===e?m.buttons+=8:4===e?m.buttons+=16:5===e&&(m.buttons+=32):0===e?m.buttons|=1:1===e?m.buttons|=4:2===e?m.buttons|=2:3===e?m.buttons|=8:4===e?m.buttons|=16:5===e&&(m.buttons|=32);var o=b.getActivePointersListsExceptType(d[0].type);for(g=0;g<o.length;g++)L(b,c,o[g]);if(0!==e){if(b.nonPrimaryPressHandler){f=b.nonPrimaryPressHandler({eventSource:b,pointerType:d[0].type,position:k(d[0].currentPos,b.element),button:e,buttons:m.buttons,isTouchEvent:"touch"===d[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}return!1}for(g=0;g<n;g++){h=d[g];i=m.getById(h.id);if(i){i.captured=!0;i.insideElementPressed=!0;i.insideElement=!0;i.contactPos=h.currentPos;i.contactTime=h.currentTime;i.lastPos=i.currentPos;i.lastTime=i.currentTime;i.currentPos=h.currentPos;i.currentTime=h.currentTime;h=i}else{h.captured=!0;h.insideElementPressed=!0;h.insideElement=!0;ea(m,h)}m.addContact();(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.addPoint(b,h);if(1===m.contacts){if(b.pressHandler){f=b.pressHandler({eventSource:b,pointerType:h.type,position:k(h.contactPos,b.element),buttons:m.buttons,isTouchEvent:"touch"===h.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}}else if(2===m.contacts&&b.pinchHandler&&"touch"===h.type){j.pinchGPoints=m.asArray();j.lastPinchDist=j.currentPinchDist=j.pinchGPoints[0].currentPos.distanceTo(j.pinchGPoints[1].currentPos);j.lastPinchCenter=j.currentPinchCenter=l(j.pinchGPoints[0].currentPos,j.pinchGPoints[1].currentPos)}}return!0}function ja(b,c,d,e){var f,g,h,i,j,m,n,o=pa[b.hash],p=b.getActivePointersListByType(d[0].type),q=d.length,r=!1,s=!1;"undefined"!=typeof c.buttons?p.buttons=c.buttons:a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9?0===e?p.buttons-=1:1===e?p.buttons-=4:2===e?p.buttons-=2:3===e?p.buttons-=8:4===e?p.buttons-=16:5===e&&(p.buttons-=32):0===e?p.buttons^=-2:1===e?p.buttons^=-5:2===e?p.buttons^=-3:3===e?p.buttons^=-9:4===e?p.buttons^=-17:5===e&&(p.buttons^=-33);if(0!==e){if(b.nonPrimaryReleaseHandler){f=b.nonPrimaryReleaseHandler({eventSource:b,pointerType:d[0].type,position:k(d[0].currentPos,b.element),button:e,buttons:p.buttons,isTouchEvent:"touch"===d[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}var t=b.getActivePointersListByType("mouse");L(b,c,t);return!1}for(i=0;i<q;i++){j=d[i];m=p.getById(j.id);if(m){if(m.captured){m.captured=!1;r=!0;s=!0}m.lastPos=m.currentPos;m.lastTime=m.currentTime;m.currentPos=j.currentPos;m.currentTime=j.currentTime;m.insideElement||fa(p,m);g=m.currentPos;h=m.currentTime;if(s){p.removeContact();(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.removePoint(b,m);if(0===p.contacts){if(b.releaseHandler){f=b.releaseHandler({eventSource:b,pointerType:m.type,position:k(g,b.element),buttons:p.buttons,insideElementPressed:m.insideElementPressed,insideElementReleased:m.insideElement,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}if(b.dragEndHandler&&!m.currentPos.equals(m.contactPos)){f=b.dragEndHandler({eventSource:b,pointerType:m.type,position:k(m.currentPos,b.element),speed:m.speed,direction:m.direction,shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}if((b.clickHandler||b.dblClickHandler)&&m.insideElement){n=h-m.contactTime<=b.clickTimeThreshold&&m.contactPos.distanceTo(g)<=b.clickDistThreshold;if(b.clickHandler){f=b.clickHandler({eventSource:b,pointerType:m.type,position:k(m.currentPos,b.element),quick:n,shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}if(b.dblClickHandler&&n){p.clicks++;if(1===p.clicks){o.lastClickPos=g;o.dblClickTimeOut=setTimeout(function(){p.clicks=0},b.dblClickTimeThreshold)}else if(2===p.clicks){clearTimeout(o.dblClickTimeOut);p.clicks=0;if(o.lastClickPos.distanceTo(g)<=b.dblClickDistThreshold){f=b.dblClickHandler({eventSource:b,pointerType:m.type,position:k(m.currentPos,b.element),shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}o.lastClickPos=null}}}}else if(2===p.contacts&&b.pinchHandler&&"touch"===m.type){o.pinchGPoints=p.asArray();o.lastPinchDist=o.currentPinchDist=o.pinchGPoints[0].currentPos.distanceTo(o.pinchGPoints[1].currentPos);o.lastPinchCenter=o.currentPinchCenter=l(o.pinchGPoints[0].currentPos,o.pinchGPoints[1].currentPos)}}else if(b.releaseHandler){f=b.releaseHandler({eventSource:b,pointerType:m.type,position:k(g,b.element),buttons:p.buttons,insideElementPressed:m.insideElementPressed,insideElementReleased:m.insideElement,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});f===!1&&a.cancelEvent(c)}}}return r}function ka(b,c,d){var e,f,g,h,i,j,m=pa[b.hash],n=b.getActivePointersListByType(d[0].type),o=d.length;"undefined"!=typeof c.buttons&&(n.buttons=c.buttons);for(e=0;e<o;e++){f=d[e];g=n.getById(f.id);if(g){f.hasOwnProperty("isPrimary")&&(g.isPrimary=f.isPrimary);g.lastPos=g.currentPos;g.lastTime=g.currentTime;g.currentPos=f.currentPos;g.currentTime=f.currentTime}else{f.captured=!1;f.insideElementPressed=!1;f.insideElement=!0;ea(n,f)}}if(b.stopHandler&&"mouse"===d[0].type){clearTimeout(b.stopTimeOut);b.stopTimeOut=setTimeout(function(){ma(b,c,d[0].type)},b.stopDelay)}if(0===n.contacts){if(b.moveHandler){j=b.moveHandler({eventSource:b,pointerType:d[0].type,position:k(d[0].currentPos,b.element),buttons:n.buttons,isTouchEvent:"touch"===d[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});j===!1&&a.cancelEvent(c)}}else if(1===n.contacts){if(b.moveHandler){g=n.asArray()[0];j=b.moveHandler({eventSource:b,pointerType:g.type,position:k(g.currentPos,b.element),buttons:n.buttons,isTouchEvent:"touch"===g.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});j===!1&&a.cancelEvent(c)}if(b.dragHandler){g=n.asArray()[0];i=g.currentPos.minus(g.lastPos);j=b.dragHandler({eventSource:b,pointerType:g.type,position:k(g.currentPos,b.element),buttons:n.buttons,delta:i,speed:g.speed,direction:g.direction,shift:c.shiftKey,isTouchEvent:"touch"===g.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});j===!1&&a.cancelEvent(c)}}else if(2===n.contacts){if(b.moveHandler){h=n.asArray();j=b.moveHandler({eventSource:b,pointerType:h[0].type,position:k(l(h[0].currentPos,h[1].currentPos),b.element),buttons:n.buttons,isTouchEvent:"touch"===h[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData});j===!1&&a.cancelEvent(c)}if(b.pinchHandler&&"touch"===d[0].type){i=m.pinchGPoints[0].currentPos.distanceTo(m.pinchGPoints[1].currentPos);if(i!=m.currentPinchDist){m.lastPinchDist=m.currentPinchDist;m.currentPinchDist=i;m.lastPinchCenter=m.currentPinchCenter;m.currentPinchCenter=l(m.pinchGPoints[0].currentPos,m.pinchGPoints[1].currentPos);j=b.pinchHandler({eventSource:b,pointerType:"touch",gesturePoints:m.pinchGPoints,lastCenter:k(m.lastPinchCenter,b.element),center:k(m.currentPinchCenter,b.element),lastDistance:m.lastPinchDist,distance:m.currentPinchDist,shift:c.shiftKey,originalEvent:c,preventDefaultAction:!1,userData:b.userData});j===!1&&a.cancelEvent(c)}}}}function la(a,b,c){ja(a,b,c,0);ha(a,b,c)}function ma(a,b,c){a.stopHandler&&a.stopHandler({eventSource:a,pointerType:c,position:j(b,a.element),buttons:a.getActivePointersListByType(c).buttons,isTouchEvent:"touch"===c,originalEvent:b,preventDefaultAction:!1,userData:a.userData})}function na(a){try{return a.addEventListener&&a.removeEventListener}catch(a){return!1}}var oa=[];var pa={};a.MouseTracker=function(b){oa.push(this);var c=arguments;a.isPlainObject(b)||(b={element:c[0],clickTimeThreshold:c[1],clickDistThreshold:c[2]});this.hash=Math.random();this.element=a.getElement(b.element);this.clickTimeThreshold=b.clickTimeThreshold||a.DEFAULT_SETTINGS.clickTimeThreshold;this.clickDistThreshold=b.clickDistThreshold||a.DEFAULT_SETTINGS.clickDistThreshold;this.dblClickTimeThreshold=b.dblClickTimeThreshold||a.DEFAULT_SETTINGS.dblClickTimeThreshold;this.dblClickDistThreshold=b.dblClickDistThreshold||a.DEFAULT_SETTINGS.dblClickDistThreshold;this.userData=b.userData||null;this.stopDelay=b.stopDelay||50;this.enterHandler=b.enterHandler||null;this.exitHandler=b.exitHandler||null;this.pressHandler=b.pressHandler||null;this.nonPrimaryPressHandler=b.nonPrimaryPressHandler||null;this.releaseHandler=b.releaseHandler||null;this.nonPrimaryReleaseHandler=b.nonPrimaryReleaseHandler||null;this.moveHandler=b.moveHandler||null;this.scrollHandler=b.scrollHandler||null;this.clickHandler=b.clickHandler||null;this.dblClickHandler=b.dblClickHandler||null;this.dragHandler=b.dragHandler||null;this.dragEndHandler=b.dragEndHandler||null;this.pinchHandler=b.pinchHandler||null;this.stopHandler=b.stopHandler||null;this.keyDownHandler=b.keyDownHandler||null;this.keyUpHandler=b.keyUpHandler||null;this.keyHandler=b.keyHandler||null;this.focusHandler=b.focusHandler||null;this.blurHandler=b.blurHandler||null;var d=this;pa[this.hash]={click:function(a){m(d,a)},dblclick:function(a){n(d,a)},keydown:function(a){o(d,a)},keyup:function(a){p(d,a)},keypress:function(a){q(d,a)},focus:function(a){r(d,a)},blur:function(a){s(d,a)},wheel:function(a){t(d,a)},mousewheel:function(a){u(d,a)},DOMMouseScroll:function(a){u(d,a)},MozMousePixelScroll:function(a){u(d,a)},mouseenter:function(a){x(d,a)},mouseleave:function(a){A(d,a)},mouseover:function(a){y(d,a)},mouseout:function(a){B(d,a)},mousedown:function(a){E(d,a)},mouseup:function(a){F(d,a)},mouseupcaptured:function(a){G(d,a)},mousemove:function(a){I(d,a)},mousemovecaptured:function(a){J(d,a)},touchstart:function(a){M(d,a)},touchend:function(a){N(d,a)},touchendcaptured:function(a){O(d,a)},touchmove:function(a){Q(d,a)},touchmovecaptured:function(a){R(d,a)},touchcancel:function(a){T(d,a)},gesturestart:function(a){U(d,a)},gesturechange:function(a){V(d,a)},pointerover:function(a){W(d,a)},MSPointerOver:function(a){W(d,a)},pointerout:function(a){X(d,a)},MSPointerOut:function(a){X(d,a)},pointerdown:function(a){Y(d,a)},MSPointerDown:function(a){Y(d,a)},pointerup:function(a){Z(d,a)},MSPointerUp:function(a){Z(d,a)},pointermove:function(a){aa(d,a)},MSPointerMove:function(a){aa(d,a)},pointercancel:function(a){da(d,a)},MSPointerCancel:function(a){da(d,a)},pointerupcaptured:function(a){$(d,a)},pointermovecaptured:function(a){ba(d,a)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null};b.startDisabled||this.setTracking(!0)};a.MouseTracker.prototype={destroy:function(){var a;d(this);this.element=null;for(a=0;a<oa.length;a++)if(oa[a]===this){oa.splice(a,1);break}pa[this.hash]=null;delete pa[this.hash]},isTracking:function(){return pa[this.hash].tracking},setTracking:function(a){a?c(this):d(this);return this},getActivePointersListsExceptType:function(a){var b=pa[this.hash];var c=[];for(var d=0;d<b.activePointersLists.length;++d)b.activePointersLists[d].type!==a&&c.push(b.activePointersLists[d]);return c},getActivePointersListByType:function(b){var c,d,e=pa[this.hash],f=e.activePointersLists.length;for(c=0;c<f;c++)if(e.activePointersLists[c].type===b)return e.activePointersLists[c];d=new a.MouseTracker.GesturePointList(b);e.activePointersLists.push(d);return d},getActivePointerCount:function(){var a,b=pa[this.hash],c=b.activePointersLists.length,d=0;for(a=0;a<c;a++)d+=b.activePointersLists[a].getLength();return d},enterHandler:function(){},exitHandler:function(){},pressHandler:function(){},nonPrimaryPressHandler:function(){},releaseHandler:function(){},nonPrimaryReleaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyDownHandler:function(){},keyUpHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}};a.MouseTracker.resetAllMouseTrackers=function(){for(var a=0;a<oa.length;a++)if(oa[a].isTracking()){oa[a].setTracking(!1);oa[a].setTracking(!0)}};a.MouseTracker.gesturePointVelocityTracker=function(){var b=[],c=0,d=0;var e=function(a,b){return a.hash.toString()+b.type+b.id.toString()};var f=function(){var c,e,f,g,h,i,j=b.length,k=a.now();g=k-d;d=k;for(c=0;c<j;c++){e=b[c];f=e.gPoint;f.direction=Math.atan2(f.currentPos.y-e.lastPos.y,f.currentPos.x-e.lastPos.x);h=e.lastPos.distanceTo(f.currentPos);e.lastPos=f.currentPos;i=1e3*h/(g+1);f.speed=.75*i+.25*f.speed}};var g=function(g,h){var i=e(g,h);b.push({guid:i,gPoint:h,lastPos:h.currentPos});if(1===b.length){d=a.now();c=window.setInterval(f,50)}};var h=function(a,d){var f,g=e(a,d),h=b.length;for(f=0;f<h;f++)if(b[f].guid===g){b.splice(f,1);h--;0===h&&window.clearInterval(c);break}};return{addPoint:g,removePoint:h}}();a.MouseTracker.captureElement=document;a.MouseTracker.wheelEventName=a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version>8||"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";a.MouseTracker.supportsMouseCapture=function(){var b=document.createElement("div");return a.isFunction(b.setCapture)&&a.isFunction(b.releaseCapture)}();a.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur",a.MouseTracker.wheelEventName];"DOMMouseScroll"==a.MouseTracker.wheelEventName&&a.MouseTracker.subscribeEvents.push("MozMousePixelScroll");if(window.PointerEvent&&(window.navigator.pointerEnabled||a.Browser.vendor!==a.BROWSERS.IE)){a.MouseTracker.havePointerEvents=!0;a.MouseTracker.subscribeEvents.push("pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel");a.MouseTracker.unprefixedPointerEvents=!0;navigator.maxTouchPoints?a.MouseTracker.maxTouchPoints=navigator.maxTouchPoints:a.MouseTracker.maxTouchPoints=0;a.MouseTracker.haveMouseEnter=!1}else if(window.MSPointerEvent&&window.navigator.msPointerEnabled){a.MouseTracker.havePointerEvents=!0;a.MouseTracker.subscribeEvents.push("MSPointerOver","MSPointerOut","MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel");a.MouseTracker.unprefixedPointerEvents=!1;navigator.msMaxTouchPoints?a.MouseTracker.maxTouchPoints=navigator.msMaxTouchPoints:a.MouseTracker.maxTouchPoints=0;a.MouseTracker.haveMouseEnter=!1}else{a.MouseTracker.havePointerEvents=!1;if(a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9){a.MouseTracker.subscribeEvents.push("mouseenter","mouseleave");a.MouseTracker.haveMouseEnter=!0}else{a.MouseTracker.subscribeEvents.push("mouseover","mouseout");a.MouseTracker.haveMouseEnter=!1}a.MouseTracker.subscribeEvents.push("mousedown","mouseup","mousemove");"ontouchstart"in window&&a.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel");"ongesturestart"in window&&a.MouseTracker.subscribeEvents.push("gesturestart","gesturechange");a.MouseTracker.mousePointerId="legacy-mouse";a.MouseTracker.maxTouchPoints=10}a.MouseTracker.GesturePointList=function(a){this._gPoints=[];this.type=a;this.buttons=0;this.contacts=0;this.clicks=0;this.captureCount=0};a.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(a){return this._gPoints.push(a)},removeById:function(a){var b,c=this._gPoints.length;for(b=0;b<c;b++)if(this._gPoints[b].id===a){this._gPoints.splice(b,1);break}return this._gPoints.length},getByIndex:function(a){return a<this._gPoints.length?this._gPoints[a]:null},getById:function(a){var b,c=this._gPoints.length;for(b=0;b<c;b++)if(this._gPoints[b].id===a)return this._gPoints[b];return null},getPrimary:function(a){var b,c=this._gPoints.length;for(b=0;b<c;b++)if(this._gPoints[b].isPrimary)return this._gPoints[b];return null},addContact:function(){++this.contacts;this.contacts>1&&("mouse"===this.type||"pen"===this.type)&&(this.contacts=1)},removeContact:function(){--this.contacts;this.contacts<0&&(this.contacts=0)}};var qa=function(){try{return window.self!==window.top}catch(a){return!0}}()}(OpenSeadragon);!function(a){a.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5};a.Control=function(b,c,d){var e=b.parentNode;if("number"==typeof c){a.console.error("Passing an anchor directly into the OpenSeadragon.Control constructor is deprecated; please use an options object instead. Support for this deprecated variant is scheduled for removal in December 2013");c={anchor:c}}c.attachToViewer="undefined"==typeof c.attachToViewer||c.attachToViewer;this.autoFade="undefined"==typeof c.autoFade||c.autoFade;this.element=b;this.anchor=c.anchor;this.container=d;if(this.anchor==a.ControlAnchor.ABSOLUTE){this.wrapper=a.makeNeutralElement("div");this.wrapper.style.position="absolute";this.wrapper.style.top="number"==typeof c.top?c.top+"px":c.top;this.wrapper.style.left="number"==typeof c.left?c.left+"px":c.left;this.wrapper.style.height="number"==typeof c.height?c.height+"px":c.height;this.wrapper.style.width="number"==typeof c.width?c.width+"px":c.width;this.wrapper.style.margin="0px";this.wrapper.style.padding="0px";this.element.style.position="relative";this.element.style.top="0px";this.element.style.left="0px";this.element.style.height="100%";this.element.style.width="100%"}else{this.wrapper=a.makeNeutralElement("div");this.wrapper.style.display="inline-block";this.anchor==a.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")}this.wrapper.appendChild(this.element);c.attachToViewer?this.anchor==a.ControlAnchor.TOP_RIGHT||this.anchor==a.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):e.appendChild(this.wrapper)};a.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element);this.container.removeChild(this.wrapper)},isVisible:function(){return"none"!=this.wrapper.style.display},setVisible:function(b){this.wrapper.style.display=b?this.anchor==a.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(b){this.element[a.SIGNAL]&&a.Browser.vendor==a.BROWSERS.IE?a.setElementOpacity(this.element,b,!0):a.setElementOpacity(this.wrapper,b,!0)}}}(OpenSeadragon);!function(a){function b(a,b){var c,d=a.controls;for(c=d.length-1;c>=0;c--)if(d[c].element==b)return c;return-1}a.ControlDock=function(b){var c,d,e=["topleft","topright","bottomright","bottomleft"];a.extend(!0,this,{id:"controldock-"+a.now()+"-"+Math.floor(1e6*Math.random()),container:a.makeNeutralElement("div"),controls:[]},b);this.container.onsubmit=function(){return!1};if(this.element){this.element=a.getElement(this.element);this.element.appendChild(this.container);this.element.style.position="relative";this.container.style.width="100%";this.container.style.height="100%"}for(d=0;d<e.length;d++){c=e[d];this.controls[c]=a.makeNeutralElement("div");this.controls[c].style.position="absolute";c.match("left")&&(this.controls[c].style.left="0px");c.match("right")&&(this.controls[c].style.right="0px");c.match("top")&&(this.controls[c].style.top="0px");c.match("bottom")&&(this.controls[c].style.bottom="0px")}this.container.appendChild(this.controls.topleft);this.container.appendChild(this.controls.topright);this.container.appendChild(this.controls.bottomright);this.container.appendChild(this.controls.bottomleft)};a.ControlDock.prototype={addControl:function(c,d){c=a.getElement(c);var e=null;if(!(b(this,c)>=0)){switch(d.anchor){case a.ControlAnchor.TOP_RIGHT:e=this.controls.topright;c.style.position="relative";c.style.paddingRight="0px";c.style.paddingTop="0px";break;case a.ControlAnchor.BOTTOM_RIGHT:e=this.controls.bottomright;c.style.position="relative";c.style.paddingRight="0px";c.style.paddingBottom="0px";break;case a.ControlAnchor.BOTTOM_LEFT:e=this.controls.bottomleft;c.style.position="relative";c.style.paddingLeft="0px";c.style.paddingBottom="0px";break;case a.ControlAnchor.TOP_LEFT:e=this.controls.topleft;c.style.position="relative";c.style.paddingLeft="0px";c.style.paddingTop="0px";break;case a.ControlAnchor.ABSOLUTE:e=this.container;c.style.margin="0px";c.style.padding="0px";break;default:case a.ControlAnchor.NONE:e=this.container;c.style.margin="0px";c.style.padding="0px"}this.controls.push(new a.Control(c,d,e));c.style.display="inline-block"}},removeControl:function(c){c=a.getElement(c);var d=b(this,c);if(d>=0){this.controls[d].destroy();this.controls.splice(d,1)}return this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var a;for(a=this.controls.length-1;a>=0;a--)if(this.controls[a].isVisible())return!0;return!1},setControlsEnabled:function(a){var b;for(b=this.controls.length-1;b>=0;b--)this.controls[b].setVisible(a);return this}}}(OpenSeadragon);!function(a){a.Placement=a.freezeObject({CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8,properties:{0:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1},1:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},2:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},3:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!0,isVerticallyCentered:!1,isBottom:!1},4:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!0,isBottom:!1},5:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!1,isBottom:!0},6:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},7:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},8:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1}}})}(OpenSeadragon);!function(a){function b(b){b=a.getElement(b);return new a.Point(0===b.clientWidth?1:b.clientWidth,0===b.clientHeight?1:b.clientHeight)}function c(b,c,d,e,f){function g(a,b){if(a.ready)e(a);else{a.addHandler("ready",function(){e(a)});a.addHandler("open-failed",function(a){f({message:a.message,source:b})})}}var h=b;if("string"==a.type(c))if(c.match(/^\s*<.*>\s*$/))c=a.parseXml(c);else if(c.match(/^\s*[\{\[].*[\}\]]\s*$/))try{var i=a.parseJSON(c);c=i}catch(a){}setTimeout(function(){if("string"==a.type(c)){c=new a.TileSource({url:c,crossOriginPolicy:void 0!==d.crossOriginPolicy?d.crossOriginPolicy:b.crossOriginPolicy,ajaxWithCredentials:b.ajaxWithCredentials,ajaxHeaders:b.ajaxHeaders,useCanvas:b.useCanvas,success:function(a){e(a.tileSource)}});c.addHandler("open-failed",function(a){f(a)})}else if(a.isPlainObject(c)||c.nodeType){void 0!==c.crossOriginPolicy||void 0===d.crossOriginPolicy&&void 0===b.crossOriginPolicy||(c.crossOriginPolicy=void 0!==d.crossOriginPolicy?d.crossOriginPolicy:b.crossOriginPolicy);void 0===c.ajaxWithCredentials&&(c.ajaxWithCredentials=b.ajaxWithCredentials);void 0===c.useCanvas&&(c.useCanvas=b.useCanvas);if(a.isFunction(c.getTileUrl)){var i=new a.TileSource(c);i.getTileUrl=c.getTileUrl;e(i)}else{var j=a.TileSource.determineType(h,c);if(!j){f({message:"Unable to load TileSource",source:c});return}var k=j.prototype.configure.apply(h,[c]);g(new j(k),c)}}else g(c,c)})}function d(b,c){if(c instanceof a.Overlay)return c;var d=null;if(c.element)d=a.getElement(c.element);else{var e=c.id?c.id:"openseadragon-overlay-"+Math.floor(1e7*Math.random());d=a.getElement(c.id);if(!d){d=document.createElement("a");d.href="#/overlay/"+e}d.id=e;a.addClass(d,c.className?c.className:"openseadragon-overlay")}var f=c.location;var g=c.width;var h=c.height;if(!f){var i=c.x;var j=c.y;if(void 0!==c.px){var k=b.viewport.imageToViewportRectangle(new a.Rect(c.px,c.py,g||0,h||0));i=k.x;j=k.y;g=void 0!==g?k.width:void 0;h=void 0!==h?k.height:void 0}f=new a.Point(i,j)}var l=c.placement;l&&"string"===a.type(l)&&(l=a.Placement[c.placement.toUpperCase()]);return new a.Overlay({element:d,location:f,placement:l,onDraw:c.onDraw,checkResize:c.checkResize,width:g,height:h,rotationMode:c.rotationMode})}function e(a,b){var c;for(c=a.length-1;c>=0;c--)if(a[c].element===b)return c;return-1}function f(b,c){return a.requestAnimationFrame(function(){c(b)})}function g(b){a.requestAnimationFrame(function(){i(b)})}function h(b){if(b.autoHideControls){b.controlsShouldFade=!0;b.controlsFadeBeginTime=a.now()+b.controlsFadeDelay;window.setTimeout(function(){g(b)},b.controlsFadeDelay)}}function i(b){var c,d,e,f;if(b.controlsShouldFade){c=a.now();d=c-b.controlsFadeBeginTime;e=1-d/b.controlsFadeLength;e=Math.min(1,e);e=Math.max(0,e);for(f=b.controls.length-1;f>=0;f--)b.controls[f].autoFade&&b.controls[f].setOpacity(e);e>0&&g(b)}}function j(a){var b;a.controlsShouldFade=!1;for(b=a.controls.length-1;b>=0;b--)a.controls[b].setOpacity(1)}function k(){j(this)}function l(){h(this)}function m(b){if(b.preventDefaultAction||b.ctrl||b.alt||b.meta)return!0;switch(b.keyCode){case 38:b.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,-40)));this.viewport.applyConstraints();return!1;case 40:b.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,40)));this.viewport.applyConstraints();return!1;case 37:this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(-40,0)));this.viewport.applyConstraints();return!1;case 39:this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(40,0)));this.viewport.applyConstraints();return!1;default:return!0}}function n(b){if(b.preventDefaultAction||b.ctrl||b.alt||b.meta)return!0;switch(b.keyCode){case 43:case 61:this.viewport.zoomBy(1.1);this.viewport.applyConstraints();return!1;case 45:this.viewport.zoomBy(.9);this.viewport.applyConstraints();return!1;case 48:this.viewport.goHome();this.viewport.applyConstraints();return!1;case 119:case 87:b.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,-40)));this.viewport.applyConstraints();return!1;case 115:case 83:b.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,40)));this.viewport.applyConstraints();return!1;case 97:this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(-40,0)));this.viewport.applyConstraints();return!1;case 100:this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(40,0)));this.viewport.applyConstraints();return!1;default:return!0}}function o(a){var b;var c=document.activeElement==this.canvas;c||this.canvas.focus();var d={tracker:a.eventSource,position:a.position,quick:a.quick,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:a.preventDefaultAction};this.raiseEvent("canvas-click",d);if(!d.preventDefaultAction&&this.viewport&&a.quick){b=this.gestureSettingsByDeviceType(a.pointerType);if(b.clickToZoom){this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,this.viewport.pointFromPixel(a.position,!0));this.viewport.applyConstraints()}}}function p(a){var b;if(!a.preventDefaultAction&&this.viewport){b=this.gestureSettingsByDeviceType(a.pointerType);if(b.dblClickToZoom){this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,this.viewport.pointFromPixel(a.position,!0));this.viewport.applyConstraints()}}this.raiseEvent("canvas-double-click",{tracker:a.eventSource,position:a.position,shift:a.shift,originalEvent:a.originalEvent})}function q(a){var b;var c={tracker:a.eventSource,position:a.position,delta:a.delta,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:a.preventDefaultAction};this.raiseEvent("canvas-drag",c);if(!c.preventDefaultAction&&this.viewport){b=this.gestureSettingsByDeviceType(a.pointerType);this.panHorizontal||(a.delta.x=0);this.panVertical||(a.delta.y=0);if(this.constrainDuringPan){var d=this.viewport.deltaPointsFromPixels(a.delta.negate());this.viewport.centerSpringX.target.value+=d.x;this.viewport.centerSpringY.target.value+=d.y;var e=this.viewport.getBounds();var f=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=d.x;this.viewport.centerSpringY.target.value-=d.y;e.x!=f.x&&(a.delta.x=0);e.y!=f.y&&(a.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta.negate()),b.flickEnabled&&!this.constrainDuringPan)}}function r(b){if(!b.preventDefaultAction&&this.viewport){var c=this.gestureSettingsByDeviceType(b.pointerType);if(c.flickEnabled&&b.speed>=c.flickMinSpeed){var d=0;this.panHorizontal&&(d=c.flickMomentum*b.speed*Math.cos(b.direction));var e=0;this.panVertical&&(e=c.flickMomentum*b.speed*Math.sin(b.direction));var f=this.viewport.pixelFromPoint(this.viewport.getCenter(!0));var g=this.viewport.pointFromPixel(new a.Point(f.x-d,f.y-e));
this.viewport.panTo(g,!1)}this.viewport.applyConstraints()}this.raiseEvent("canvas-drag-end",{tracker:b.eventSource,position:b.position,speed:b.speed,direction:b.direction,shift:b.shift,originalEvent:b.originalEvent})}function s(a){this.raiseEvent("canvas-enter",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,buttons:a.buttons,pointers:a.pointers,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function t(b){window.location!=window.parent.location&&a.MouseTracker.resetAllMouseTrackers();this.raiseEvent("canvas-exit",{tracker:b.eventSource,pointerType:b.pointerType,position:b.position,buttons:b.buttons,pointers:b.pointers,insideElementPressed:b.insideElementPressed,buttonDownAny:b.buttonDownAny,originalEvent:b.originalEvent})}function u(a){this.raiseEvent("canvas-press",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent})}function v(a){this.raiseEvent("canvas-release",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent})}function w(a){this.raiseEvent("canvas-nonprimary-press",{tracker:a.eventSource,position:a.position,pointerType:a.pointerType,button:a.button,buttons:a.buttons,originalEvent:a.originalEvent})}function x(a){this.raiseEvent("canvas-nonprimary-release",{tracker:a.eventSource,position:a.position,pointerType:a.pointerType,button:a.button,buttons:a.buttons,originalEvent:a.originalEvent})}function y(a){var b,c,d,e;if(!a.preventDefaultAction&&this.viewport){b=this.gestureSettingsByDeviceType(a.pointerType);if(b.pinchToZoom){c=this.viewport.pointFromPixel(a.center,!0);d=this.viewport.pointFromPixel(a.lastCenter,!0);e=d.minus(c);this.panHorizontal||(e.x=0);this.panVertical||(e.y=0);this.viewport.zoomBy(a.distance/a.lastDistance,c,!0);this.viewport.panBy(e,!0);this.viewport.applyConstraints()}if(b.pinchRotate){var f=Math.atan2(a.gesturePoints[0].currentPos.y-a.gesturePoints[1].currentPos.y,a.gesturePoints[0].currentPos.x-a.gesturePoints[1].currentPos.x);var g=Math.atan2(a.gesturePoints[0].lastPos.y-a.gesturePoints[1].lastPos.y,a.gesturePoints[0].lastPos.x-a.gesturePoints[1].lastPos.x);this.viewport.setRotation(this.viewport.getRotation()+(f-g)*(180/Math.PI))}}this.raiseEvent("canvas-pinch",{tracker:a.eventSource,gesturePoints:a.gesturePoints,lastCenter:a.lastCenter,center:a.center,lastDistance:a.lastDistance,distance:a.distance,shift:a.shift,originalEvent:a.originalEvent});return!1}function z(b){var c,d,e,f;e=a.now();f=e-this._lastScrollTime;if(f>this.minScrollDeltaTime){this._lastScrollTime=e;if(!b.preventDefaultAction&&this.viewport){c=this.gestureSettingsByDeviceType(b.pointerType);if(c.scrollToZoom){d=Math.pow(this.zoomPerScroll,b.scroll);this.viewport.zoomBy(d,this.viewport.pointFromPixel(b.position,!0));this.viewport.applyConstraints()}}this.raiseEvent("canvas-scroll",{tracker:b.eventSource,position:b.position,scroll:b.scroll,shift:b.shift,originalEvent:b.originalEvent});if(c&&c.scrollToZoom)return!1}else{c=this.gestureSettingsByDeviceType(b.pointerType);if(c&&c.scrollToZoom)return!1}}function A(a){U[this.hash].mouseInside=!0;j(this);this.raiseEvent("container-enter",{tracker:a.eventSource,position:a.position,buttons:a.buttons,pointers:a.pointers,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function B(a){if(a.pointers<1){U[this.hash].mouseInside=!1;U[this.hash].animating||h(this)}this.raiseEvent("container-exit",{tracker:a.eventSource,position:a.position,buttons:a.buttons,pointers:a.pointers,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function C(a){D(a);a.isOpen()?a._updateRequestId=f(a,C):a._updateRequestId=!1}function D(a){if(!a._opening){if(a.autoResize){var c=b(a.container);var d=U[a.hash].prevContainerSize;if(!c.equals(d)){var e=a.viewport;if(a.preserveImageSizeOnResize){var f=d.x/c.x;var g=e.getZoom()*f;var i=e.getCenter();e.resize(c,!1);e.zoomTo(g,null,!0);e.panTo(i,!0)}else{var k=e.getBounds();e.resize(c,!0);e.fitBoundsWithConstraints(k,!0)}U[a.hash].prevContainerSize=c;U[a.hash].forceRedraw=!0}}var l=a.viewport.update();var m=a.world.update()||l;l&&a.raiseEvent("viewport-change");a.referenceStrip&&(m=a.referenceStrip.update(a.viewport)||m);if(!U[a.hash].animating&&m){a.raiseEvent("animation-start");j(a)}if(m||U[a.hash].forceRedraw||a.world.needsDraw()){E(a);a._drawOverlays();a.navigator&&a.navigator.update(a.viewport);U[a.hash].forceRedraw=!1;m&&a.raiseEvent("animation")}if(U[a.hash].animating&&!m){a.raiseEvent("animation-finish");U[a.hash].mouseInside||h(a)}U[a.hash].animating=m}}function E(a){a.imageLoader.clear();a.drawer.clear();a.world.draw();a.raiseEvent("update-viewport",{})}function F(a,b){return a?a+b:b}function G(){U[this.hash].lastZoomTime=a.now();U[this.hash].zoomFactor=this.zoomPerSecond;U[this.hash].zooming=!0;J(this)}function H(){U[this.hash].lastZoomTime=a.now();U[this.hash].zoomFactor=1/this.zoomPerSecond;U[this.hash].zooming=!0;J(this)}function I(){U[this.hash].zooming=!1}function J(b){a.requestAnimationFrame(a.delegate(b,K))}function K(){var b,c,d;if(U[this.hash].zooming&&this.viewport){b=a.now();c=b-U[this.hash].lastZoomTime;d=Math.pow(U[this.hash].zoomFactor,c/1e3);this.viewport.zoomBy(d);this.viewport.applyConstraints();U[this.hash].lastZoomTime=b;J(this)}}function L(){if(this.viewport){U[this.hash].zooming=!1;this.viewport.zoomBy(this.zoomPerClick/1);this.viewport.applyConstraints()}}function M(){if(this.viewport){U[this.hash].zooming=!1;this.viewport.zoomBy(1/this.zoomPerClick);this.viewport.applyConstraints()}}function N(){this.buttons.emulateEnter();this.buttons.emulateExit()}function O(){this.viewport&&this.viewport.goHome()}function P(){this.isFullPage()&&!a.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage());this.buttons&&this.buttons.emulateExit();this.fullPageButton.element.focus();this.viewport&&this.viewport.applyConstraints()}function Q(){if(this.viewport){var a=this.viewport.getRotation();0===a?a=270:a-=90;this.viewport.setRotation(a)}}function R(){if(this.viewport){var a=this.viewport.getRotation();270===a?a=0:a+=90;this.viewport.setRotation(a)}}function S(){var a=this._sequenceIndex-1;this.navPrevNextWrap&&a<0&&(a+=this.tileSources.length);this.goToPage(a)}function T(){var a=this._sequenceIndex+1;this.navPrevNextWrap&&a>=this.tileSources.length&&(a=0);this.goToPage(a)}var U={};var V=1;a.Viewer=function(c){var d,e=arguments,g=this;a.isPlainObject(c)||(c={id:e[0],xmlPath:e.length>1?e[1]:void 0,prefixUrl:e.length>2?e[2]:void 0,controls:e.length>3?e[3]:void 0,overlays:e.length>4?e[4]:void 0});if(c.config){a.extend(!0,c,c.config);delete c.config}a.extend(!0,this,{id:c.id,hash:c.hash||V++,initialPage:0,element:null,container:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttons:null,profiler:null},a.DEFAULT_SETTINGS,c);if("undefined"==typeof this.hash)throw new Error("A hash must be defined, either by specifying options.id or options.hash.");"undefined"!=typeof U[this.hash]&&a.console.warn("Hash "+this.hash+" has already been used.");U[this.hash]={fsBoundsDelta:new a.Point(1,1),prevContainerSize:null,animating:!1,forceRedraw:!1,mouseInside:!1,group:null,zooming:!1,zoomFactor:null,lastZoomTime:null,fullPage:!1,onfullscreenchange:null};this._sequenceIndex=0;this._firstOpen=!0;this._updateRequestId=null;this._loadQueue=[];this.currentOverlays=[];this._lastScrollTime=a.now();a.EventSource.call(this);this.addHandler("open-failed",function(b){var c=a.getString("Errors.OpenFailed",b.eventSource,b.message);g._showMessage(c)});a.ControlDock.call(this,c);this.xmlPath&&(this.tileSources=[this.xmlPath]);this.element=this.element||document.getElementById(this.id);this.canvas=a.makeNeutralElement("div");this.canvas.className="openseadragon-canvas";!function(a){a.width="100%";a.height="100%";a.overflow="hidden";a.position="absolute";a.top="0px";a.left="0px"}(this.canvas.style);a.setElementTouchActionNone(this.canvas);""!==c.tabIndex&&(this.canvas.tabIndex=void 0===c.tabIndex?0:c.tabIndex);this.container.className="openseadragon-container";!function(a){a.width="100%";a.height="100%";a.position="relative";a.overflow="hidden";a.left="0px";a.top="0px";a.textAlign="left"}(this.container.style);this.container.insertBefore(this.canvas,this.container.firstChild);this.element.appendChild(this.container);this.bodyWidth=document.body.style.width;this.bodyHeight=document.body.style.height;this.bodyOverflow=document.body.style.overflow;this.docOverflow=document.documentElement.style.overflow;this.innerTracker=new a.MouseTracker({element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,keyDownHandler:a.delegate(this,m),keyHandler:a.delegate(this,n),clickHandler:a.delegate(this,o),dblClickHandler:a.delegate(this,p),dragHandler:a.delegate(this,q),dragEndHandler:a.delegate(this,r),enterHandler:a.delegate(this,s),exitHandler:a.delegate(this,t),pressHandler:a.delegate(this,u),releaseHandler:a.delegate(this,v),nonPrimaryPressHandler:a.delegate(this,w),nonPrimaryReleaseHandler:a.delegate(this,x),scrollHandler:a.delegate(this,z),pinchHandler:a.delegate(this,y)});this.outerTracker=new a.MouseTracker({element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:a.delegate(this,A),exitHandler:a.delegate(this,B)});this.toolbar&&(this.toolbar=new a.ControlDock({element:this.toolbar}));this.bindStandardControls();U[this.hash].prevContainerSize=b(this.container);this.world=new a.World({viewer:this});this.world.addHandler("add-item",function(a){g.source=g.world.getItemAt(0).source;U[g.hash].forceRedraw=!0;g._updateRequestId||(g._updateRequestId=f(g,C))});this.world.addHandler("remove-item",function(a){g.world.getItemCount()?g.source=g.world.getItemAt(0).source:g.source=null;U[g.hash].forceRedraw=!0});this.world.addHandler("metrics-change",function(a){g.viewport&&g.viewport._setContentBounds(g.world.getHomeBounds(),g.world.getContentFactor())});this.world.addHandler("item-index-change",function(a){g.source=g.world.getItemAt(0).source});this.viewport=new a.Viewport({containerSize:U[this.hash].prevContainerSize,springStiffness:this.springStiffness,animationTime:this.animationTime,minZoomImageRatio:this.minZoomImageRatio,maxZoomPixelRatio:this.maxZoomPixelRatio,visibilityRatio:this.visibilityRatio,wrapHorizontal:this.wrapHorizontal,wrapVertical:this.wrapVertical,defaultZoomLevel:this.defaultZoomLevel,minZoomLevel:this.minZoomLevel,maxZoomLevel:this.maxZoomLevel,viewer:this,degrees:this.degrees,navigatorRotate:this.navigatorRotate,homeFillsViewer:this.homeFillsViewer,margins:this.viewportMargins});this.viewport._setContentBounds(this.world.getHomeBounds(),this.world.getContentFactor());this.imageLoader=new a.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:c.timeout});this.tileCache=new a.TileCache({maxImageCacheCount:this.maxImageCacheCount});this.drawer=new a.Drawer({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor});this.overlaysContainer=a.makeNeutralElement("div");this.canvas.appendChild(this.overlaysContainer);if(!this.drawer.canRotate()){if(this.rotateLeft){d=this.buttons.buttons.indexOf(this.rotateLeft);this.buttons.buttons.splice(d,1);this.buttons.element.removeChild(this.rotateLeft.element)}if(this.rotateRight){d=this.buttons.buttons.indexOf(this.rotateRight);this.buttons.buttons.splice(d,1);this.buttons.element.removeChild(this.rotateRight.element)}}this.showNavigator&&(this.navigator=new a.Navigator({id:this.navigatorId,position:this.navigatorPosition,sizeRatio:this.navigatorSizeRatio,maintainSizeRatio:this.navigatorMaintainSizeRatio,top:this.navigatorTop,left:this.navigatorLeft,width:this.navigatorWidth,height:this.navigatorHeight,autoResize:this.navigatorAutoResize,autoFade:this.navigatorAutoFade,prefixUrl:this.prefixUrl,viewer:this,navigatorRotate:this.navigatorRotate,crossOriginPolicy:this.crossOriginPolicy}));this.sequenceMode&&this.bindSequenceControls();this.tileSources&&this.open(this.tileSources);for(d=0;d<this.customControls.length;d++)this.addControl(this.customControls[d].id,{anchor:this.customControls[d].anchor});a.requestAnimationFrame(function(){h(g)})};a.extend(a.Viewer.prototype,a.EventSource.prototype,a.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},openDzi:function(b){a.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead.");return this.open(b)},openTileSource:function(b){a.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead.");return this.open(b)},open:function(b,c){var e=this;this.close();if(b)if(this.sequenceMode&&a.isArray(b)){if(this.referenceStrip){this.referenceStrip.destroy();this.referenceStrip=null}"undefined"==typeof c||isNaN(c)||(this.initialPage=c);this.tileSources=b;this._sequenceIndex=Math.max(0,Math.min(this.tileSources.length-1,this.initialPage));if(this.tileSources.length){this.open(this.tileSources[this._sequenceIndex]);this.showReferenceStrip&&this.addReferenceStrip()}this._updateSequenceButtons(this._sequenceIndex)}else{a.isArray(b)||(b=[b]);if(b.length){this._opening=!0;var f=b.length;var g=0;var h=0;var i;var j=function(){if(g+h===f)if(g){if(e._firstOpen||!e.preserveViewport){e.viewport.goHome(!0);e.viewport.update()}e._firstOpen=!1;var a=b[0];a.tileSource&&(a=a.tileSource);if(e.overlays&&!e.preserveOverlays)for(var c=0;c<e.overlays.length;c++)e.currentOverlays[c]=d(e,e.overlays[c]);e._drawOverlays();e._opening=!1;e.raiseEvent("open",{source:a})}else{e._opening=!1;e.raiseEvent("open-failed",i)}};var k=function(b){a.isPlainObject(b)&&b.tileSource||(b={tileSource:b});if(void 0!==b.index){a.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead");delete b.index}void 0===b.collectionImmediately&&(b.collectionImmediately=!0);var c=b.success;b.success=function(a){g++;if(b.tileSource.overlays)for(var d=0;d<b.tileSource.overlays.length;d++)e.addOverlay(b.tileSource.overlays[d]);c&&c(a);j()};var d=b.error;b.error=function(a){h++;i||(i=a);d&&d(a);j()};e.addTiledImage(b)};for(var l=0;l<b.length;l++)k(b[l]);return this}}},close:function(){if(!U[this.hash])return this;this._opening=!1;this.navigator&&this.navigator.close();if(!this.preserveOverlays){this.clearOverlays();this.overlaysContainer.innerHTML=""}U[this.hash].animating=!1;this.world.removeAll();this.imageLoader.clear();this.raiseEvent("close");return this},destroy:function(){if(U[this.hash]){this.close();this.clearOverlays();this.overlaysContainer.innerHTML="";if(this.referenceStrip){this.referenceStrip.destroy();this.referenceStrip=null}if(null!==this._updateRequestId){a.cancelAnimationFrame(this._updateRequestId);this._updateRequestId=null}this.drawer&&this.drawer.destroy();this.removeAllHandlers();if(this.element)for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.innerTracker&&this.innerTracker.destroy();this.outerTracker&&this.outerTracker.destroy();U[this.hash]=null;delete U[this.hash];this.canvas=null;this.container=null;this.element=null}},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(a){this.innerTracker.setTracking(a);this.outerTracker.setTracking(a);this.raiseEvent("mouse-enabled",{enabled:a});return this},areControlsEnabled:function(){var a,b=this.controls.length;for(a=0;a<this.controls.length;a++)b=b&&this.controls[a].isVisibile();return b},setControlsEnabled:function(a){a?j(this):h(this);this.raiseEvent("controls-enabled",{enabled:a});return this},setDebugMode:function(a){for(var b=0;b<this.world.getItemCount();b++)this.world.getItemAt(b).debugMode=a;this.debugMode=a;this.forceRedraw()},isFullPage:function(){return U[this.hash].fullPage},setFullPage:function(b){var c,d,e=document.body,f=e.style,g=document.documentElement.style,h=this;if(b==this.isFullPage())return this;var i={fullPage:b,preventDefaultAction:!1};this.raiseEvent("pre-full-page",i);if(i.preventDefaultAction)return this;if(b){this.elementSize=a.getElementSize(this.element);this.pageScroll=a.getPageScroll();this.elementMargin=this.element.style.margin;this.element.style.margin="0";this.elementPadding=this.element.style.padding;this.element.style.padding="0";this.bodyMargin=f.margin;this.docMargin=g.margin;f.margin="0";g.margin="0";this.bodyPadding=f.padding;this.docPadding=g.padding;f.padding="0";g.padding="0";this.bodyWidth=f.width;this.docWidth=g.width;f.width="100%";g.width="100%";this.bodyHeight=f.height;this.docHeight=g.height;f.height="100%";g.height="100%";this.previousBody=[];U[this.hash].prevElementParent=this.element.parentNode;U[this.hash].prevNextSibling=this.element.nextSibling;U[this.hash].prevElementWidth=this.element.style.width;U[this.hash].prevElementHeight=this.element.style.height;c=e.childNodes.length;for(d=0;d<c;d++){this.previousBody.push(e.childNodes[0]);e.removeChild(e.childNodes[0])}if(this.toolbar&&this.toolbar.element){this.toolbar.parentNode=this.toolbar.element.parentNode;this.toolbar.nextSibling=this.toolbar.element.nextSibling;e.appendChild(this.toolbar.element);a.addClass(this.toolbar.element,"fullpage")}a.addClass(this.element,"fullpage");e.appendChild(this.element);this.element.style.height=a.getWindowSize().y+"px";this.element.style.width=a.getWindowSize().x+"px";this.toolbar&&this.toolbar.element&&(this.element.style.height=a.getElementSize(this.element).y-a.getElementSize(this.toolbar.element).y+"px");U[this.hash].fullPage=!0;a.delegate(this,A)({})}else{this.element.style.margin=this.elementMargin;this.element.style.padding=this.elementPadding;f.margin=this.bodyMargin;g.margin=this.docMargin;f.padding=this.bodyPadding;g.padding=this.docPadding;f.width=this.bodyWidth;g.width=this.docWidth;f.height=this.bodyHeight;g.height=this.docHeight;e.removeChild(this.element);c=this.previousBody.length;for(d=0;d<c;d++)e.appendChild(this.previousBody.shift());a.removeClass(this.element,"fullpage");U[this.hash].prevElementParent.insertBefore(this.element,U[this.hash].prevNextSibling);if(this.toolbar&&this.toolbar.element){e.removeChild(this.toolbar.element);a.removeClass(this.toolbar.element,"fullpage");this.toolbar.parentNode.insertBefore(this.toolbar.element,this.toolbar.nextSibling);delete this.toolbar.parentNode;delete this.toolbar.nextSibling}this.element.style.width=U[this.hash].prevElementWidth;this.element.style.height=U[this.hash].prevElementHeight;var j=0;var k=function(){a.setPageScroll(h.pageScroll);var b=a.getPageScroll();j++;j<10&&(b.x!==h.pageScroll.x||b.y!==h.pageScroll.y)&&a.requestAnimationFrame(k)};a.requestAnimationFrame(k);U[this.hash].fullPage=!1;a.delegate(this,B)({})}this.navigator&&this.viewport&&this.navigator.update(this.viewport);this.raiseEvent("full-page",{fullPage:b});return this},setFullScreen:function(b){var c=this;if(!a.supportsFullScreen)return this.setFullPage(b);if(a.isFullScreen()===b)return this;var d={fullScreen:b,preventDefaultAction:!1};this.raiseEvent("pre-full-screen",d);if(d.preventDefaultAction)return this;if(b){this.setFullPage(!0);if(!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width;this.fullPageStyleHeight=this.element.style.height;this.element.style.width="100%";this.element.style.height="100%";var e=function(){var b=a.isFullScreen();if(!b){a.removeEvent(document,a.fullScreenEventName,e);a.removeEvent(document,a.fullScreenErrorEventName,e);c.setFullPage(!1);if(c.isFullPage()){c.element.style.width=c.fullPageStyleWidth;c.element.style.height=c.fullPageStyleHeight}}c.navigator&&c.viewport&&c.navigator.update(c.viewport);c.raiseEvent("full-screen",{fullScreen:b})};a.addEvent(document,a.fullScreenEventName,e);a.addEvent(document,a.fullScreenErrorEventName,e);a.requestFullScreen(document.body)}else a.exitFullScreen();return this},isVisible:function(){return"hidden"!=this.container.style.visibility},setVisible:function(a){this.container.style.visibility=a?"":"hidden";this.raiseEvent("visible",{visible:a});return this},addTiledImage:function(b){function d(a){for(var c=0;c<g._loadQueue.length;c++)if(g._loadQueue[c]===h){g._loadQueue.splice(c,1);break}0===g._loadQueue.length&&e(h);g.raiseEvent("add-item-failed",a);b.error&&b.error(a)}function e(a){if(g.collectionMode){g.world.arrange({immediately:a.options.collectionImmediately,rows:g.collectionRows,columns:g.collectionColumns,layout:g.collectionLayout,tileSize:g.collectionTileSize,tileMargin:g.collectionTileMargin});g.world.setAutoRefigureSizes(!0)}}function f(){var b,c,d;for(;g._loadQueue.length;){b=g._loadQueue[0];if(!b.tileSource)break;g._loadQueue.splice(0,1);if(b.options.replace){var f=g.world.getIndexOfItem(b.options.replaceItem);f!=-1&&(b.options.index=f);g.world.removeItem(b.options.replaceItem)}c=new a.TiledImage({viewer:g,source:b.tileSource,viewport:g.viewport,drawer:g.drawer,tileCache:g.tileCache,imageLoader:g.imageLoader,x:b.options.x,y:b.options.y,width:b.options.width,height:b.options.height,fitBounds:b.options.fitBounds,fitBoundsPlacement:b.options.fitBoundsPlacement,clip:b.options.clip,placeholderFillStyle:b.options.placeholderFillStyle,opacity:b.options.opacity,preload:b.options.preload,degrees:b.options.degrees,compositeOperation:b.options.compositeOperation,springStiffness:g.springStiffness,animationTime:g.animationTime,minZoomImageRatio:g.minZoomImageRatio,wrapHorizontal:g.wrapHorizontal,wrapVertical:g.wrapVertical,immediateRender:g.immediateRender,blendTime:g.blendTime,alwaysBlend:g.alwaysBlend,minPixelRatio:g.minPixelRatio,smoothTileEdgesMinZoom:g.smoothTileEdgesMinZoom,iOSDevice:g.iOSDevice,crossOriginPolicy:b.options.crossOriginPolicy,ajaxWithCredentials:b.options.ajaxWithCredentials,loadTilesWithAjax:b.options.loadTilesWithAjax,ajaxHeaders:b.options.ajaxHeaders,debugMode:g.debugMode});g.collectionMode&&g.world.setAutoRefigureSizes(!1);g.world.addItem(c,{index:b.options.index});0===g._loadQueue.length&&e(b);1!==g.world.getItemCount()||g.preserveViewport||g.viewport.goHome(!0);if(g.navigator){d=a.extend({},b.options,{replace:!1,originalTiledImage:c,tileSource:b.tileSource});g.navigator.addTiledImage(d)}b.options.success&&b.options.success({item:c})}}a.console.assert(b,"[Viewer.addTiledImage] options is required");a.console.assert(b.tileSource,"[Viewer.addTiledImage] options.tileSource is required");a.console.assert(!b.replace||b.index>-1&&b.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var g=this;b.replace&&(b.replaceItem=g.world.getItemAt(b.index));this._hideMessage();void 0===b.placeholderFillStyle&&(b.placeholderFillStyle=this.placeholderFillStyle);void 0===b.opacity&&(b.opacity=this.opacity);void 0===b.preload&&(b.preload=this.preload);void 0===b.compositeOperation&&(b.compositeOperation=this.compositeOperation);void 0===b.crossOriginPolicy&&(b.crossOriginPolicy=void 0!==b.tileSource.crossOriginPolicy?b.tileSource.crossOriginPolicy:this.crossOriginPolicy);void 0===b.ajaxWithCredentials&&(b.ajaxWithCredentials=this.ajaxWithCredentials);void 0===b.loadTilesWithAjax&&(b.loadTilesWithAjax=this.loadTilesWithAjax);void 0===b.ajaxHeaders||null===b.ajaxHeaders?b.ajaxHeaders=this.ajaxHeaders:a.isPlainObject(b.ajaxHeaders)&&a.isPlainObject(this.ajaxHeaders)&&(b.ajaxHeaders=a.extend({},this.ajaxHeaders,b.ajaxHeaders));var h={options:b};if(a.isArray(b.tileSource))setTimeout(function(){d({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:b.tileSource,options:b})});else{this._loadQueue.push(h);c(this,b.tileSource,b,function(a){h.tileSource=a;f()},function(a){a.options=b;d(a);f()})}},addSimpleImage:function(b){a.console.assert(b,"[Viewer.addSimpleImage] options is required");a.console.assert(b.url,"[Viewer.addSimpleImage] options.url is required");var c=a.extend({},b,{tileSource:{type:"image",url:b.url}});delete c.url;this.addTiledImage(c)},addLayer:function(b){var c=this;a.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var d=a.extend({},b,{success:function(a){c.raiseEvent("add-layer",{options:b,drawer:a.item})},error:function(a){c.raiseEvent("add-layer-failed",a)}});this.addTiledImage(d);return this},getLayerAtLevel:function(b){a.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead.");return this.world.getItemAt(b)},getLevelOfLayer:function(b){a.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead.");return this.world.getIndexOfItem(b)},getLayersCount:function(){a.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead.");return this.world.getItemCount()},setLayerLevel:function(b,c){a.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead.");return this.world.setItemIndex(b,c)},removeLayer:function(b){a.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead.");return this.world.removeItem(b)},forceRedraw:function(){U[this.hash].forceRedraw=!0;return this},bindSequenceControls:function(){var b=a.delegate(this,k),c=a.delegate(this,l),d=a.delegate(this,T),e=a.delegate(this,S),f=this.navImages,g=!0;if(this.showSequenceControl){(this.previousButton||this.nextButton)&&(g=!1);this.previousButton=new a.Button({element:this.previousButton?a.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.PreviousPage"),srcRest:F(this.prefixUrl,f.previous.REST),srcGroup:F(this.prefixUrl,f.previous.GROUP),srcHover:F(this.prefixUrl,f.previous.HOVER),srcDown:F(this.prefixUrl,f.previous.DOWN),onRelease:e,onFocus:b,onBlur:c});this.nextButton=new a.Button({element:this.nextButton?a.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.NextPage"),srcRest:F(this.prefixUrl,f.next.REST),srcGroup:F(this.prefixUrl,f.next.GROUP),srcHover:F(this.prefixUrl,f.next.HOVER),srcDown:F(this.prefixUrl,f.next.DOWN),onRelease:d,onFocus:b,onBlur:c});this.navPrevNextWrap||this.previousButton.disable();this.tileSources&&this.tileSources.length||this.nextButton.disable();if(g){this.paging=new a.ButtonGroup({buttons:[this.previousButton,this.nextButton],clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold});this.pagingControl=this.paging.element;this.toolbar?this.toolbar.addControl(this.pagingControl,{anchor:a.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||a.ControlAnchor.TOP_LEFT})}}return this},bindStandardControls:function(){var b=a.delegate(this,G),c=a.delegate(this,I),d=a.delegate(this,L),e=a.delegate(this,H),f=a.delegate(this,M),g=a.delegate(this,O),h=a.delegate(this,P),i=a.delegate(this,Q),j=a.delegate(this,R),m=a.delegate(this,k),n=a.delegate(this,l),o=this.navImages,p=[],q=!0;if(this.showNavigationControl){(this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton)&&(q=!1);if(this.showZoomControl){p.push(this.zoomInButton=new a.Button({element:this.zoomInButton?a.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.ZoomIn"),srcRest:F(this.prefixUrl,o.zoomIn.REST),srcGroup:F(this.prefixUrl,o.zoomIn.GROUP),srcHover:F(this.prefixUrl,o.zoomIn.HOVER),srcDown:F(this.prefixUrl,o.zoomIn.DOWN),onPress:b,onRelease:c,onClick:d,onEnter:b,onExit:c,onFocus:m,onBlur:n}));p.push(this.zoomOutButton=new a.Button({element:this.zoomOutButton?a.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.ZoomOut"),srcRest:F(this.prefixUrl,o.zoomOut.REST),srcGroup:F(this.prefixUrl,o.zoomOut.GROUP),srcHover:F(this.prefixUrl,o.zoomOut.HOVER),srcDown:F(this.prefixUrl,o.zoomOut.DOWN),onPress:e,onRelease:c,onClick:f,onEnter:e,onExit:c,onFocus:m,onBlur:n}))}this.showHomeControl&&p.push(this.homeButton=new a.Button({element:this.homeButton?a.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.Home"),srcRest:F(this.prefixUrl,o.home.REST),srcGroup:F(this.prefixUrl,o.home.GROUP),srcHover:F(this.prefixUrl,o.home.HOVER),srcDown:F(this.prefixUrl,o.home.DOWN),onRelease:g,onFocus:m,onBlur:n}));this.showFullPageControl&&p.push(this.fullPageButton=new a.Button({element:this.fullPageButton?a.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.FullPage"),srcRest:F(this.prefixUrl,o.fullpage.REST),srcGroup:F(this.prefixUrl,o.fullpage.GROUP),srcHover:F(this.prefixUrl,o.fullpage.HOVER),srcDown:F(this.prefixUrl,o.fullpage.DOWN),onRelease:h,onFocus:m,onBlur:n}));if(this.showRotationControl){p.push(this.rotateLeftButton=new a.Button({element:this.rotateLeftButton?a.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.RotateLeft"),srcRest:F(this.prefixUrl,o.rotateleft.REST),srcGroup:F(this.prefixUrl,o.rotateleft.GROUP),srcHover:F(this.prefixUrl,o.rotateleft.HOVER),srcDown:F(this.prefixUrl,o.rotateleft.DOWN),onRelease:i,onFocus:m,onBlur:n}));p.push(this.rotateRightButton=new a.Button({element:this.rotateRightButton?a.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:a.getString("Tooltips.RotateRight"),srcRest:F(this.prefixUrl,o.rotateright.REST),srcGroup:F(this.prefixUrl,o.rotateright.GROUP),srcHover:F(this.prefixUrl,o.rotateright.HOVER),srcDown:F(this.prefixUrl,o.rotateright.DOWN),onRelease:j,onFocus:m,onBlur:n}))}if(q){this.buttons=new a.ButtonGroup({buttons:p,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold});this.navControl=this.buttons.element;this.addHandler("open",a.delegate(this,N));this.toolbar?this.toolbar.addControl(this.navControl,{anchor:this.navigationControlAnchor||a.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||a.ControlAnchor.TOP_LEFT})}}return this},currentPage:function(){return this._sequenceIndex},goToPage:function(a){if(this.tileSources&&a>=0&&a<this.tileSources.length){this.raiseEvent("page",{page:a});this._sequenceIndex=a;this._updateSequenceButtons(a);this.open(this.tileSources[a]);this.referenceStrip&&this.referenceStrip.setFocus(a)}return this},addOverlay:function(b,c,f,g){var h;h=a.isPlainObject(b)?b:{element:b,location:c,placement:f,onDraw:g};b=a.getElement(h.element);if(e(this.currentOverlays,b)>=0)return this;var i=d(this,h);this.currentOverlays.push(i);i.drawHTML(this.overlaysContainer,this.viewport);this.raiseEvent("add-overlay",{element:b,location:h.location,placement:h.placement});return this},updateOverlay:function(b,c,d){var f;b=a.getElement(b);f=e(this.currentOverlays,b);if(f>=0){this.currentOverlays[f].update(c,d);U[this.hash].forceRedraw=!0;this.raiseEvent("update-overlay",{element:b,location:c,placement:d})}return this;
},removeOverlay:function(b){var c;b=a.getElement(b);c=e(this.currentOverlays,b);if(c>=0){this.currentOverlays[c].destroy();this.currentOverlays.splice(c,1);U[this.hash].forceRedraw=!0;this.raiseEvent("remove-overlay",{element:b})}return this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();U[this.hash].forceRedraw=!0;this.raiseEvent("clear-overlay",{});return this},getOverlayById:function(b){var c;b=a.getElement(b);c=e(this.currentOverlays,b);return c>=0?this.currentOverlays[c]:null},_updateSequenceButtons:function(a){this.nextButton&&(this.tileSources&&this.tileSources.length-1!==a?this.nextButton.enable():this.navPrevNextWrap||this.nextButton.disable());this.previousButton&&(a>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(b){this._hideMessage();var c=a.makeNeutralElement("div");c.appendChild(document.createTextNode(b));this.messageDiv=a.makeCenteredNode(c);a.addClass(this.messageDiv,"openseadragon-message");this.container.appendChild(this.messageDiv)},_hideMessage:function(){var a=this.messageDiv;if(a){a.parentNode.removeChild(a);delete this.messageDiv}},gestureSettingsByDeviceType:function(a){switch(a){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var a,b=this.currentOverlays.length;for(a=0;a<b;a++)this.currentOverlays[a].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]},removeReferenceStrip:function(){this.showReferenceStrip=!1;if(this.referenceStrip){this.referenceStrip.destroy();this.referenceStrip=null}},addReferenceStrip:function(){this.showReferenceStrip=!0;if(this.sequenceMode){if(this.referenceStrip)return;if(this.tileSources.length&&this.tileSources.length>1){this.referenceStrip=new a.ReferenceStrip({id:this.referenceStripElement,position:this.referenceStripPosition,sizeRatio:this.referenceStripSizeRatio,scroll:this.referenceStripScroll,height:this.referenceStripHeight,width:this.referenceStripWidth,tileSources:this.tileSources,prefixUrl:this.prefixUrl,viewer:this});this.referenceStrip.setFocus(this._sequenceIndex)}}else a.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')}})}(OpenSeadragon);!function(a){function b(a){if(a.quick&&this.viewer.viewport){this.viewer.viewport.panTo(this.viewport.pointFromPixel(a.position));this.viewer.viewport.applyConstraints()}}function c(a){if(this.viewer.viewport){this.panHorizontal||(a.delta.x=0);this.panVertical||(a.delta.y=0);this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta));this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints()}}function d(a){a.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function e(a){this.viewer.raiseEvent("navigator-scroll",{tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent});return!1}function f(a,b){a.style.webkitTransform="rotate("+b+"deg)";a.style.mozTransform="rotate("+b+"deg)";a.style.msTransform="rotate("+b+"deg)";a.style.oTransform="rotate("+b+"deg)";a.style.transform="rotate("+b+"deg)"}a.Navigator=function(g){function h(a){f(l.displayRegionContainer,a);f(l.displayRegion,-a);l.viewport.setRotation(a)}var i,j,k=g.viewer,l=this;if(g.id){this.element=document.getElementById(g.id);g.controlOptions={anchor:a.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}}else{g.id="navigator-"+a.now();this.element=a.makeNeutralElement("div");g.controlOptions={anchor:a.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:g.autoFade};if(g.position)if("BOTTOM_RIGHT"==g.position)g.controlOptions.anchor=a.ControlAnchor.BOTTOM_RIGHT;else if("BOTTOM_LEFT"==g.position)g.controlOptions.anchor=a.ControlAnchor.BOTTOM_LEFT;else if("TOP_RIGHT"==g.position)g.controlOptions.anchor=a.ControlAnchor.TOP_RIGHT;else if("TOP_LEFT"==g.position)g.controlOptions.anchor=a.ControlAnchor.TOP_LEFT;else if("ABSOLUTE"==g.position){g.controlOptions.anchor=a.ControlAnchor.ABSOLUTE;g.controlOptions.top=g.top;g.controlOptions.left=g.left;g.controlOptions.height=g.height;g.controlOptions.width=g.width}}this.element.id=g.id;this.element.className+=" navigator";g=a.extend(!0,{sizeRatio:a.DEFAULT_SETTINGS.navigatorSizeRatio},g,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,autoResize:g.autoResize,minZoomImageRatio:1});g.minPixelRatio=this.minPixelRatio=k.minPixelRatio;a.setElementTouchActionNone(this.element);this.borderWidth=2;this.fudge=new a.Point(1,1);this.totalBorderWidths=new a.Point(2*this.borderWidth,2*this.borderWidth).minus(this.fudge);g.controlOptions.anchor!=a.ControlAnchor.NONE&&!function(a,b){a.margin="0px";a.border=b+"px solid #555";a.padding="0px";a.background="#000";a.opacity=.8;a.overflow="hidden"}(this.element.style,this.borderWidth);this.displayRegion=a.makeNeutralElement("div");this.displayRegion.id=this.element.id+"-displayregion";this.displayRegion.className="displayregion";!function(a,b){a.position="relative";a.top="0px";a.left="0px";a.fontSize="0px";a.overflow="hidden";a.border=b+"px solid #900";a.margin="0px";a.padding="0px";a.background="transparent";a.float="left";a.cssFloat="left";a.styleFloat="left";a.zIndex=999999999;a.cursor="default"}(this.displayRegion.style,this.borderWidth);this.displayRegionContainer=a.makeNeutralElement("div");this.displayRegionContainer.id=this.element.id+"-displayregioncontainer";this.displayRegionContainer.className="displayregioncontainer";this.displayRegionContainer.style.width="100%";this.displayRegionContainer.style.height="100%";k.addControl(this.element,g.controlOptions);this._resizeWithViewer=g.controlOptions.anchor!=a.ControlAnchor.ABSOLUTE&&g.controlOptions.anchor!=a.ControlAnchor.NONE;if(this._resizeWithViewer){if(g.width&&g.height){this.element.style.height="number"==typeof g.height?g.height+"px":g.height;this.element.style.width="number"==typeof g.width?g.width+"px":g.width}else{i=a.getElementSize(k.element);this.element.style.height=Math.round(i.y*g.sizeRatio)+"px";this.element.style.width=Math.round(i.x*g.sizeRatio)+"px";this.oldViewerSize=i}j=a.getElementSize(this.element);this.elementArea=j.x*j.y}this.oldContainerSize=new a.Point(0,0);a.Viewer.apply(this,[g]);this.displayRegionContainer.appendChild(this.displayRegion);this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);if(g.navigatorRotate){var m=g.viewer.viewport?g.viewer.viewport.getRotation():g.viewer.degrees||0;h(m);g.viewer.addHandler("rotate",function(a){h(a.degrees)})}this.innerTracker.destroy();this.innerTracker=new a.MouseTracker({element:this.element,dragHandler:a.delegate(this,c),clickHandler:a.delegate(this,b),releaseHandler:a.delegate(this,d),scrollHandler:a.delegate(this,e)});this.addHandler("reset-size",function(){l.viewport&&l.viewport.goHome(!0)});k.world.addHandler("item-index-change",function(a){window.setTimeout(function(){var b=l.world.getItemAt(a.previousIndex);l.world.setItemIndex(b,a.newIndex)},1)});k.world.addHandler("remove-item",function(a){var b=a.item;var c=l._getMatchingItem(b);c&&l.world.removeItem(c)});this.update(k.viewport)};a.extend(a.Navigator.prototype,a.EventSource.prototype,a.Viewer.prototype,{updateSize:function(){if(this.viewport){var b=new a.Point(0===this.container.clientWidth?1:this.container.clientWidth,0===this.container.clientHeight?1:this.container.clientHeight);if(!b.equals(this.oldContainerSize)){this.viewport.resize(b,!0);this.viewport.goHome(!0);this.oldContainerSize=b;this.drawer.clear();this.world.draw()}}},update:function(b){var c,d,e,f,g,h;c=a.getElementSize(this.viewer.element);if(this._resizeWithViewer&&c.x&&c.y&&!c.equals(this.oldViewerSize)){this.oldViewerSize=c;if(this.maintainSizeRatio||!this.elementArea){d=c.x*this.sizeRatio;e=c.y*this.sizeRatio}else{d=Math.sqrt(this.elementArea*(c.x/c.y));e=this.elementArea/d}this.element.style.width=Math.round(d)+"px";this.element.style.height=Math.round(e)+"px";this.elementArea||(this.elementArea=d*e);this.updateSize()}if(b&&this.viewport){f=b.getBoundsNoRotate(!0);g=this.viewport.pixelFromPointNoRotate(f.getTopLeft(),!1);h=this.viewport.pixelFromPointNoRotate(f.getBottomRight(),!1).minus(this.totalBorderWidths);var i=this.displayRegion.style;i.display=this.world.getItemCount()?"block":"none";i.top=Math.round(g.y)+"px";i.left=Math.round(g.x)+"px";var j=Math.abs(g.x-h.x);var k=Math.abs(g.y-h.y);i.width=Math.round(Math.max(j,0))+"px";i.height=Math.round(Math.max(k,0))+"px"}},addTiledImage:function(b){var c=this;var d=b.originalTiledImage;delete b.original;var e=a.extend({},b,{success:function(a){function b(){c._matchBounds(g,d)}function e(){c._matchOpacity(g,d)}function f(){c._matchCompositeOperation(g,d)}var g=a.item;g._originalForNavigator=d;c._matchBounds(g,d,!0);d.addHandler("bounds-change",b);d.addHandler("clip-change",b);d.addHandler("opacity-change",e);d.addHandler("composite-operation-change",f)}});return a.Viewer.prototype.addTiledImage.apply(this,[e])},_getMatchingItem:function(a){var b=this.world.getItemCount();var c;for(var d=0;d<b;d++){c=this.world.getItemAt(d);if(c._originalForNavigator===a)return c}return null},_matchBounds:function(a,b,c){var d=b.getBoundsNoRotate();a.setPosition(d.getTopLeft(),c);a.setWidth(d.width,c);a.setRotation(b.getRotation(),c);a.setClip(b.getClip())},_matchOpacity:function(a,b){a.setOpacity(b.opacity)},_matchCompositeOperation:function(a,b){a.setCompositeOperation(b.compositeOperation)}})}(OpenSeadragon);!function(a){var b={Errors:{Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",OpenFailed:"Unable to open {0}: {1}"},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out",NextPage:"Next page",PreviousPage:"Previous page",RotateLeft:"Rotate left",RotateRight:"Rotate right"}};a.extend(a,{getString:function(c){var d,e=c.split("."),f=null,g=arguments,h=b;for(d=0;d<e.length-1;d++)h=h[e[d]]||{};f=h[e[d]];if("string"!=typeof f){a.console.log("Untranslated source string:",c);f=""}return f.replace(/\{\d+\}/g,function(a){var b=parseInt(a.match(/\d+/),10)+1;return b<g.length?g[b]:""})},setString:function(a,c){var d,e=a.split("."),f=b;for(d=0;d<e.length-1;d++){f[e[d]]||(f[e[d]]={});f=f[e[d]]}f[e[d]]=c}})}(OpenSeadragon);!function(a){a.Point=function(a,b){this.x="number"==typeof a?a:0;this.y="number"==typeof b?b:0};a.Point.prototype={clone:function(){return new a.Point(this.x,this.y)},plus:function(b){return new a.Point(this.x+b.x,this.y+b.y)},minus:function(b){return new a.Point(this.x-b.x,this.y-b.y)},times:function(b){return new a.Point(this.x*b,this.y*b)},divide:function(b){return new a.Point(this.x/b,this.y/b)},negate:function(){return new a.Point(-this.x,-this.y)},distanceTo:function(a){return Math.sqrt(Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2))},squaredDistanceTo:function(a){return Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2)},apply:function(b){return new a.Point(b(this.x),b(this.y))},equals:function(b){return b instanceof a.Point&&this.x===b.x&&this.y===b.y},rotate:function(b,c){c=c||new a.Point(0,0);var d;var e;if(b%90===0){var f=a.positiveModulo(b,360);switch(f){case 0:d=1;e=0;break;case 90:d=0;e=1;break;case 180:d=-1;e=0;break;case 270:d=0;e=-1}}else{var g=b*Math.PI/180;d=Math.cos(g);e=Math.sin(g)}var h=d*(this.x-c.x)-e*(this.y-c.y)+c.x;var i=e*(this.x-c.x)+d*(this.y-c.y)+c.y;return new a.Point(h,i)},toString:function(){return"("+Math.round(100*this.x)/100+","+Math.round(100*this.y)/100+")"}}}(OpenSeadragon);!function(a){function b(b){var c,d,e=b.responseText,f=b.status;if(!b)throw new Error(a.getString("Errors.Security"));if(200!==b.status&&0!==b.status){f=b.status;c=404==f?"Not Found":b.statusText;throw new Error(a.getString("Errors.Status",f,c))}if(e.match(/\s*<.*/))try{d=b.responseXML&&b.responseXML.documentElement?b.responseXML:a.parseXml(e)}catch(a){d=b.responseText}else if(e.match(/\s*[\{\[].*/))try{d=a.parseJSON(e)}catch(a){d=e}else d=e;return d}a.TileSource=function(b,c,d,e,f,g){var h=this;var i,j,k=arguments;i=a.isPlainObject(b)?b:{width:k[0],height:k[1],tileSize:k[2],tileOverlap:k[3],minLevel:k[4],maxLevel:k[5]};a.EventSource.call(this);a.extend(!0,this,i);if(!this.success)for(j=0;j<arguments.length;j++)if(a.isFunction(arguments[j])){this.success=arguments[j];break}this.success&&this.addHandler("ready",function(a){h.success(a)});"string"==a.type(arguments[0])&&(this.url=arguments[0]);if(this.url){this.aspectRatio=1;this.dimensions=new a.Point(10,10);this._tileWidth=0;this._tileHeight=0;this.tileOverlap=0;this.minLevel=0;this.maxLevel=0;this.ready=!1;this.getImageInfo(this.url)}else{this.ready=!0;this.aspectRatio=i.width&&i.height?i.width/i.height:1;this.dimensions=new a.Point(i.width,i.height);if(this.tileSize){this._tileWidth=this._tileHeight=this.tileSize;delete this.tileSize}else{if(this.tileWidth){this._tileWidth=this.tileWidth;delete this.tileWidth}else this._tileWidth=0;if(this.tileHeight){this._tileHeight=this.tileHeight;delete this.tileHeight}else this._tileHeight=0}this.tileOverlap=i.tileOverlap?i.tileOverlap:0;this.minLevel=i.minLevel?i.minLevel:0;this.maxLevel=void 0!==i.maxLevel&&null!==i.maxLevel?i.maxLevel:i.width&&i.height?Math.ceil(Math.log(Math.max(i.width,i.height))/Math.log(2)):0;this.success&&a.isFunction(this.success)&&this.success(this)}};a.TileSource.prototype={getTileSize:function(b){a.console.error("[TileSource.getTileSize] is deprecated.Use TileSource.getTileWidth() and TileSource.getTileHeight() instead");return this._tileWidth},getTileWidth:function(a){return this._tileWidth?this._tileWidth:this.getTileSize(a)},getTileHeight:function(a){return this._tileHeight?this._tileHeight:this.getTileSize(a)},getLevelScale:function(a){var b,c={};for(b=0;b<=this.maxLevel;b++)c[b]=1/Math.pow(2,this.maxLevel-b);this.getLevelScale=function(a){return c[a]};return this.getLevelScale(a)},getNumTiles:function(b){var c=this.getLevelScale(b),d=Math.ceil(c*this.dimensions.x/this.getTileWidth(b)),e=Math.ceil(c*this.dimensions.y/this.getTileHeight(b));return new a.Point(d,e)},getPixelRatio:function(b){var c=this.dimensions.times(this.getLevelScale(b)),d=1/c.x,e=1/c.y;return new a.Point(d,e)},getClosestLevel:function(){var a,b;for(a=this.minLevel+1;a<=this.maxLevel;a++){b=this.getNumTiles(a);if(b.x>1||b.y>1)break}return a-1},getTileAtPoint:function(b,c){var d=c.x>=0&&c.x<=1&&c.y>=0&&c.y<=1/this.aspectRatio;a.console.assert(d,"[TileSource.getTileAtPoint] must be called with a valid point.");var e=this.dimensions.x*this.getLevelScale(b);var f=c.x*e;var g=c.y*e;var h=Math.floor(f/this.getTileWidth(b));var i=Math.floor(g/this.getTileHeight(b));c.x>=1&&(h=this.getNumTiles(b).x-1);var j=1e-16;c.y>=1/this.aspectRatio-j&&(i=this.getNumTiles(b).y-1);return new a.Point(h,i)},getTileBounds:function(b,c,d){var e=this.dimensions.times(this.getLevelScale(b)),f=this.getTileWidth(b),g=this.getTileHeight(b),h=0===c?0:f*c-this.tileOverlap,i=0===d?0:g*d-this.tileOverlap,j=f+(0===c?1:2)*this.tileOverlap,k=g+(0===d?1:2)*this.tileOverlap,l=1/e.x;j=Math.min(j,e.x-h);k=Math.min(k,e.y-i);return new a.Rect(h*l,i*l,j*l,k*l)},getImageInfo:function(c){var d,e,f,g,h,i,j,k=this;if(c){h=c.split("/");i=h[h.length-1];j=i.lastIndexOf(".");j>-1&&(h[h.length-1]=i.slice(0,j))}e=function(b){"string"==typeof b&&(b=a.parseXml(b));var d=a.TileSource.determineType(k,b,c);if(d){g=d.prototype.configure.apply(k,[b,c]);void 0===g.ajaxWithCredentials&&(g.ajaxWithCredentials=k.ajaxWithCredentials);f=new d(g);k.ready=!0;k.raiseEvent("ready",{tileSource:f})}else k.raiseEvent("open-failed",{message:"Unable to load TileSource",source:c})};if(c.match(/\.js$/)){d=c.split("/").pop().replace(".js","");a.jsonp({url:c,async:!1,callbackName:d,callback:e})}else a.makeAjaxRequest({url:c,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(a){var c=b(a);e(c)},error:function(a,b){var d;try{d="HTTP "+a.status+" attempting to load TileSource"}catch(a){var e;e="undefined"!=typeof b&&b.toString?b.toString():"Unknown error";d=e+" attempting to load TileSource"}k.raiseEvent("open-failed",{message:d,source:c})}})},supports:function(a,b){return!1},configure:function(a,b){throw new Error("Method not implemented.")},getTileUrl:function(a,b,c){throw new Error("Method not implemented.")},getTileAjaxHeaders:function(a,b,c){return{}},tileExists:function(a,b,c){var d=this.getNumTiles(a);return a>=this.minLevel&&a<=this.maxLevel&&b>=0&&c>=0&&b<d.x&&c<d.y}};a.extend(!0,a.TileSource.prototype,a.EventSource.prototype);a.TileSource.determineType=function(b,c,d){var e;for(e in OpenSeadragon)if(e.match(/.+TileSource$/)&&a.isFunction(OpenSeadragon[e])&&a.isFunction(OpenSeadragon[e].prototype.supports)&&OpenSeadragon[e].prototype.supports.call(b,c,d))return OpenSeadragon[e];a.console.error("No TileSource was able to open %s %s",d,c)}}(OpenSeadragon);!function(a){function b(b,d){if(!d||!d.documentElement)throw new Error(a.getString("Errors.Xml"));var e,f,g,h,i,j=d.documentElement,k=j.localName||j.tagName,l=d.documentElement.namespaceURI,m=null,n=[];if("Image"==k)try{h=j.getElementsByTagName("Size")[0];void 0===h&&(h=j.getElementsByTagNameNS(l,"Size")[0]);m={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:j.getAttribute("Url"),Format:j.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(j.getAttribute("Overlap"),10),TileSize:parseInt(j.getAttribute("TileSize"),10),Size:{Height:parseInt(h.getAttribute("Height"),10),Width:parseInt(h.getAttribute("Width"),10)}}};if(!a.imageFormatSupported(m.Image.Format))throw new Error(a.getString("Errors.ImageFormat",m.Image.Format.toUpperCase()));e=j.getElementsByTagName("DisplayRect");void 0===e&&(e=j.getElementsByTagNameNS(l,"DisplayRect")[0]);for(i=0;i<e.length;i++){f=e[i];g=f.getElementsByTagName("Rect")[0];void 0===g&&(g=f.getElementsByTagNameNS(l,"Rect")[0]);n.push({Rect:{X:parseInt(g.getAttribute("X"),10),Y:parseInt(g.getAttribute("Y"),10),Width:parseInt(g.getAttribute("Width"),10),Height:parseInt(g.getAttribute("Height"),10),MinLevel:parseInt(f.getAttribute("MinLevel"),10),MaxLevel:parseInt(f.getAttribute("MaxLevel"),10)}})}n.length&&(m.Image.DisplayRect=n);return c(b,m)}catch(b){throw b instanceof Error?b:new Error(a.getString("Errors.Dzi"))}else{if("Collection"==k)throw new Error(a.getString("Errors.Dzc"));if("Error"==k){var o=j.getElementsByTagName("Message")[0];var p=o.firstChild.nodeValue;throw new Error(p)}}throw new Error(a.getString("Errors.Dzi"))}function c(b,c){var d,e,f=c.Image,g=f.Url,h=f.Format,i=f.Size,j=f.DisplayRect||[],k=parseInt(i.Width,10),l=parseInt(i.Height,10),m=parseInt(f.TileSize,10),n=parseInt(f.Overlap,10),o=[];for(e=0;e<j.length;e++){d=j[e].Rect;o.push(new a.DisplayRect(parseInt(d.X,10),parseInt(d.Y,10),parseInt(d.Width,10),parseInt(d.Height,10),parseInt(d.MinLevel,10),parseInt(d.MaxLevel,10)))}return a.extend(!0,{width:k,height:l,tileSize:m,tileOverlap:n,minLevel:null,maxLevel:null,tilesUrl:g,fileFormat:h,displayRects:o},c)}a.DziTileSource=function(b,c,d,e,f,g,h,i,j){var k,l,m,n;n=a.isPlainObject(b)?b:{width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4],fileFormat:arguments[5],displayRects:arguments[6],minLevel:arguments[7],maxLevel:arguments[8]};this._levelRects={};this.tilesUrl=n.tilesUrl;this.fileFormat=n.fileFormat;this.displayRects=n.displayRects;if(this.displayRects)for(k=this.displayRects.length-1;k>=0;k--){l=this.displayRects[k];for(m=l.minLevel;m<=l.maxLevel;m++){this._levelRects[m]||(this._levelRects[m]=[]);this._levelRects[m].push(l)}}a.TileSource.apply(this,[n])};a.extend(a.DziTileSource.prototype,a.TileSource.prototype,{supports:function(a,b){var c;a.Image?c=a.Image.xmlns:a.documentElement&&("Image"!=a.documentElement.localName&&"Image"!=a.documentElement.tagName||(c=a.documentElement.namespaceURI));c=(c||"").toLowerCase();return c.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||c.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(d,e){var f;f=a.isPlainObject(d)?c(this,d):b(this,d);if(e&&!f.tilesUrl){f.tilesUrl=e.replace(/([^\/]+?)(\.(dzi|xml|js)?(\?[^\/]*)?)?\/?$/,"$1_files/");e.search(/\.(dzi|xml|js)\?/)!=-1?f.queryParams=e.match(/\?.*/):f.queryParams=""}return f},getTileUrl:function(a,b,c){return[this.tilesUrl,a,"/",b,"_",c,".",this.fileFormat,this.queryParams].join("")},tileExists:function(a,b,c){var d,e,f,g,h,i,j,k=this._levelRects[a];if(!k||!k.length)return!0;for(j=k.length-1;j>=0;j--){d=k[j];if(!(a<d.minLevel||a>d.maxLevel)){e=this.getLevelScale(a);f=d.x*e;g=d.y*e;h=f+d.width*e;i=g+d.height*e;f=Math.floor(f/this._tileWidth);g=Math.floor(g/this._tileWidth);h=Math.ceil(h/this._tileWidth);i=Math.ceil(i/this._tileWidth);if(f<=b&&b<h&&g<=c&&c<i)return!0}}return!1}})}(OpenSeadragon);!function(a){function b(a){var b=["http://library.stanford.edu/iiif/image-api/compliance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0","http://iiif.io/api/image/2/level0.json"];var c=b.indexOf(a[0])!=-1;return!c||a.indexOf("sizeByW")!=-1}function c(a){var b=[];for(var c=0;c<a.sizes.length;c++)b.push({url:a["@id"]+"/full/"+a.sizes[c].width+",/0/default.jpg",width:a.sizes[c].width,height:a.sizes[c].height});return b.sort(function(a,b){return a.width-b.width})}function d(b){if(!b||!b.documentElement)throw new Error(a.getString("Errors.Xml"));var c=b.documentElement,d=c.tagName,f=null;if("info"==d)try{f={};e(c,f);return f}catch(b){throw b instanceof Error?b:new Error(a.getString("Errors.IIIF"))}throw new Error(a.getString("Errors.IIIF"))}function e(b,c,d){var f,g;if(3==b.nodeType&&d){g=b.nodeValue.trim();g.match(/^\d*$/)&&(g=Number(g));if(c[d]){a.isArray(c[d])||(c[d]=[c[d]]);c[d].push(g)}else c[d]=g}else if(1==b.nodeType)for(f=0;f<b.childNodes.length;f++)e(b.childNodes[f],c,b.nodeName)}a.IIIFTileSource=function(d){a.extend(!0,this,d);if(!(this.height&&this.width&&this["@id"]))throw new Error("IIIF required parameters not provided.");d.tileSizePerScaleFactor={};if(this.tile_width&&this.tile_height){d.tileWidth=this.tile_width;d.tileHeight=this.tile_height}else if(this.tile_width)d.tileSize=this.tile_width;else if(this.tile_height)d.tileSize=this.tile_height;else if(this.tiles)if(1==this.tiles.length){d.tileWidth=this.tiles[0].width;d.tileHeight=this.tiles[0].height||this.tiles[0].width;this.scale_factors=this.tiles[0].scaleFactors}else{this.scale_factors=[];for(var e=0;e<this.tiles.length;e++)for(var f=0;f<this.tiles[e].scaleFactors.length;f++){var g=this.tiles[e].scaleFactors[f];this.scale_factors.push(g);d.tileSizePerScaleFactor[g]={width:this.tiles[e].width,height:this.tiles[e].height||this.tiles[e].width}}}else if(b(d.profile)){var h=Math.min(this.height,this.width),i=[256,512,1024],j=[];for(var k=0;k<i.length;k++)i[k]<=h&&j.push(i[k]);j.length>0?d.tileSize=Math.max.apply(null,j):d.tileSize=h}else if(this.sizes&&this.sizes.length>0){this.emulateLegacyImagePyramid=!0;d.levels=c(this);a.extend(!0,d,{width:d.levels[d.levels.length-1].width,height:d.levels[d.levels.length-1].height,tileSize:Math.max(d.height,d.width),tileOverlap:0,minLevel:0,maxLevel:d.levels.length-1});this.levels=d.levels}else a.console.error("Nothing in the info.json to construct image pyramids from");d.maxLevel||this.emulateLegacyImagePyramid||(this.scale_factors?d.maxLevel=Math.floor(Math.pow(Math.max.apply(null,this.scale_factors),.5)):d.maxLevel=Number(Math.ceil(Math.log(Math.max(this.width,this.height),2))));a.TileSource.apply(this,[d])};a.extend(a.IIIFTileSource.prototype,a.TileSource.prototype,{supports:function(a,b){return!(!a.protocol||"http://iiif.io/api/image"!=a.protocol)||(!(!a["@context"]||"http://library.stanford.edu/iiif/image-api/1.1/context.json"!=a["@context"]&&"http://iiif.io/api/image/1/context.json"!=a["@context"])||(!(!a.profile||0!==a.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html"))||(!!(a.identifier&&a.width&&a.height)||!(!a.documentElement||"info"!=a.documentElement.tagName||"http://library.stanford.edu/iiif/image-api/ns/"!=a.documentElement.namespaceURI))))},configure:function(b,c){if(a.isPlainObject(b)){if(b["@context"])return b;b["@context"]="http://iiif.io/api/image/1.0/context.json";b["@id"]=c.replace("/info.json","");return b}var e=d(b);e["@context"]="http://iiif.io/api/image/1.0/context.json";e["@id"]=c.replace("/info.xml","");return e},getTileWidth:function(b){if(this.emulateLegacyImagePyramid)return a.TileSource.prototype.getTileWidth.call(this,b);var c=Math.pow(2,this.maxLevel-b);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[c]?this.tileSizePerScaleFactor[c].width:this._tileWidth},getTileHeight:function(b){if(this.emulateLegacyImagePyramid)return a.TileSource.prototype.getTileHeight.call(this,b);var c=Math.pow(2,this.maxLevel-b);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[c]?this.tileSizePerScaleFactor[c].height:this._tileHeight},getLevelScale:function(b){if(this.emulateLegacyImagePyramid){var c=NaN;this.levels.length>0&&b>=this.minLevel&&b<=this.maxLevel&&(c=this.levels[b].width/this.levels[this.maxLevel].width);return c}return a.TileSource.prototype.getLevelScale.call(this,b)},getNumTiles:function(b){if(this.emulateLegacyImagePyramid){var c=this.getLevelScale(b);return c?new a.Point(1,1):new a.Point(0,0)}return a.TileSource.prototype.getNumTiles.call(this,b)},getTileAtPoint:function(b,c){return this.emulateLegacyImagePyramid?new a.Point(0,0):a.TileSource.prototype.getTileAtPoint.call(this,b,c)},getTileUrl:function(a,b,c){if(this.emulateLegacyImagePyramid){var d=null;this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(d=this.levels[a].url);return d}var e,f,g,h,i,j,k,l,m,n,o,p,q="0",r=Math.pow(.5,this.maxLevel-a),s=Math.ceil(this.width*r),t=Math.ceil(this.height*r);e=this.getTileWidth(a);f=this.getTileHeight(a);g=Math.ceil(e/r);h=Math.ceil(f/r);o=this["@context"].indexOf("/1.0/context.json")>-1||this["@context"].indexOf("/1.1/context.json")>-1||this["@context"].indexOf("/1/context.json")>-1?"native.jpg":"default.jpg";if(s<e&&t<f){n=s+",";i="full"}else{j=b*g;k=c*h;l=Math.min(g,this.width-j);m=Math.min(h,this.height-k);n=Math.ceil(l*r)+",";i=[j,k,l,m].join(",")}p=[this["@id"],i,n,q,o].join("/");return p}})}(OpenSeadragon);!function(a){a.OsmTileSource=function(b,c,d,e,f){var g;g=a.isPlainObject(b)?b:{width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};if(!g.width||!g.height){g.width=65572864;g.height=65572864}if(!g.tileSize){g.tileSize=256;g.tileOverlap=0}g.tilesUrl||(g.tilesUrl="http://tile.openstreetmap.org/");g.minLevel=8;a.TileSource.apply(this,[g])};a.extend(a.OsmTileSource.prototype,a.TileSource.prototype,{supports:function(a,b){return a.type&&"openstreetmaps"==a.type},configure:function(a,b){return a},getTileUrl:function(a,b,c){return this.tilesUrl+(a-8)+"/"+b+"/"+c+".png"}})}(OpenSeadragon);!function(a){a.TmsTileSource=function(b,c,d,e,f){var g;g=a.isPlainObject(b)?b:{width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var h,i=256*Math.ceil(g.width/256),j=256*Math.ceil(g.height/256);h=i>j?i/256:j/256;g.maxLevel=Math.ceil(Math.log(h)/Math.log(2))-1;g.tileSize=256;g.width=i;g.height=j;a.TileSource.apply(this,[g])};a.extend(a.TmsTileSource.prototype,a.TileSource.prototype,{supports:function(a,b){return a.type&&"tiledmapservice"==a.type},configure:function(a,b){return a},getTileUrl:function(a,b,c){var d=this.getNumTiles(a).y-1;return this.tilesUrl+a+"/"+b+"/"+(d-c)+".png"}})}(OpenSeadragon);!function(a){a.ZoomifyTileSource=function(a){a.tileSize=256;var b={x:a.width,y:a.height};a.imageSizes=[{x:a.width,y:a.height}];a.gridSize=[this._getGridSize(a.width,a.height,a.tileSize)];for(;parseInt(b.x,10)>a.tileSize||parseInt(b.y,10)>a.tileSize;){b.x=Math.floor(b.x/2);b.y=Math.floor(b.y/2);a.imageSizes.push({x:b.x,y:b.y});a.gridSize.push(this._getGridSize(b.x,b.y,a.tileSize))}a.imageSizes.reverse();a.gridSize.reverse();a.minLevel=0;a.maxLevel=a.gridSize.length-1;OpenSeadragon.TileSource.apply(this,[a])};a.extend(a.ZoomifyTileSource.prototype,a.TileSource.prototype,{_getGridSize:function(a,b,c){return{x:Math.ceil(a/c),y:Math.ceil(b/c)}},_calculateAbsoluteTileNumber:function(a,b,c){var d=0;var e={};for(var f=0;f<a;f++){e=this.gridSize[f];d+=e.x*e.y}e=this.gridSize[a];d+=e.x*c+b;return d},supports:function(a,b){return a.type&&"zoomifytileservice"==a.type},configure:function(a,b){return a},getTileUrl:function(a,b,c){var d=0;var e=this._calculateAbsoluteTileNumber(a,b,c);d=Math.floor(e/256);return this.tilesUrl+"TileGroup"+d+"/"+a+"-"+b+"-"+c+".jpg"}})}(OpenSeadragon);!function(a){function b(b){var c,d,e=[];for(d=0;d<b.length;d++){c=b[d];c.height&&c.width&&c.url?e.push({url:c.url,width:Number(c.width),height:Number(c.height)}):a.console.error("Unsupported image format: %s",c.url?c.url:"<no URL>")}return e.sort(function(a,b){return a.height-b.height})}function c(b,c){if(!c||!c.documentElement)throw new Error(a.getString("Errors.Xml"));var e,f,g=c.documentElement,h=g.tagName,i=null,j=[];if("image"==h)try{i={type:g.getAttribute("type"),levels:[]};j=g.getElementsByTagName("level");for(f=0;f<j.length;f++){e=j[f];i.levels.push({url:e.getAttribute("url"),width:parseInt(e.getAttribute("width"),10),height:parseInt(e.getAttribute("height"),10)})}return d(b,i)}catch(a){throw a instanceof Error?a:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if("collection"==h)throw new Error("Legacy Image Pyramid Collections not yet supported.");if("error"==h)throw new Error("Error: "+c)}throw new Error("Unknown element "+h)}function d(a,b){return b.levels}a.LegacyTileSource=function(c){var d,e,f;a.isArray(c)&&(d={type:"legacy-image-pyramid",levels:c});d.levels=b(d.levels);if(d.levels.length>0){e=d.levels[d.levels.length-1].width;f=d.levels[d.levels.length-1].height}else{e=0;f=0;a.console.error("No supported image formats found")}a.extend(!0,d,{width:e,height:f,tileSize:Math.max(f,e),tileOverlap:0,minLevel:0,maxLevel:d.levels.length>0?d.levels.length-1:0});a.TileSource.apply(this,[d]);this.levels=d.levels};a.extend(a.LegacyTileSource.prototype,a.TileSource.prototype,{supports:function(a,b){return a.type&&"legacy-image-pyramid"==a.type||a.documentElement&&"legacy-image-pyramid"==a.documentElement.getAttribute("type")},configure:function(b,e){var f;f=a.isPlainObject(b)?d(this,b):c(this,b);return f},getLevelScale:function(a){var b=NaN;this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].width/this.levels[this.maxLevel].width);return b},getNumTiles:function(b){var c=this.getLevelScale(b);return c?new a.Point(1,1):new a.Point(0,0)},getTileUrl:function(a,b,c){var d=null;this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(d=this.levels[a].url);return d}})}(OpenSeadragon);!function(a){a.ImageTileSource=function(b){b=a.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1,useCanvas:!0},b);a.TileSource.apply(this,[b])};a.extend(a.ImageTileSource.prototype,a.TileSource.prototype,{supports:function(a,b){return a.type&&"image"===a.type},configure:function(a,b){return a},getImageInfo:function(b){var c=this._image=new Image;var d=this;this.crossOriginPolicy&&(c.crossOrigin=this.crossOriginPolicy);this.ajaxWithCredentials&&(c.useCredentials=this.ajaxWithCredentials);a.addEvent(c,"load",function(){d.width=Object.prototype.hasOwnProperty.call(c,"naturalWidth")?c.naturalWidth:c.width;d.height=Object.prototype.hasOwnProperty.call(c,"naturalHeight")?c.naturalHeight:c.height;d.aspectRatio=d.width/d.height;d.dimensions=new a.Point(d.width,d.height);d._tileWidth=d.width;d._tileHeight=d.height;
d.tileOverlap=0;d.minLevel=0;d.levels=d._buildLevels();d.maxLevel=d.levels.length-1;d.ready=!0;d.raiseEvent("ready",{tileSource:d})});a.addEvent(c,"error",function(){d.raiseEvent("open-failed",{message:"Error loading image at "+b,source:b})});c.src=b},getLevelScale:function(a){var b=NaN;a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].width/this.levels[this.maxLevel].width);return b},getNumTiles:function(b){var c=this.getLevelScale(b);return c?new a.Point(1,1):new a.Point(0,0)},getTileUrl:function(a,b,c){var d=null;a>=this.minLevel&&a<=this.maxLevel&&(d=this.levels[a].url);return d},getContext2D:function(a,b,c){var d=null;a>=this.minLevel&&a<=this.maxLevel&&(d=this.levels[a].context2D);return d},_buildLevels:function(){var b=[{url:this._image.src,width:Object.prototype.hasOwnProperty.call(this._image,"naturalWidth")?this._image.naturalWidth:this._image.width,height:Object.prototype.hasOwnProperty.call(this._image,"naturalHeight")?this._image.naturalHeight:this._image.height}];if(!this.buildPyramid||!a.supportsCanvas||!this.useCanvas){delete this._image;return b}var c=Object.prototype.hasOwnProperty.call(this._image,"naturalWidth")?this._image.naturalWidth:this._image.width;var d=Object.prototype.hasOwnProperty.call(this._image,"naturalHeight")?this._image.naturalHeight:this._image.height;var e=document.createElement("canvas");var f=e.getContext("2d");e.width=c;e.height=d;f.drawImage(this._image,0,0,c,d);b[0].context2D=f;delete this._image;if(a.isCanvasTainted(e))return b;for(;c>=2&&d>=2;){c=Math.floor(c/2);d=Math.floor(d/2);var g=document.createElement("canvas");var h=g.getContext("2d");g.width=c;g.height=d;h.drawImage(e,0,0,c,d);b.splice(0,0,{context2D:h,width:c,height:d});e=g;f=h}return b}})}(OpenSeadragon);!function(a){a.TileSourceCollection=function(b,c,d,e){a.console.error("TileSourceCollection is deprecated; use World instead")}}(OpenSeadragon);!function(a){function b(b){a.requestAnimationFrame(function(){c(b)})}function c(c){var d,e,f;if(c.shouldFade){d=a.now();e=d-c.fadeBeginTime;f=1-e/c.fadeLength;f=Math.min(1,f);f=Math.max(0,f);c.imgGroup&&a.setElementOpacity(c.imgGroup,f,!0);f>0&&b(c)}}function d(c){c.shouldFade=!0;c.fadeBeginTime=a.now()+c.fadeDelay;window.setTimeout(function(){b(c)},c.fadeDelay)}function e(b){b.shouldFade=!1;b.imgGroup&&a.setElementOpacity(b.imgGroup,1,!0)}function f(b,c){if(!b.element.disabled){if(c>=a.ButtonState.GROUP&&b.currentState==a.ButtonState.REST){e(b);b.currentState=a.ButtonState.GROUP}if(c>=a.ButtonState.HOVER&&b.currentState==a.ButtonState.GROUP){b.imgHover&&(b.imgHover.style.visibility="");b.currentState=a.ButtonState.HOVER}if(c>=a.ButtonState.DOWN&&b.currentState==a.ButtonState.HOVER){b.imgDown&&(b.imgDown.style.visibility="");b.currentState=a.ButtonState.DOWN}}}function g(b,c){if(!b.element.disabled){if(c<=a.ButtonState.HOVER&&b.currentState==a.ButtonState.DOWN){b.imgDown&&(b.imgDown.style.visibility="hidden");b.currentState=a.ButtonState.HOVER}if(c<=a.ButtonState.GROUP&&b.currentState==a.ButtonState.HOVER){b.imgHover&&(b.imgHover.style.visibility="hidden");b.currentState=a.ButtonState.GROUP}if(c<=a.ButtonState.REST&&b.currentState==a.ButtonState.GROUP){d(b);b.currentState=a.ButtonState.REST}}}a.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3};a.Button=function(b){var c=this;a.EventSource.call(this);a.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:a.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:a.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null},b);this.element=b.element||a.makeNeutralElement("div");if(!b.element){this.imgRest=a.makeTransparentImage(this.srcRest);this.imgGroup=a.makeTransparentImage(this.srcGroup);this.imgHover=a.makeTransparentImage(this.srcHover);this.imgDown=a.makeTransparentImage(this.srcDown);this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip;this.element.style.position="relative";a.setElementTouchActionNone(this.element);this.imgGroup.style.position=this.imgHover.style.position=this.imgDown.style.position="absolute";this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top="0px";this.imgGroup.style.left=this.imgHover.style.left=this.imgDown.style.left="0px";this.imgHover.style.visibility=this.imgDown.style.visibility="hidden";a.Browser.vendor==a.BROWSERS.FIREFOX&&a.Browser.version<3&&(this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top="");this.element.appendChild(this.imgRest);this.element.appendChild(this.imgGroup);this.element.appendChild(this.imgHover);this.element.appendChild(this.imgDown)}this.addHandler("press",this.onPress);this.addHandler("release",this.onRelease);this.addHandler("click",this.onClick);this.addHandler("enter",this.onEnter);this.addHandler("exit",this.onExit);this.addHandler("focus",this.onFocus);this.addHandler("blur",this.onBlur);this.currentState=a.ButtonState.GROUP;this.fadeBeginTime=null;this.shouldFade=!1;this.element.style.display="inline-block";this.element.style.position="relative";this.element.title=this.tooltip;this.tracker=new a.MouseTracker({element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(b){if(b.insideElementPressed){f(c,a.ButtonState.DOWN);c.raiseEvent("enter",{originalEvent:b.originalEvent})}else b.buttonDownAny||f(c,a.ButtonState.HOVER)},focusHandler:function(a){this.enterHandler(a);c.raiseEvent("focus",{originalEvent:a.originalEvent})},exitHandler:function(b){g(c,a.ButtonState.GROUP);b.insideElementPressed&&c.raiseEvent("exit",{originalEvent:b.originalEvent})},blurHandler:function(a){this.exitHandler(a);c.raiseEvent("blur",{originalEvent:a.originalEvent})},pressHandler:function(b){f(c,a.ButtonState.DOWN);c.raiseEvent("press",{originalEvent:b.originalEvent})},releaseHandler:function(b){if(b.insideElementPressed&&b.insideElementReleased){g(c,a.ButtonState.HOVER);c.raiseEvent("release",{originalEvent:b.originalEvent})}else b.insideElementPressed?g(c,a.ButtonState.GROUP):f(c,a.ButtonState.HOVER)},clickHandler:function(a){a.quick&&c.raiseEvent("click",{originalEvent:a.originalEvent})},keyHandler:function(a){if(13===a.keyCode){c.raiseEvent("click",{originalEvent:a.originalEvent});c.raiseEvent("release",{originalEvent:a.originalEvent});return!1}return!0}});g(this,a.ButtonState.REST)};a.extend(a.Button.prototype,a.EventSource.prototype,{notifyGroupEnter:function(){f(this,a.ButtonState.GROUP)},notifyGroupExit:function(){g(this,a.ButtonState.REST)},disable:function(){this.notifyGroupExit();this.element.disabled=!0;a.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1;a.setElementOpacity(this.element,1,!0);this.notifyGroupEnter()}})}(OpenSeadragon);!function(a){a.ButtonGroup=function(b){a.extend(!0,this,{buttons:[],clickTimeThreshold:a.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:a.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},b);var c,d=this.buttons.concat([]),e=this;this.element=b.element||a.makeNeutralElement("div");if(!b.group){this.label=a.makeNeutralElement("label");this.element.style.display="inline-block";this.element.appendChild(this.label);for(c=0;c<d.length;c++)this.element.appendChild(d[c].element)}a.setElementTouchActionNone(this.element);this.tracker=new a.MouseTracker({element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(a){var b;for(b=0;b<e.buttons.length;b++)e.buttons[b].notifyGroupEnter()},exitHandler:function(a){var b;if(!a.insideElementPressed)for(b=0;b<e.buttons.length;b++)e.buttons[b].notifyGroupExit()}})};a.ButtonGroup.prototype={emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateExit:function(){this.tracker.exitHandler({eventSource:this.tracker})}}}(OpenSeadragon);!function(a){a.Rect=function(b,c,d,e,f){this.x="number"==typeof b?b:0;this.y="number"==typeof c?c:0;this.width="number"==typeof d?d:0;this.height="number"==typeof e?e:0;this.degrees="number"==typeof f?f:0;this.degrees=a.positiveModulo(this.degrees,360);var g,h;if(this.degrees>=270){g=this.getTopRight();this.x=g.x;this.y=g.y;h=this.height;this.height=this.width;this.width=h;this.degrees-=270}else if(this.degrees>=180){g=this.getBottomRight();this.x=g.x;this.y=g.y;this.degrees-=180}else if(this.degrees>=90){g=this.getBottomLeft();this.x=g.x;this.y=g.y;h=this.height;this.height=this.width;this.width=h;this.degrees-=90}};a.Rect.fromSummits=function(b,c,d){var e=b.distanceTo(c);var f=b.distanceTo(d);var g=c.minus(b);var h=Math.atan(g.y/g.x);g.x<0?h+=Math.PI:g.y<0&&(h+=2*Math.PI);return new a.Rect(b.x,b.y,e,f,h/Math.PI*180)};a.Rect.prototype={clone:function(){return new a.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new a.Point(this.x,this.y)},getBottomRight:function(){return new a.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new a.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new a.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new a.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new a.Point(this.width,this.height)},equals:function(b){return b instanceof a.Rect&&this.x===b.x&&this.y===b.y&&this.width===b.width&&this.height===b.height&&this.degrees===b.degrees},times:function(b){return new a.Rect(this.x*b,this.y*b,this.width*b,this.height*b,this.degrees)},translate:function(b){return new a.Rect(this.x+b.x,this.y+b.y,this.width,this.height,this.degrees)},union:function(b){var c=this.getBoundingBox();var d=b.getBoundingBox();var e=Math.min(c.x,d.x);var f=Math.min(c.y,d.y);var g=Math.max(c.x+c.width,d.x+d.width);var h=Math.max(c.y+c.height,d.y+d.height);return new a.Rect(e,f,g-e,h-f)},intersection:function(b){function c(b,c,e,f){var g=c.minus(b);var h=f.minus(e);var i=-h.x*g.y+g.x*h.y;if(0===i)return null;var j=(g.x*(b.y-e.y)-g.y*(b.x-e.x))/i;var k=(h.x*(b.y-e.y)-h.y*(b.x-e.x))/i;return-d<=j&&j<=1-d&&-d<=k&&k<=1-d?new a.Point(b.x+k*g.x,b.y+k*g.y):null}var d=1e-10;var e=[];var f=this.getTopLeft();b.containsPoint(f,d)&&e.push(f);var g=this.getTopRight();b.containsPoint(g,d)&&e.push(g);var h=this.getBottomLeft();b.containsPoint(h,d)&&e.push(h);var i=this.getBottomRight();b.containsPoint(i,d)&&e.push(i);var j=b.getTopLeft();this.containsPoint(j,d)&&e.push(j);var k=b.getTopRight();this.containsPoint(k,d)&&e.push(k);var l=b.getBottomLeft();this.containsPoint(l,d)&&e.push(l);var m=b.getBottomRight();this.containsPoint(m,d)&&e.push(m);var n=this._getSegments();var o=b._getSegments();for(var p=0;p<n.length;p++){var q=n[p];for(var r=0;r<o.length;r++){var s=o[r];var t=c(q[0],q[1],s[0],s[1]);t&&e.push(t)}}if(0===e.length)return null;var u=e[0].x;var v=e[0].x;var w=e[0].y;var x=e[0].y;for(var y=1;y<e.length;y++){var z=e[y];z.x<u&&(u=z.x);z.x>v&&(v=z.x);z.y<w&&(w=z.y);z.y>x&&(x=z.y)}return new a.Rect(u,w,v-u,x-w)},_getSegments:function(){var a=this.getTopLeft();var b=this.getTopRight();var c=this.getBottomLeft();var d=this.getBottomRight();return[[a,b],[b,d],[d,c],[c,a]]},rotate:function(b,c){b=a.positiveModulo(b,360);if(0===b)return this.clone();c=c||this.getCenter();var d=this.getTopLeft().rotate(b,c);var e=this.getTopRight().rotate(b,c);var f=e.minus(d);f=f.apply(function(a){var b=1e-15;return Math.abs(a)<b?0:a});var g=Math.atan(f.y/f.x);f.x<0?g+=Math.PI:f.y<0&&(g+=2*Math.PI);return new a.Rect(d.x,d.y,this.width,this.height,g/Math.PI*180)},getBoundingBox:function(){if(0===this.degrees)return this.clone();var b=this.getTopLeft();var c=this.getTopRight();var d=this.getBottomLeft();var e=this.getBottomRight();var f=Math.min(b.x,c.x,d.x,e.x);var g=Math.max(b.x,c.x,d.x,e.x);var h=Math.min(b.y,c.y,d.y,e.y);var i=Math.max(b.y,c.y,d.y,e.y);return new a.Rect(f,h,g-f,i-h)},getIntegerBoundingBox:function(){var b=this.getBoundingBox();var c=Math.floor(b.x);var d=Math.floor(b.y);var e=Math.ceil(b.width+b.x-c);var f=Math.ceil(b.height+b.y-d);return new a.Rect(c,d,e,f)},containsPoint:function(a,b){b=b||0;var c=this.getTopLeft();var d=this.getTopRight();var e=this.getBottomLeft();var f=d.minus(c);var g=e.minus(c);return(a.x-c.x)*f.x+(a.y-c.y)*f.y>=-b&&(a.x-d.x)*f.x+(a.y-d.y)*f.y<=b&&(a.x-c.x)*g.x+(a.y-c.y)*g.y>=-b&&(a.x-e.x)*g.x+(a.y-e.y)*g.y<=b},toString:function(){return"["+Math.round(100*this.x)/100+", "+Math.round(100*this.y)/100+", "+Math.round(100*this.width)/100+"x"+Math.round(100*this.height)/100+", "+Math.round(100*this.degrees)/100+"deg]"}}}(OpenSeadragon);!function(a){function b(b){var c=Number(this.element.style.marginLeft.replace("px","")),e=Number(this.element.style.marginTop.replace("px","")),f=Number(this.element.style.width.replace("px","")),g=Number(this.element.style.height.replace("px","")),h=a.getElementSize(this.viewer.canvas);this.dragging=!0;if(this.element)if("horizontal"==this.scroll){if(-b.delta.x>0){if(c>-(f-h.x)){this.element.style.marginLeft=c+2*b.delta.x+"px";d(this,h.x,c+2*b.delta.x)}}else if(-b.delta.x<0&&c<0){this.element.style.marginLeft=c+2*b.delta.x+"px";d(this,h.x,c+2*b.delta.x)}}else if(-b.delta.y>0){if(e>-(g-h.y)){this.element.style.marginTop=e+2*b.delta.y+"px";d(this,h.y,e+2*b.delta.y)}}else if(-b.delta.y<0&&e<0){this.element.style.marginTop=e+2*b.delta.y+"px";d(this,h.y,e+2*b.delta.y)}return!1}function c(b){var c=Number(this.element.style.marginLeft.replace("px","")),e=Number(this.element.style.marginTop.replace("px","")),f=Number(this.element.style.width.replace("px","")),g=Number(this.element.style.height.replace("px","")),h=a.getElementSize(this.viewer.canvas);if(this.element)if("horizontal"==this.scroll){if(b.scroll>0){if(c>-(f-h.x)){this.element.style.marginLeft=c-60*b.scroll+"px";d(this,h.x,c-60*b.scroll)}}else if(b.scroll<0&&c<0){this.element.style.marginLeft=c-60*b.scroll+"px";d(this,h.x,c-60*b.scroll)}}else if(b.scroll<0){if(e>h.y-g){this.element.style.marginTop=e+60*b.scroll+"px";d(this,h.y,e+60*b.scroll)}}else if(b.scroll>0&&e<0){this.element.style.marginTop=e+60*b.scroll+"px";d(this,h.y,e+60*b.scroll)}return!1}function d(b,c,d){var e,f,g,h,i,j,k;e="horizontal"==b.scroll?b.panelWidth:b.panelHeight;f=Math.ceil(c/e)+5;g=Math.ceil((Math.abs(d)+c)/e)+1;f=g-f;f=f<0?0:f;for(j=f;j<g&&j<b.panels.length;j++){k=b.panels[j];if(!k.activePanel){var l;var m=b.viewer.tileSources[j];l=m.referenceStripThumbnailUrl?{type:"image",url:m.referenceStripThumbnailUrl}:m;h=new a.Viewer({id:k.id,tileSources:[l],element:k,navigatorSizeRatio:b.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0});h.displayRegion=a.makeNeutralElement("div");h.displayRegion.id=k.id+"-displayregion";h.displayRegion.className="displayregion";i=h.displayRegion.style;i.position="relative";i.top="0px";i.left="0px";i.fontSize="0px";i.overflow="hidden";i.float="left";i.cssFloat="left";i.styleFloat="left";i.zIndex=999999999;i.cursor="default";i.width=b.panelWidth-4+"px";i.height=b.panelHeight-4+"px";h.displayRegion.innerTracker=new a.MouseTracker({element:h.displayRegion,startDisabled:!0});k.getElementsByTagName("div")[0].appendChild(h.displayRegion);b.miniViewers[k.id]=h;k.activePanel=!0}}}function e(a){var b=a.eventSource.element;"horizontal"==this.scroll?b.style.marginBottom="0px":b.style.marginLeft="0px";return!1}function f(b){var c=b.eventSource.element;"horizontal"==this.scroll?c.style.marginBottom="-"+a.getElementSize(c).y/2+"px":c.style.marginLeft="-"+a.getElementSize(c).x/2+"px";return!1}function g(a){if(a.preventDefaultAction||a.ctrl||a.alt||a.meta)return!0;switch(a.keyCode){case 38:c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});return!1;case 40:c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});return!1;case 37:c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});return!1;case 39:c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});return!1;default:return!0}}function h(a){if(a.preventDefaultAction||a.ctrl||a.alt||a.meta)return!0;switch(a.keyCode){case 61:c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});return!1;case 45:c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});return!1;case 48:case 119:case 87:c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});return!1;case 115:case 83:c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});return!1;case 97:c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});return!1;case 100:c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});return!1;default:return!0}}var i={};a.ReferenceStrip=function(j){var k,l,m,n=this,o=j.viewer,p=a.getElementSize(o.element);if(!j.id){j.id="referencestrip-"+a.now();this.element=a.makeNeutralElement("div");this.element.id=j.id;this.element.className="referencestrip"}j=a.extend(!0,{sizeRatio:a.DEFAULT_SETTINGS.referenceStripSizeRatio,position:a.DEFAULT_SETTINGS.referenceStripPosition,scroll:a.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:a.DEFAULT_SETTINGS.clickTimeThreshold},j,{element:this.element,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1});a.extend(this,j);i[this.id]={animating:!1};this.minPixelRatio=this.viewer.minPixelRatio;l=this.element.style;l.marginTop="0px";l.marginRight="0px";l.marginBottom="0px";l.marginLeft="0px";l.left="0px";l.bottom="0px";l.border="0px";l.background="#000";l.position="relative";a.setElementTouchActionNone(this.element);a.setElementOpacity(this.element,.8);this.viewer=o;this.innerTracker=new a.MouseTracker({element:this.element,dragHandler:a.delegate(this,b),scrollHandler:a.delegate(this,c),enterHandler:a.delegate(this,e),exitHandler:a.delegate(this,f),keyDownHandler:a.delegate(this,g),keyHandler:a.delegate(this,h)});if(j.width&&j.height){this.element.style.width=j.width+"px";this.element.style.height=j.height+"px";o.addControl(this.element,{anchor:a.ControlAnchor.BOTTOM_LEFT})}else if("horizontal"==j.scroll){this.element.style.width=p.x*j.sizeRatio*o.tileSources.length+12*o.tileSources.length+"px";this.element.style.height=p.y*j.sizeRatio+"px";o.addControl(this.element,{anchor:a.ControlAnchor.BOTTOM_LEFT})}else{this.element.style.height=p.y*j.sizeRatio*o.tileSources.length+12*o.tileSources.length+"px";this.element.style.width=p.x*j.sizeRatio+"px";o.addControl(this.element,{anchor:a.ControlAnchor.TOP_LEFT})}this.panelWidth=p.x*this.sizeRatio+8;this.panelHeight=p.y*this.sizeRatio+8;this.panels=[];this.miniViewers={};for(m=0;m<o.tileSources.length;m++){k=a.makeNeutralElement("div");k.id=this.element.id+"-"+m;k.style.width=n.panelWidth+"px";k.style.height=n.panelHeight+"px";k.style.display="inline";k.style.float="left";k.style.cssFloat="left";k.style.styleFloat="left";k.style.padding="2px";a.setElementTouchActionNone(k);k.innerTracker=new a.MouseTracker({element:k,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,pressHandler:function(b){b.eventSource.dragging=a.now()},releaseHandler:function(b){var c=b.eventSource,d=c.element.id,e=Number(d.split("-")[2]),f=a.now();if(b.insideElementPressed&&b.insideElementReleased&&c.dragging&&f-c.dragging<c.clickTimeThreshold){c.dragging=null;o.goToPage(e)}}});this.element.appendChild(k);k.activePanel=!1;this.panels.push(k)}d(this,"vertical"==this.scroll?p.y:p.x,0);this.setFocus(0)};a.extend(a.ReferenceStrip.prototype,a.EventSource.prototype,a.Viewer.prototype,{setFocus:function(b){var c,f=a.getElement(this.element.id+"-"+b),g=a.getElementSize(this.viewer.canvas),h=Number(this.element.style.width.replace("px","")),i=Number(this.element.style.height.replace("px","")),j=-Number(this.element.style.marginLeft.replace("px","")),k=-Number(this.element.style.marginTop.replace("px",""));if(this.currentSelected!==f){this.currentSelected&&(this.currentSelected.style.background="#000");this.currentSelected=f;this.currentSelected.style.background="#999";if("horizontal"==this.scroll){c=Number(b)*(this.panelWidth+3);if(c>j+g.x-this.panelWidth){c=Math.min(c,h-g.x);this.element.style.marginLeft=-c+"px";d(this,g.x,-c)}else if(c<j){c=Math.max(0,c-g.x/2);this.element.style.marginLeft=-c+"px";d(this,g.x,-c)}}else{c=Number(b)*(this.panelHeight+3);if(c>k+g.y-this.panelHeight){c=Math.min(c,i-g.y);this.element.style.marginTop=-c+"px";d(this,g.y,-c)}else if(c<k){c=Math.max(0,c-g.y/2);this.element.style.marginTop=-c+"px";d(this,g.y,-c)}}this.currentPage=b;e.call(this,{eventSource:this.innerTracker})}},update:function(){if(i[this.id].animating){a.console.log("image reference strip update");return!0}return!1},destroy:function(){if(this.miniViewers)for(var a in this.miniViewers)this.miniViewers[a].destroy();this.element&&this.element.parentNode.removeChild(this.element)}})}(OpenSeadragon);!function(a){a.DisplayRect=function(b,c,d,e,f,g){a.Rect.apply(this,[b,c,d,e]);this.minLevel=f;this.maxLevel=g};a.extend(a.DisplayRect.prototype,a.Rect.prototype)}(OpenSeadragon);!function(a){function b(a,b){return(1-Math.exp(a*-b))/(1-Math.exp(-a))}a.Spring=function(b){var c=arguments;"object"!=typeof b&&(b={initial:c.length&&"number"==typeof c[0]?c[0]:void 0,springStiffness:c.length>1?c[1].springStiffness:5,animationTime:c.length>1?c[1].animationTime:1.5});a.console.assert("number"==typeof b.springStiffness&&0!==b.springStiffness,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number");a.console.assert("number"==typeof b.animationTime&&b.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0");if(b.exponential){this._exponential=!0;delete b.exponential}a.extend(!0,this,b);this.current={value:"number"==typeof this.initial?this.initial:this._exponential?0:1,time:a.now()};a.console.assert(!this._exponential||0!==this.current.value,"[OpenSeadragon.Spring] value must be non-zero for exponential springs");this.start={value:this.current.value,time:this.current.time};this.target={value:this.current.value,time:this.current.time};if(this._exponential){this.start._logValue=Math.log(this.start.value);this.target._logValue=Math.log(this.target.value);this.current._logValue=Math.log(this.current.value)}};a.Spring.prototype={resetTo:function(b){a.console.assert(!this._exponential||0!==b,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs");this.start.value=this.target.value=this.current.value=b;this.start.time=this.target.time=this.current.time=a.now();if(this._exponential){this.start._logValue=Math.log(this.start.value);this.target._logValue=Math.log(this.target.value);this.current._logValue=Math.log(this.current.value)}},springTo:function(b){a.console.assert(!this._exponential||0!==b,"[OpenSeadragon.Spring.springTo] target must be non-zero for exponential springs");this.start.value=this.current.value;this.start.time=this.current.time;this.target.value=b;this.target.time=this.start.time+1e3*this.animationTime;if(this._exponential){this.start._logValue=Math.log(this.start.value);this.target._logValue=Math.log(this.target.value)}},shiftBy:function(b){this.start.value+=b;this.target.value+=b;if(this._exponential){a.console.assert(0!==this.target.value&&0!==this.start.value,"[OpenSeadragon.Spring.shiftBy] spring value must be non-zero for exponential springs");this.start._logValue=Math.log(this.start.value);this.target._logValue=Math.log(this.target.value)}},setExponential:function(b){this._exponential=b;if(this._exponential){a.console.assert(0!==this.current.value&&0!==this.target.value&&0!==this.start.value,"[OpenSeadragon.Spring.setExponential] spring value must be non-zero for exponential springs");this.start._logValue=Math.log(this.start.value);this.target._logValue=Math.log(this.target.value);this.current._logValue=Math.log(this.current.value)}},update:function(){this.current.time=a.now();var c,d;if(this._exponential){c=this.start._logValue;d=this.target._logValue}else{c=this.start.value;d=this.target.value}var e=this.current.time>=this.target.time?d:c+(d-c)*b(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));var f=this.current.value;this._exponential?this.current.value=Math.exp(e):this.current.value=e;return f!=this.current.value},isAtTargetValue:function(){return this.current.value===this.target.value}}}(OpenSeadragon);!function(a){function b(b){a.extend(!0,this,{timeout:a.DEFAULT_SETTINGS.timeout,jobId:null},b);this.image=null}function c(a,b,c){var d;a.jobsInProgress--;if((!a.jobLimit||a.jobsInProgress<a.jobLimit)&&a.jobQueue.length>0){d=a.jobQueue.shift();d.start();a.jobsInProgress++}c(b.image,b.errorMsg,b.request)}b.prototype={errorMsg:null,start:function(){var b=this;var c=this.abort;this.image=new Image;this.image.onload=function(){b.finish(!0)};this.image.onabort=this.image.onerror=function(){b.errorMsg="Image load aborted";b.finish(!1)};this.jobId=window.setTimeout(function(){b.errorMsg="Image load exceeded timeout";b.finish(!1)},this.timeout);if(this.loadWithAjax){this.request=a.makeAjaxRequest({url:this.src,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,responseType:"arraybuffer",success:function(a){var c;try{c=new window.Blob([a.response])}catch(b){var d=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"===b.name&&d){var e=new d;e.append(a.response);c=e.getBlob()}}if(0===c.size){b.errorMsg="Empty image response.";b.finish(!1)}var f=(window.URL||window.webkitURL).createObjectURL(c);b.image.src=f},error:function(a){b.errorMsg="Image load aborted - XHR error";b.finish(!1)}});this.abort=function(){b.request.abort();"function"==typeof c&&c()}}else{this.crossOriginPolicy!==!1&&(this.image.crossOrigin=this.crossOriginPolicy);this.image.src=this.src}},finish:function(a){this.image.onload=this.image.onerror=this.image.onabort=null;a||(this.image=null);this.jobId&&window.clearTimeout(this.jobId);this.callback(this)}};a.ImageLoader=function(b){a.extend(!0,this,{jobLimit:a.DEFAULT_SETTINGS.imageLoaderLimit,timeout:a.DEFAULT_SETTINGS.timeout,jobQueue:[],jobsInProgress:0},b)};a.ImageLoader.prototype={addJob:function(a){var d=this,e=function(b){c(d,b,a.callback)},f={src:a.src,loadWithAjax:a.loadWithAjax,ajaxHeaders:a.loadWithAjax?a.ajaxHeaders:null,crossOriginPolicy:a.crossOriginPolicy,ajaxWithCredentials:a.ajaxWithCredentials,callback:e,abort:a.abort,timeout:this.timeout},g=new b(f);if(!this.jobLimit||this.jobsInProgress<this.jobLimit){g.start();this.jobsInProgress++}else this.jobQueue.push(g)},clear:function(){for(var a=0;a<this.jobQueue.length;a++){var b=this.jobQueue[a];"function"==typeof b.abort&&b.abort()}this.jobQueue=[]}}}(OpenSeadragon);!function(a){a.Tile=function(a,b,c,d,e,f,g,h,i){this.level=a;this.x=b;this.y=c;this.bounds=d;this.exists=e;this.url=f;this.context2D=g;this.loadWithAjax=h;this.ajaxHeaders=i;this.ajaxHeaders?this.cacheKey=this.url+"+"+JSON.stringify(this.ajaxHeaders):this.cacheKey=this.url;this.loaded=!1;this.loading=!1;this.element=null;this.imgElement=null;this.image=null;this.style=null;this.position=null;this.size=null;this.blendStart=null;this.opacity=null;this.squaredDistance=null;this.visibility=null;this.beingDrawn=!1;this.lastTouchTime=0;this.isRightMost=!1;this.isBottomMost=!1};a.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},_hasTransparencyChannel:function(){return!!this.context2D||this.url.match(".png")},drawHTML:function(b){if(this.cacheImageRecord)if(this.loaded){if(!this.element){this.element=a.makeNeutralElement("div");this.imgElement=this.cacheImageRecord.getImage().cloneNode();this.imgElement.style.msInterpolationMode="nearest-neighbor";this.imgElement.style.width="100%";this.imgElement.style.height="100%";this.style=this.element.style;this.style.position="absolute"}this.element.parentNode!=b&&b.appendChild(this.element);this.imgElement.parentNode!=this.element&&this.element.appendChild(this.imgElement);this.style.top=this.position.y+"px";this.style.left=this.position.x+"px";this.style.height=this.size.y+"px";this.style.width=this.size.x+"px";a.setElementOpacity(this.element,this.opacity)}else a.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString());else a.console.warn("[Tile.drawHTML] attempting to draw tile %s when it's not cached",this.toString())},drawCanvas:function(b,c,d,e){var f,g=this.position.times(a.pixelDensityRatio),h=this.size.times(a.pixelDensityRatio);if(this.context2D||this.cacheImageRecord){f=this.context2D||this.cacheImageRecord.getRenderedContext();if(this.loaded&&f){b.save();b.globalAlpha=this.opacity;if("number"==typeof d&&1!==d){g=g.times(d);h=h.times(d)}e instanceof a.Point&&(g=g.plus(e));1===b.globalAlpha&&this._hasTransparencyChannel()&&b.clearRect(g.x+1,g.y+1,h.x-2,h.y-2);c({context:b,tile:this,rendered:f});b.drawImage(f.canvas,0,0,f.canvas.width,f.canvas.height,g.x,g.y,h.x,h.y);b.restore()}else a.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString())}else a.console.warn("[Tile.drawCanvas] attempting to draw tile %s when it's not cached",this.toString())},getScaleForEdgeSmoothing:function(){var b;if(this.cacheImageRecord)b=this.cacheImageRecord.getRenderedContext();else{if(!this.context2D){a.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString());return 1}b=this.context2D}return b.canvas.width/(this.size.x*a.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(b,c,d){var e=Math.max(1,Math.ceil((d.x-c.x)/2));var f=Math.max(1,Math.ceil((d.y-c.y)/2));return new a.Point(e,f).minus(this.position.times(a.pixelDensityRatio).times(b||1).apply(function(a){return a%1}))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement);this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element);this.element=null;this.imgElement=null;this.loaded=!1;this.loading=!1}}}(OpenSeadragon);!function(a){a.OverlayPlacement=a.Placement;a.OverlayRotationMode=a.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3});a.Overlay=function(b,c,d){var e;e=a.isPlainObject(b)?b:{element:b,location:c,placement:d};this.element=e.element;this.style=e.element.style;this._init(e)};a.Overlay.prototype={_init:function(b){this.location=b.location;this.placement=void 0===b.placement?a.Placement.TOP_LEFT:b.placement;this.onDraw=b.onDraw;this.checkResize=void 0===b.checkResize||b.checkResize;this.width=void 0===b.width?null:b.width;this.height=void 0===b.height?null:b.height;this.rotationMode=b.rotationMode||a.OverlayRotationMode.EXACT;if(this.location instanceof a.Rect){this.width=this.location.width;this.height=this.location.height;this.location=this.location.getTopLeft();this.placement=a.Placement.TOP_LEFT}this.scales=null!==this.width&&null!==this.height;this.bounds=new a.Rect(this.location.x,this.location.y,this.width,this.height);this.position=this.location},adjust:function(b,c){var d=a.Placement.properties[this.placement];if(d){d.isHorizontallyCentered?b.x-=c.x/2:d.isRight&&(b.x-=c.x);d.isVerticallyCentered?b.y-=c.y/2:d.isBottom&&(b.y-=c.y)}},destroy:function(){var b=this.element;var c=this.style;if(b.parentNode){b.parentNode.removeChild(b);if(b.prevElementParent){c.display="none";document.body.appendChild(b)}}this.onDraw=null;c.top="";c.left="";c.position="";null!==this.width&&(c.width="");null!==this.height&&(c.height="");var d=a.getCssPropertyWithVendorPrefix("transformOrigin");var e=a.getCssPropertyWithVendorPrefix("transform");if(d&&e){c[d]="";c[e]=""}},drawHTML:function(b,c){var d=this.element;if(d.parentNode!==b){d.prevElementParent=d.parentNode;d.prevNextSibling=d.nextSibling;b.appendChild(d);this.style.position="absolute";this.size=a.getElementSize(d)}var e=this._getOverlayPositionAndSize(c);
var f=e.position;var g=this.size=e.size;var h=e.rotate;if(this.onDraw)this.onDraw(f,g,this.element);else{var i=this.style;i.left=f.x+"px";i.top=f.y+"px";null!==this.width&&(i.width=g.x+"px");null!==this.height&&(i.height=g.y+"px");var j=a.getCssPropertyWithVendorPrefix("transformOrigin");var k=a.getCssPropertyWithVendorPrefix("transform");if(j&&k)if(h){i[j]=this._getTransformOrigin();i[k]="rotate("+h+"deg)"}else{i[j]="";i[k]=""}"none"!==i.display&&(i.display="block")}},_getOverlayPositionAndSize:function(b){var c=b.pixelFromPoint(this.location,!0);var d=this._getSizeInPixels(b);this.adjust(c,d);var e=0;if(b.degrees&&this.rotationMode!==a.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===a.OverlayRotationMode.BOUNDING_BOX&&null!==this.width&&null!==this.height){var f=new a.Rect(c.x,c.y,d.x,d.y);var g=this._getBoundingBox(f,b.degrees);c=g.getTopLeft();d=g.getSize()}else e=b.degrees;return{position:c,size:d,rotate:e}},_getSizeInPixels:function(b){var c=this.size.x;var d=this.size.y;if(null!==this.width||null!==this.height){var e=b.deltaPixelsFromPointsNoRotate(new a.Point(this.width||0,this.height||0),!0);null!==this.width&&(c=e.x);null!==this.height&&(d=e.y)}if(this.checkResize&&(null===this.width||null===this.height)){var f=this.size=a.getElementSize(this.element);null===this.width&&(c=f.x);null===this.height&&(d=f.y)}return new a.Point(c,d)},_getBoundingBox:function(a,b){var c=this._getPlacementPoint(a);return a.rotate(b,c).getBoundingBox()},_getPlacementPoint:function(b){var c=new a.Point(b.x,b.y);var d=a.Placement.properties[this.placement];if(d){d.isHorizontallyCentered?c.x+=b.width/2:d.isRight&&(c.x+=b.width);d.isVerticallyCentered?c.y+=b.height/2:d.isBottom&&(c.y+=b.height)}return c},_getTransformOrigin:function(){var b="";var c=a.Placement.properties[this.placement];if(!c)return b;c.isLeft?b="left":c.isRight&&(b="right");c.isTop?b+=" top":c.isBottom&&(b+=" bottom");return b},update:function(b,c){var d=a.isPlainObject(b)?b:{location:b,placement:c};this._init({location:d.location||this.location,placement:void 0!==d.placement?d.placement:this.placement,onDraw:d.onDraw||this.onDraw,checkResize:d.checkResize||this.checkResize,width:void 0!==d.width?d.width:this.width,height:void 0!==d.height?d.height:this.height,rotationMode:d.rotationMode||this.rotationMode})},getBounds:function(b){a.console.assert(b,"A viewport must now be passed to Overlay.getBounds.");var c=this.width;var d=this.height;if(null===c||null===d){var e=b.deltaPointsFromPixelsNoRotate(this.size,!0);null===c&&(c=e.x);null===d&&(d=e.y)}var f=this.location.clone();this.adjust(f,new a.Point(c,d));return this._adjustBoundsForRotation(b,new a.Rect(f.x,f.y,c,d))},_adjustBoundsForRotation:function(b,c){if(!b||0===b.degrees||this.rotationMode===a.OverlayRotationMode.EXACT)return c;if(this.rotationMode===a.OverlayRotationMode.BOUNDING_BOX){if(null===this.width||null===this.height)return c;var d=this._getOverlayPositionAndSize(b);return b.viewerElementToViewportRectangle(new a.Rect(d.position.x,d.position.y,d.size.x,d.size.y))}return c.rotate(-b.degrees,this._getPlacementPoint(c))}}}(OpenSeadragon);!function(a){a.Drawer=function(b){a.console.assert(b.viewer,"[Drawer] options.viewer is required");var c=arguments;a.isPlainObject(b)||(b={source:c[0],viewport:c[1],element:c[2]});a.console.assert(b.viewport,"[Drawer] options.viewport is required");a.console.assert(b.element,"[Drawer] options.element is required");b.source&&a.console.error("[Drawer] options.source is no longer accepted; use TiledImage instead");this.viewer=b.viewer;this.viewport=b.viewport;this.debugGridColor="string"==typeof b.debugGridColor?[b.debugGridColor]:b.debugGridColor||a.DEFAULT_SETTINGS.debugGridColor;b.opacity&&a.console.error("[Drawer] options.opacity is no longer accepted; set the opacity on the TiledImage instead");this.useCanvas=a.supportsCanvas&&(!this.viewer||this.viewer.useCanvas);this.container=a.getElement(b.element);this.canvas=a.makeNeutralElement(this.useCanvas?"canvas":"div");this.context=this.useCanvas?this.canvas.getContext("2d"):null;this.sketchCanvas=null;this.sketchContext=null;this.element=this.container;this.container.dir="ltr";if(this.useCanvas){var d=this._calculateCanvasSize();this.canvas.width=d.x;this.canvas.height=d.y}this.canvas.style.width="100%";this.canvas.style.height="100%";this.canvas.style.position="absolute";a.setElementOpacity(this.canvas,this.opacity,!0);this.container.style.textAlign="left";this.container.appendChild(this.canvas)};a.Drawer.prototype={addOverlay:function(b,c,d,e){a.console.error("drawer.addOverlay is deprecated. Use viewer.addOverlay instead.");this.viewer.addOverlay(b,c,d,e);return this},updateOverlay:function(b,c,d){a.console.error("drawer.updateOverlay is deprecated. Use viewer.updateOverlay instead.");this.viewer.updateOverlay(b,c,d);return this},removeOverlay:function(b){a.console.error("drawer.removeOverlay is deprecated. Use viewer.removeOverlay instead.");this.viewer.removeOverlay(b);return this},clearOverlays:function(){a.console.error("drawer.clearOverlays is deprecated. Use viewer.clearOverlays instead.");this.viewer.clearOverlays();return this},setOpacity:function(b){a.console.error("drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.");var c=this.viewer.world;for(var d=0;d<c.getItemCount();d++)c.getItemAt(d).setOpacity(b);return this},getOpacity:function(){a.console.error("drawer.getOpacity is deprecated. Use tiledImage.getOpacity instead.");var b=this.viewer.world;var c=0;for(var d=0;d<b.getItemCount();d++){var e=b.getItemAt(d).getOpacity();e>c&&(c=e)}return c},needsUpdate:function(){a.console.error("[Drawer.needsUpdate] this function is deprecated. Use World.needsDraw instead.");return this.viewer.world.needsDraw()},numTilesLoaded:function(){a.console.error("[Drawer.numTilesLoaded] this function is deprecated. Use TileCache.numTilesLoaded instead.");return this.viewer.tileCache.numTilesLoaded()},reset:function(){a.console.error("[Drawer.reset] this function is deprecated. Use World.resetItems instead.");this.viewer.world.resetItems();return this},update:function(){a.console.error("[Drawer.update] this function is deprecated. Use Drawer.clear and World.draw instead.");this.clear();this.viewer.world.draw();return this},canRotate:function(){return this.useCanvas},destroy:function(){this.canvas.width=1;this.canvas.height=1;this.sketchCanvas=null;this.sketchContext=null},clear:function(){this.canvas.innerHTML="";if(this.useCanvas){var a=this._calculateCanvasSize();if(this.canvas.width!=a.x||this.canvas.height!=a.y){this.canvas.width=a.x;this.canvas.height=a.y;if(null!==this.sketchCanvas){var b=this._calculateSketchCanvasSize();this.sketchCanvas.width=b.x;this.sketchCanvas.height=b.y}}this._clear()}},_clear:function(a,b){if(this.useCanvas){var c=this._getContext(a);if(b)c.clearRect(b.x,b.y,b.width,b.height);else{var d=c.canvas;c.clearRect(0,0,d.width,d.height)}}},viewportToDrawerRectangle:function(b){var c=this.viewport.pixelFromPointNoRotate(b.getTopLeft(),!0);var d=this.viewport.deltaPixelsFromPointsNoRotate(b.getSize(),!0);return new a.Rect(c.x*a.pixelDensityRatio,c.y*a.pixelDensityRatio,d.x*a.pixelDensityRatio,d.y*a.pixelDensityRatio)},drawTile:function(b,c,d,e,f){a.console.assert(b,"[Drawer.drawTile] tile is required");a.console.assert(c,"[Drawer.drawTile] drawingHandler is required");if(this.useCanvas){var g=this._getContext(d);e=e||1;b.drawCanvas(g,c,e,f)}else b.drawHTML(this.canvas)},_getContext:function(a){var b=this.context;if(a){if(null===this.sketchCanvas){this.sketchCanvas=document.createElement("canvas");var c=this._calculateSketchCanvasSize();this.sketchCanvas.width=c.x;this.sketchCanvas.height=c.y;this.sketchContext=this.sketchCanvas.getContext("2d");if(0===this.viewport.getRotation()){var d=this;this.viewer.addHandler("rotate",function a(){if(0!==d.viewport.getRotation()){d.viewer.removeHandler("rotate",a);var b=d._calculateSketchCanvasSize();d.sketchCanvas.width=b.x;d.sketchCanvas.height=b.y}})}}b=this.sketchContext}return b},saveContext:function(a){this.useCanvas&&this._getContext(a).save()},restoreContext:function(a){this.useCanvas&&this._getContext(a).restore()},setClip:function(a,b){if(this.useCanvas){var c=this._getContext(b);c.beginPath();c.rect(a.x,a.y,a.width,a.height);c.clip()}},drawRectangle:function(a,b,c){if(this.useCanvas){var d=this._getContext(c);d.save();d.fillStyle=b;d.fillRect(a.x,a.y,a.width,a.height);d.restore()}},blendSketch:function(b,c,d,e){var f=b;a.isPlainObject(f)||(f={opacity:b,scale:c,translate:d,compositeOperation:e});if(this.useCanvas&&this.sketchCanvas){b=f.opacity;e=f.compositeOperation;var g=f.bounds;this.context.save();this.context.globalAlpha=b;e&&(this.context.globalCompositeOperation=e);if(g){if(g.x<0){g.width+=g.x;g.x=0}g.x+g.width>this.canvas.width&&(g.width=this.canvas.width-g.x);if(g.y<0){g.height+=g.y;g.y=0}g.y+g.height>this.canvas.height&&(g.height=this.canvas.height-g.y);this.context.drawImage(this.sketchCanvas,g.x,g.y,g.width,g.height,g.x,g.y,g.width,g.height)}else{c=f.scale||1;d=f.translate;var h=d instanceof a.Point?d:new a.Point(0,0);var i=0;var j=0;if(d){var k=this.sketchCanvas.width-this.canvas.width;var l=this.sketchCanvas.height-this.canvas.height;i=Math.round(k/2);j=Math.round(l/2)}this.context.drawImage(this.sketchCanvas,h.x-i*c,h.y-j*c,(this.canvas.width+2*i)*c,(this.canvas.height+2*j)*c,-i,-j,this.canvas.width+2*i,this.canvas.height+2*j)}this.context.restore()}},drawDebugInfo:function(b,c,d,e){if(this.useCanvas){var f=this.viewer.world.getIndexOfItem(e)%this.debugGridColor.length;var g=this.context;g.save();g.lineWidth=2*a.pixelDensityRatio;g.font="small-caps bold "+13*a.pixelDensityRatio+"px arial";g.strokeStyle=this.debugGridColor[f];g.fillStyle=this.debugGridColor[f];0!==this.viewport.degrees&&this._offsetForRotation({degrees:this.viewport.degrees});e.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:e.getRotation(!0),point:e.viewport.pixelFromPointNoRotate(e._getRotationPoint(!0),!0)});g.strokeRect(b.position.x*a.pixelDensityRatio,b.position.y*a.pixelDensityRatio,b.size.x*a.pixelDensityRatio,b.size.y*a.pixelDensityRatio);var h=(b.position.x+b.size.x/2)*a.pixelDensityRatio;var i=(b.position.y+b.size.y/2)*a.pixelDensityRatio;g.translate(h,i);g.rotate(Math.PI/180*-this.viewport.degrees);g.translate(-h,-i);if(0===b.x&&0===b.y){g.fillText("Zoom: "+this.viewport.getZoom(),b.position.x*a.pixelDensityRatio,(b.position.y-30)*a.pixelDensityRatio);g.fillText("Pan: "+this.viewport.getBounds().toString(),b.position.x*a.pixelDensityRatio,(b.position.y-20)*a.pixelDensityRatio)}g.fillText("Level: "+b.level,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+20)*a.pixelDensityRatio);g.fillText("Column: "+b.x,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+30)*a.pixelDensityRatio);g.fillText("Row: "+b.y,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+40)*a.pixelDensityRatio);g.fillText("Order: "+d+" of "+c,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+50)*a.pixelDensityRatio);g.fillText("Size: "+b.size.toString(),(b.position.x+10)*a.pixelDensityRatio,(b.position.y+60)*a.pixelDensityRatio);g.fillText("Position: "+b.position.toString(),(b.position.x+10)*a.pixelDensityRatio,(b.position.y+70)*a.pixelDensityRatio);0!==this.viewport.degrees&&this._restoreRotationChanges();e.getRotation(!0)%360!==0&&this._restoreRotationChanges();g.restore()}},debugRect:function(b){if(this.useCanvas){var c=this.context;c.save();c.lineWidth=2*a.pixelDensityRatio;c.strokeStyle=this.debugGridColor[0];c.fillStyle=this.debugGridColor[0];c.strokeRect(b.x*a.pixelDensityRatio,b.y*a.pixelDensityRatio,b.width*a.pixelDensityRatio,b.height*a.pixelDensityRatio);c.restore()}},getCanvasSize:function(b){var c=this._getContext(b).canvas;return new a.Point(c.width,c.height)},getCanvasCenter:function(){return new a.Point(this.canvas.width/2,this.canvas.height/2)},_offsetForRotation:function(b){var c=b.point?b.point.times(a.pixelDensityRatio):this.getCanvasCenter();var d=this._getContext(b.useSketch);d.save();d.translate(c.x,c.y);d.rotate(Math.PI/180*b.degrees);d.translate(-c.x,-c.y)},_restoreRotationChanges:function(a){var b=this._getContext(a);b.restore()},_calculateCanvasSize:function(){var b=a.pixelDensityRatio;var c=this.viewport.getContainerSize();return{x:c.x*b,y:c.y*b}},_calculateSketchCanvasSize:function(){var a=this._calculateCanvasSize();if(0===this.viewport.getRotation())return a;var b=Math.ceil(Math.sqrt(a.x*a.x+a.y*a.y));return{x:b,y:b}}}}(OpenSeadragon);!function(a){a.Viewport=function(b){var c=arguments;c.length&&c[0]instanceof a.Point&&(b={containerSize:c[0],contentSize:c[1],config:c[2]});if(b.config){a.extend(!0,b,b.config);delete b.config}this._margins=a.extend({left:0,top:0,right:0,bottom:0},b.margins||{});delete b.margins;a.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,viewer:null,springStiffness:a.DEFAULT_SETTINGS.springStiffness,animationTime:a.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:a.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:a.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:a.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:a.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:a.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:a.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:a.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:a.DEFAULT_SETTINGS.maxZoomLevel,degrees:a.DEFAULT_SETTINGS.degrees,homeFillsViewer:a.DEFAULT_SETTINGS.homeFillsViewer},b);this._updateContainerInnerSize();this.centerSpringX=new a.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime});this.centerSpringY=new a.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime});this.zoomSpring=new a.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime});this._oldCenterX=this.centerSpringX.current.value;this._oldCenterY=this.centerSpringY.current.value;this._oldZoom=this.zoomSpring.current.value;this._setContentBounds(new a.Rect(0,0,1,1),1);this.goHome(!0);this.update()};a.Viewport.prototype={resetContentSize:function(b){a.console.assert(b,"[Viewport.resetContentSize] contentSize is required");a.console.assert(b instanceof a.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point");a.console.assert(b.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0");a.console.assert(b.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0");this._setContentBounds(new a.Rect(0,0,1,b.y/b.x),b.x);return this},setHomeBounds:function(b,c){a.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually.");this._setContentBounds(b,c)},_setContentBounds:function(b,c){a.console.assert(b,"[Viewport._setContentBounds] bounds is required");a.console.assert(b instanceof a.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect");a.console.assert(b.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0");a.console.assert(b.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0");this._contentBoundsNoRotate=b.clone();this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(c);this._contentBounds=b.rotate(this.degrees).getBoundingBox();this._contentSize=this._contentBounds.getSize().times(c);this._contentAspectRatio=this._contentSize.x/this._contentSize.y;this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:c,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var a=this._contentAspectRatio/this.getAspectRatio();var b;b=this.homeFillsViewer?a>=1?a:1:a>=1?1:a;return b/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var b=this._contentBounds.getCenter();var c=1/this.getHomeZoom();var d=c/this.getAspectRatio();return new a.Rect(b.x-c/2,b.y-d/2,c,d)},goHome:function(a){this.viewer&&this.viewer.raiseEvent("home",{immediately:a});return this.fitBounds(this.getHomeBounds(),a)},getMinZoom:function(){var a=this.getHomeZoom(),b=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*a;return b},getMaxZoom:function(){var a=this.maxZoomLevel;if(!a){a=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x;a/=this._contentBounds.width}return Math.max(a,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new a.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return a.extend({},this._margins)},setMargins:function(b){a.console.assert("object"===a.type(b),"[Viewport.setMargins] margins must be an object");this._margins=a.extend({left:0,top:0,right:0,bottom:0},b);this._updateContainerInnerSize();this.viewer&&this.viewer.forceRedraw()},getBounds:function(a){return this.getBoundsNoRotate(a).rotate(-this.getRotation())},getBoundsNoRotate:function(b){var c=this.getCenter(b);var d=1/this.getZoom(b);var e=d/this.getAspectRatio();return new a.Rect(c.x-d/2,c.y-e/2,d,e)},getBoundsWithMargins:function(a){return this.getBoundsNoRotateWithMargins(a).rotate(-this.getRotation(),this.getCenter(a))},getBoundsNoRotateWithMargins:function(a){var b=this.getBoundsNoRotate(a);var c=this._containerInnerSize.x*this.getZoom(a);b.x-=this._margins.left/c;b.y-=this._margins.top/c;b.width+=(this._margins.left+this._margins.right)/c;b.height+=(this._margins.top+this._margins.bottom)/c;return b},getCenter:function(b){var c,d,e,f,g,h,i,j,k=new a.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),l=new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);if(b)return k;if(!this.zoomPoint)return l;c=this.pixelFromPoint(this.zoomPoint,!0);d=this.getZoom();e=1/d;f=e/this.getAspectRatio();g=new a.Rect(k.x-e/2,k.y-f/2,e,f);h=this._pixelFromPoint(this.zoomPoint,g);i=h.minus(c);j=i.divide(this._containerInnerSize.x*d);return l.plus(j)},getZoom:function(a){return a?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(a){return Math.max(Math.min(a,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(b){var c=new a.Rect(b.x,b.y,b.width,b.height);if(this.wrapHorizontal);else{var d=this.visibilityRatio*c.width;var e=c.x+c.width;var f=this._contentBoundsNoRotate.x+this._contentBoundsNoRotate.width;var g=this._contentBoundsNoRotate.x-e+d;var h=f-c.x-d;d>this._contentBoundsNoRotate.width?c.x+=(g+h)/2:h<0?c.x+=h:g>0&&(c.x+=g)}if(this.wrapVertical);else{var i=this.visibilityRatio*c.height;var j=c.y+c.height;var k=this._contentBoundsNoRotate.y+this._contentBoundsNoRotate.height;var l=this._contentBoundsNoRotate.y-j+i;var m=k-c.y-i;i>this._contentBoundsNoRotate.height?c.y+=(l+m)/2:m<0?c.y+=m:l>0&&(c.y+=l)}return c},_raiseConstraintsEvent:function(a){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:a})},applyConstraints:function(a){var b=this.getZoom();var c=this._applyZoomConstraints(b);b!==c&&this.zoomTo(c,this.zoomPoint,a);var d=this.getBoundsNoRotate();var e=this._applyBoundaryConstraints(d);this._raiseConstraintsEvent(a);(d.x!==e.x||d.y!==e.y||a)&&this.fitBounds(e.rotate(-this.getRotation()),a);return this},ensureVisible:function(a){return this.applyConstraints(a)},_fitBounds:function(b,c){c=c||{};var d=c.immediately||!1;var e=c.constraints||!1;var f=this.getAspectRatio();var g=b.getCenter();var h=new a.Rect(b.x,b.y,b.width,b.height,b.degrees+this.getRotation()).getBoundingBox();h.getAspectRatio()>=f?h.height=h.width/f:h.width=h.height*f;h.x=g.x-h.width/2;h.y=g.y-h.height/2;var i=1/h.width;if(e){var j=h.getAspectRatio();var k=this._applyZoomConstraints(i);if(i!==k){i=k;h.width=1/i;h.x=g.x-h.width/2;h.height=h.width/j;h.y=g.y-h.height/2}h=this._applyBoundaryConstraints(h);g=h.getCenter();this._raiseConstraintsEvent(d)}if(d){this.panTo(g,!0);return this.zoomTo(i,null,!0)}this.panTo(this.getCenter(!0),!0);this.zoomTo(this.getZoom(!0),null,!0);var l=this.getBounds();var m=this.getZoom();if(0===m||Math.abs(i/m-1)<1e-8){this.zoomTo(i,!0);return this.panTo(g,d)}h=h.rotate(-this.getRotation());var n=h.getTopLeft().times(i).minus(l.getTopLeft().times(m)).divide(i-m);return this.zoomTo(i,n,d)},fitBounds:function(a,b){return this._fitBounds(a,{immediately:b,constraints:!1})},fitBoundsWithConstraints:function(a,b){return this._fitBounds(a,{immediately:b,constraints:!0})},fitVertically:function(b){var c=new a.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(c,b)},fitHorizontally:function(b){var c=new a.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(c,b)},getConstrainedBounds:function(a){var b,c;b=this.getBounds(a);c=this._applyBoundaryConstraints(b);return c},panBy:function(b,c){var d=new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(d.plus(b),c)},panTo:function(a,b){if(b){this.centerSpringX.resetTo(a.x);this.centerSpringY.resetTo(a.y)}else{this.centerSpringX.springTo(a.x);this.centerSpringY.springTo(a.y)}this.viewer&&this.viewer.raiseEvent("pan",{center:a,immediately:b});return this},zoomBy:function(a,b,c){return this.zoomTo(this.zoomSpring.target.value*a,b,c)},zoomTo:function(b,c,d){var e=this;this.zoomPoint=c instanceof a.Point&&!isNaN(c.x)&&!isNaN(c.y)?c:null;d?this._adjustCenterSpringsForZoomPoint(function(){e.zoomSpring.resetTo(b)}):this.zoomSpring.springTo(b);this.viewer&&this.viewer.raiseEvent("zoom",{zoom:b,refPoint:c,immediately:d});return this},setRotation:function(b){if(!this.viewer||!this.viewer.drawer.canRotate())return this;this.degrees=a.positiveModulo(b,360);this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor());this.viewer.forceRedraw();this.viewer.raiseEvent("rotate",{degrees:b});return this},getRotation:function(){return this.degrees},resize:function(a,b){var c,d=this.getBoundsNoRotate(),e=d;this.containerSize.x=a.x;this.containerSize.y=a.y;this._updateContainerInnerSize();if(b){c=a.x/this.containerSize.x;e.width=d.width*c;e.height=e.width/this.getAspectRatio()}this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:a,maintain:b});return this.fitBounds(e,!0)},_updateContainerInnerSize:function(){this._containerInnerSize=new a.Point(Math.max(1,this.containerSize.x-(this._margins.left+this._margins.right)),Math.max(1,this.containerSize.y-(this._margins.top+this._margins.bottom)))},update:function(){var a=this;this._adjustCenterSpringsForZoomPoint(function(){a.zoomSpring.update()});this.centerSpringX.update();this.centerSpringY.update();var b=this.centerSpringX.current.value!==this._oldCenterX||this.centerSpringY.current.value!==this._oldCenterY||this.zoomSpring.current.value!==this._oldZoom;this._oldCenterX=this.centerSpringX.current.value;this._oldCenterY=this.centerSpringY.current.value;this._oldZoom=this.zoomSpring.current.value;return b},_adjustCenterSpringsForZoomPoint:function(a){if(this.zoomPoint){var b=this.pixelFromPoint(this.zoomPoint,!0);a();var c=this.pixelFromPoint(this.zoomPoint,!0);var d=c.minus(b);var e=this.deltaPointsFromPixels(d,!0);this.centerSpringX.shiftBy(e.x);this.centerSpringY.shiftBy(e.y);this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else a()},deltaPixelsFromPointsNoRotate:function(a,b){return a.times(this._containerInnerSize.x*this.getZoom(b))},deltaPixelsFromPoints:function(a,b){return this.deltaPixelsFromPointsNoRotate(a.rotate(this.getRotation()),b)},deltaPointsFromPixelsNoRotate:function(a,b){return a.divide(this._containerInnerSize.x*this.getZoom(b))},deltaPointsFromPixels:function(a,b){return this.deltaPointsFromPixelsNoRotate(a,b).rotate(-this.getRotation())},pixelFromPointNoRotate:function(a,b){return this._pixelFromPointNoRotate(a,this.getBoundsNoRotate(b))},pixelFromPoint:function(a,b){return this._pixelFromPoint(a,this.getBoundsNoRotate(b))},_pixelFromPointNoRotate:function(b,c){return b.minus(c.getTopLeft()).times(this._containerInnerSize.x/c.width).plus(new a.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(a,b){return this._pixelFromPointNoRotate(a.rotate(this.getRotation(),this.getCenter(!0)),b)},pointFromPixelNoRotate:function(b,c){var d=this.getBoundsNoRotate(c);return b.minus(new a.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/d.width).plus(d.getTopLeft())},pointFromPixel:function(a,b){return this.pointFromPixelNoRotate(a,b).rotate(-this.getRotation(),this.getCenter(!0))},_viewportToImageDelta:function(b,c){var d=this._contentBoundsNoRotate.width;return new a.Point(b*this._contentSizeNoRotate.x/d,c*this._contentSizeNoRotate.x/d)},viewportToImageCoordinates:function(b,c){if(b instanceof a.Point)return this.viewportToImageCoordinates(b.x,b.y);if(this.viewer){var d=this.viewer.world.getItemCount();if(d>1)a.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(1===d){var e=this.viewer.world.getItemAt(0);return e.viewportToImageCoordinates(b,c,!0)}}return this._viewportToImageDelta(b-this._contentBoundsNoRotate.x,c-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(b,c){var d=this._contentBoundsNoRotate.width;return new a.Point(b/this._contentSizeNoRotate.x*d,c/this._contentSizeNoRotate.x*d)},imageToViewportCoordinates:function(b,c){if(b instanceof a.Point)return this.imageToViewportCoordinates(b.x,b.y);if(this.viewer){var d=this.viewer.world.getItemCount();if(d>1)a.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(1===d){var e=this.viewer.world.getItemAt(0);return e.imageToViewportCoordinates(b,c,!0)}}var f=this._imageToViewportDelta(b,c);f.x+=this._contentBoundsNoRotate.x;f.y+=this._contentBoundsNoRotate.y;return f},imageToViewportRectangle:function(b,c,d,e){var f=b;f instanceof a.Rect||(f=new a.Rect(b,c,d,e));if(this.viewer){var g=this.viewer.world.getItemCount();if(g>1)a.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(1===g){var h=this.viewer.world.getItemAt(0);return h.imageToViewportRectangle(b,c,d,e,!0)}}var i=this.imageToViewportCoordinates(f.x,f.y);var j=this._imageToViewportDelta(f.width,f.height);return new a.Rect(i.x,i.y,j.x,j.y,f.degrees)},viewportToImageRectangle:function(b,c,d,e){var f=b;f instanceof a.Rect||(f=new a.Rect(b,c,d,e));if(this.viewer){var g=this.viewer.world.getItemCount();if(g>1)a.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(1===g){var h=this.viewer.world.getItemAt(0);return h.viewportToImageRectangle(b,c,d,e,!0)}}var i=this.viewportToImageCoordinates(f.x,f.y);var j=this._viewportToImageDelta(f.width,f.height);return new a.Rect(i.x,i.y,j.x,j.y,f.degrees)},viewerElementToImageCoordinates:function(a){var b=this.pointFromPixel(a,!0);return this.viewportToImageCoordinates(b)},imageToViewerElementCoordinates:function(a){var b=this.imageToViewportCoordinates(a);return this.pixelFromPoint(b,!0)},windowToImageCoordinates:function(b){a.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var c=b.minus(a.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(c)},imageToWindowCoordinates:function(b){a.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var c=this.imageToViewerElementCoordinates(b);return c.plus(a.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(a){return this.pointFromPixel(a,!0)},viewportToViewerElementCoordinates:function(a){return this.pixelFromPoint(a,!0)},viewerElementToViewportRectangle:function(b){return a.Rect.fromSummits(this.pointFromPixel(b.getTopLeft(),!0),this.pointFromPixel(b.getTopRight(),!0),this.pointFromPixel(b.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(b){return a.Rect.fromSummits(this.pixelFromPoint(b.getTopLeft(),!0),this.pixelFromPoint(b.getTopRight(),!0),this.pixelFromPoint(b.getBottomLeft(),!0))},windowToViewportCoordinates:function(b){a.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");var c=b.minus(a.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(c)},viewportToWindowCoordinates:function(b){a.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var c=this.viewportToViewerElementCoordinates(b);return c.plus(a.getElementPosition(this.viewer.element))},viewportToImageZoom:function(b){if(this.viewer){var c=this.viewer.world.getItemCount();if(c>1)a.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(1===c){var d=this.viewer.world.getItemAt(0);return d.viewportToImageZoom(b)}}var e=this._contentSizeNoRotate.x;var f=this._containerInnerSize.x;var g=this._contentBoundsNoRotate.width;var h=f/e*g;return b*h},imageToViewportZoom:function(b){if(this.viewer){var c=this.viewer.world.getItemCount();if(c>1)a.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image.");else if(1===c){var d=this.viewer.world.getItemAt(0);return d.imageToViewportZoom(b)}}var e=this._contentSizeNoRotate.x;var f=this._containerInnerSize.x;var g=this._contentBoundsNoRotate.width;var h=e/f/g;return b*h}}}(OpenSeadragon);!function(a){function b(a,b,d,e,f,g,h,i,j){var k=h.getBoundingBox().getTopLeft();var l=h.getBoundingBox().getBottomRight();a.viewer&&a.viewer.raiseEvent("update-level",{tiledImage:a,havedrawn:b,level:e,opacity:f,visibility:g,drawArea:h,topleft:k,bottomright:l,currenttime:i,best:j});m(a.coverage,e);m(a.loadingCoverage,e);var n=a._getCornerTiles(e,k,l);var o=n.topLeft;var p=n.bottomRight;var q=a.source.getNumTiles(e);var r=a.viewport.pixelFromPoint(a.viewport.getCenter());for(var s=o.x;s<=p.x;s++)for(var t=o.y;t<=p.y;t++){if(!a.wrapHorizontal&&!a.wrapVertical){var u=a.source.getTileBounds(e,s,t);if(null===h.intersection(u))continue}j=c(a,d,b,s,t,e,f,g,r,q,i,j)}return j}function c(a,b,c,e,f,j,m,o,p,q,r,s){var t=d(e,f,j,a,a.source,a.tilesMatrix,r,q,a._worldWidthCurrent,a._worldHeightCurrent),u=c;a.viewer&&a.viewer.raiseEvent("update-tile",{tiledImage:a,tile:t});l(a.coverage,j,e,f,!1);var v=t.loaded||t.loading||k(a.loadingCoverage,j,e,f);l(a.loadingCoverage,j,e,f,v);if(!t.exists)return s;b&&!u&&(k(a.coverage,j,e,f)?l(a.coverage,j,e,f,!0):u=!0);if(!u)return s;h(t,a.source.tileOverlap,a.viewport,p,o,a);if(!t.loaded)if(t.context2D)g(a,t);else{var w=a._tileCache.getImageRecord(t.cacheKey);if(w){var x=w.getImage();g(a,t,x)}}if(t.loaded){var y=i(a,t,e,f,j,m,r);y&&(a._needsDraw=!0)}else t.loading?a._tilesLoading++:v||(s=n(s,t));return s}function d(b,c,d,e,f,g,h,i,j,k){var l,m,n,o,p,q,r,s;g[d]||(g[d]={});g[d][b]||(g[d][b]={});if(!g[d][b][c]){l=(i.x+b%i.x)%i.x;m=(i.y+c%i.y)%i.y;n=f.getTileBounds(d,l,m);o=f.tileExists(d,l,m);p=f.getTileUrl(d,l,m);if(e.loadTilesWithAjax){q=f.getTileAjaxHeaders(d,l,m);a.isPlainObject(e.ajaxHeaders)&&(q=a.extend({},e.ajaxHeaders,q))}else q=null;r=f.getContext2D?f.getContext2D(d,l,m):void 0;n.x+=(b-l)/i.x;n.y+=k/j*((c-m)/i.y);s=new a.Tile(d,b,c,n,o,p,r,e.loadTilesWithAjax,q);l===i.x-1&&(s.isRightMost=!0);m===i.y-1&&(s.isBottomMost=!0);g[d][b][c]=s}s=g[d][b][c];s.lastTouchTime=h;return s}function e(a,b,c){b.loading=!0;a._imageLoader.addJob({src:b.url,loadWithAjax:b.loadWithAjax,ajaxHeaders:b.ajaxHeaders,crossOriginPolicy:a.crossOriginPolicy,ajaxWithCredentials:a.ajaxWithCredentials,callback:function(d,e,g){f(a,b,c,d,e,g)},abort:function(){b.loading=!1}})}function f(b,c,d,e,f,h){if(e)if(d<b.lastResetTime){a.console.log("Ignoring tile %s loaded before reset: %s",c,c.url);
c.loading=!1}else{var i=function(){var a=b.source.getClosestLevel();g(b,c,e,a,h)};b._midDraw?window.setTimeout(i,1):i()}else{a.console.log("Tile %s failed to load: %s - error: %s",c,c.url,f);b.viewer.raiseEvent("tile-load-failed",{tile:c,tiledImage:b,time:d,message:f,tileRequest:h});c.loading=!1;c.exists=!1}}function g(a,b,c,d,e){function f(){h++;return g}function g(){h--;if(0===h){b.loading=!1;b.loaded=!0;b.context2D||a._tileCache.cacheTile({image:c,tile:b,cutoff:d,tiledImage:a});a._needsDraw=!0}}var h=0;a.viewer.raiseEvent("tile-loaded",{tile:b,tiledImage:a,tileRequest:e,image:c,getCompletionCallback:f});f()()}function h(b,c,d,e,f,g){var h=b.bounds.getTopLeft();h.x*=g._scaleSpring.current.value;h.y*=g._scaleSpring.current.value;h.x+=g._xSpring.current.value;h.y+=g._ySpring.current.value;var i=b.bounds.getSize();i.x*=g._scaleSpring.current.value;i.y*=g._scaleSpring.current.value;var j=d.pixelFromPointNoRotate(h,!0),k=d.pixelFromPointNoRotate(h,!1),l=d.deltaPixelsFromPointsNoRotate(i,!0),m=d.deltaPixelsFromPointsNoRotate(i,!1),n=k.plus(m.divide(2)),o=e.squaredDistanceTo(n);c||(l=l.plus(new a.Point(1,1)));b.isRightMost&&g.wrapHorizontal&&(l.x+=.75);b.isBottomMost&&g.wrapVertical&&(l.y+=.75);b.position=j;b.size=l;b.squaredDistance=o;b.visibility=f}function i(a,b,c,d,e,f,g){var h,i,j=1e3*a.blendTime;b.blendStart||(b.blendStart=g);h=g-b.blendStart;i=j?Math.min(1,h/j):1;a.alwaysBlend&&(i*=f);b.opacity=i;a.lastDrawn.push(b);if(1==i){l(a.coverage,e,c,d,!0);a._hasOpaqueTile=!0}else if(h<j)return!0;return!1}function j(a,b,c,d){var e,f,g,h;if(!a[b])return!1;if(void 0===c||void 0===d){e=a[b];for(g in e)if(e.hasOwnProperty(g)){f=e[g];for(h in f)if(f.hasOwnProperty(h)&&!f[h])return!1}return!0}return void 0===a[b][c]||void 0===a[b][c][d]||a[b][c][d]===!0}function k(a,b,c,d){return void 0===c||void 0===d?j(a,b+1):j(a,b+1,2*c,2*d)&&j(a,b+1,2*c,2*d+1)&&j(a,b+1,2*c+1,2*d)&&j(a,b+1,2*c+1,2*d+1)}function l(b,c,d,e,f){if(b[c]){b[c][d]||(b[c][d]={});b[c][d][e]=f}else a.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",c)}function m(a,b){a[b]={}}function n(a,b){return a?b.visibility>a.visibility?b:b.visibility==a.visibility&&b.squaredDistance<a.squaredDistance?b:a:b}function o(b,c){if(0!==b.opacity&&(0!==c.length||b.placeholderFillStyle)){var d=c[0];var e;d&&(e=b.opacity<1||b.compositeOperation&&"source-over"!==b.compositeOperation||!b._isBottomItem()&&d._hasTransparencyChannel());var f;var g;var h=b.viewport.getZoom(!0);var i=b.viewportToImageZoom(h);if(c.length>1&&i>b.smoothTileEdgesMinZoom&&!b.iOSDevice&&b.getRotation(!0)%360===0&&a.supportsCanvas){e=!0;f=d.getScaleForEdgeSmoothing();g=d.getTranslationForEdgeSmoothing(f,b._drawer.getCanvasSize(!1),b._drawer.getCanvasSize(!0))}var j;if(e){f||(j=b.viewport.viewportToViewerElementRectangle(b.getClippedBounds(!0)).getIntegerBoundingBox().times(a.pixelDensityRatio));b._drawer._clear(!0,j)}if(!f){0!==b.viewport.degrees&&b._drawer._offsetForRotation({degrees:b.viewport.degrees,useSketch:e});b.getRotation(!0)%360!==0&&b._drawer._offsetForRotation({degrees:b.getRotation(!0),point:b.viewport.pixelFromPointNoRotate(b._getRotationPoint(!0),!0),useSketch:e})}var k=!1;if(b._clip){b._drawer.saveContext(e);var l=b.imageToViewportRectangle(b._clip,!0);l=l.rotate(-b.getRotation(!0),b._getRotationPoint(!0));var m=b._drawer.viewportToDrawerRectangle(l);f&&(m=m.times(f));g&&(m=m.translate(g));b._drawer.setClip(m,e);k=!0}if(b.placeholderFillStyle&&b._hasOpaqueTile===!1){var n=b._drawer.viewportToDrawerRectangle(b.getBounds(!0));f&&(n=n.times(f));g&&(n=n.translate(g));var o=null;o="function"==typeof b.placeholderFillStyle?b.placeholderFillStyle(b,b._drawer.context):b.placeholderFillStyle;b._drawer.drawRectangle(n,o,e)}for(var q=c.length-1;q>=0;q--){d=c[q];b._drawer.drawTile(d,b._drawingHandler,e,f,g);d.beingDrawn=!0;b.viewer&&b.viewer.raiseEvent("tile-drawn",{tiledImage:b,tile:d})}k&&b._drawer.restoreContext(e);if(!f){b.getRotation(!0)%360!==0&&b._drawer._restoreRotationChanges(e);0!==b.viewport.degrees&&b._drawer._restoreRotationChanges(e)}if(e){if(f){0!==b.viewport.degrees&&b._drawer._offsetForRotation({degrees:b.viewport.degrees,useSketch:!1});b.getRotation(!0)%360!==0&&b._drawer._offsetForRotation({degrees:b.getRotation(!0),point:b.viewport.pixelFromPointNoRotate(b._getRotationPoint(!0),!0),useSketch:!1})}b._drawer.blendSketch({opacity:b.opacity,scale:f,translate:g,compositeOperation:b.compositeOperation,bounds:j});if(f){b.getRotation(!0)%360!==0&&b._drawer._restoreRotationChanges(!1);0!==b.viewport.degrees&&b._drawer._restoreRotationChanges(!1)}}p(b,c)}}function p(b,c){if(b.debugMode)for(var d=c.length-1;d>=0;d--){var e=c[d];try{b._drawer.drawDebugInfo(e,c.length,d,b)}catch(b){a.console.error(b)}}}a.TiledImage=function(b){var c=this;a.console.assert(b.tileCache,"[TiledImage] options.tileCache is required");a.console.assert(b.drawer,"[TiledImage] options.drawer is required");a.console.assert(b.viewer,"[TiledImage] options.viewer is required");a.console.assert(b.imageLoader,"[TiledImage] options.imageLoader is required");a.console.assert(b.source,"[TiledImage] options.source is required");a.console.assert(!b.clip||b.clip instanceof a.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present");a.EventSource.call(this);this._tileCache=b.tileCache;delete b.tileCache;this._drawer=b.drawer;delete b.drawer;this._imageLoader=b.imageLoader;delete b.imageLoader;b.clip instanceof a.Rect&&(this._clip=b.clip.clone());delete b.clip;var d=b.x||0;delete b.x;var e=b.y||0;delete b.y;this.normHeight=b.source.dimensions.y/b.source.dimensions.x;this.contentAspectX=b.source.dimensions.x/b.source.dimensions.y;var f=1;if(b.width){f=b.width;delete b.width;if(b.height){a.console.error("specifying both width and height to a tiledImage is not supported");delete b.height}}else if(b.height){f=b.height/this.normHeight;delete b.height}var g=b.fitBounds;delete b.fitBounds;var h=b.fitBoundsPlacement||OpenSeadragon.Placement.CENTER;delete b.fitBoundsPlacement;var i=b.degrees||0;delete b.degrees;a.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_midDraw:!1,_needsDraw:!0,_hasOpaqueTile:!1,_tilesLoading:0,springStiffness:a.DEFAULT_SETTINGS.springStiffness,animationTime:a.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:a.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:a.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:a.DEFAULT_SETTINGS.wrapVertical,immediateRender:a.DEFAULT_SETTINGS.immediateRender,blendTime:a.DEFAULT_SETTINGS.blendTime,alwaysBlend:a.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:a.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:a.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:a.DEFAULT_SETTINGS.iOSDevice,debugMode:a.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:a.DEFAULT_SETTINGS.crossOriginPolicy,ajaxWithCredentials:a.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:a.DEFAULT_SETTINGS.placeholderFillStyle,opacity:a.DEFAULT_SETTINGS.opacity,preload:a.DEFAULT_SETTINGS.preload,compositeOperation:a.DEFAULT_SETTINGS.compositeOperation},b);this._preload=this.preload;delete this.preload;this._fullyLoaded=!1;this._xSpring=new a.Spring({initial:d,springStiffness:this.springStiffness,animationTime:this.animationTime});this._ySpring=new a.Spring({initial:e,springStiffness:this.springStiffness,animationTime:this.animationTime});this._scaleSpring=new a.Spring({initial:f,springStiffness:this.springStiffness,animationTime:this.animationTime});this._degreesSpring=new a.Spring({initial:i,springStiffness:this.springStiffness,animationTime:this.animationTime});this._updateForScale();g&&this.fitBounds(g,h,!0);this._drawingHandler=function(b){c.viewer.raiseEvent("tile-drawing",a.extend({tiledImage:c},b))}};a.extend(a.TiledImage.prototype,a.EventSource.prototype,{needsDraw:function(){return this._needsDraw},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(a){if(a!==this._fullyLoaded){this._fullyLoaded=a;this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded})}},reset:function(){this._tileCache.clearTilesFor(this);this.lastResetTime=a.now();this._needsDraw=!0},update:function(){var a=this._xSpring.update();var b=this._ySpring.update();var c=this._scaleSpring.update();var d=this._degreesSpring.update();if(a||b||c||d){this._updateForScale();this._needsDraw=!0;return!0}return!1},draw:function(){if(0!==this.opacity||this._preload){this._midDraw=!0;this._updateViewport();this._midDraw=!1}},destroy:function(){this.reset()},getBounds:function(a){return this.getBoundsNoRotate(a).rotate(this.getRotation(a),this._getRotationPoint(a))},getBoundsNoRotate:function(b){return b?new a.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new a.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){a.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead");return this.getBounds()},getClippedBounds:function(b){var c=this.getBoundsNoRotate(b);if(this._clip){var d=b?this._worldWidthCurrent:this._worldWidthTarget;var e=d/this.source.dimensions.x;var f=this._clip.times(e);c=new a.Rect(c.x+f.x,c.y+f.y,f.width,f.height)}return c.rotate(this.getRotation(b),this._getRotationPoint(b))},getContentSize:function(){return new a.Point(this.source.dimensions.x,this.source.dimensions.y)},_viewportToImageDelta:function(b,c,d){var e=d?this._scaleSpring.current.value:this._scaleSpring.target.value;return new a.Point(b*(this.source.dimensions.x/e),c*(this.source.dimensions.y*this.contentAspectX/e))},viewportToImageCoordinates:function(b,c,d){var e;if(b instanceof a.Point){d=c;e=b}else e=new a.Point(b,c);e=e.rotate(-this.getRotation(d),this._getRotationPoint(d));return d?this._viewportToImageDelta(e.x-this._xSpring.current.value,e.y-this._ySpring.current.value):this._viewportToImageDelta(e.x-this._xSpring.target.value,e.y-this._ySpring.target.value)},_imageToViewportDelta:function(b,c,d){var e=d?this._scaleSpring.current.value:this._scaleSpring.target.value;return new a.Point(b/this.source.dimensions.x*e,c/this.source.dimensions.y/this.contentAspectX*e)},imageToViewportCoordinates:function(b,c,d){if(b instanceof a.Point){d=c;c=b.y;b=b.x}var e=this._imageToViewportDelta(b,c);if(d){e.x+=this._xSpring.current.value;e.y+=this._ySpring.current.value}else{e.x+=this._xSpring.target.value;e.y+=this._ySpring.target.value}return e.rotate(this.getRotation(d),this._getRotationPoint(d))},imageToViewportRectangle:function(b,c,d,e,f){var g=b;g instanceof a.Rect?f=c:g=new a.Rect(b,c,d,e);var h=this.imageToViewportCoordinates(g.getTopLeft(),f);var i=this._imageToViewportDelta(g.width,g.height,f);return new a.Rect(h.x,h.y,i.x,i.y,g.degrees+this.getRotation(f))},viewportToImageRectangle:function(b,c,d,e,f){var g=b;b instanceof a.Rect?f=c:g=new a.Rect(b,c,d,e);var h=this.viewportToImageCoordinates(g.getTopLeft(),f);var i=this._viewportToImageDelta(g.width,g.height,f);return new a.Rect(h.x,h.y,i.x,i.y,g.degrees-this.getRotation(f))},viewerElementToImageCoordinates:function(a){var b=this.viewport.pointFromPixel(a,!0);return this.viewportToImageCoordinates(b)},imageToViewerElementCoordinates:function(a){var b=this.imageToViewportCoordinates(a);return this.viewport.pixelFromPoint(b,!0)},windowToImageCoordinates:function(a){var b=a.minus(OpenSeadragon.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(b)},imageToWindowCoordinates:function(a){var b=this.imageToViewerElementCoordinates(a);return b.plus(OpenSeadragon.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(b){var c=this._scaleSpring.current.value;b=b.rotate(-this.getRotation(!0),this._getRotationPoint(!0));return new a.Rect((b.x-this._xSpring.current.value)/c,(b.y-this._ySpring.current.value)/c,b.width/c,b.height/c,b.degrees)},viewportToImageZoom:function(a){var b=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return b*a},imageToViewportZoom:function(a){var b=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return a/b},setPosition:function(a,b){var c=this._xSpring.target.value===a.x&&this._ySpring.target.value===a.y;if(b){if(c&&this._xSpring.current.value===a.x&&this._ySpring.current.value===a.y)return;this._xSpring.resetTo(a.x);this._ySpring.resetTo(a.y);this._needsDraw=!0}else{if(c)return;this._xSpring.springTo(a.x);this._ySpring.springTo(a.y);this._needsDraw=!0}c||this._raiseBoundsChange()},setWidth:function(a,b){this._setScale(a,b)},setHeight:function(a,b){this._setScale(a/this.normHeight,b)},fitBounds:function(b,c,d){c=c||a.Placement.CENTER;var e=a.Placement.properties[c];var f=this.contentAspectX;var g=0;var h=0;var i=1;var j=1;if(this._clip){f=this._clip.getAspectRatio();i=this._clip.width/this.source.dimensions.x;j=this._clip.height/this.source.dimensions.y;if(b.getAspectRatio()>f){g=this._clip.x/this._clip.height*b.height;h=this._clip.y/this._clip.height*b.height}else{g=this._clip.x/this._clip.width*b.width;h=this._clip.y/this._clip.width*b.width}}if(b.getAspectRatio()>f){var k=b.height/j;var l=0;e.isHorizontallyCentered?l=(b.width-b.height*f)/2:e.isRight&&(l=b.width-b.height*f);this.setPosition(new a.Point(b.x-g+l,b.y-h),d);this.setHeight(k,d)}else{var m=b.width/i;var n=0;e.isVerticallyCentered?n=(b.height-b.width/f)/2:e.isBottom&&(n=b.height-b.width/f);this.setPosition(new a.Point(b.x-g,b.y-h+n),d);this.setWidth(m,d)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(b){a.console.assert(!b||b instanceof a.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null");b instanceof a.Rect?this._clip=b.clone():this._clip=null;this._needsDraw=!0;this.raiseEvent("clip-change")},getOpacity:function(){return this.opacity},setOpacity:function(a){if(a!==this.opacity){this.opacity=a;this._needsDraw=!0;this.raiseEvent("opacity-change",{opacity:this.opacity})}},getPreload:function(){return this._preload},setPreload:function(a){this._preload=!!a;this._needsDraw=!0},getRotation:function(a){return a?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(a,b){if(this._degreesSpring.target.value!==a||!this._degreesSpring.isAtTargetValue()){b?this._degreesSpring.resetTo(a):this._degreesSpring.springTo(a);this._needsDraw=!0;this._raiseBoundsChange()}},_getRotationPoint:function(a){return this.getBoundsNoRotate(a).getCenter()},getCompositeOperation:function(){return this.compositeOperation},setCompositeOperation:function(a){if(a!==this.compositeOperation){this.compositeOperation=a;this._needsDraw=!0;this.raiseEvent("composite-operation-change",{compositeOperation:this.compositeOperation})}},_setScale:function(a,b){var c=this._scaleSpring.target.value===a;if(b){if(c&&this._scaleSpring.current.value===a)return;this._scaleSpring.resetTo(a);this._updateForScale();this._needsDraw=!0}else{if(c)return;this._scaleSpring.springTo(a);this._updateForScale();this._needsDraw=!0}c||this._raiseBoundsChange()},_updateForScale:function(){this._worldWidthTarget=this._scaleSpring.target.value;this._worldHeightTarget=this.normHeight*this._scaleSpring.target.value;this._worldWidthCurrent=this._scaleSpring.current.value;this._worldHeightCurrent=this.normHeight*this._scaleSpring.current.value},_raiseBoundsChange:function(){this.raiseEvent("bounds-change")},_isBottomItem:function(){return this.viewer.world.getItemAt(0)===this},_getLevelsInterval:function(){var a=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2)));var b=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value;var c=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(b/this.minPixelRatio)/Math.log(2))));a=Math.min(a,c);return{lowestLevel:a,highestLevel:c}},_updateViewport:function(){this._needsDraw=!1;this._tilesLoading=0;this.loadingCoverage={};for(;this.lastDrawn.length>0;){var c=this.lastDrawn.pop();c.beingDrawn=!1}var d=this.viewport;var f=this._viewportToTiledImageRectangle(d.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var g=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));f=f.intersection(g);if(null===f)return}var h=this._getLevelsInterval();var i=h.lowestLevel;var k=h.highestLevel;var l=null;var m=!1;var n=a.now();for(var p=k;p>=i;p--){var q=!1;var r=d.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(p),!0).x*this._scaleSpring.current.value;if(p===i||!m&&r>=this.minPixelRatio){q=!0;m=!0}else if(!m)continue;var s=d.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(p),!1).x*this._scaleSpring.current.value;var t=d.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value;var u=this.immediateRender?1:t;var v=Math.min(1,(r-.5)/.5);var w=u/Math.abs(u-s);l=b(this,m,q,p,v,w,f,n,l);if(j(this.coverage,p))break}o(this,this.lastDrawn);if(l&&!l.context2D){e(this,l,n);this._needsDraw=!0;this._setFullyLoaded(!1)}else this._setFullyLoaded(0===this._tilesLoading)},_getCornerTiles:function(b,c,d){var e;var f;if(this.wrapHorizontal){e=a.positiveModulo(c.x,1);f=a.positiveModulo(d.x,1)}else{e=Math.max(0,c.x);f=Math.min(1,d.x)}var g;var h;var i=1/this.source.aspectRatio;if(this.wrapVertical){g=a.positiveModulo(c.y,i);h=a.positiveModulo(d.y,i)}else{g=Math.max(0,c.y);h=Math.min(i,d.y)}var j=this.source.getTileAtPoint(b,new a.Point(e,g));var k=this.source.getTileAtPoint(b,new a.Point(f,h));var l=this.source.getNumTiles(b);if(this.wrapHorizontal){j.x+=l.x*Math.floor(c.x);k.x+=l.x*Math.floor(d.x)}if(this.wrapVertical){j.y+=l.y*Math.floor(c.y/i);k.y+=l.y*Math.floor(d.y/i)}return{topLeft:j,bottomRight:k}}})}(OpenSeadragon);!function(a){var b=function(b){a.console.assert(b,"[TileCache.cacheTile] options is required");a.console.assert(b.tile,"[TileCache.cacheTile] options.tile is required");a.console.assert(b.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");this.tile=b.tile;this.tiledImage=b.tiledImage};var c=function(b){a.console.assert(b,"[ImageRecord] options is required");a.console.assert(b.image,"[ImageRecord] options.image is required");this._image=b.image;this._tiles=[]};c.prototype={destroy:function(){this._image=null;this._renderedContext=null;this._tiles=null},getImage:function(){return this._image},getRenderedContext:function(){if(!this._renderedContext){var a=document.createElement("canvas");a.width=this._image.width;a.height=this._image.height;this._renderedContext=a.getContext("2d");this._renderedContext.drawImage(this._image,0,0);this._image=null}return this._renderedContext},setRenderedContext:function(b){a.console.error("ImageRecord.setRenderedContext is deprecated. The rendered context should be created by the ImageRecord itself when calling ImageRecord.getRenderedContext.");this._renderedContext=b},addTile:function(b){a.console.assert(b,"[ImageRecord.addTile] tile is required");this._tiles.push(b)},removeTile:function(b){for(var c=0;c<this._tiles.length;c++)if(this._tiles[c]===b){this._tiles.splice(c,1);return}a.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",b)},getTileCount:function(){return this._tiles.length}};a.TileCache=function(b){b=b||{};this._maxImageCacheCount=b.maxImageCacheCount||a.DEFAULT_SETTINGS.maxImageCacheCount;this._tilesLoaded=[];this._imagesLoaded=[];this._imagesLoadedCount=0};a.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(d){a.console.assert(d,"[TileCache.cacheTile] options is required");a.console.assert(d.tile,"[TileCache.cacheTile] options.tile is required");a.console.assert(d.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required");a.console.assert(d.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var e=d.cutoff||0;var f=this._tilesLoaded.length;var g=this._imagesLoaded[d.tile.cacheKey];if(!g){a.console.assert(d.image,"[TileCache.cacheTile] options.image is required to create an ImageRecord");g=this._imagesLoaded[d.tile.cacheKey]=new c({image:d.image});this._imagesLoadedCount++}g.addTile(d.tile);d.tile.cacheImageRecord=g;if(this._imagesLoadedCount>this._maxImageCacheCount){var h=null;var i=-1;var j=null;var k,l,m,n,o,p;for(var q=this._tilesLoaded.length-1;q>=0;q--){p=this._tilesLoaded[q];k=p.tile;if(!(k.level<=e||k.beingDrawn))if(h){n=k.lastTouchTime;l=h.lastTouchTime;o=k.level;m=h.level;if(n<l||n==l&&o>m){h=k;i=q;j=p}}else{h=k;i=q;j=p}}if(h&&i>=0){this._unloadTile(j);f=i}}this._tilesLoaded[f]=new b({tile:d.tile,tiledImage:d.tiledImage})},clearTilesFor:function(b){a.console.assert(b,"[TileCache.clearTilesFor] tiledImage is required");var c;for(var d=0;d<this._tilesLoaded.length;++d){c=this._tilesLoaded[d];if(c.tiledImage===b){this._unloadTile(c);this._tilesLoaded.splice(d,1);d--}}},getImageRecord:function(b){a.console.assert(b,"[TileCache.getImageRecord] cacheKey is required");return this._imagesLoaded[b]},_unloadTile:function(b){a.console.assert(b,"[TileCache._unloadTile] tileRecord is required");var c=b.tile;var d=b.tiledImage;c.unload();c.cacheImageRecord=null;var e=this._imagesLoaded[c.cacheKey];e.removeTile(c);if(!e.getTileCount()){e.destroy();delete this._imagesLoaded[c.cacheKey];this._imagesLoadedCount--}d.viewer.raiseEvent("tile-unloaded",{tile:c,tiledImage:d})}}}(OpenSeadragon);!function(a){a.World=function(b){var c=this;a.console.assert(b.viewer,"[World] options.viewer is required");a.EventSource.call(this);this.viewer=b.viewer;this._items=[];this._needsDraw=!1;this._autoRefigureSizes=!0;this._needsSizesFigured=!1;this._delegatedFigureSizes=function(a){c._autoRefigureSizes?c._figureSizes():c._needsSizesFigured=!0};this._figureSizes()};a.extend(a.World.prototype,a.EventSource.prototype,{addItem:function(b,c){a.console.assert(b,"[World.addItem] item is required");a.console.assert(b instanceof a.TiledImage,"[World.addItem] only TiledImages supported at this time");c=c||{};if(void 0!==c.index){var d=Math.max(0,Math.min(this._items.length,c.index));this._items.splice(d,0,b)}else this._items.push(b);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0;this._needsDraw=!0;b.addHandler("bounds-change",this._delegatedFigureSizes);b.addHandler("clip-change",this._delegatedFigureSizes);this.raiseEvent("add-item",{item:b})},getItemAt:function(b){a.console.assert(void 0!==b,"[World.getItemAt] index is required");return this._items[b]},getIndexOfItem:function(b){a.console.assert(b,"[World.getIndexOfItem] item is required");return a.indexOf(this._items,b)},getItemCount:function(){return this._items.length},setItemIndex:function(b,c){a.console.assert(b,"[World.setItemIndex] item is required");a.console.assert(void 0!==c,"[World.setItemIndex] index is required");var d=this.getIndexOfItem(b);if(c>=this._items.length)throw new Error("Index bigger than number of layers.");if(c!==d&&d!==-1){this._items.splice(d,1);this._items.splice(c,0,b);this._needsDraw=!0;this.raiseEvent("item-index-change",{item:b,previousIndex:d,newIndex:c})}},removeItem:function(b){a.console.assert(b,"[World.removeItem] item is required");var c=a.indexOf(this._items,b);if(c!==-1){b.removeHandler("bounds-change",this._delegatedFigureSizes);b.removeHandler("clip-change",this._delegatedFigureSizes);b.destroy();this._items.splice(c,1);this._figureSizes();this._needsDraw=!0;this._raiseRemoveItem(b)}},removeAll:function(){this.viewer._cancelPendingImages();var a;var b;for(b=0;b<this._items.length;b++){a=this._items[b];a.removeHandler("bounds-change",this._delegatedFigureSizes);a.removeHandler("clip-change",this._delegatedFigureSizes);a.destroy()}var c=this._items;this._items=[];this._figureSizes();this._needsDraw=!0;for(b=0;b<c.length;b++){a=c[b];this._raiseRemoveItem(a)}},resetItems:function(){for(var a=0;a<this._items.length;a++)this._items[a].reset()},update:function(){var a=!1;for(var b=0;b<this._items.length;b++)a=this._items[b].update()||a;return a},draw:function(){for(var a=0;a<this._items.length;a++)this._items[a].draw();this._needsDraw=!1},needsDraw:function(){for(var a=0;a<this._items.length;a++)if(this._items[a].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(a){this._autoRefigureSizes=a;if(a&this._needsSizesFigured){this._figureSizes();this._needsSizesFigured=!1}},arrange:function(b){b=b||{};var c=b.immediately||!1;var d=b.layout||a.DEFAULT_SETTINGS.collectionLayout;var e=b.rows||a.DEFAULT_SETTINGS.collectionRows;var f=b.columns||a.DEFAULT_SETTINGS.collectionColumns;var g=b.tileSize||a.DEFAULT_SETTINGS.collectionTileSize;var h=b.tileMargin||a.DEFAULT_SETTINGS.collectionTileMargin;var i=g+h;var j;j=!b.rows&&f?f:Math.ceil(this._items.length/e);var k=0;var l=0;var m,n,o,p,q;this.setAutoRefigureSizes(!1);for(var r=0;r<this._items.length;r++){if(r&&r%j===0)if("horizontal"===d){l+=i;k=0}else{k+=i;l=0}m=this._items[r];n=m.getBounds();o=n.width>n.height?g:g*(n.width/n.height);p=o*(n.height/n.width);q=new a.Point(k+(g-o)/2,l+(g-p)/2);m.setPosition(q,c);m.setWidth(o,c);"horizontal"===d?k+=i:l+=i}this.setAutoRefigureSizes(!0)},_figureSizes:function(){var b=this._homeBounds?this._homeBounds.clone():null;var c=this._contentSize?this._contentSize.clone():null;var d=this._contentFactor||0;if(this._items.length){var e=this._items[0];var f=e.getBounds();this._contentFactor=e.getContentSize().x/f.width;var g=e.getClippedBounds().getBoundingBox();var h=g.x;var i=g.y;var j=g.x+g.width;var k=g.y+g.height;for(var l=1;l<this._items.length;l++){e=this._items[l];f=e.getBounds();this._contentFactor=Math.max(this._contentFactor,e.getContentSize().x/f.width);g=e.getClippedBounds().getBoundingBox();h=Math.min(h,g.x);i=Math.min(i,g.y);j=Math.max(j,g.x+g.width);k=Math.max(k,g.y+g.height)}this._homeBounds=new a.Rect(h,i,j-h,k-i);this._contentSize=new a.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}else{this._homeBounds=new a.Rect(0,0,1,1);this._contentSize=new a.Point(1,1);this._contentFactor=1}this._contentFactor===d&&this._homeBounds.equals(b)&&this._contentSize.equals(c)||this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(a){this.raiseEvent("remove-item",{item:a})}})}(OpenSeadragon);
//# sourceMappingURL=openseadragon.min.js.map