-
Notifications
You must be signed in to change notification settings - Fork 1
/
openseadragon.min.js
12 lines (12 loc) · 185 KB
/
openseadragon.min.js
1
2
3
4
5
6
7
8
9
10
11
12
//! OpenSeadragon 2.1.0
//! Built on 2015-11-12
//! Git commit: v2.1.0-3-b2c17b5
//! http://openseadragon.github.io
//! License: http://openseadragon.github.io/license/
window.OpenSeadragon=window.OpenSeadragon||function(a){return new OpenSeadragon.Viewer(a)},"function"==typeof define&&define.amd&&define(function(){return window.OpenSeadragon}),function(a){a.version={versionStr:"2.1.0",major:parseInt("2",10),minor:parseInt("1",10),revision:parseInt("0",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.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(c){b=!0}return b},a.pixelDensityRatio=function(){if(a.supportsCanvas){var b=document.createElement("canvas").getContext("2d"),c=window.devicePixelRatio||1,d=b.webkitBackingStorePixelRatio||b.mozBackingStorePixelRatio||b.msBackingStorePixelRatio||b.oBackingStorePixelRatio||b.backingStorePixelRatio||1;return c/d}return 1}()}(OpenSeadragon),function($){function getOffsetParent(a,b){return b&&a!=document.body?document.body:a.offsetParent}function processDZIResponse(a,b){var c,d,e=null;if(!a)throw new Error($.getString("Errors.Security"));if(200!==a.status&&0!==a.status)throw c=a.status,d=404==c?"Not Found":a.statusText,new Error($.getString("Errors.Status",c,d));return a.responseXML&&a.responseXML.documentElement?e=a.responseXML:a.responseText&&(e=$.parseXml(a.responseText)),processDZIXml(e,b)}function processDZIXml(a,b){if(!a||!a.documentElement)throw new Error($.getString("Errors.Xml"));var c=a.documentElement,d=c.tagName;if("Image"==d)try{return processDZI(c,b)}catch(e){throw e instanceof Error?e:new Error($.getString("Errors.Dzi"))}else{if("Collection"==d)throw new Error($.getString("Errors.Dzc"));if("Error"==d)return $._processDZIError(c)}throw new Error($.getString("Errors.Dzi"))}function processDZI(a,b){var c,d,e,f=a.getAttribute("Format"),g=a.getElementsByTagName("Size")[0],h=a.getElementsByTagName("DisplayRect"),i=parseInt(g.getAttribute("Width"),10),j=parseInt(g.getAttribute("Height"),10),k=parseInt(a.getAttribute("TileSize"),10),l=parseInt(a.getAttribute("Overlap"),10),m=[];if(!$.imageFormatSupported(f))throw new Error($.getString("Errors.ImageFormat",f.toUpperCase()));for(e=0;e<h.length;e++)c=h[e],d=c.getElementsByTagName("Rect")[0],m.push(new $.DisplayRect(parseInt(d.getAttribute("X"),10),parseInt(d.getAttribute("Y"),10),parseInt(d.getAttribute("Width"),10),parseInt(d.getAttribute("Height"),10),0,parseInt(c.getAttribute("MaxLevel"),10)));return new $.DziTileSource(i,j,k,l,b,f,m)}function processDZIJSON(a,b){var c,d,e=a.Format,f=a.Size,g=a.DisplayRect||[],h=parseInt(f.Width,10),i=parseInt(f.Height,10),j=parseInt(a.TileSize,10),k=parseInt(a.Overlap,10),l=[];if(!$.imageFormatSupported(e))throw new Error($.getString("Errors.ImageFormat",e.toUpperCase()));for(d=0;d<g.length;d++)c=g[d].Rect,l.push(new $.DisplayRect(parseInt(c.X,10),parseInt(c.Y,10),parseInt(c.Width,10),parseInt(c.Height,10),0,parseInt(c.MaxLevel,10)));return new $.DziTileSource(h,i,j,k,b,e,l)}$.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=arguments.length,i=!1,j=1;for("boolean"==typeof g&&(i=g,g=arguments[1]||{},j=2),"object"==typeof g||OpenSeadragon.isFunction(g)||(g={}),h===j&&(g=this,--j);h>j;j++)if(a=arguments[j],null!==a||void 0!==a)for(b in a)c=g[b],d=a[b],g!==d&&(i&&d&&(OpenSeadragon.isPlainObject(d)||(e=OpenSeadragon.isArray(d)))?(e?(e=!1,f=c&&OpenSeadragon.isArray(c)?c:[]):f=c&&OpenSeadragon.isPlainObject(c)?c:{},g[b]=OpenSeadragon.extend(i,f,d)):void 0!==d&&(g[b]=d));return g},$.extend($,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,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,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,navigatorRotate:!0,degrees:0,opacity:1,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"},SIGNAL:"----seadragon----",delegate:function(a,b){return function(){var c=arguments;return void 0===c&&(c=[]),b.apply(a,c)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5},getElement:function(a){return"string"==typeof a&&(a=document.getElementById(a)),a},getElementPosition:function(a){var b,c,d=new $.Point;for(a=$.getElement(a),b="fixed"==$.getElementStyle(a).position,c=getOffsetParent(a,b);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};return d?(b=d.documentElement,"undefined"!=typeof a.getBoundingClientRect&&(e=a.getBoundingClientRect()),c=d==d.window?d:9===d.nodeType?d.defaultView||d.parentWindow:!1,new $.Point(e.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0),e.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0))):new $.Point},getElementSize:function(a){return a=$.getElement(a),new $.Point(a.clientWidth,a.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(a){return a=$.getElement(a),a.currentStyle}:function(a){return a=$.getElement(a),window.getComputedStyle(a,"")},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){return a?$.getEvent=function(a){return a}:$.getEvent=function(){return window.event},$.getEvent(a)},getMousePosition:function(a){if("number"==typeof a.pageX)$.getMousePosition=function(a){var b=new $.Point;return a=$.getEvent(a),b.x=a.pageX,b.y=a.pageY,b};else{if("number"!=typeof a.clientX)throw new Error("Unknown event mouse position, no known technique.");$.getMousePosition=function(a){var b=new $.Point;return a=$.getEvent(a),b.x=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,b.y=a.clientY+document.body.scrollTop+document.documentElement.scrollTop,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)return void($.setPageScroll=function(a){document.body.scrollLeft=a.x,document.body.scrollTop=a.y});if(document.documentElement.scrollLeft=a.x,document.documentElement.scrollTop=a.y,c=$.getPageScroll(),c.x!==b.x&&c.y!==b.y)return void($.setPageScroll=function(a){document.documentElement.scrollLeft=a.x,document.documentElement.scrollTop=a.y});$.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")];return $.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),b[0]},makeNeutralElement:function(a){var b=document.createElement(a),c=b.style;return c.background="transparent none",c.border="none",c.margin="0px",c.padding="0px",c.position="static",b},now:function(){return Date.now?$.now=Date.now:$.now=function(){return(new Date).getTime()},$.now()},makeTransparentImage:function(a){return $.makeTransparentImage=function(a){var b=$.makeNeutralElement("img");return b.src=a,b},$.Browser.vendor==$.BROWSERS.IE&&$.Browser.version<7&&($.makeTransparentImage=function(a){var b=$.makeNeutralElement("img"),c=null;return 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')",c}),$.makeTransparentImage(a)},setElementOpacity:function(a,b,c){var d,e;a=$.getElement(a),c&&!$.Browser.alpha&&(b=Math.round(b)),$.Browser.opacity?a.style.opacity=1>b?b:"":1>b?(d=Math.round(100*b),e="alpha(opacity="+d+")",a.style.filter=e):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?-1===(" "+a.className+" ").indexOf(" "+b+" ")&&(a.className+=" "+b):a.className=b},indexOf:function(a,b,c){return 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;if(e=a.length,0===e||f>=e)return-1;for(0>f&&(f=e-Math.abs(f)),d=f;e>d;d++)if(a[d]===b)return d;return-1},this.indexOf(a,b,c)},removeClass:function(a,b){var c,d,e=[];for(a=$.getElement(a),c=a.className.split(/\s+/),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(c){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;$.isPlainObject(a)&&(b=a.success,c=a.error,d=a.withCredentials,a=a.url);var e=$.getUrlProtocol(a),f=$.createAjaxRequest("file:"===e);if(!$.isFunction(b))throw new Error("makeAjaxRequest requires a success callback");f.onreadystatechange=function(){4==f.readyState&&(f.onreadystatechange=function(){},200===f.status||0===f.status&&"http:"!==e&&"https:"!==e?b(f):($.console.log("AJAX request returned %d: %s",f.status,a),$.isFunction(c)&&c(f)))},d&&(f.withCredentials=!0);try{f.open("GET",a,!0),f.send(null)}catch(g){var h=g.message,i=$.Browser.vendor==$.BROWSERS.IE&&$.Browser.version<10;if(i&&"undefined"!=typeof g.number&&-2147024891==g.number&&(h+="\nSee http://msdn.microsoft.com/en-us/library/ms537505(v=vs.85).aspx#xdomain"),$.console.log("%s while making AJAX request: %s",g.name,h),f.onreadystatechange=function(){},window.XDomainRequest){var j=new XDomainRequest;if(j){j.onload=function(a){$.isFunction(b)&&b({responseText:j.responseText,status:200,statusText:"OK"})},j.onerror=function(a){$.isFunction(c)&&c({responseText:j.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{j.open("GET",a),j.send()}catch(k){$.isFunction(c)&&c(f,g)}}}else $.isFunction(c)&&c(f,g)}},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(b){}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){(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;return b=new DOMParser,c=b.parseFromString(a,"text/xml")};else{if(!window.ActiveXObject)throw new Error("Browser doesn't support XML DOM.");$.parseXml=function(a){var b=null;return b=new ActiveXObject("Microsoft.XMLDOM"),b.async=!1,b.loadXML(a),b}}return $.parseXml(a)},parseJSON:function(string){return window.JSON&&window.JSON.parse?$.parseJSON=window.JSON.parse:$.parseJSON=function(string){return eval("("+string+")")},$.parseJSON(string)},imageFormatSupported:function(a){return a=a?a:"",!!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.appName,navigator.appVersion),c=navigator.userAgent;switch(navigator.appName){case"Microsoft Internet Explorer":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":window.addEventListener&&(c.indexOf("Firefox")>=0?($.Browser.vendor=$.BROWSERS.FIREFOX,$.Browser.version=parseFloat(c.substring(c.indexOf("Firefox")+8))):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")))):(a=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),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,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){return e.push([++g,a]),d||(d=setInterval(function(){if(e.length){var a=$.now(),b=f;for(f=e,e=b;f.length;)f.shift()[1](a)}else clearInterval(d),d=void 0},20)),g},$.cancelAnimationFrame=function(a){var b,c;for(b=0,c=e.length;c>b;b+=1)if(e[b][0]===a)return void e.splice(b,1);for(b=0,c=f.length;c>b;b+=1)if(f[b][0]===a)return void f.splice(b,1)}}}(window),$._processDZIError=function(a){var b=a.getElementsByTagName("Message")[0],c=b.firstChild.nodeValue;throw new Error(c)}}(OpenSeadragon),function(a){var b={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};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"):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"):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"):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"):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={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];return b&&b.length?(b=1===b.length?[b[0]]:Array.apply(null,b),function(a,c){var d,e=b.length;for(d=0;e>d;d++)b[d]&&(c.eventSource=a,c.userData=b[d].userData,b[d].handler(c))}):null},raiseEvent:function(a,b){var c=this.getHandler(a);c&&(b||(b={}),c(this,b))}}}(OpenSeadragon),function(a){function b(b){var c,d=oa[b.hash],e=d.activePointersLists.length;for(c=0;e>c;c++)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;e>c;c++)d.activePointersLists.pop()}function c(c){var d,e,f=oa[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=oa[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=oa[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){var d,f=b.getActivePointersListByType(c);f.captureCount++,1===f.captureCount&&(a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9?b.element.setCapture(!0):(d=e(b,a.MouseTracker.havePointerEvents?"pointerevent":c),a.addEvent(a.MouseTracker.captureElement,d.upName,d.upHandler,!0),a.addEvent(a.MouseTracker.captureElement,d.moveName,d.moveHandler,!0)))}function g(b,c){var d,f=b.getActivePointersListByType(c);f.captureCount--,0===f.captureCount&&(a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9?b.element.releaseCapture():(d=e(b,a.MouseTracker.havePointerEvents?"pointerevent":c),a.removeEvent(a.MouseTracker.captureElement,d.moveName,d.moveHandler,!0),a.removeEvent(a.MouseTracker.captureElement,d.upName,d.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;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;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;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;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;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=-1/a.DEFAULT_SETTINGS.pixelsPerWheelLine*c.wheelDelta:d.deltaY=c.detail,v(b,d,c)}function v(b,c,d){var e,f=0;f=c.deltaY<0?1:-1,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()},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=[];for(d=0;e>d;d++)f.push(c.getByIndex(d));f.length>0&&(ja(a,b,f,0),c.captureCount=1,g(a,"touch"),ha(a,b,f))}function M(b,c){var d,e,g,h,j=c.changedTouches.length,k=[],l=b.getActivePointersListByType("touch");for(d=a.now(),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)),e=0;j>e;e++)k.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:i(c.changedTouches[e]),currentTime:d});for(ga(b,c,k),e=0;e<na.length;e++)if(na[e]!==b&&na[e].isTracking()&&w(na[e].element,b.element)){for(h=[],g=0;j>g;g++)h.push({id:c.changedTouches[g].identifier,type:"touch",currentPos:i(c.changedTouches[g]),currentTime:d});ga(na[e],c,h)}ia(b,c,k,0)&&(a.stopEvent(c),f(b,"touch")),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=[];for(d=a.now(),e=0;j>e;e++)k.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:i(c.changedTouches[e]),currentTime:d});for(ja(b,c,k,0)&&g(b,"touch"),ha(b,c,k),e=0;e<na.length;e++)if(na[e]!==b&&na[e].isTracking()&&w(na[e].element,b.element)){for(h=[],f=0;j>f;f++)h.push({id:c.changedTouches[f].identifier,type:"touch",currentPos:i(c.changedTouches[f]),currentTime:d});ha(na[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;e>d;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=(b.changedTouches.length,a.getActivePointersListByType("touch"));L(a,b,c)}function U(a,b){return b.stopPropagation(),
b.preventDefault(),!1}function V(a,b){return b.stopPropagation(),b.preventDefault(),!1}function W(b,c){var d;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;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()},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){return 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,a.add(b)}function fa(a,b){var c,d;return a.getById(b.id)?(c=a.removeById(b.id),b.hasOwnProperty("isPrimary")||(d=a.getPrimary(),d||(d=a.getByIndex(0),d&&(d.isPrimary=!0)))):c=a.getLength(),c}function ga(b,c,d){var e,f,g,h,i=b.getActivePointersListByType(d[0].type),j=d.length;for(e=0;j>e;e++)f=d[e],g=i.getById(f.id),g?(g.insideElement=!0,g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime,f=g):(f.captured=!1,f.insideElementPressed=!1,f.insideElement=!0,ea(i,f)),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=(oa[b.hash],b.getActivePointersListByType(d[0].type)),j=d.length;for(e=0;j>e;e++)f=d[e],g=i.getById(f.id),g&&(g.captured?(g.insideElement=!1,g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime):fa(i,g),f=g),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:!1,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=oa[b.hash],m=b.getActivePointersListByType(d[0].type),n=d.length;if("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),0!==e)return 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)),!1;for(g=0;n>g;g++)h=d[g],i=m.getById(h.id),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):(h.captured=!0,h.insideElementPressed=!0,h.insideElement=!0,ea(m,h)),m.contacts++,(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.addPoint(b,h),1===m.contacts?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)):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=oa[b.hash],p=b.getActivePointersListByType(d[0].type),q=d.length,r=!1,s=!1;if("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),0!==e)return 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)),!1;for(i=0;q>i;i++)j=d[i],m=p.getById(j.id),m&&(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,s?(p.contacts--,(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.removePoint(b,m),0===p.contacts?(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)),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)),(b.clickHandler||b.dblClickHandler)&&m.insideElement&&(n=h-m.contactTime<=b.clickTimeThreshold&&m.contactPos.distanceTo(g)<=b.clickDistThreshold,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)),b.dblClickHandler&&n&&(p.clicks++,1===p.clicks?(o.lastClickPos=g,o.dblClickTimeOut=setTimeout(function(){p.clicks=0},b.dblClickTimeThreshold)):2===p.clicks&&(clearTimeout(o.dblClickTimeOut),p.clicks=0,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)))):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))):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=oa[b.hash],n=b.getActivePointersListByType(d[0].type),o=d.length;for("undefined"!=typeof c.buttons&&(n.buttons=c.buttons),e=0;o>e;e++)f=d[e],g=n.getById(f.id),g?(f.hasOwnProperty("isPrimary")&&(g.isPrimary=f.isPrimary),g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime):(f.captured=!1,f.insideElementPressed=!1,f.insideElement=!0,ea(n,f));b.stopHandler&&"mouse"===d[0].type&&(clearTimeout(b.stopTimeOut),b.stopTimeOut=setTimeout(function(){ma(b,c,d[0].type)},b.stopDelay)),0===n.contacts?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)):1===n.contacts?(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)),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))):2===n.contacts&&(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)),b.pinchHandler&&"touch"===d[0].type&&(i=m.pinchGPoints[0].currentPos.distanceTo(m.pinchGPoints[1].currentPos),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})}var na=[],oa={};a.MouseTracker=function(b){na.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;oa[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;for(d(this),this.element=null,a=0;a<na.length;a++)if(na[a]===this){na.splice(a,1);break}oa[this.hash]=null,delete oa[this.hash]},isTracking:function(){return oa[this.hash].tracking},setTracking:function(a){return a?c(this):d(this),this},getActivePointersListByType:function(b){var c,d,e=oa[this.hash],f=e.activePointersLists.length;for(c=0;f>c;c++)if(e.activePointersLists[c].type===b)return e.activePointersLists[c];return d=new a.MouseTracker.GesturePointList(b),e.activePointersLists.push(d),d},getActivePointerCount:function(){var a,b=oa[this.hash],c=b.activePointersLists.length,d=0;for(a=0;c>a;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.gesturePointVelocityTracker=function(){var b=[],c=0,d=0,e=function(a,b){return a.hash.toString()+b.type+b.id.toString()},f=function(){var c,e,f,g,h,i,j=b.length,k=a.now();for(g=k-d,d=k,c=0;j>c;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},g=function(g,h){var i=e(g,h);b.push({guid:i,gPoint:h,lastPos:h.currentPos}),1===b.length&&(d=a.now(),c=window.setInterval(f,50))},h=function(a,d){var f,g=e(a,d),h=b.length;for(f=0;h>f;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"),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):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):(a.MouseTracker.havePointerEvents=!1,a.Browser.vendor===a.BROWSERS.IE&&a.Browser.version<9?(a.MouseTracker.subscribeEvents.push("mouseenter","mouseleave"),a.MouseTracker.haveMouseEnter=!0):(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;c>b;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;c>b;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;c>b;b++)if(this._gPoints[b].isPrimary)return this._gPoints[b];return null}}}(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;"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?!0:c.attachToViewer,this.autoFade="undefined"==typeof c.autoFade?!0:c.autoFade,this.element=b,this.anchor=c.anchor,this.container=d,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%"):(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"];for(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},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%"),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);return d>=0&&(this.controls[d].destroy(),this.controls.splice(d,1)),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){function b(b){return b=a.getElement(b),new a.Point(0===b.clientWidth?1:b.clientWidth,0===b.clientHeight?1:b.clientHeight)}function c(b,c,d,e){function f(a,b){a.ready?d(a):(a.addHandler("ready",function(){d(a)}),a.addHandler("open-failed",function(a){e({message:a.message,source:b})}))}var g=b;"string"==a.type(c)&&(c.match(/\s*<.*/)?c=a.parseXml(c):c.match(/\s*[\{\[].*/)&&(c=a.parseJSON(c))),setTimeout(function(){if("string"==a.type(c))c=new a.TileSource({url:c,crossOriginPolicy:b.crossOriginPolicy,ajaxWithCredentials:b.ajaxWithCredentials,useCanvas:b.useCanvas,success:function(a){d(a.tileSource)}}),c.addHandler("open-failed",function(a){e(a)});else if(a.isPlainObject(c)||c.nodeType)if(!c.crossOriginPolicy&&b.crossOriginPolicy&&(c.crossOriginPolicy=b.crossOriginPolicy),void 0===c.ajaxWithCredentials&&(c.ajaxWithCredentials=b.ajaxWithCredentials),void 0===c.useCanvas&&(c.useCanvas=b.useCanvas),a.isFunction(c.getTileUrl)){var h=new a.TileSource(c);h.getTileUrl=c.getTileUrl,d(h)}else{var i=a.TileSource.determineType(g,c);if(!i)return void e({message:"Unable to load TileSource",source:c});var j=i.prototype.configure.apply(g,[c]);f(new i(j),c)}else f(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),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;f||(f=c.width&&c.height?void 0!==c.px?b.viewport.imageToViewportRectangle(new a.Rect(c.px,c.py,c.width,c.height)):new a.Rect(c.x,c.y,c.width,c.height):void 0!==c.px?b.viewport.imageToViewportCoordinates(new a.Point(c.px,c.py)):new a.Point(c.x,c.y));var g=c.placement;return g&&"string"===a.type(g)&&(g=a.OverlayPlacement[c.placement.toUpperCase()]),new a.Overlay({element:d,location:f,placement:g,onDraw:c.onDraw,checkResize:c.checkResize})}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){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){for(c=a.now(),d=c-b.controlsFadeBeginTime,e=1-d/b.controlsFadeLength,e=Math.min(1,e),e=Math.max(0,e),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;for(a.controlsShouldFade=!1,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:return b.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,-40))),this.viewport.applyConstraints(),!1;case 40:return b.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,40))),this.viewport.applyConstraints(),!1;case 37:return this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(-40,0))),this.viewport.applyConstraints(),!1;case 39:return this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(40,0))),this.viewport.applyConstraints(),!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:return this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),!1;case 45:return this.viewport.zoomBy(.9),this.viewport.applyConstraints(),!1;case 48:return this.viewport.goHome(),this.viewport.applyConstraints(),!1;case 119:case 87:return b.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,-40))),this.viewport.applyConstraints(),!1;case 115:case 83:return b.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(0,40))),this.viewport.applyConstraints(),!1;case 97:return this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(-40,0))),this.viewport.applyConstraints(),!1;case 100:return this.viewport.panBy(this.viewport.deltaPointsFromPixels(new a.Point(40,0))),this.viewport.applyConstraints(),!1;default:return!0}}function o(a){var b,c=document.activeElement==this.canvas;c||this.canvas.focus(),!a.preventDefaultAction&&this.viewport&&a.quick&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.clickToZoom&&(this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,this.viewport.pointFromPixel(a.position,!0)),this.viewport.applyConstraints())),this.raiseEvent("canvas-click",{tracker:a.eventSource,position:a.position,quick:a.quick,shift:a.shift,originalEvent:a.originalEvent})}function p(a){var b;!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),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;!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta.negate()),b.flickEnabled),this.constrainDuringPan&&this.viewport.applyConstraints()),this.raiseEvent("canvas-drag",{tracker:a.eventSource,position:a.position,delta:a.delta,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent})}function r(b){var c;if(!b.preventDefaultAction&&this.viewport){if(c=this.gestureSettingsByDeviceType(b.pointerType),c.flickEnabled&&b.speed>=c.flickMinSpeed){var d=c.flickMomentum*b.speed*Math.cos(b.direction-Math.PI/180*this.viewport.degrees),e=c.flickMomentum*b.speed*Math.sin(b.direction-Math.PI/180*this.viewport.degrees),f=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),g=this.viewport.pointFromPixel(new a.Point(f.x-d,f.y-e));this.panHorizontal||(g.x=f.x),this.panVertical||(g.y=f.y),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(a){this.raiseEvent("canvas-exit",{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 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),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()),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),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))}return 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}),!1}function z(b){var c,d,e,f;return e=a.now(),f=e-this._lastScrollTime,f>this.minScrollDeltaTime?(this._lastScrollTime=e,!b.preventDefaultAction&&this.viewport&&(c=this.gestureSettingsByDeviceType(b.pointerType),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}),c&&c.scrollToZoom?!1:void 0):!1}function A(a){V[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){a.pointers<1&&(V[this.hash].mouseInside=!1,V[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){var c;if(a.autoResize&&(c=b(a.container),!c.equals(V[a.hash].prevContainerSize))){if(a.preserveImageSizeOnResize){var d=V[a.hash].prevContainerSize,e=a.viewport.getBounds(!0),f=c.x-d.x,g=c.y-d.y,i=a.viewport.deltaPointsFromPixels(new OpenSeadragon.Point(f,g),!0);a.viewport.resize(new OpenSeadragon.Point(c.x,c.y),!1),e.width+=i.x,e.height+=i.y,e.x-=i.x/2,e.y-=i.y/2,a.viewport.fitBoundsWithConstraints(e,!0)}else{var k=a.viewport.getBounds(),l=a.viewport.getCenter();E(a,c,k,l)}V[a.hash].prevContainerSize=c,V[a.hash].forceRedraw=!0}var m=a.viewport.update(),n=a.world.update()||m;m&&a.raiseEvent("viewport-change"),a.referenceStrip&&(n=a.referenceStrip.update(a.viewport)||n),!V[a.hash].animating&&n&&(a.raiseEvent("animation-start"),j(a)),(n||V[a.hash].forceRedraw||a.world.needsDraw())&&(F(a),a._drawOverlays(),a.navigator&&a.navigator.update(a.viewport),V[a.hash].forceRedraw=!1,n&&a.raiseEvent("animation")),V[a.hash].animating&&!n&&(a.raiseEvent("animation-finish"),V[a.hash].mouseInside||h(a)),V[a.hash].animating=n}}function E(b,c,d,e){var f=b.viewport;f.resize(c,!0);var g=new a.Rect(e.x-d.width/2,e.y-d.height/2,d.width,d.height);f.fitBoundsWithConstraints(g,!0)}function F(a){a.imageLoader.clear(),a.drawer.clear(),a.world.draw(),a.raiseEvent("update-viewport",{})}function G(a,b){return a?a+b:b}function H(){V[this.hash].lastZoomTime=a.now(),V[this.hash].zoomFactor=this.zoomPerSecond,V[this.hash].zooming=!0,K(this)}function I(){V[this.hash].lastZoomTime=a.now(),V[this.hash].zoomFactor=1/this.zoomPerSecond,V[this.hash].zooming=!0,K(this)}function J(){V[this.hash].zooming=!1}function K(b){a.requestAnimationFrame(a.delegate(b,L))}function L(){var b,c,d;V[this.hash].zooming&&this.viewport&&(b=a.now(),c=b-V[this.hash].lastZoomTime,d=Math.pow(V[this.hash].zoomFactor,c/1e3),this.viewport.zoomBy(d),this.viewport.applyConstraints(),V[this.hash].lastZoomTime=b,K(this))}function M(){this.viewport&&(V[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function N(){this.viewport&&(V[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function O(){this.buttons.emulateEnter(),this.buttons.emulateExit()}function P(){this.viewport&&this.viewport.goHome()}function Q(){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 R(){if(this.viewport){var a=this.viewport.getRotation();0===a?a=270:a-=90,this.viewport.setRotation(a)}}function S(){if(this.viewport){var a=this.viewport.getRotation();270===a?a=0:a+=90,this.viewport.setRotation(a)}}function T(){var a=this._sequenceIndex-1;this.navPrevNextWrap&&0>a&&(a+=this.tileSources.length),this.goToPage(a)}function U(){var a=this._sequenceIndex+1;this.navPrevNextWrap&&a>=this.tileSources.length&&(a=0),this.goToPage(a)}var V={},W=1;a.Viewer=function(c){var d,e=arguments,g=this;if(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}),c.config&&(a.extend(!0,c,c.config),delete c.config),a.extend(!0,this,{id:c.id,hash:c.hash||W++,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),"undefined"==typeof this.hash)throw new Error("A hash must be defined, either by specifying options.id or options.hash.");for("undefined"!=typeof V[this.hash]&&a.console.warn("Hash "+this.hash+" has already been used."),V[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),this.canvas.tabIndex=c.tabIndex||0,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?!1:!0,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?!1:!0,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(),V[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,V[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,V[g.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(a){g.viewport&&g.viewport.setHomeBounds(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:V[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.setHomeBounds(this.world.getHomeBounds(),this.world.getContentFactor()),this.imageLoader=new a.ImageLoader({jobLimit:this.imageLoaderLimit}),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),this.drawer.canRotate()||(this.rotateLeft&&(d=this.buttons.buttons.indexOf(this.rotateLeft),this.buttons.buttons.splice(d,1),this.buttons.element.removeChild(this.rotateLeft.element)),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,prefixUrl:this.prefixUrl,viewer:this,navigatorRotate:this.navigatorRotate,crossOriginPolicy:this.crossOriginPolicy})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),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){return a.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(b)},openTileSource:function(b){return a.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(b)},open:function(b){var c=this;if(this.close(),b){if(this.sequenceMode&&a.isArray(b))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),this.tileSources=b,this._sequenceIndex=Math.max(0,Math.min(this.tileSources.length-1,this.initialPage)),this.tileSources.length&&(this.open(this.tileSources[this._sequenceIndex]),this.showReferenceStrip&&(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}))),void this._updateSequenceButtons(this._sequenceIndex);if(a.isArray(b)||(b=[b]),b.length){this._opening=!0;for(var e,f=b.length,g=0,h=0,i=function(){if(g+h===f)if(g){(c._firstOpen||!c.preserveViewport)&&(c.viewport.goHome(!0),c.viewport.update()),c._firstOpen=!1;var a=b[0];if(a.tileSource&&(a=a.tileSource),c.overlays&&!c.preserveOverlays)for(var i=0;i<c.overlays.length;i++)c.currentOverlays[i]=d(c,c.overlays[i]);c._drawOverlays(),c._opening=!1,c.raiseEvent("open",{source:a})}else c._opening=!1,c.raiseEvent("open-failed",e)},j=function(b){a.isPlainObject(b)&&b.tileSource||(b={tileSource:b}),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 d=b.success;b.success=function(a){if(g++,b.tileSource.overlays)for(var e=0;e<b.tileSource.overlays.length;e++)c.addOverlay(b.tileSource.overlays[e]);d&&d(a),i()};var f=b.error;b.error=function(a){h++,e||(e=a),f&&f(a),i()},c.addTiledImage(b)},k=0;k<b.length;k++)j(b[k]);return this}}},close:function(){return V[this.hash]?(this._opening=!1,this.navigator&&this.navigator.close(),this.preserveOverlays||(this.clearOverlays(),this.overlaysContainer.innerHTML=""),V[this.hash].animating=!1,this.world.removeAll(),this.imageLoader.clear(),this.raiseEvent("close"),this):this},destroy:function(){if(V[this.hash]){if(this.close(),this.clearOverlays(),this.overlaysContainer.innerHTML="",this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),null!==this._updateRequestId&&(a.cancelAnimationFrame(this._updateRequestId),this._updateRequestId=null),this.drawer&&this.drawer.destroy(),this.removeAllHandlers(),this.element)for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.innerTracker&&this.innerTracker.destroy(),this.outerTracker&&this.outerTracker.destroy(),V[this.hash]=null,delete V[this.hash],this.canvas=null,this.container=null,this.element=null}},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(a){return this.innerTracker.setTracking(a),this.raiseEvent("mouse-enabled",{enabled:a}),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){return a?j(this):h(this),this.raiseEvent("controls-enabled",{enabled:a}),this},isFullPage:function(){return V[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};if(this.raiseEvent("pre-full-page",i),i.preventDefaultAction)return this;if(b){for(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.bodyHeight=f.height,f.width="100%",f.height="100%",this.previousBody=[],V[this.hash].prevElementParent=this.element.parentNode,V[this.hash].prevNextSibling=this.element.nextSibling,V[this.hash].prevElementWidth=this.element.style.width,V[this.hash].prevElementHeight=this.element.style.height,c=e.childNodes.length,d=0;c>d;d++)this.previousBody.push(e.childNodes[0]),e.removeChild(e.childNodes[0]);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"),V[this.hash].fullPage=!0,a.delegate(this,A)({})}else{for(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,f.height=this.bodyHeight,e.removeChild(this.element),c=this.previousBody.length,d=0;c>d;d++)e.appendChild(this.previousBody.shift());a.removeClass(this.element,"fullpage"),V[this.hash].prevElementParent.insertBefore(this.element,V[this.hash].prevNextSibling),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=V[this.hash].prevElementWidth,this.element.style.height=V[this.hash].prevElementHeight;var j=0,k=function(){a.setPageScroll(h.pageScroll);var b=a.getPageScroll();j++,(10>j&&b.x!==h.pageScroll.x||b.y!==h.pageScroll.y)&&a.requestAnimationFrame(k)};a.requestAnimationFrame(k),V[this.hash].fullPage=!1,a.delegate(this,B)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:b}),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};if(this.raiseEvent("pre-full-screen",d),d.preventDefaultAction)return this;if(b){if(this.setFullPage(!0),!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();b||(a.removeEvent(document,a.fullScreenEventName,e),a.removeEvent(document,a.fullScreenErrorEventName,e),c.setFullPage(!1),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){return this.container.style.visibility=a?"":"hidden",this.raiseEvent("visible",{visible:a}),this},addTiledImage:function(b){function d(a){for(var c=0;c<f._loadQueue.length;c++)if(f._loadQueue[c]===g){f._loadQueue.splice(c,1);break}0===f._loadQueue.length&&e(g),f.raiseEvent("add-item-failed",a),b.error&&b.error(a)}function e(a){f.collectionMode&&(f.world.arrange({immediately:a.options.collectionImmediately,rows:f.collectionRows,columns:f.collectionColumns,layout:f.collectionLayout,tileSize:f.collectionTileSize,tileMargin:f.collectionTileMargin}),f.world.setAutoRefigureSizes(!0))}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 f=this;b.replace&&(b.replaceItem=f.world.getItemAt(b.index)),this._hideMessage(),void 0===b.placeholderFillStyle&&(b.placeholderFillStyle=this.placeholderFillStyle),void 0===b.opacity&&(b.opacity=this.opacity);var g={options:b};return a.isArray(b.tileSource)?void setTimeout(function(){d({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:b.tileSource,options:b})}):(this._loadQueue.push(g),void c(this,b.tileSource,function(b){g.tileSource=b;for(var c,d,h;f._loadQueue.length&&(c=f._loadQueue[0],c.tileSource);){if(f._loadQueue.splice(0,1),c.options.replace){var i=f.world.getIndexOfItem(c.options.replaceItem);-1!=i&&(c.options.index=i),f.world.removeItem(c.options.replaceItem)}d=new a.TiledImage({viewer:f,source:c.tileSource,viewport:f.viewport,drawer:f.drawer,tileCache:f.tileCache,imageLoader:f.imageLoader,x:c.options.x,y:c.options.y,width:c.options.width,height:c.options.height,clip:c.options.clip,placeholderFillStyle:c.options.placeholderFillStyle,opacity:c.options.opacity,springStiffness:f.springStiffness,animationTime:f.animationTime,minZoomImageRatio:f.minZoomImageRatio,wrapHorizontal:f.wrapHorizontal,wrapVertical:f.wrapVertical,immediateRender:f.immediateRender,blendTime:f.blendTime,alwaysBlend:f.alwaysBlend,minPixelRatio:f.minPixelRatio,crossOriginPolicy:f.crossOriginPolicy,debugMode:f.debugMode}),f.collectionMode&&f.world.setAutoRefigureSizes(!1),f.world.addItem(d,{index:c.options.index}),0===f._loadQueue.length&&e(c),1!==f.world.getItemCount()||f.preserveViewport||f.viewport.goHome(!0),f.navigator&&(h=a.extend({},c.options,{originalTiledImage:d,tileSource:c.tileSource}),f.navigator.addTiledImage(h)),c.options.success&&c.options.success({item:d})}},function(a){a.options=b,d(a)}))},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)}});return this.addTiledImage(d),this},getLayerAtLevel:function(b){return a.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(b)},getLevelOfLayer:function(b){return a.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(b)},getLayersCount:function(){return a.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(b,c){return a.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(b,c)},removeLayer:function(b){return a.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(b)},forceRedraw:function(){return V[this.hash].forceRedraw=!0,this},bindSequenceControls:function(){var b=a.delegate(this,k),c=a.delegate(this,l),d=a.delegate(this,U),e=a.delegate(this,T),f=this.navImages,g=!0;return 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:G(this.prefixUrl,f.previous.REST),srcGroup:G(this.prefixUrl,f.previous.GROUP),srcHover:G(this.prefixUrl,f.previous.HOVER),srcDown:G(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:G(this.prefixUrl,f.next.REST),srcGroup:G(this.prefixUrl,f.next.GROUP),srcHover:G(this.prefixUrl,f.next.HOVER),srcDown:G(this.prefixUrl,f.next.DOWN),onRelease:d,onFocus:b,onBlur:c}),this.navPrevNextWrap||this.previousButton.disable(),this.tileSources&&this.tileSources.length||this.nextButton.disable(),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}))),this},bindStandardControls:function(){var b=a.delegate(this,H),c=a.delegate(this,J),d=a.delegate(this,M),e=a.delegate(this,I),f=a.delegate(this,N),g=a.delegate(this,P),h=a.delegate(this,Q),i=a.delegate(this,R),j=a.delegate(this,S),m=a.delegate(this,k),n=a.delegate(this,l),o=this.navImages,p=[],q=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton)&&(q=!1),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:G(this.prefixUrl,o.zoomIn.REST),srcGroup:G(this.prefixUrl,o.zoomIn.GROUP),srcHover:G(this.prefixUrl,o.zoomIn.HOVER),srcDown:G(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:G(this.prefixUrl,o.zoomOut.REST),srcGroup:G(this.prefixUrl,o.zoomOut.GROUP),srcHover:G(this.prefixUrl,o.zoomOut.HOVER),srcDown:G(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:G(this.prefixUrl,o.home.REST),srcGroup:G(this.prefixUrl,o.home.GROUP),srcHover:G(this.prefixUrl,o.home.HOVER),srcDown:G(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:G(this.prefixUrl,o.fullpage.REST),srcGroup:G(this.prefixUrl,o.fullpage.GROUP),srcHover:G(this.prefixUrl,o.fullpage.HOVER),srcDown:G(this.prefixUrl,o.fullpage.DOWN),onRelease:h,onFocus:m,onBlur:n})),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:G(this.prefixUrl,o.rotateleft.REST),srcGroup:G(this.prefixUrl,o.rotateleft.GROUP),srcHover:G(this.prefixUrl,o.rotateleft.HOVER),srcDown:G(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:G(this.prefixUrl,o.rotateright.REST),srcGroup:G(this.prefixUrl,o.rotateright.GROUP),srcHover:G(this.prefixUrl,o.rotateright.HOVER),srcDown:G(this.prefixUrl,o.rotateright.DOWN),onRelease:j,onFocus:m,onBlur:n}))),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,O)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:a.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||a.ControlAnchor.TOP_LEFT}))),this},currentPage:function(){return this._sequenceIndex},goToPage:function(a){return 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)),this},addOverlay:function(b,c,f,g){var h;if(h=a.isPlainObject(b)?b:{element:b,location:c,placement:f,onDraw:g},b=a.getElement(h.element),e(this.currentOverlays,b)>=0)return this;var i=d(this,h);return this.currentOverlays.push(i),i.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:b,location:h.location,placement:h.placement}),this},updateOverlay:function(b,c,d){var f;return b=a.getElement(b),f=e(this.currentOverlays,b),f>=0&&(this.currentOverlays[f].update(c,d),V[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:b,location:c,placement:d})),this},removeOverlay:function(b){var c;return b=a.getElement(b),c=e(this.currentOverlays,b),c>=0&&(this.currentOverlays[c].destroy(),this.currentOverlays.splice(c,1),V[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:b})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return V[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},_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;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;b>a;a++)this.currentOverlays[a].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]}})}(OpenSeadragon),function(a){function b(a){a.quick&&this.viewer.viewport&&(this.viewer.viewport.panTo(this.viewport.pointFromPixel(a.position).rotate(-this.viewer.viewport.degrees,this.viewer.viewport.getHomeBounds().getCenter())),this.viewer.viewport.applyConstraints())}function c(a){this.viewer.viewport&&(this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta)))}function d(a){a.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function e(a){return this.viewer.raiseEvent("navigator-scroll",{tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent}),!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){var h,i,j=g.viewer,k=this;g.id?(this.element=document.getElementById(g.id),g.controlOptions={anchor:a.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(g.id="navigator-"+a.now(),this.element=a.makeNeutralElement("div"),g.controlOptions={anchor:a.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:!0},g.position&&("BOTTOM_RIGHT"==g.position?g.controlOptions.anchor=a.ControlAnchor.BOTTOM_RIGHT:"BOTTOM_LEFT"==g.position?g.controlOptions.anchor=a.ControlAnchor.BOTTOM_LEFT:"TOP_RIGHT"==g.position?g.controlOptions.anchor=a.ControlAnchor.TOP_RIGHT:"TOP_LEFT"==g.position?g.controlOptions.anchor=a.ControlAnchor.TOP_LEFT:"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=j.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%",j.addControl(this.element,g.controlOptions),this._resizeWithViewer=g.controlOptions.anchor!=a.ControlAnchor.ABSOLUTE&&g.controlOptions.anchor!=a.ControlAnchor.NONE,this._resizeWithViewer&&(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):(h=a.getElementSize(j.element),this.element.style.height=Math.round(h.y*g.sizeRatio)+"px",this.element.style.width=Math.round(h.x*g.sizeRatio)+"px",this.oldViewerSize=h),i=a.getElementSize(this.element),this.elementArea=i.x*i.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),g.navigatorRotate&&g.viewer.addHandler("rotate",function(a){f(k.displayRegionContainer,a.degrees),f(k.displayRegion,-a.degrees),k.viewport.setRotation(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(){k.viewport&&k.viewport.goHome(!0)}),this.addHandler("reset-size",function(){k.viewport&&k.viewport.goHome(!0)}),j.world.addHandler("item-index-change",function(a){var b=k.world.getItemAt(a.previousIndex);k.world.setItemIndex(b,a.newIndex)}),j.world.addHandler("remove-item",function(a){var b=a.item,c=k._getMatchingItem(b);c&&k.world.removeItem(c)}),this.update(j.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);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;if(c=a.getElementSize(this.viewer.element),this._resizeWithViewer&&c.x&&c.y&&!c.equals(this.oldViewerSize)&&(this.oldViewerSize=c,this.maintainSizeRatio||!this.elementArea?(d=c.x*this.sizeRatio,e=c.y*this.sizeRatio):(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()),b&&this.viewport){f=b.getBounds(!0),g=this.viewport.pixelFromPoint(f.getTopLeft(),!1),h=this.viewport.pixelFromPoint(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),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,d=b.originalTiledImage;delete b.original;var e=a.extend({},b,{success:function(a){var b=a.item;b._originalForNavigator=d,c._matchBounds(b,d,!0),d.addHandler("bounds-change",function(){c._matchBounds(b,d)})}});return a.Viewer.prototype.addTiledImage.apply(this,[e])},_getMatchingItem:function(a){for(var b,c=this.world.getItemCount(),d=0;c>d;d++)if(b=this.world.getItemAt(d),b._originalForNavigator===a)return b;return null},_matchBounds:function(a,b,c){var d=b.getBounds();a.setPosition(d.getTopLeft(),c),a.setWidth(d.width,c)}})}(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]]||{};return f=h[e[d]],"string"!=typeof f&&(a.console.debug("Untranslated source string:",c),f=""),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))},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){var d=b*Math.PI/180,e=Math.cos(d)*(this.x-c.x)-Math.sin(d)*(this.y-c.y)+c.x,f=Math.sin(d)*(this.x-c.x)+Math.cos(d)*(this.y-c.y)+c.y;return new a.Point(e,f)},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)throw f=b.status,c=404==f?"Not Found":b.statusText,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(g){d=b.responseText}else d=e.match(/\s*[\{\[].*/)?a.parseJSON(e):e;return d}a.TileSource=function(b,c,d,e,f,g){var h,i,j=this,k=arguments;if(h=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,h),!this.success)for(i=0;i<arguments.length;i++)if(a.isFunction(arguments[i])){this.success=arguments[i];break}this.success&&this.addHandler("ready",function(a){j.success(a)}),"string"==a.type(arguments[0])&&(this.url=arguments[0]),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)):(this.ready=!0,this.aspectRatio=h.width&&h.height?h.width/h.height:1,this.dimensions=new a.Point(h.width,h.height),this.tileSize?(this._tileWidth=this._tileHeight=this.tileSize,delete this.tileSize):(this.tileWidth?(this._tileWidth=this.tileWidth,delete this.tileWidth):this._tileWidth=0,this.tileHeight?(this._tileHeight=this.tileHeight,delete this.tileHeight):this._tileHeight=0),this.tileOverlap=h.tileOverlap?h.tileOverlap:0,this.minLevel=h.minLevel?h.minLevel:0,this.maxLevel=void 0!==h.maxLevel&&null!==h.maxLevel?h.maxLevel:h.width&&h.height?Math.ceil(Math.log(Math.max(h.width,h.height))/Math.log(2)):0,this.success&&a.isFunction(this.success)&&this.success(this))},a.TileSource.prototype={getTileSize:function(b){return a.console.error("[TileSource.getTileSize] is deprecated.Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),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);return this.getLevelScale=function(a){return c[a]},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(b){var c,d,e;for(c=this.minLevel;c<this.maxLevel&&(e=this.getNumTiles(c),d=new a.Point(Math.floor(b.x/this.getTileWidth(c)),Math.floor(b.y/this.getTileHeight(c))),!(e.x+1>=d.x&&e.y+1>=d.y));c++);return Math.max(0,c-1)},getTileAtPoint:function(b,c){var d=c.times(this.dimensions.x).times(this.getLevelScale(b)),e=Math.floor(d.x/this.getTileWidth(b)),f=Math.floor(d.y/this.getTileHeight(b));return new a.Point(e,f)},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;return j=Math.min(j,e.x-h),k=Math.min(k,e.y-i),new a.Rect(h*l,i*l,j*l,k*l)},getImageInfo:function(c){var d,e,f,g,h,i,j,k=this;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);return d?(g=d.prototype.configure.apply(k,[b,c]),void 0===g.ajaxWithCredentials&&(g.ajaxWithCredentials=k.ajaxWithCredentials),f=new d(g),k.ready=!0,void k.raiseEvent("ready",{tileSource:f})):void k.raiseEvent("open-failed",{message:"Unable to load TileSource",source:c})},c.match(/\.js$/)?(d=c.split("/").pop().replace(".js",""),a.jsonp({url:c,async:!1,callbackName:d,callback:e})):a.makeAjaxRequest({url:c,withCredentials:this.ajaxWithCredentials,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(e){var f;f="undefined"!=typeof b&&b.toString?b.toString():"Unknown error",d=f+" 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.")},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{if(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)}}},!a.imageFormatSupported(m.Image.Format))throw new Error(a.getString("Errors.ImageFormat",m.Image.Format.toUpperCase()));for(e=j.getElementsByTagName("DisplayRect"),void 0===e&&(e=j.getElementsByTagNameNS(l,"DisplayRect")[0]),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)}});return n.length&&(m.Image.DisplayRect=n),c(b,m)}catch(o){throw o instanceof Error?o:new Error(a.getString("Errors.Dzi"))}else{if("Collection"==k)throw new Error(a.getString("Errors.Dzc"));if("Error"==k)return a._processDZIError(j)}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;if(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,this.displayRects)for(k=this.displayRects.length-1;k>=0;k--)for(l=this.displayRects[k],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;return a.Image?c=a.Image.xmlns:a.documentElement&&("Image"==a.documentElement.localName||"Image"==a.documentElement.tagName)&&(c=a.documentElement.namespaceURI),"http://schemas.microsoft.com/deepzoom/2008"==c||"http://schemas.microsoft.com/deepzoom/2009"==c},configure:function(d,e){var f;return f=a.isPlainObject(d)?c(this,d):b(this,d),e&&!f.tilesUrl&&(f.tilesUrl=e.replace(/([^\/]+)\.(dzi|xml|js)(\?.*|$)/,"$1_files/"),-1!=e.search(/\.(dzi|xml|js)\?/)?f.queryParams=e.match(/\?.*/):f.queryParams=""),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--)if(d=k[j],!(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.tileSize),g=Math.floor(g/this.tileSize),h=Math.ceil(h/this.tileSize),i=Math.ceil(i/this.tileSize),b>=f&&h>b&&c>=g&&i>c))return!0;return!1}})}(OpenSeadragon),function(a){function b(b){if(!b||!b.documentElement)throw new Error(a.getString("Errors.Xml"));var d=b.documentElement,e=d.tagName,f=null;if("info"==e)try{return f={},c(d,f),f}catch(g){throw g instanceof Error?g:new Error(a.getString("Errors.IIIF"))}throw new Error(a.getString("Errors.IIIF"))}function c(b,d,e){var f,g;if(3==b.nodeType&&e)g=b.nodeValue.trim(),g.match(/^\d*$/)&&(g=Number(g)),d[e]?(a.isArray(d[e])||(d[e]=[d[e]]),d[e].push(g)):d[e]=g;else if(1==b.nodeType)for(f=0;f<b.childNodes.length;f++)c(b.childNodes[f],d,b.nodeName)}a.IIIFTileSource=function(b){if(a.extend(!0,this,b),!(this.height&&this.width&&this["@id"]))throw new Error("IIIF required parameters not provided.");if(b.tileSizePerScaleFactor={},this.tile_width&&this.tile_height)b.tileWidth=this.tile_width,b.tileHeight=this.tile_height;else if(this.tile_width)b.tileSize=this.tile_width;else if(this.tile_height)b.tileSize=this.tile_height;else if(this.tiles)if(1==this.tiles.length)b.tileWidth=this.tiles[0].width,b.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var c=0;c<this.tiles.length;c++)for(var d=0;d<this.tiles[c].scaleFactors.length;d++){var e=this.tiles[c].scaleFactors[d];this.scale_factors.push(e),b.tileSizePerScaleFactor[e]={width:this.tiles[c].width,height:this.tiles[c].height||this.tiles[c].width}}}else{for(var f=Math.min(this.height,this.width),g=[256,512,1024],h=[],i=0;i<g.length;i++)g[i]<=f&&h.push(g[i]);h.length>0?b.tileSize=Math.max.apply(null,h):b.tileSize=f}b.maxLevel||(this.scale_factors?b.maxLevel=Math.floor(Math.pow(Math.max.apply(null,this.scale_factors),.5)):b.maxLevel=Number(Math.ceil(Math.log(Math.max(this.width,this.height),2)))),a.TileSource.apply(this,[b])},a.extend(a.IIIFTileSource.prototype,a.TileSource.prototype,{supports:function(a,b){return a.protocol&&"http://iiif.io/api/image"==a.protocol?!0:!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")?!0:a.identifier&&a.width&&a.height?!0:a.documentElement&&"info"==a.documentElement.tagName&&"http://library.stanford.edu/iiif/image-api/ns/"==a.documentElement.namespaceURI?!0:!1:!0},configure:function(c,d){if(a.isPlainObject(c))return c["@context"]?c:(c["@context"]="http://iiif.io/api/image/1.0/context.json",c["@id"]=d.replace("/info.json",""),c);var e=b(c);return e["@context"]="http://iiif.io/api/image/1.0/context.json",e["@id"]=d.replace("/info.xml",""),e},getTileWidth:function(a){var b=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[b]?this.tileSizePerScaleFactor[b].width:this._tileWidth},getTileHeight:function(a){var b=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[b]?this.tileSizePerScaleFactor[b].height:this._tileHeight},getTileUrl:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p="0",q=Math.pow(.5,this.maxLevel-a),r=Math.ceil(this.width*q),s=Math.ceil(this.height*q);return d=this.getTileWidth(a),e=this.getTileHeight(a),f=Math.ceil(d/q),g=Math.ceil(e/q),n=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",d>r&&e>s?(m=r+",",h="full"):(i=b*f,j=c*g,k=Math.min(f,this.width-i),l=Math.min(g,this.height-j),m=Math.ceil(k*q)+",",h=[i,j,k,l].join(",")),o=[this["@id"],h,m,p,n].join("/")}})}(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]},g.width&&g.height||(g.width=65572864,g.height=65572864),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){function b(b){var c,d,e=[];for(d=0;d<b.length;d++)c=b[d],c.height&&c.width&&c.url&&(c.url.toLowerCase().match(/^.*\.(png|jpg|jpeg|gif)$/)||c.mimetype&&c.mimetype.toLowerCase().match(/^.*\/(png|jpg|jpeg|gif)$/))?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{for(i={type:g.getAttribute("type"),levels:[]},j=g.getElementsByTagName("level"),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(k){throw k instanceof Error?k: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),d.levels.length>0?(e=d.levels[d.levels.length-1].width,f=d.levels[d.levels.length-1].height):(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;return f=a.isPlainObject(b)?d(this,b):c(this,b)},getLevelScale:function(a){var b=NaN;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].width/this.levels[this.maxLevel].width),b},getNumTiles:function(b){var c=this.getLevelScale(b);return c?new a.Point(1,1):new a.Point(0,0)},getTileAtPoint:function(b,c){return new a.Point(0,0)},getTileUrl:function(a,b,c){var d=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(d=this.levels[a].url),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,d=this;this.crossOriginPolicy&&(c.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(c.useCredentials=this.ajaxWithCredentials),a.addEvent(c,"load",function(){d.width=c.naturalWidth,d.height=c.naturalHeight,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;return a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].width/this.levels[this.maxLevel].width),b},getNumTiles:function(b){var c=this.getLevelScale(b);return c?new a.Point(1,1):new a.Point(0,0)},getTileAtPoint:function(b,c){return new a.Point(0,0)},getTileUrl:function(a,b,c){var d=null;return a>=this.minLevel&&a<=this.maxLevel&&(d=this.levels[a].url),d},getContext2D:function(a,b,c){var d=null;return a>=this.minLevel&&a<=this.maxLevel&&(d=this.levels[a].context2D),d},_buildLevels:function(){var b=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!a.supportsCanvas||!this.useCanvas)return delete this._image,b;var c=this._image.naturalWidth,d=this._image.naturalHeight,e=document.createElement("canvas"),f=e.getContext("2d");if(e.width=c,e.height=d,f.drawImage(this._image,0,0,c,d),b[0].context2D=f,delete this._image,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"),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;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){b.element.disabled||(c>=a.ButtonState.GROUP&&b.currentState==a.ButtonState.REST&&(e(b),b.currentState=a.ButtonState.GROUP),c>=a.ButtonState.HOVER&&b.currentState==a.ButtonState.GROUP&&(b.imgHover&&(b.imgHover.style.visibility=""),b.currentState=a.ButtonState.HOVER),c>=a.ButtonState.DOWN&&b.currentState==a.ButtonState.HOVER&&(b.imgDown&&(b.imgDown.style.visibility=""),b.currentState=a.ButtonState.DOWN))}function g(b,c){b.element.disabled||(c<=a.ButtonState.HOVER&&b.currentState==a.ButtonState.DOWN&&(b.imgDown&&(b.imgDown.style.visibility="hidden"),b.currentState=a.ButtonState.HOVER),c<=a.ButtonState.GROUP&&b.currentState==a.ButtonState.HOVER&&(b.imgHover&&(b.imgHover.style.visibility="hidden"),b.currentState=a.ButtonState.GROUP),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"),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){b.insideElementPressed?(f(c,a.ButtonState.DOWN),c.raiseEvent("enter",{originalEvent:b.originalEvent})):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){b.insideElementPressed&&b.insideElementReleased?(g(c,a.ButtonState.HOVER),c.raiseEvent("release",{originalEvent:b.originalEvent})):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){return 13===a.keyCode?(c.raiseEvent("click",{originalEvent:a.originalEvent}),c.raiseEvent("release",{originalEvent:a.originalEvent}),!1):!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;if(this.element=b.element||a.makeNeutralElement("div"),!b.group)for(this.label=a.makeNeutralElement("label"),this.element.style.display="inline-block",this.element.appendChild(this.label),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(a,b,c,d){this.x="number"==typeof a?a:0,this.y="number"==typeof b?b:0,this.width="number"==typeof c?c:0,this.height="number"==typeof d?d:0},a.Rect.prototype={clone:function(){return new a.Rect(this.x,this.y,this.width,this.height)},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)},getTopRight:function(){return new a.Point(this.x+this.width,this.y)},getBottomLeft:function(){return new a.Point(this.x,this.y+this.height)},getCenter:function(){return new a.Point(this.x+this.width/2,this.y+this.height/2)},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},times:function(a){return new OpenSeadragon.Rect(this.x*a,this.y*a,this.width*a,this.height*a)},union:function(a){var b=Math.min(this.x,a.x),c=Math.min(this.y,a.y),d=Math.max(this.x+this.width,a.x+a.width),e=Math.max(this.y+this.height,a.y+a.height);return new OpenSeadragon.Rect(b,c,d-b,e-c)},rotate:function(b,c){var d,e=this.width,f=this.height;if(b=(b+360)%360,b%90!==0)throw new Error("Currently only 0, 90, 180, and 270 degrees are supported.");
if(0===b)return new a.Rect(this.x,this.y,this.width,this.height);switch(c=c||this.getCenter(),b){case 90:d=this.getBottomLeft(),e=this.height,f=this.width;break;case 180:d=this.getBottomRight();break;case 270:d=this.getTopRight(),e=this.height,f=this.width;break;default:d=this.getTopLeft()}return d=d.rotate(b,c),new a.Rect(d.x,d.y,e,f)},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+"]"}}}(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);return this.dragging=!0,this.element&&("horizontal"==this.scroll?-b.delta.x>0?c>-(f-h.x)&&(this.element.style.marginLeft=c+2*b.delta.x+"px",d(this,h.x,c+2*b.delta.x)):-b.delta.x<0&&0>c&&(this.element.style.marginLeft=c+2*b.delta.x+"px",d(this,h.x,c+2*b.delta.x)):-b.delta.y>0?e>-(g-h.y)&&(this.element.style.marginTop=e+2*b.delta.y+"px",d(this,h.y,e+2*b.delta.y)):-b.delta.y<0&&0>e&&(this.element.style.marginTop=e+2*b.delta.y+"px",d(this,h.y,e+2*b.delta.y))),!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);return this.element&&("horizontal"==this.scroll?b.scroll>0?c>-(f-h.x)&&(this.element.style.marginLeft=c-60*b.scroll+"px",d(this,h.x,c-60*b.scroll)):b.scroll<0&&0>c&&(this.element.style.marginLeft=c-60*b.scroll+"px",d(this,h.x,c-60*b.scroll)):b.scroll<0?e>h.y-g&&(this.element.style.marginTop=e+60*b.scroll+"px",d(this,h.y,e+60*b.scroll)):b.scroll>0&&0>e&&(this.element.style.marginTop=e+60*b.scroll+"px",d(this,h.y,e+60*b.scroll))),!1}function d(b,c,d){var e,f,g,h,i,j,k;for(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=0>f?0:f,j=f;g>j&&j<b.panels.length;j++)k=b.panels[j],k.activePanel||(h=new a.Viewer({id:k.id,tileSources:[b.viewer.tileSources[j]],element:k,navigatorSizeRatio:b.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0}),h.displayRegion=a.makeNeutralElement("textarea"),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),k.activePanel=!0)}function e(a){var b=a.eventSource.element;return"horizontal"==this.scroll?b.style.marginBottom="0px":b.style.marginLeft="0px",!1}function f(b){var c=b.eventSource.element;return"horizontal"==this.scroll?c.style.marginBottom="-"+a.getElementSize(c).y/2+"px":c.style.marginLeft="-"+a.getElementSize(c).x/2+"px",!1}function g(a){if(a.preventDefaultAction||a.ctrl||a.alt||a.meta)return!0;switch(a.keyCode){case 38:return c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),!1;case 40:return c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),!1;case 37:return c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),!1;case 39:return c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),!1;default:return!0}}function h(a){if(a.preventDefaultAction||a.ctrl||a.alt||a.meta)return!0;switch(a.keyCode){case 61:return c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),!1;case 45:return c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),!1;case 48:case 119:case 87:return c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),!1;case 115:case 83:return c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),!1;case 97:return c.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),!1;case 100:return c.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),!1;default:return!0}}var i={};a.ReferenceStrip=function(j){var k,l,m,n=this,o=j.viewer,p=a.getElementSize(o.element);for(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)}),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})):"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})):(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=[],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();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",""));this.currentSelected!==f&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=f,this.currentSelected.style.background="#999","horizontal"==this.scroll?(c=Number(b)*(this.panelWidth+3),c>j+g.x-this.panelWidth?(c=Math.min(c,h-g.x),this.element.style.marginLeft=-c+"px",d(this,g.x,-c)):j>c&&(c=Math.max(0,c-g.x/2),this.element.style.marginLeft=-c+"px",d(this,g.x,-c))):(c=Number(b)*(this.panelHeight+3),c>k+g.y-this.panelHeight?(c=Math.min(c,i-g.y),this.element.style.marginTop=-c+"px",d(this,g.y,-c)):k>c&&(c=Math.max(0,c-g.y/2),this.element.style.marginTop=-c+"px",d(this,g.y,-c))),this.currentPage=b,a.getElement(f.id+"-displayregion").focus(),e.call(this,{eventSource:this.innerTracker}))},update:function(){return i[this.id].animating?(a.console.log("image reference strip update"),!0):!1},destroy:function(){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&&0!==b.springStiffness,"[OpenSeadragon.Spring] options.animationTime must be a non-zero number"),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},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(),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,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,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,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;this._exponential?(c=this.start._logValue,d=this.target._logValue):(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));this._exponential?this.current.value=Math.exp(e):this.current.value=e}}}(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--,(!a.jobLimit||a.jobsInProgress<a.jobLimit)&&a.jobQueue.length>0&&(d=a.jobQueue.shift(),d.start(),a.jobsInProgress++),c(b.image,b.errorMsg)}b.prototype={errorMsg:null,start:function(){var a=this;this.image=new Image,this.crossOriginPolicy!==!1&&(this.image.crossOrigin=this.crossOriginPolicy),this.image.onload=function(){a.finish(!0)},this.image.onabort=this.image.onerror=function(){a.errorMsg="Image load aborted",a.finish(!1)},this.jobId=window.setTimeout(function(){a.errorMsg="Image load exceeded timeout",a.finish(!1)},this.timeout),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,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,crossOriginPolicy:a.crossOriginPolicy,callback:e,abort:a.abort},g=new b(f);!this.jobLimit||this.jobsInProgress<this.jobLimit?(g.start(),this.jobsInProgress++):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){this.level=a,this.x=b,this.y=c,this.bounds=d,this.exists=e,this.url=f,this.context2D=g,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.distance=null,this.visibility=null,this.beingDrawn=!1,this.lastTouchTime=0},a.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},drawHTML:function(b){return this.cacheImageRecord?this.loaded?(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",void a.setElementOpacity(this.element,this.opacity)):void a.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString()):void a.console.warn("[Tile.drawHTML] attempting to draw tile %s when it's not cached",this.toString())},drawCanvas:function(b,c){var d,e=this.position,f=this.size;return this.context2D||this.cacheImageRecord?(d=this.context2D||this.cacheImageRecord.getRenderedContext(),this.loaded&&d?(b.save(),b.globalAlpha=this.opacity,1===b.globalAlpha&&(this.context2D||this.url.match(".png"))&&b.clearRect(e.x*a.pixelDensityRatio+1,e.y*a.pixelDensityRatio+1,f.x*a.pixelDensityRatio-2,f.y*a.pixelDensityRatio-2),c({context:b,tile:this,rendered:d}),b.drawImage(d.canvas,0,0,d.canvas.width,d.canvas.height,e.x*a.pixelDensityRatio,e.y*a.pixelDensityRatio,f.x*a.pixelDensityRatio,f.y*a.pixelDensityRatio),void b.restore()):void a.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString())):void a.console.warn("[Tile.drawCanvas] attempting to draw tile %s when it's not cached",this.toString())},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={CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8},a.Overlay=function(b,c,d){var e;e=a.isPlainObject(b)?b:{element:b,location:c,placement:d},this.element=e.element,this.scales=e.location instanceof a.Rect,this.bounds=new a.Rect(e.location.x,e.location.y,e.location.width,e.location.height),this.position=new a.Point(e.location.x,e.location.y),this.size=new a.Point(e.location.width,e.location.height),this.style=e.element.style,this.placement=e.location instanceof a.Point?e.placement:a.OverlayPlacement.TOP_LEFT,this.onDraw=e.onDraw,this.checkResize=void 0===e.checkResize?!0:e.checkResize},a.Overlay.prototype={adjust:function(b,c){switch(this.placement){case a.OverlayPlacement.TOP_LEFT:break;case a.OverlayPlacement.TOP:b.x-=c.x/2;break;case a.OverlayPlacement.TOP_RIGHT:b.x-=c.x;break;case a.OverlayPlacement.RIGHT:b.x-=c.x,b.y-=c.y/2;break;case a.OverlayPlacement.BOTTOM_RIGHT:b.x-=c.x,b.y-=c.y;break;case a.OverlayPlacement.BOTTOM:b.x-=c.x/2,b.y-=c.y;break;case a.OverlayPlacement.BOTTOM_LEFT:b.y-=c.y;break;case a.OverlayPlacement.LEFT:b.y-=c.y/2;break;default:case a.OverlayPlacement.CENTER:b.x-=c.x/2,b.y-=c.y/2}},destroy:function(){var a=this.element,b=this.style;a.parentNode&&(a.parentNode.removeChild(a),a.prevElementParent&&(b.display="none",document.body.appendChild(a))),this.onDraw=null,b.top="",b.left="",b.position="",this.scales&&(b.width="",b.height="")},drawHTML:function(b,c){var d,e,f=this.element,g=this.style,h=this.scales,i=c.degrees,j=c.pixelFromPoint(this.bounds.getTopLeft(),!0);if(f.parentNode!=b&&(f.prevElementParent=f.parentNode,f.prevNextSibling=f.nextSibling,b.appendChild(f),this.size=a.getElementSize(f)),d=h?c.deltaPixelsFromPoints(this.bounds.getSize(),!0):this.checkResize?a.getElementSize(f):this.size,this.position=j,this.size=d,this.adjust(j,d),j=j.apply(Math.round),d=d.apply(Math.round),0!==i&&this.scales){e=new a.Point(d.x/2,d.y/2);var k=new a.Point(c.viewer.drawer.canvas.width/2,c.viewer.drawer.canvas.height/2);j=j.plus(e).rotate(i,k).minus(e),d=d.rotate(i,new a.Point(0,0)),d=new a.Point(Math.abs(d.x),Math.abs(d.y))}this.onDraw?this.onDraw(j,d,f):(g.left=j.x+"px",g.top=j.y+"px",g.position="absolute","none"!=g.display&&(g.display="block"),h&&(g.width=d.x+"px",g.height=d.y+"px"))},update:function(b,c){this.scales=b instanceof a.Rect,this.bounds=new a.Rect(b.x,b.y,b.width,b.height),this.placement=b instanceof a.Point?c:a.OverlayPlacement.TOP_LEFT}}}(OpenSeadragon),function(a){a.Drawer=function(b){a.console.assert(b.viewer,"[Drawer] options.viewer is required");var c=arguments;if(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=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:!0),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",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){return a.console.error("drawer.addOverlay is deprecated. Use viewer.addOverlay instead."),this.viewer.addOverlay(b,c,d,e),this},updateOverlay:function(b,c,d){return a.console.error("drawer.updateOverlay is deprecated. Use viewer.updateOverlay instead."),this.viewer.updateOverlay(b,c,d),this},removeOverlay:function(b){return a.console.error("drawer.removeOverlay is deprecated. Use viewer.removeOverlay instead."),this.viewer.removeOverlay(b),this},clearOverlays:function(){return a.console.error("drawer.clearOverlays is deprecated. Use viewer.clearOverlays instead."),this.viewer.clearOverlays(),this},setOpacity:function(b){a.console.error("drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.");for(var c=this.viewer.world,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.");for(var b=this.viewer.world,c=0,d=0;d<b.getItemCount();d++){var e=b.getItemAt(d).getOpacity();e>c&&(c=e)}return c},needsUpdate:function(){return a.console.error("[Drawer.needsUpdate] this function is deprecated. Use World.needsDraw instead."),this.viewer.world.needsDraw()},numTilesLoaded:function(){return a.console.error("[Drawer.numTilesLoaded] this function is deprecated. Use TileCache.numTilesLoaded instead."),this.viewer.tileCache.numTilesLoaded()},reset:function(){return a.console.error("[Drawer.reset] this function is deprecated. Use World.resetItems instead."),this.viewer.world.resetItems(),this},update:function(){return a.console.error("[Drawer.update] this function is deprecated. Use Drawer.clear and World.draw instead."),this.clear(),this.viewer.world.draw(),this},canRotate:function(){return this.useCanvas},destroy:function(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null},clear:function(){if(this.canvas.innerHTML="",this.useCanvas){var a=this._calculateCanvasSize();(this.canvas.width!=a.x||this.canvas.height!=a.y)&&(this.canvas.width=a.x,this.canvas.height=a.y,null!==this.sketchCanvas&&(this.sketchCanvas.width=this.canvas.width,this.sketchCanvas.height=this.canvas.height)),this._clear()}},_clear:function(a){if(this.useCanvas){var b=this._getContext(a),c=b.canvas;b.clearRect(0,0,c.width,c.height)}},viewportToDrawerRectangle:function(b){var c=this.viewport.pixelFromPoint(b.getTopLeft(),!0),d=this.viewport.deltaPixelsFromPoints(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){if(a.console.assert(b,"[Drawer.drawTile] tile is required"),a.console.assert(c,"[Drawer.drawTile] drawingHandler is required"),this.useCanvas){var e=this._getContext(d);0!==this.viewport.degrees?(this._offsetForRotation(b,this.viewport.degrees,d),b.drawCanvas(e,c),this._restoreRotationChanges(b,d)):b.drawCanvas(e,c)}else b.drawHTML(this.canvas)},_getContext:function(a){var b=this.context;return a&&(null===this.sketchCanvas&&(this.sketchCanvas=document.createElement("canvas"),this.sketchCanvas.width=this.canvas.width,this.sketchCanvas.height=this.canvas.height,this.sketchContext=this.sketchCanvas.getContext("2d")),b=this.sketchContext),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(a){this.useCanvas&&this.sketchCanvas&&(this.context.save(),this.context.globalAlpha=a,this.context.drawImage(this.sketchCanvas,0,0),this.context.restore())},drawDebugInfo:function(b,c,d){if(this.useCanvas){var e=this.context;e.save(),e.lineWidth=2*a.pixelDensityRatio,e.font="small-caps bold "+13*a.pixelDensityRatio+"px arial",e.strokeStyle=this.debugGridColor,e.fillStyle=this.debugGridColor,0!==this.viewport.degrees&&this._offsetForRotation(b,this.viewport.degrees),e.strokeRect(b.position.x*a.pixelDensityRatio,b.position.y*a.pixelDensityRatio,b.size.x*a.pixelDensityRatio,b.size.y*a.pixelDensityRatio);var f=(b.position.x+b.size.x/2)*a.pixelDensityRatio,g=(b.position.y+b.size.y/2)*a.pixelDensityRatio;e.translate(f,g),e.rotate(Math.PI/180*-this.viewport.degrees),e.translate(-f,-g),0===b.x&&0===b.y&&(e.fillText("Zoom: "+this.viewport.getZoom(),b.position.x*a.pixelDensityRatio,(b.position.y-30)*a.pixelDensityRatio),e.fillText("Pan: "+this.viewport.getBounds().toString(),b.position.x*a.pixelDensityRatio,(b.position.y-20)*a.pixelDensityRatio)),e.fillText("Level: "+b.level,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+20)*a.pixelDensityRatio),e.fillText("Column: "+b.x,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+30)*a.pixelDensityRatio),e.fillText("Row: "+b.y,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+40)*a.pixelDensityRatio),e.fillText("Order: "+d+" of "+c,(b.position.x+10)*a.pixelDensityRatio,(b.position.y+50)*a.pixelDensityRatio),e.fillText("Size: "+b.size.toString(),(b.position.x+10)*a.pixelDensityRatio,(b.position.y+60)*a.pixelDensityRatio),e.fillText("Position: "+b.position.toString(),(b.position.x+10)*a.pixelDensityRatio,(b.position.y+70)*a.pixelDensityRatio),0!==this.viewport.degrees&&this._restoreRotationChanges(b),e.restore()}},debugRect:function(b){if(this.useCanvas){var c=this.context;c.save(),c.lineWidth=2*a.pixelDensityRatio,c.strokeStyle=this.debugGridColor,c.fillStyle=this.debugGridColor,c.strokeRect(b.x*a.pixelDensityRatio,b.y*a.pixelDensityRatio,b.width*a.pixelDensityRatio,b.height*a.pixelDensityRatio),c.restore()}},_offsetForRotation:function(a,b,c){var d=this.canvas.width/2,e=this.canvas.height/2,f=this._getContext(c);f.save(),f.translate(d,e),f.rotate(Math.PI/180*b),f.translate(-d,-e)},_restoreRotationChanges:function(a,b){var c=this._getContext(b);c.restore()},_calculateCanvasSize:function(){var b=a.pixelDensityRatio,c=this.viewport.getContainerSize();return{x:c.x*b,y:c.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]}),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.contentSize?this.resetContentSize(this.contentSize):this.setHomeBounds(new a.Rect(0,0,1,1),1),this.goHome(!0),this.update()},a.Viewport.prototype={resetContentSize:function(b){return 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.setHomeBounds(new a.Rect(0,0,1,b.y/b.x),b.x),this},setHomeBounds:function(b,c){a.console.assert(b,"[Viewport.setHomeBounds] bounds is required"),a.console.assert(b instanceof a.Rect,"[Viewport.setHomeBounds] bounds must be an OpenSeadragon.Rect"),a.console.assert(b.width>0,"[Viewport.setHomeBounds] bounds.width must be greater than 0"),a.console.assert(b.height>0,"[Viewport.setHomeBounds] bounds.height must be greater than 0"),this.homeBounds=b.clone(),this.contentSize=this.homeBounds.getSize().times(c),this.contentAspectX=this.contentSize.x/this.contentSize.y,this.contentAspectY=this.contentSize.y/this.contentSize.x,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this.contentSize.clone(),contentFactor:c,homeBounds:this.homeBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var a,b=this.contentAspectX/this.getAspectRatio();return a=this.homeFillsViewer?b>=1?b:1:b>=1?1:b,a/this.homeBounds.width},getHomeBounds:function(){var b=this.homeBounds.getCenter(),c=1/this.getHomeZoom(),d=c/this.getAspectRatio();return new a.Rect(b.x-c/2,b.y-d/2,c,d)},goHome:function(a){return this.viewer&&this.viewer.raiseEvent("home",{immediately:a}),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;return a||(a=this.contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,a/=this.homeBounds.width),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.forceRedraw()},getBounds:function(b){var c=this.getCenter(b),d=1/this.getZoom(b),e=d/this.getAspectRatio();return new a.Rect(c.x-d/2,c.y-e/2,d,e)},getBoundsWithMargins:function(a){var b=this.getBounds(a),c=this._containerInnerSize.x*this.getZoom(a);return 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,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);return b?k:this.zoomPoint?(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),l.plus(j)):l},getZoom:function(a){return a?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyBoundaryConstraints:function(b,c){var d=0,e=0,f=new a.Rect(b.x,b.y,b.width,b.height),g=this.visibilityRatio*f.width,h=this.visibilityRatio*f.height;if(this.wrapHorizontal);else{var i=f.x+(f.width-g);this.homeBounds.x>i&&(d=this.homeBounds.x-i);var j=this.homeBounds.x+this.homeBounds.width,k=f.x+g;if(k>j){var l=j-k;d=d?(d+l)/2:l}}if(this.wrapVertical);else{var m=f.y+(f.height-h);this.homeBounds.y>m&&(e=this.homeBounds.y-m);var n=this.homeBounds.y+this.homeBounds.height,o=f.y+h;if(o>n){var p=n-o;e=e?(e+p)/2:p}}return(d||e)&&(f.x+=d,f.y+=e),this.viewer&&this.viewer.raiseEvent("constrain",{immediately:c}),f},applyConstraints:function(a){var b,c,d=this.getZoom(),e=Math.max(Math.min(d,this.getMaxZoom()),this.getMinZoom());return d!=e&&this.zoomTo(e,this.zoomPoint,a),b=this.getBounds(),c=this._applyBoundaryConstraints(b,a),(b.x!==c.x||b.y!==c.y||a)&&this.fitBounds(c,a),this},ensureVisible:function(a){return this.applyConstraints(a)},_fitBounds:function(b,c){c=c||{};var d,e,f,g,h,i,j=c.immediately||!1,k=c.constraints||!1,l=this.getAspectRatio(),m=b.getCenter(),n=new a.Rect(b.x,b.y,b.width,b.height);return n.getAspectRatio()>=l?(n.height=b.width/l,n.y=m.y-n.height/2):(n.width=b.height*l,
n.x=m.x-n.width/2),k&&(h=n.getAspectRatio()),this.panTo(this.getCenter(!0),!0),this.zoomTo(this.getZoom(!0),null,!0),d=this.getBounds(),e=this.getZoom(),f=1/n.width,k&&(i=Math.max(Math.min(f,this.getMaxZoom()),this.getMinZoom()),f!==i&&(f=i,n.width=1/f,n.x=m.x-n.width/2,n.height=n.width/h,n.y=m.y-n.height/2),n=this._applyBoundaryConstraints(n,j),m=n.getCenter()),j?(this.panTo(m,!0),this.zoomTo(f,null,!0)):Math.abs(f-e)<1e-8||Math.abs(n.width-d.width)<1e-8?this.panTo(m,j):(g=d.getTopLeft().times(this._containerInnerSize.x/d.width).minus(n.getTopLeft().times(this._containerInnerSize.x/n.width)).divide(this._containerInnerSize.x/d.width-this._containerInnerSize.x/n.width),this.zoomTo(f,g,j))},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.homeBounds.x+this.homeBounds.width/2,this.homeBounds.y,0,this.homeBounds.height);return this.fitBounds(c,b)},fitHorizontally:function(b){var c=new a.Rect(this.homeBounds.x,this.homeBounds.y+this.homeBounds.height/2,this.homeBounds.width,0);return this.fitBounds(c,b)},panBy:function(b,c){var d=new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return b=b.rotate(-this.degrees,new a.Point(0,0)),this.panTo(d.plus(b),c)},panTo:function(a,b){return b?(this.centerSpringX.resetTo(a.x),this.centerSpringY.resetTo(a.y)):(this.centerSpringX.springTo(a.x),this.centerSpringY.springTo(a.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:a,immediately:b}),this},zoomBy:function(b,c,d){return c instanceof a.Point&&!isNaN(c.x)&&!isNaN(c.y)&&(c=c.rotate(-this.degrees,new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value))),this.zoomTo(this.zoomSpring.target.value*b,c,d)},zoomTo:function(b,c,d){return this.zoomPoint=c instanceof a.Point&&!isNaN(c.x)&&!isNaN(c.y)?c:null,d?this.zoomSpring.resetTo(b):this.zoomSpring.springTo(b),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:b,refPoint:c,immediately:d}),this},setRotation:function(a){return this.viewer&&this.viewer.drawer.canRotate()?(a=(a+360)%360,this.degrees=a,this.viewer.forceRedraw(),null!==this.viewer&&this.viewer.raiseEvent("rotate",{degrees:a}),this):this},getRotation:function(){return this.degrees},resize:function(a,b){var c,d=this.getBounds(),e=d;return this.containerSize.x=a.x,this.containerSize.y=a.y,this._updateContainerInnerSize(),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}),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,b,c,d;this.zoomPoint&&(a=this.pixelFromPoint(this.zoomPoint,!0)),this.zoomSpring.update(),this.zoomPoint&&this.zoomSpring.current.value!=this._oldZoom?(b=this.pixelFromPoint(this.zoomPoint,!0),c=b.minus(a),d=this.deltaPointsFromPixels(c,!0),this.centerSpringX.shiftBy(d.x),this.centerSpringY.shiftBy(d.y)):this.zoomPoint=null,this.centerSpringX.update(),this.centerSpringY.update();var e=this.centerSpringX.current.value!=this._oldCenterX||this.centerSpringY.current.value!=this._oldCenterY||this.zoomSpring.current.value!=this._oldZoom;return this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,e},deltaPixelsFromPoints:function(a,b){return a.times(this._containerInnerSize.x*this.getZoom(b))},deltaPointsFromPixels:function(a,b){return a.divide(this._containerInnerSize.x*this.getZoom(b))},pixelFromPoint:function(a,b){return this._pixelFromPoint(a,this.getBounds(b))},_pixelFromPoint:function(b,c){return b.minus(c.getTopLeft()).times(this._containerInnerSize.x/c.width).plus(new a.Point(this._margins.left,this._margins.top))},pointFromPixel:function(b,c){var d=this.getBounds(c);return b.minus(new a.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/d.width).plus(d.getTopLeft())},_viewportToImageDelta:function(b,c){var d=this.homeBounds.width;return new a.Point(b*(this.contentSize.x/d),c*(this.contentSize.y*this.contentAspectX/d))},viewportToImageCoordinates:function(b,c){return 1==arguments.length?this.viewportToImageCoordinates(b.x,b.y):(this.viewer&&this.viewer.world.getItemCount()>1&&a.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead."),this._viewportToImageDelta(b-this.homeBounds.x,c-this.homeBounds.y))},_imageToViewportDelta:function(b,c){var d=this.homeBounds.width;return new a.Point(b/this.contentSize.x*d,c/this.contentSize.y/this.contentAspectX*d)},imageToViewportCoordinates:function(b,c){if(1==arguments.length)return this.imageToViewportCoordinates(b.x,b.y);this.viewer&&this.viewer.world.getItemCount()>1&&a.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");var d=this._imageToViewportDelta(b,c);return d.x+=this.homeBounds.x,d.y+=this.homeBounds.y,d},imageToViewportRectangle:function(b,c,d,e){var f,g,h;return 1==arguments.length?(h=b,this.imageToViewportRectangle(h.x,h.y,h.width,h.height)):(f=this.imageToViewportCoordinates(b,c),g=this._imageToViewportDelta(d,e),new a.Rect(f.x,f.y,g.x,g.y))},viewportToImageRectangle:function(b,c,d,e){var f,g,h;return 1==arguments.length?(h=b,this.viewportToImageRectangle(h.x,h.y,h.width,h.height)):(f=this.viewportToImageCoordinates(b,c),g=this._viewportToImageDelta(d,e),new a.Rect(f.x,f.y,g.x,g.y))},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(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))},viewerElementToViewportCoordinates:function(a){return this.pointFromPixel(a,!0)},viewportToViewerElementCoordinates:function(a){return this.pixelFromPoint(a,!0)},windowToViewportCoordinates:function(a){var b=a.minus(OpenSeadragon.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(b)},viewportToWindowCoordinates:function(a){var b=this.viewportToViewerElementCoordinates(a);return b.plus(OpenSeadragon.getElementPosition(this.viewer.element))},viewportToImageZoom:function(b){this.viewer&&this.viewer.world.getItemCount()>1&&a.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");var c=this.contentSize.x,d=this._containerInnerSize.x,e=this.homeBounds.width,f=d/c*e;return b*f},imageToViewportZoom:function(b){this.viewer&&this.viewer.world.getItemCount()>1&&a.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image.");var c=this.contentSize.x,d=this._containerInnerSize.x,e=this.homeBounds.width,f=c/d/e;return b*f}}}(OpenSeadragon),function(a){function b(b){b._needsDraw=!1;var d,e,g,h,i,j,l,m,n=null,o=!1,q=a.now(),r=b.viewport.getBoundsWithMargins(!0),s=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(0),!0).x*b._scaleSpring.current.value,t=Math.max(b.source.minLevel,Math.floor(Math.log(b.minZoomImageRatio)/Math.log(2))),u=Math.min(Math.abs(b.source.maxLevel),Math.abs(Math.floor(Math.log(s/b.minPixelRatio)/Math.log(2)))),v=b.viewport.degrees;for(r.x-=b._xSpring.current.value,r.y-=b._ySpring.current.value;b.lastDrawn.length>0;)d=b.lastDrawn.pop(),d.beingDrawn=!1;if(90===v||270===v)r=r.rotate(v);else if(0!==v&&180!==v){var w=r.rotate(90);r.x-=w.width/2,r.y-=w.height/2,r.width+=w.width,r.height+=w.height}var x=r.getTopLeft(),y=r.getBottomRight();if(!(!b.wrapHorizontal&&(y.x<0||x.x>b._worldWidthCurrent)||!b.wrapVertical&&(y.y<0||x.y>b._worldHeightCurrent))){b.wrapHorizontal||(x.x=Math.max(x.x,0),y.x=Math.min(y.x,b._worldWidthCurrent)),b.wrapVertical||(x.y=Math.max(x.y,0),y.y=Math.min(y.y,b._worldHeightCurrent)),t=Math.min(t,u);var z;for(e=u;e>=t;e--){if(z=!1,g=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(e),!0).x*b._scaleSpring.current.value,!o&&g>=b.minPixelRatio||e==t)z=!0,o=!0;else if(!o)continue;if(h=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(e),!1).x*b._scaleSpring.current.value,i=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(Math.max(b.source.getClosestLevel(b.viewport.containerSize)-1,0)),!1).x*b._scaleSpring.current.value,j=b.immediateRender?1:i,l=Math.min(1,(g-.5)/.5),m=j/Math.abs(j-h),n=c(b,o,z,e,l,m,x,y,q,n),k(b.coverage,e))break}p(b,b.lastDrawn),n&&!n.context2D&&f(b,n,q)}}function c(a,b,c,e,f,g,h,i,j,k){var l,m,o,p,q,r=a.viewport.pixelFromPoint(a.viewport.getCenter());for(a.viewer&&a.viewer.raiseEvent("update-level",{tiledImage:a,havedrawn:b,level:e,opacity:f,visibility:g,topleft:h,bottomright:i,currenttime:j,best:k}),o=a.source.getTileAtPoint(e,h.divide(a._scaleSpring.current.value)),p=a.source.getTileAtPoint(e,i.divide(a._scaleSpring.current.value)),q=a.source.getNumTiles(e),n(a.coverage,e),a.wrapHorizontal||(p.x=Math.min(p.x,q.x-1)),a.wrapVertical||(p.y=Math.min(p.y,q.y-1)),l=o.x;l<=p.x;l++)for(m=o.y;m<=p.y;m++)k=d(a,c,b,l,m,e,f,g,r,q,j,k);return k}function d(a,b,c,d,f,g,k,n,p,q,r,s){var t=e(d,f,g,a.source,a.tilesMatrix,r,q,a._worldWidthCurrent,a._worldHeightCurrent),u=b;if(a.viewer&&a.viewer.raiseEvent("update-tile",{tiledImage:a,tile:t}),m(a.coverage,g,d,f,!1),!t.exists)return s;if(c&&!u&&(l(a.coverage,g,d,f)?m(a.coverage,g,d,f,!0):u=!0),!u)return s;if(i(t,a.source.tileOverlap,a.viewport,p,n,a),!t.loaded)if(t.context2D)h(a,t);else{var v=a._tileCache.getImageRecord(t.url);if(v){var w=v.getImage();h(a,t,w)}}if(t.loaded){var x=j(a,t,d,f,g,k,r);x&&(a._needsDraw=!0)}else t.loading||(s=o(s,t));return s}function e(b,c,d,e,f,g,h,i,j){var k,l,m,n,o,p,q;return f[d]||(f[d]={}),f[d][b]||(f[d][b]={}),f[d][b][c]||(k=(h.x+b%h.x)%h.x,l=(h.y+c%h.y)%h.y,m=e.getTileBounds(d,k,l),n=e.tileExists(d,k,l),o=e.getTileUrl(d,k,l),p=e.getContext2D?e.getContext2D(d,k,l):void 0,m.x+=(b-k)/h.x,m.y+=j/i*((c-l)/h.y),f[d][b][c]=new a.Tile(d,b,c,m,n,o,p)),q=f[d][b][c],q.lastTouchTime=g,q}function f(a,b,c){b.loading=!0,a._imageLoader.addJob({src:b.url,crossOriginPolicy:a.crossOriginPolicy,callback:function(d,e){g(a,b,c,d,e)},abort:function(){b.loading=!1}})}function g(b,c,d,e,f){if(e){if(d<b.lastResetTime)return a.console.log("Ignoring tile %s loaded before reset: %s",c,c.url),void(c.loading=!1)}else if(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}),!b.debugMode)return c.loading=!1,void(c.exists=!1);var g=function(){var a=Math.ceil(Math.log(b.source.getTileWidth(c.level))/Math.log(2));h(b,c,e,a)};b._midDraw?window.setTimeout(g,1):g()}function h(a,b,c,d){function e(){return g++,f}function f(){g--,0===g&&(b.loading=!1,b.loaded=!0,b.context2D||a._tileCache.cacheTile({image:c,tile:b,cutoff:d,tiledImage:a}),a._needsDraw=!0)}var g=0;a.viewer.raiseEvent("tile-loaded",{tile:b,tiledImage:a,image:c,getCompletionCallback:e}),e()()}function i(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.pixelFromPoint(h,!0),k=d.pixelFromPoint(h,!1),l=d.deltaPixelsFromPoints(i,!0),m=d.deltaPixelsFromPoints(i,!1),n=k.plus(m.divide(2)),o=e.distanceTo(n);c||(l=l.plus(new a.Point(1,1))),b.position=j,b.size=l,b.distance=o,b.visibility=f}function j(a,b,c,d,e,f,g){var h,i,j=1e3*a.blendTime;if(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),1==i)m(a.coverage,e,c,d,!0),a._hasOpaqueTile=!0;else if(j>h)return!0;return!1}function k(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 l(a,b,c,d){return void 0===c||void 0===d?k(a,b+1):k(a,b+1,2*c,2*d)&&k(a,b+1,2*c,2*d+1)&&k(a,b+1,2*c+1,2*d)&&k(a,b+1,2*c+1,2*d+1)}function m(b,c,d,e,f){return b[c]?(b[c][d]||(b[c][d]={}),void(b[c][d][e]=f)):void a.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",c)}function n(a,b){a[b]={}}function o(a,b){return a?b.visibility>a.visibility?b:b.visibility==a.visibility&&b.distance<a.distance?b:a:b}function p(a,b){var c,d;if(a.opacity<=0)return void q(a,b);var e=a.opacity<1;e&&a._drawer._clear(!0);var f=!1;if(a._clip){a._drawer.saveContext(e);var g=a.imageToViewportRectangle(a._clip,!0),h=a._drawer.viewportToDrawerRectangle(g);a._drawer.setClip(h,e),f=!0}if(a.placeholderFillStyle&&a._hasOpaqueTile===!1){var i=a._drawer.viewportToDrawerRectangle(a.getBounds(!0)),j=null;j="function"==typeof a.placeholderFillStyle?a.placeholderFillStyle(a,a._drawer.context):a.placeholderFillStyle,a._drawer.drawRectangle(i,j,e)}for(c=b.length-1;c>=0;c--)d=b[c],a._drawer.drawTile(d,a._drawingHandler,e),d.beingDrawn=!0,a.viewer&&a.viewer.raiseEvent("tile-drawn",{tiledImage:a,tile:d});f&&a._drawer.restoreContext(e),e&&a._drawer.blendSketch(a.opacity),q(a,b)}function q(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)}catch(f){a.console.error(f)}}}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;b.width?(f=b.width,delete b.width,b.height&&(a.console.error("specifying both width and height to a tiledImage is not supported"),delete b.height)):b.height&&(f=b.height/this.normHeight,delete b.height),a.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},lastDrawn:[],lastResetTime:0,_midDraw:!1,_needsDraw:!0,_hasOpaqueTile:!1,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,debugMode:a.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:a.DEFAULT_SETTINGS.crossOriginPolicy,placeholderFillStyle:a.DEFAULT_SETTINGS.placeholderFillStyle,opacity:a.DEFAULT_SETTINGS.opacity},b),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._updateForScale(),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},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=a.now(),this._needsDraw=!0},update:function(){var a=this._xSpring.current.value,b=this._ySpring.current.value,c=this._scaleSpring.current.value;return this._xSpring.update(),this._ySpring.update(),this._scaleSpring.update(),this._xSpring.current.value!==a||this._ySpring.current.value!==b||this._scaleSpring.current.value!==c?(this._updateForScale(),this._needsDraw=!0,!0):!1},draw:function(){this._midDraw=!0,b(this),this._midDraw=!1},destroy:function(){this.reset()},getBounds: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(){return a.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},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){return b instanceof a.Point&&(d=c,c=b.y,b=b.x),d?this._viewportToImageDelta(b-this._xSpring.current.value,c-this._ySpring.current.value):this._viewportToImageDelta(b-this._xSpring.target.value,c-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){b instanceof a.Point&&(d=c,c=b.y,b=b.x);var e=this._imageToViewportDelta(b,c);return d?(e.x+=this._xSpring.current.value,e.y+=this._ySpring.current.value):(e.x+=this._xSpring.target.value,e.y+=this._ySpring.target.value),e},imageToViewportRectangle:function(b,c,d,e,f){b instanceof a.Rect&&(f=c,d=b.width,e=b.height,c=b.y,b=b.x);var g=this.imageToViewportCoordinates(b,c,f),h=this._imageToViewportDelta(d,e,f);return new a.Rect(g.x,g.y,h.x,h.y)},viewportToImageRectangle:function(b,c,d,e,f){b instanceof a.Rect&&(f=c,d=b.width,e=b.height,c=b.y,b=b.x);var g=this.viewportToImageCoordinates(b,c,f),h=this._viewportToImageDelta(d,e,f);return new a.Rect(g.x,g.y,h.x,h.y)},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))},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)},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},getOpacity:function(){return this.opacity},setOpacity:function(a){this.opacity=a,this._needsDraw=!0},_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")}})}(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},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)return void this._tiles.splice(c,1);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.url,"[TileCache.cacheTile] options.tile.url is required"),a.console.assert(d.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var e=d.cutoff||0,f=this._tilesLoaded.length,g=this._imagesLoaded[d.tile.url];if(g||(a.console.assert(d.image,"[TileCache.cacheTile] options.image is required to create an ImageRecord"),g=this._imagesLoaded[d.tile.url]=new c({image:d.image}),this._imagesLoadedCount++),g.addTile(d.tile),d.tile.cacheImageRecord=g,this._imagesLoadedCount>this._maxImageCacheCount){for(var h,i,j,k,l,m,n=null,o=-1,p=null,q=this._tilesLoaded.length-1;q>=0;q--)m=this._tilesLoaded[q],h=m.tile,h.level<=e||h.beingDrawn||(n?(k=h.lastTouchTime,i=n.lastTouchTime,l=h.level,j=n.level,(i>k||k==i&&l>j)&&(n=h,o=q,p=m)):(n=h,o=q,p=m));n&&o>=0&&(this._unloadTile(p),f=o)}this._tilesLoaded[f]=new b({tile:d.tile,tiledImage:d.tiledImage})},clearTilesFor:function(b){a.console.assert(b,"[TileCache.clearTilesFor] tiledImage is required");for(var c,d=0;d<this._tilesLoaded.length;++d)c=this._tilesLoaded[d],c.tiledImage===b&&(this._unloadTile(c),this._tilesLoaded.splice(d,1),d--)},getImageRecord:function(b){return a.console.assert(b,"[TileCache.getImageRecord] url is required"),this._imagesLoaded[b]},_unloadTile:function(b){a.console.assert(b,"[TileCache._unloadTile] tileRecord is required");var c=b.tile,d=b.tiledImage;c.unload(),c.cacheImageRecord=null;var e=this._imagesLoaded[c.url];e.removeTile(c),e.getTileCount()||(e.destroy(),delete this._imagesLoaded[c.url],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){if(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||{},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),this.raiseEvent("add-item",{item:b})},getItemAt:function(b){return a.console.assert(void 0!==b,"[World.getItemAt] index is required"),this._items[b]},getIndexOfItem:function(b){return a.console.assert(b,"[World.getIndexOfItem] item is required"),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.");c!==d&&-1!==d&&(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);-1!==c&&(b.removeHandler("bounds-change",this._delegatedFigureSizes),b.destroy(),this._items.splice(c,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(b))},removeAll:function(){this.viewer._cancelPendingImages();for(var a,b=0;b<this._items.length;b++)a=this._items[b],a.removeHandler("bounds-change",this._delegatedFigureSizes),a.destroy();var c=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,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(){for(var a=!1,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,a&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(b){b=b||{};var c,d=b.immediately||!1,e=b.layout||a.DEFAULT_SETTINGS.collectionLayout,f=b.rows||a.DEFAULT_SETTINGS.collectionRows,g=b.columns||a.DEFAULT_SETTINGS.collectionColumns,h=b.tileSize||a.DEFAULT_SETTINGS.collectionTileSize,i=b.tileMargin||a.DEFAULT_SETTINGS.collectionTileMargin,j=h+i;c=!b.rows&&g?g:Math.ceil(this._items.length/f);var k,l,m,n,o,p=0,q=0;this.setAutoRefigureSizes(!1);for(var r=0;r<this._items.length;r++)r&&r%c===0&&("horizontal"===e?(q+=j,p=0):(p+=j,q=0)),k=this._items[r],l=k.getBounds(),m=l.width>l.height?h:h*(l.width/l.height),n=m*(l.height/l.width),o=new a.Point(p+(h-m)/2,q+(h-n)/2),k.setPosition(o,d),k.setWidth(m,d),"horizontal"===e?p+=j:q+=j;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var b=this._homeBounds?this._homeBounds.clone():null,c=this._contentSize?this._contentSize.clone():null,d=this._contentFactor||0;if(this._items.length){var e=this._items[0].getBounds();this._contentFactor=this._items[0].getContentSize().x/e.width;for(var f,g=e.x,h=e.y,i=e.x+e.width,j=e.y+e.height,k=1;k<this._items.length;k++)f=this._items[k].getBounds(),this._contentFactor=Math.max(this._contentFactor,this._items[k].getContentSize().x/f.width),g=Math.min(g,f.x),h=Math.min(h,f.y),i=Math.max(i,f.x+f.width),j=Math.max(j,f.y+f.height);this._homeBounds=new a.Rect(g,h,i-g,j-h),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