UNPKG

universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

2 lines 245 kB
/*! For license information please see 560.78f9a68d704ec0740f3d.js.LICENSE.txt */
(self.webpackChunkUV=self.webpackChunkUV||[]).push([[560],{5842:(e,t,i)=>{var n;window,e.exports=(n=i(4791),function(e){function t(n){if(i[n])return i[n].exports;var o=i[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,i){if(1&i&&(e=t(e)),8&i)return e;if(4&i&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&i&&"string"!=typeof e)for(var o in e)t.d(n,o,function(t){return e[t]}.bind(null,o));return n},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e){e.exports=n},function(e,t,i){"use strict";i.r(t);var n=i(0),o=i.n(n);t.default=function(e,t){if(!e.version||1>e.version.major)throw new Error("OpenSeadragonViewerInputHook requires OpenSeadragon version 1.0.0+");return e.Viewer.prototype.addViewerInputHook=function(e){return(e=e||{}).viewer=this,new t.ViewerInputHook(e)},t.ViewerInputHook=function(e){var t,i;for((e=e||{}).hooks=e.hooks||[],this.viewer=e.viewer||null,this.viewerTrackers={},this.hooks=[],this.viewer&&(this.viewerTrackers.viewer=this.viewer.innerTracker,this.viewerTrackers.viewer_outer=this.viewer.outerTracker),t=0;t<e.hooks.length;t++){if("string"==typeof e.hooks[t].tracker){if(!this.viewer)throw new Error("A viewer must be specified.");if(void 0===(i=this.viewerTrackers[e.hooks[t].tracker]))throw new Error("Unknown tracker specified: "+e.hooks[t].tracker)}else i=e.hooks[t].tracker;this.hooks.push({tracker:i,handlerName:e.hooks[t].handler,origHandler:i[e.hooks[t].handler],hookHandler:e.hooks[t].hookHandler}),function(e,t,i,n){var o=t[i];t[i]=function(t){return e._callHandlers(n,o,t)}}(this,i,e.hooks[t].handler,e.hooks[t].hookHandler)}},t.ViewerInputHook.version={versionStr:"2.2.1",major:2,minor:2,revision:1},t.ViewerInputHook.prototype._callHandlers=function(e,t,i){var n=e(i);return t&&!i.stopHandlers&&(n=t(i)),!i.stopBubbling&&n},t.ViewerInputHook.prototype.destroy=function(){for(;0<this.hooks.length;){var e=this.hooks.pop();e.tracker[e.handlerName]=e.origHandler}this.viewer&&(delete this.viewerTrackers.viewer,delete this.viewerTrackers.viewer_outer,this.viewer=null)},t.ViewerInputHook}(o.a||window.OpenSeadragon,window.OpenSeadragonImaging=window.OpenSeadragonImaging||{})}]).default)},4791:function(e,t){var i,n,o,r;function s(e){return new s.Viewer(e)}!function(e){e.version={versionStr:"4.0.0",major:parseInt("4",10),minor:parseInt("0",10),revision:parseInt("0",10)};var t,i={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},n=Object.prototype.toString,o=Object.prototype.hasOwnProperty;e.isFunction=function(t){return"function"===e.type(t)},e.isArray=Array.isArray||function(t){return"array"===e.type(t)},e.isWindow=function(e){return e&&"object"==typeof e&&"setInterval"in e},e.type=function(e){return null==e?String(e):i[n.call(e)]||"object"},e.isPlainObject=function(t){if(!t||"object"!==s.type(t)||t.nodeType||e.isWindow(t))return!1;if(t.constructor&&!o.call(t,"constructor")&&!o.call(t.constructor.prototype,"isPrototypeOf"))return!1;var i;for(var n in t)i=n;return void 0===i||o.call(t,i)},e.isEmptyObject=function(e){for(var t in e)return!1;return!0},e.freezeObject=function(t){return Object.freeze?e.freezeObject=Object.freeze:e.freezeObject=function(e){return e},e.freezeObject(t)},e.supportsCanvas=(t=document.createElement("canvas"),!(!e.isFunction(t.getContext)||!t.getContext("2d"))),e.isCanvasTainted=function(e){var t=!1;try{e.getContext("2d").getImageData(0,0,1,1)}catch(e){t=!0}return t},e.supportsAddEventListener=!(!document.documentElement.addEventListener||!document.addEventListener),e.supportsRemoveEventListener=!(!document.documentElement.removeEventListener||!document.removeEventListener),e.supportsEventListenerOptions=function(){var t=0;if(e.supportsAddEventListener)try{var i={get capture(){return t++,!1},get once(){return t++,!1},get passive(){return t++,!1}};window.addEventListener("test",null,i),window.removeEventListener("test",null,i)}catch(e){t=0}return t>=3}(),e.getCurrentPixelDensityRatio=function(){if(e.supportsCanvas){var t=document.createElement("canvas").getContext("2d"),i=window.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return Math.max(i,1)/n}return 1},e.pixelDensityRatio=e.getCurrentPixelDensityRatio()}(s),function(e){e.extend=function(){var t,i,n,o,r,a,l=arguments[0]||{},h=arguments.length,c=!1,u=1;for("boolean"==typeof l&&(c=l,l=arguments[1]||{},u=2),"object"==typeof l||s.isFunction(l)||(l={}),h===u&&(l=this,--u);u<h;u++)if(null!==(t=arguments[u])||void 0!==t)for(i in t){var d=Object.getOwnPropertyDescriptor(t,i);void 0!==d?d.get||d.set?Object.defineProperty(l,i,d):l!==(o=d.value)&&(c&&o&&(s.isPlainObject(o)||(r=s.isArray(o)))?(n=l[i],r?(r=!1,a=n&&s.isArray(n)?n:[]):a=n&&s.isPlainObject(n)?n:{},l[i]=s.extend(c,a,o)):void 0!==o&&(l[i]=o)):e.console.warn('Could not copy inherited property "'+i+'".')}return l},e.extend(e,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,loadTilesWithAjax:!1,ajaxHeaders:{},splitHashDataForPost:!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:{dragToPan:!0,scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!0,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!1,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerDblClickDrag:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,smoothTileEdgesMinZoom:1.1,iOSDevice:function(){if("object"!=typeof navigator)return!1;var e=navigator.userAgent;return"string"==typeof e&&(-1!==e.indexOf("iPhone")||-1!==e.indexOf("iPad")||-1!==e.indexOf("iPod"))}(),pixelsPerWheelLine:40,pixelsPerArrowPress:40,autoResize:!0,preserveImageSizeOnResize:!1,minScrollDeltaTime:50,rotationIncrement:90,showSequenceControl:!0,sequenceControlAnchor:null,preserveViewport:!1,preserveOverlays:!1,navPrevNextWrap:!1,showNavigationControl:!0,navigationControlAnchor:null,showZoomControl:!0,showHomeControl:!0,showFullPageControl:!0,showRotationControl:!1,showFlipControl:!1,controlsFadeDelay:2e3,controlsFadeLength:1500,mouseNavEnabled:!0,showNavigator:!1,navigatorElement:null,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorAutoFade:!0,navigatorRotate:!0,navigatorBackground:"#000",navigatorOpacity:.8,navigatorBorderColor:"#555",navigatorDisplayRegionColor:"#900",degrees:0,flipped:!1,opacity:1,preload:!1,compositeOperation:null,imageSmoothingEnabled:!0,placeholderFillStyle:null,subPixelRoundingForTransparency: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"},flip:{REST:"flip_rest.png",GROUP:"flip_grouphover.png",HOVER:"flip_hover.png",DOWN:"flip_pressed.png"},previous:{REST:"previous_rest.png",GROUP:"previous_grouphover.png",HOVER:"previous_hover.png",DOWN:"previous_pressed.png"},next:{REST:"next_rest.png",GROUP:"next_grouphover.png",HOVER:"next_hover.png",DOWN:"next_pressed.png"}},debugMode:!1,debugGridColor:["#437AB2","#1B9E77","#D95F02","#7570B3","#E7298A","#66A61E","#E6AB02","#A6761D","#666666"],silenceMultiImageWarnings:!1},SIGNAL:"----seadragon----",delegate:function(e,t){return function(){var i=arguments;return void 0===i&&(i=[]),t.apply(e,i)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5,EDGE:6,CHROMEEDGE:7},SUBPIXEL_ROUNDING_OCCURRENCES:{NEVER:0,ONLY_AT_REST:1,ALWAYS:2},_viewers:new Map,getViewer:function(t){return e._viewers.get(this.getElement(t))},getElement:function(e){return"string"==typeof e&&(e=document.getElementById(e)),e},getElementPosition:function(t){var i,n,r=new e.Point;for(n=o(t=e.getElement(t),i="fixed"===e.getElementStyle(t).position);n;)r.x+=t.offsetLeft,r.y+=t.offsetTop,i&&(r=r.plus(e.getPageScroll())),n=o(t=n,i="fixed"===e.getElementStyle(t).position);return r},getElementOffset:function(t){var i,n,o=(t=e.getElement(t))&&t.ownerDocument,r={top:0,left:0};return o?(i=o.documentElement,void 0!==t.getBoundingClientRect&&(r=t.getBoundingClientRect()),n=o===o.window?o:9===o.nodeType&&(o.defaultView||o.parentWindow),new e.Point(r.left+(n.pageXOffset||i.scrollLeft)-(i.clientLeft||0),r.top+(n.pageYOffset||i.scrollTop)-(i.clientTop||0))):new e.Point},getElementSize:function(t){return t=e.getElement(t),new e.Point(t.clientWidth,t.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(t){return(t=e.getElement(t)).currentStyle}:function(t){return t=e.getElement(t),window.getComputedStyle(t,"")},getCssPropertyWithVendorPrefix:function(t){var i={};return e.getCssPropertyWithVendorPrefix=function(t){if(void 0!==i[t])return i[t];var n=document.createElement("div").style,o=null;if(void 0!==n[t])o=t;else for(var r=["Webkit","Moz","MS","O","webkit","moz","ms","o"],s=e.capitalizeFirstLetter(t),a=0;a<r.length;a++){var l=r[a]+s;if(void 0!==n[l]){o=l;break}}return i[t]=o,o},e.getCssPropertyWithVendorPrefix(t)},capitalizeFirstLetter:function(e){return e.charAt(0).toUpperCase()+e.slice(1)},positiveModulo:function(e,t){var i=e%t;return i<0&&(i+=t),i},pointInElement:function(t,i){t=e.getElement(t);var n=e.getElementOffset(t),o=e.getElementSize(t);return i.x>=n.x&&i.x<n.x+o.x&&i.y<n.y+o.y&&i.y>=n.y},getMousePosition:function(t){if("number"==typeof t.pageX)e.getMousePosition=function(t){var i=new e.Point;return i.x=t.pageX,i.y=t.pageY,i};else{if("number"!=typeof t.clientX)throw new Error("Unknown event mouse position, no known technique.");e.getMousePosition=function(t){var i=new e.Point;return i.x=t.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,i.y=t.clientY+document.body.scrollTop+document.documentElement.scrollTop,i}}return e.getMousePosition(t)},getPageScroll:function(){var t=document.documentElement||{},i=document.body||{};if("number"==typeof window.pageXOffset)e.getPageScroll=function(){return new e.Point(window.pageXOffset,window.pageYOffset)};else if(i.scrollLeft||i.scrollTop)e.getPageScroll=function(){return new e.Point(document.body.scrollLeft,document.body.scrollTop)};else{if(!t.scrollLeft&&!t.scrollTop)return new e.Point(0,0);e.getPageScroll=function(){return new e.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)}}return e.getPageScroll()},setPageScroll:function(t){if(void 0!==window.scrollTo)e.setPageScroll=function(e){window.scrollTo(e.x,e.y)};else{var i=e.getPageScroll();if(i.x===t.x&&i.y===t.y)return;document.body.scrollLeft=t.x,document.body.scrollTop=t.y;var n=e.getPageScroll();if(n.x!==i.x&&n.y!==i.y)return void(e.setPageScroll=function(e){document.body.scrollLeft=e.x,document.body.scrollTop=e.y});if(document.documentElement.scrollLeft=t.x,document.documentElement.scrollTop=t.y,(n=e.getPageScroll()).x!==i.x&&n.y!==i.y)return void(e.setPageScroll=function(e){document.documentElement.scrollLeft=e.x,document.documentElement.scrollTop=e.y});e.setPageScroll=function(e){}}e.setPageScroll(t)},getWindowSize:function(){var t=document.documentElement||{},i=document.body||{};if("number"==typeof window.innerWidth)e.getWindowSize=function(){return new e.Point(window.innerWidth,window.innerHeight)};else if(t.clientWidth||t.clientHeight)e.getWindowSize=function(){return new e.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else{if(!i.clientWidth&&!i.clientHeight)throw new Error("Unknown window size, no known technique.");e.getWindowSize=function(){return new e.Point(document.body.clientWidth,document.body.clientHeight)}}return e.getWindowSize()},makeCenteredNode:function(t){t=e.getElement(t);var i=[e.makeNeutralElement("div"),e.makeNeutralElement("div"),e.makeNeutralElement("div")];return e.extend(i[0].style,{display:"table",height:"100%",width:"100%"}),e.extend(i[1].style,{display:"table-row"}),e.extend(i[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),i[0].appendChild(i[1]),i[1].appendChild(i[2]),i[2].appendChild(t),i[0]},makeNeutralElement:function(e){var t=document.createElement(e),i=t.style;return i.background="transparent none",i.border="none",i.margin="0px",i.padding="0px",i.position="static",t},now:function(){return Date.now?e.now=Date.now:e.now=function(){return(new Date).getTime()},e.now()},makeTransparentImage:function(t){var i=e.makeNeutralElement("img");return i.src=t,i},setElementOpacity:function(t,i,n){var o;t=e.getElement(t),n&&!e.Browser.alpha&&(i=Math.round(i)),e.Browser.opacity?t.style.opacity=i<1?i:"":i<1?(o="alpha(opacity="+Math.round(100*i)+")",t.style.filter=o):t.style.filter=""},setElementTouchActionNone:function(t){void 0!==(t=e.getElement(t)).style.touchAction?t.style.touchAction="none":void 0!==t.style.msTouchAction&&(t.style.msTouchAction="none")},setElementPointerEvents:function(t,i){void 0!==(t=e.getElement(t)).style&&void 0!==t.style.pointerEvents&&(t.style.pointerEvents=i)},setElementPointerEventsNone:function(t){e.setElementPointerEvents(t,"none")},addClass:function(t,i){(t=e.getElement(t)).className?-1===(" "+t.className+" ").indexOf(" "+i+" ")&&(t.className+=" "+i):t.className=i},indexOf:function(e,t,i){return Array.prototype.indexOf?this.indexOf=function(e,t,i){return e.indexOf(t,i)}:this.indexOf=function(e,t,i){var n,o,r=i||0;if(!e)throw new TypeError;if(0===(o=e.length)||r>=o)return-1;for(r<0&&(r=o-Math.abs(r)),n=r;n<o;n++)if(e[n]===t)return n;return-1},this.indexOf(e,t,i)},removeClass:function(t,i){var n,o,r=[];for(n=(t=e.getElement(t)).className.split(/\s+/),o=0;o<n.length;o++)n[o]&&n[o]!==i&&r.push(n[o]);t.className=r.join(" ")},normalizeEventListenerOptions:function(t){return void 0!==t?"boolean"==typeof t?e.supportsEventListenerOptions?{capture:t}:t:e.supportsEventListenerOptions?t:void 0!==t.capture&&t.capture:!!e.supportsEventListenerOptions&&{capture:!1}},addEvent:function(){if(e.supportsAddEventListener)return function(t,i,n,o){o=e.normalizeEventListenerOptions(o),(t=e.getElement(t)).addEventListener(i,n,o)};if(document.documentElement.attachEvent&&document.attachEvent)return function(t,i,n){(t=e.getElement(t)).attachEvent("on"+i,n)};throw new Error("No known event model.")}(),removeEvent:function(){if(e.supportsRemoveEventListener)return function(t,i,n,o){o=e.normalizeEventListenerOptions(o),(t=e.getElement(t)).removeEventListener(i,n,o)};if(document.documentElement.detachEvent&&document.detachEvent)return function(t,i,n){(t=e.getElement(t)).detachEvent("on"+i,n)};throw new Error("No known event model.")}(),cancelEvent:function(e){e.preventDefault()},eventIsCanceled:function(e){return e.defaultPrevented},stopEvent:function(e){e.stopPropagation()},createCallback:function(e,t){var i,n=[];for(i=2;i<arguments.length;i++)n.push(arguments[i]);return function(){var i,o=n.concat([]);for(i=0;i<arguments.length;i++)o.push(arguments[i]);return t.apply(e,o)}},getUrlParameter:function(e){return n[e]||null},getUrlProtocol:function(e){var t=e.match(/^([a-z]+:)\/\//i);return null===t?window.location.protocol:t[1].toLowerCase()},createAjaxRequest:function(t){var i;try{i=!!new ActiveXObject("Microsoft.XMLHTTP")}catch(e){i=!1}if(i)window.XMLHttpRequest?e.createAjaxRequest=function(e){return e?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest}:e.createAjaxRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP")};else{if(!window.XMLHttpRequest)throw new Error("Browser doesn't support XMLHttpRequest.");e.createAjaxRequest=function(){return new XMLHttpRequest}}return e.createAjaxRequest(t)},makeAjaxRequest:function(t,i,n){var o,r,s,a;e.isPlainObject(t)&&(i=t.success,n=t.error,o=t.withCredentials,r=t.headers,s=t.responseType||null,a=t.postData||null,t=t.url);var l=e.getUrlProtocol(t),h=e.createAjaxRequest("file:"===l);if(!e.isFunction(i))throw new Error("makeAjaxRequest requires a success callback");h.onreadystatechange=function(){4===h.readyState&&(h.onreadystatechange=function(){},h.status>=200&&h.status<300||0===h.status&&"http:"!==l&&"https:"!==l?i(h):e.isFunction(n)?n(h):e.console.error("AJAX request returned %d: %s",h.status,t))};var c=a?"POST":"GET";try{if(h.open(c,t,!0),s&&(h.responseType=s),r)for(var u in r)Object.prototype.hasOwnProperty.call(r,u)&&r[u]&&h.setRequestHeader(u,r[u]);o&&(h.withCredentials=!0),h.send(a)}catch(t){e.console.error("%s while making AJAX request: %s",t.name,t.message),h.onreadystatechange=function(){},e.isFunction(n)&&n(h,t)}return h},jsonp:function(t){var i,n=t.url,o=document.head||document.getElementsByTagName("head")[0]||document.documentElement,r=t.callbackName||"openseadragon"+e.now(),s=window[r],a="$1"+r+"$2",l=t.param||"callback",h=t.callback;n=n.replace(/(=)\?(&|$)|\?\?/i,a),n+=(/\?/.test(n)?"&":"?")+l+"="+r,window[r]=function(t){if(s)window[r]=s;else try{delete window[r]}catch(e){}h&&e.isFunction(h)&&h(t)},i=document.createElement("script"),void 0===t.async&&!1===t.async||(i.async="async"),t.scriptCharset&&(i.charset=t.scriptCharset),i.src=n,i.onload=i.onreadystatechange=function(e,t){(t||!i.readyState||/loaded|complete/.test(i.readyState))&&(i.onload=i.onreadystatechange=null,o&&i.parentNode&&o.removeChild(i),i=void 0)},o.insertBefore(i,o.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(t){if(window.DOMParser)e.parseXml=function(e){return(new DOMParser).parseFromString(e,"text/xml")};else{if(!window.ActiveXObject)throw new Error("Browser doesn't support XML DOM.");e.parseXml=function(e){var t=null;return(t=new ActiveXObject("Microsoft.XMLDOM")).async=!1,t.loadXML(e),t}}return e.parseXml(t)},parseJSON:function(t){return e.parseJSON=window.JSON.parse,e.parseJSON(t)},imageFormatSupported:function(e){return!!i[(e=e||"").toLowerCase()]},setImageFormatsSupported:function(t){e.extend(i,t)}});var t=function(e){};e.console=window.console||{log:t,debug:t,info:t,warn:t,error:t,assert:t},e.Browser={vendor:e.BROWSERS.UNKNOWN,version:0,alpha:!0};var i={bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1},n={};function o(e,t){return t&&e!==document.body?document.body:e.offsetParent}!function(){var t=navigator.appVersion,i=navigator.userAgent;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(i.substring(i.indexOf("MSIE")+5,i.indexOf(";",i.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(i.indexOf("Edge")>=0?(e.Browser.vendor=e.BROWSERS.EDGE,e.Browser.version=parseFloat(i.substring(i.indexOf("Edge")+5))):i.indexOf("Edg")>=0?(e.Browser.vendor=e.BROWSERS.CHROMEEDGE,e.Browser.version=parseFloat(i.substring(i.indexOf("Edg")+4))):i.indexOf("Firefox")>=0?(e.Browser.vendor=e.BROWSERS.FIREFOX,e.Browser.version=parseFloat(i.substring(i.indexOf("Firefox")+8))):i.indexOf("Safari")>=0?(e.Browser.vendor=i.indexOf("Chrome")>=0?e.BROWSERS.CHROME:e.BROWSERS.SAFARI,e.Browser.version=parseFloat(i.substring(i.substring(0,i.indexOf("Safari")).lastIndexOf("/")+1,i.indexOf("Safari")))):null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(i)&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(RegExp.$1)));break;case"Opera":e.Browser.vendor=e.BROWSERS.OPERA,e.Browser.version=parseFloat(t)}var o,r,s,a=window.location.search.substring(1).split("&");for(s=0;s<a.length;s++)if((r=(o=a[s]).indexOf("="))>0){var l=o.substring(0,r),h=o.substring(r+1);try{n[l]=decodeURIComponent(h)}catch(t){e.console.error("Ignoring malformed URL parameter: %s=%s",l,h)}}e.Browser.alpha=!(e.Browser.vendor===e.BROWSERS.CHROME&&e.Browser.version<2),e.Browser.opacity=!0,e.Browser.vendor===e.BROWSERS.IE&&e.Browser.version<11&&e.console.error("Internet Explorer versions < 11 are not supported by OpenSeadragon")}(),function(t){var i=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame,n=t.cancelAnimationFrame||t.mozCancelAnimationFrame||t.webkitCancelAnimationFrame||t.msCancelAnimationFrame;if(i&&n)e.requestAnimationFrame=function(){return i.apply(t,arguments)},e.cancelAnimationFrame=function(){return n.apply(t,arguments)};else{var o,r=[],s=[],a=0;e.requestAnimationFrame=function(t){return r.push([++a,t]),o||(o=setInterval((function(){if(r.length){var t=e.now(),i=s;for(s=r,r=i;s.length;)s.shift()[1](t)}else clearInterval(o),o=void 0}),20)),a},e.cancelAnimationFrame=function(e){var t,i;for(t=0,i=r.length;t<i;t+=1)if(r[t][0]===e)return void r.splice(t,1);for(t=0,i=s.length;t<i;t+=1)if(s[t][0]===e)return void s.splice(t,1)}}}(window)}(s),void 0===(n="function"==typeof(i=function(){return s})?i.apply(t,[]):i)||(e.exports=n),o=s,r={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""},document.exitFullscreen?(r.supportsFullScreen=!0,r.getFullScreenElement=function(){return document.fullscreenElement},r.requestFullScreen=function(e){return e.requestFullscreen()},r.exitFullScreen=function(){document.exitFullscreen()},r.fullScreenEventName="fullscreenchange",r.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(r.supportsFullScreen=!0,r.getFullScreenElement=function(){return document.msFullscreenElement},r.requestFullScreen=function(e){return e.msRequestFullscreen()},r.exitFullScreen=function(){document.msExitFullscreen()},r.fullScreenEventName="MSFullscreenChange",r.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(r.supportsFullScreen=!0,r.getFullScreenElement=function(){return document.webkitFullscreenElement},r.requestFullScreen=function(e){return e.webkitRequestFullscreen()},r.exitFullScreen=function(){document.webkitExitFullscreen()},r.fullScreenEventName="webkitfullscreenchange",r.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(r.supportsFullScreen=!0,r.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},r.requestFullScreen=function(e){return e.webkitRequestFullScreen()},r.exitFullScreen=function(){document.webkitCancelFullScreen()},r.fullScreenEventName="webkitfullscreenchange",r.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(r.supportsFullScreen=!0,r.getFullScreenElement=function(){return document.mozFullScreenElement},r.requestFullScreen=function(e){return e.mozRequestFullScreen()},r.exitFullScreen=function(){document.mozCancelFullScreen()},r.fullScreenEventName="mozfullscreenchange",r.fullScreenErrorEventName="mozfullscreenerror"),r.isFullScreen=function(){return null!==r.getFullScreenElement()},r.cancelFullScreen=function(){o.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),r.exitFullScreen()},o.extend(o,r),function(e){e.EventSource=function(){this.events={}},e.EventSource.prototype={addOnceHandler:function(e,t,i,n){var o=this;n=n||1;var r=0,s=function(i){++r===n&&o.removeHandler(e,s),t(i)};this.addHandler(e,s,i)},addHandler:function(t,i,n){var o=this.events[t];o||(this.events[t]=o=[]),i&&e.isFunction(i)&&(o[o.length]={handler:i,userData:n||null})},removeHandler:function(t,i){var n,o=this.events[t],r=[];if(o&&e.isArray(o)){for(n=0;n<o.length;n++)o[n].handler!==i&&r.push(o[n]);this.events[t]=r}},numberOfHandlers:function(e){var t=this.events[e];return t?t.length:0},removeAllHandlers:function(e){if(e)this.events[e]=[];else for(var t in this.events)this.events[t]=[]},getHandler:function(e){var t=this.events[e];return t&&t.length?(t=1===t.length?[t[0]]:Array.apply(null,t),function(e,i){var n,o=t.length;for(n=0;n<o;n++)t[n]&&(i.eventSource=e,i.userData=t[n].userData,t[n].handler(i))}):null},raiseEvent:function(e,t){var i=this.getHandler(e);i&&(t||(t={}),i(this,t))}}}(s),function(e){var t=[],i={};e.MouseTracker=function(n){t.push(this);var o=arguments;e.isPlainObject(n)||(n={element:o[0],clickTimeThreshold:o[1],clickDistThreshold:o[2]}),this.hash=Math.random(),this.element=e.getElement(n.element),this.clickTimeThreshold=n.clickTimeThreshold||e.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=n.clickDistThreshold||e.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=n.dblClickTimeThreshold||e.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=n.dblClickDistThreshold||e.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=n.userData||null,this.stopDelay=n.stopDelay||50,this.preProcessEventHandler=n.preProcessEventHandler||null,this.contextMenuHandler=n.contextMenuHandler||null,this.enterHandler=n.enterHandler||null,this.leaveHandler=n.leaveHandler||null,this.exitHandler=n.exitHandler||null,this.overHandler=n.overHandler||null,this.outHandler=n.outHandler||null,this.pressHandler=n.pressHandler||null,this.nonPrimaryPressHandler=n.nonPrimaryPressHandler||null,this.releaseHandler=n.releaseHandler||null,this.nonPrimaryReleaseHandler=n.nonPrimaryReleaseHandler||null,this.moveHandler=n.moveHandler||null,this.scrollHandler=n.scrollHandler||null,this.clickHandler=n.clickHandler||null,this.dblClickHandler=n.dblClickHandler||null,this.dragHandler=n.dragHandler||null,this.dragEndHandler=n.dragEndHandler||null,this.pinchHandler=n.pinchHandler||null,this.stopHandler=n.stopHandler||null,this.keyDownHandler=n.keyDownHandler||null,this.keyUpHandler=n.keyUpHandler||null,this.keyHandler=n.keyHandler||null,this.focusHandler=n.focusHandler||null,this.blurHandler=n.blurHandler||null;var r=this;i[this.hash]={click:function(t){!function(t,i){var n={originalEvent:i,eventType:"click",pointerType:"mouse",isEmulated:!1};z(t,n),n.preventDefault&&!n.defaultPrevented&&e.cancelEvent(i),n.stopPropagation&&e.stopEvent(i)}(r,t)},dblclick:function(t){!function(t,i){var n={originalEvent:i,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};z(t,n),n.preventDefault&&!n.defaultPrevented&&e.cancelEvent(i),n.stopPropagation&&e.stopEvent(i)}(r,t)},keydown:function(t){!function(t,i){var n=null,o={originalEvent:i,eventType:"keydown",pointerType:"",isEmulated:!1};z(t,o),!t.keyDownHandler||o.preventGesture||o.defaultPrevented||(n={eventSource:t,keyCode:i.keyCode?i.keyCode:i.charCode,ctrl:i.ctrlKey,shift:i.shiftKey,alt:i.altKey,meta:i.metaKey,originalEvent:i,preventDefault:o.preventDefault||o.defaultPrevented,userData:t.userData},t.keyDownHandler(n)),(n&&n.preventDefault||o.preventDefault&&!o.defaultPrevented)&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i)}(r,t)},keyup:function(t){!function(t,i){var n=null,o={originalEvent:i,eventType:"keyup",pointerType:"",isEmulated:!1};z(t,o),!t.keyUpHandler||o.preventGesture||o.defaultPrevented||(n={eventSource:t,keyCode:i.keyCode?i.keyCode:i.charCode,ctrl:i.ctrlKey,shift:i.shiftKey,alt:i.altKey,meta:i.metaKey,originalEvent:i,preventDefault:o.preventDefault||o.defaultPrevented,userData:t.userData},t.keyUpHandler(n)),(n&&n.preventDefault||o.preventDefault&&!o.defaultPrevented)&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i)}(r,t)},keypress:function(t){!function(t,i){var n=null,o={originalEvent:i,eventType:"keypress",pointerType:"",isEmulated:!1};z(t,o),!t.keyHandler||o.preventGesture||o.defaultPrevented||(n={eventSource:t,keyCode:i.keyCode?i.keyCode:i.charCode,ctrl:i.ctrlKey,shift:i.shiftKey,alt:i.altKey,meta:i.metaKey,originalEvent:i,preventDefault:o.preventDefault||o.defaultPrevented,userData:t.userData},t.keyHandler(n)),(n&&n.preventDefault||o.preventDefault&&!o.defaultPrevented)&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i)}(r,t)},focus:function(e){!function(e,t){var i={originalEvent:t,eventType:"focus",pointerType:"",isEmulated:!1};z(e,i),e.focusHandler&&!i.preventGesture&&e.focusHandler({eventSource:e,originalEvent:t,userData:e.userData})}(r,e)},blur:function(e){!function(e,t){var i={originalEvent:t,eventType:"blur",pointerType:"",isEmulated:!1};z(e,i),e.blurHandler&&!i.preventGesture&&e.blurHandler({eventSource:e,originalEvent:t,userData:e.userData})}(r,e)},contextmenu:function(t){!function(t,i){var n=null,o={originalEvent:i,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};z(t,o),!t.contextMenuHandler||o.preventGesture||o.defaultPrevented||(n={eventSource:t,position:T(y(i),t.element),originalEvent:o.originalEvent,preventDefault:o.preventDefault||o.defaultPrevented,userData:t.userData},t.contextMenuHandler(n)),(n&&n.preventDefault||o.preventDefault&&!o.defaultPrevented)&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i)}(r,t)},wheel:function(e){!function(e,t){E(e,t,t)}(r,e)},mousewheel:function(e){S(r,e)},DOMMouseScroll:function(e){S(r,e)},MozMousePixelScroll:function(e){S(r,e)},losecapture:function(t){!function(t,i){var n={id:e.MouseTracker.mousePointerId,type:"mouse"},o={originalEvent:i,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};z(t,o),i.target===t.element&&L(t,n,!1),o.stopPropagation&&e.stopEvent(i)}(r,t)},mouseenter:function(e){P(r,e)},mouseleave:function(e){_(r,e)},mouseover:function(e){R(r,e)},mouseout:function(e){C(r,e)},mousedown:function(e){b(r,e)},mouseup:function(e){D(r,e)},mousemove:function(e){k(r,e)},touchstart:function(t){!function(t,i){var n,o,r,s=i.changedTouches.length,a=t.getActivePointersListByType("touch");n=e.now(),a.getLength()>i.touches.length-s&&e.console.warn("Tracked touch contact count doesn't match event.touches.length");var l={originalEvent:i,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(z(t,l),o=0;o<s;o++)F(t,l,r={id:i.changedTouches[o].identifier,type:"touch",isPrimary:0===a.getLength(),currentPos:y(i.changedTouches[o]),currentTime:n}),N(t,l,r,0),L(t,r,!0);l.preventDefault&&!l.defaultPrevented&&e.cancelEvent(i),l.stopPropagation&&e.stopEvent(i)}(r,t)},touchend:function(t){!function(t,i){var n,o,r,s=i.changedTouches.length;n=e.now();var a={originalEvent:i,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(z(t,a),o=0;o<s;o++)A(t,a,r={id:i.changedTouches[o].identifier,type:"touch",currentPos:y(i.changedTouches[o]),currentTime:n},0),L(t,r,!1),M(t,a,r);a.preventDefault&&!a.defaultPrevented&&e.cancelEvent(i),a.stopPropagation&&e.stopEvent(i)}(r,t)},touchmove:function(t){!function(t,i){var n,o,r=i.changedTouches.length;n=e.now();var s={originalEvent:i,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(z(t,s),o=0;o<r;o++)U(t,s,{id:i.changedTouches[o].identifier,type:"touch",currentPos:y(i.changedTouches[o]),currentTime:n});s.preventDefault&&!s.defaultPrevented&&e.cancelEvent(i),s.stopPropagation&&e.stopEvent(i)}(r,t)},touchcancel:function(t){!function(t,i){var n,o=i.changedTouches.length,r={originalEvent:i,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(z(t,r),n=0;n<o;n++)V(t,0,{id:i.changedTouches[n].identifier,type:"touch"});r.stopPropagation&&e.stopEvent(i)}(r,t)},gesturestart:function(t){!function(t,i){e.eventIsCanceled(i)||i.preventDefault()}(0,t)},gesturechange:function(t){!function(t,i){e.eventIsCanceled(i)||i.preventDefault()}(0,t)},gotpointercapture:function(t){!function(t,i){var n={originalEvent:i,eventType:"gotpointercapture",pointerType:v(i),isEmulated:!1};z(t,n),i.target===t.element&&L(t,{id:i.pointerId,type:v(i)},!0),n.stopPropagation&&e.stopEvent(i)}(r,t)},lostpointercapture:function(t){!function(t,i){var n={originalEvent:i,eventType:"lostpointercapture",pointerType:v(i),isEmulated:!1};z(t,n),i.target===t.element&&L(t,{id:i.pointerId,type:v(i)},!1),n.stopPropagation&&e.stopEvent(i)}(r,t)},pointerenter:function(e){P(r,e)},pointerleave:function(e){_(r,e)},pointerover:function(e){R(r,e)},pointerout:function(e){C(r,e)},pointerdown:function(e){b(r,e)},pointerup:function(e){D(r,e)},pointermove:function(e){k(r,e)},pointercancel:function(t){!function(t,i){var n={id:i.pointerId,type:v(i)},o={originalEvent:i,eventType:"pointercancel",pointerType:n.type,isEmulated:!1};z(t,o),V(t,0,n),o.stopPropagation&&e.stopEvent(i)}(r,t)},pointerupcaptured:function(t){!function(t,i){t.getActivePointersListByType(v(i)).getById(i.pointerId)&&I(t,i),e.stopEvent(i)}(r,t)},pointermovecaptured:function(t){!function(t,i){t.getActivePointersListByType(v(i)).getById(i.pointerId)&&O(t,i),e.stopEvent(i)}(r,t)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null,sentDragEvent:!1},this.hasGestureHandlers=!!(this.pressHandler||this.nonPrimaryPressHandler||this.releaseHandler||this.nonPrimaryReleaseHandler||this.clickHandler||this.dblClickHandler||this.dragHandler||this.dragEndHandler||this.pinchHandler),this.hasScrollHandler=!!this.scrollHandler,e.MouseTracker.havePointerEvents&&e.setElementPointerEvents(this.element,"auto"),this.exitHandler&&e.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead."),n.startDisabled||this.setTracking(!0)},e.MouseTracker.prototype={destroy:function(){var e;for(d(this),this.element=null,e=0;e<t.length;e++)if(t[e]===this){t.splice(e,1);break}i[this.hash]=null,delete i[this.hash]},isTracking:function(){return i[this.hash].tracking},setTracking:function(t){return t?function(t){var n,o,r=i[t.hash];if(!r.tracking){for(o=0;o<e.MouseTracker.subscribeEvents.length;o++)n=e.MouseTracker.subscribeEvents[o],e.addEvent(t.element,n,r[n],n===e.MouseTracker.wheelEventName&&{passive:!1,capture:!1});u(t),r.tracking=!0}}(this):d(this),this},getActivePointersListByType:function(t){var n,o,r=i[this.hash],s=r.activePointersLists.length;for(n=0;n<s;n++)if(r.activePointersLists[n].type===t)return r.activePointersLists[n];return o=new e.MouseTracker.GesturePointList(t),r.activePointersLists.push(o),o},getActivePointerCount:function(){var e,t=i[this.hash],n=t.activePointersLists.length,o=0;for(e=0;e<n;e++)o+=t.activePointersLists[e].getLength();return o},preProcessEventHandler:function(){},contextMenuHandler:function(){},enterHandler:function(){},leaveHandler:function(){},exitHandler:function(){},overHandler:function(){},outHandler: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(){}};var n,o,r,s,a,l,h=function(){try{return window.self!==window.top}catch(e){return!0}}();function c(e){try{return e.addEventListener&&e.removeEventListener}catch(e){return!1}}function u(e){var t,n,o,r,s,a=i[e.hash],l=a.activePointersLists.length;for(t=0;t<l;t++)if((o=a.activePointersLists[t]).getLength()>0){for(s=[],r=o.asArray(),n=0;n<r.length;n++)s.push(r[n]);for(n=0;n<s.length;n++)B(e,o,s[n])}for(t=0;t<l;t++)a.activePointersLists.pop();a.sentDragEvent=!1}function d(t){var n,o,r=i[t.hash];if(r.tracking){for(o=0;o<e.MouseTracker.subscribeEvents.length;o++)n=e.MouseTracker.subscribeEvents[o],e.removeEvent(t.element,n,r[n],!1);u(t),r.tracking=!1}}function p(e,t){var n=i[e.hash];if("pointerevent"===t)return{upName:"pointerup",upHandler:n.pointerupcaptured,moveName:"pointermove",moveHandler:n.pointermovecaptured};if("mouse"===t)return{upName:"pointerup",upHandler:n.pointerupcaptured,moveName:"pointermove",moveHandler:n.pointermovecaptured};if("touch"===t)return{upName:"touchend",upHandler:n.touchendcaptured,moveName:"touchmove",moveHandler:n.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function g(t,i){var n,o;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents){if(!(o=t.getActivePointersListByType(i.type).getById(i.id))||!o.captured)return;try{t.element.releasePointerCapture(i.id)}catch(e){}}else t.element.releaseCapture();else n=p(t,e.MouseTracker.havePointerEvents?"pointerevent":i.type),h&&c(window.top)&&e.removeEvent(window.top,n.upName,n.upHandler,!0),e.removeEvent(e.MouseTracker.captureElement,n.moveName,n.moveHandler,!0),e.removeEvent(e.MouseTracker.captureElement,n.upName,n.upHandler,!0);L(t,i,!1)}function m(t){return e.MouseTracker.havePointerEvents?t.pointerId:e.MouseTracker.mousePointerId}function v(t){return e.MouseTracker.havePointerEvents?t.pointerType||(e.Browser.vendor===e.BROWSERS.IE?"mouse":""):"mouse"}function f(t){return!e.MouseTracker.havePointerEvents||t.isPrimary}function y(t){return e.getMousePosition(t)}function w(e,t){return T(y(e),t)}function T(t,i){var n=e.getElementOffset(i);return t.minus(n)}function x(t,i){return new e.Point((t.x+i.x)/2,(t.y+i.y)/2)}function S(t,i){var n={target:i.target||i.srcElement,type:"wheel",shiftKey:i.shiftKey||!1,clientX:i.clientX,clientY:i.clientY,pageX:i.pageX?i.pageX:i.clientX,pageY:i.pageY?i.pageY:i.clientY,deltaMode:"MozMousePixelScroll"===i.type?0:1,deltaX:0,deltaZ:0};"mousewheel"===e.MouseTracker.wheelEventName?n.deltaY=-i.wheelDelta/e.DEFAULT_SETTINGS.pixelsPerWheelLine:n.deltaY=i.detail,E(t,n,i)}function E(t,i,n){var o,r,s=null;o=i.deltaY<0?1:-1,z(t,r={originalEvent:i,eventType:"wheel",pointerType:"mouse",isEmulated:i!==n}),!t.scrollHandler||r.preventGesture||r.defaultPrevented||(s={eventSource:t,pointerType:"mouse",position:w(i,t.element),scroll:o,shift:i.shiftKey,isTouchEvent:!1,originalEvent:n,preventDefault:r.preventDefault||r.defaultPrevented,userData:t.userData},t.scrollHandler(s)),r.stopPropagation&&e.stopEvent(n),(s&&s.preventDefault||r.preventDefault&&!r.defaultPrevented)&&e.cancelEvent(n)}function P(t,i){var n={id:m(i),type:v(i),isPrimary:f(i),currentPos:y(i),currentTime:e.now()},o={originalEvent:i,eventType:"pointerenter",pointerType:n.type,isEmulated:!1};z(t,o),F(t,o,n)}function _(t,i){var n={id:m(i),type:v(i),isPrimary:f(i),currentPos:y(i),currentTime:e.now()},o={originalEvent:i,eventType:"pointerleave",pointerType:n.type,isEmulated:!1};z(t,o),M(t,o,n)}function R(t,i){var n={id:m(i),type:v(i),isPrimary:f(i),currentPos:y(i),currentTime:e.now()},o={originalEvent:i,eventType:"pointerover",pointerType:n.type,isEmulated:!1};z(t,o),function(e,t,i){var n,o;(o=(n=e.getActivePointersListByType(i.type)).getById(i.id))?i=o:(i.captured=!1,i.insideElementPressed=!1),e.overHandler&&e.overHandler({eventSource:e,pointerType:i.type,position:T(i.currentPos,e.element),buttons:n.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==n.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData})}(t,o,n),o.preventDefault&&!o.defaultPrevented&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i)}function C(t,i){var n={id:m(i),type:v(i),isPrimary:f(i),currentPos:y(i),currentTime:e.now()},o={originalEvent:i,eventType:"pointerout",pointerType:n.type,isEmulated:!1};z(t,o),function(e,t,i){var n,o;(o=(n=e.getActivePointersListByType(i.type)).getById(i.id))?i=o:(i.captured=!1,i.insideElementPressed=!1),e.outHandler&&e.outHandler({eventSource:e,pointerType:i.type,position:i.currentPos&&T(i.currentPos,e.element),buttons:n.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==n.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData})}(t,o,n),o.preventDefault&&!o.defaultPrevented&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i)}function b(t,i){var n={id:m(i),type:v(i),isPrimary:f(i),currentPos:y(i),currentTime:e.now()},o=e.MouseTracker.havePointerEvents&&"touch"===n.type&&e.Browser.vendor!==e.BROWSERS.IE,r={originalEvent:i,eventType:"pointerdown",pointerType:n.type,isEmulated:!1};z(t,r),N(t,r,n,i.button),r.preventDefault&&!r.defaultPrevented&&e.cancelEvent(i),r.stopPropagation&&e.stopEvent(i),r.shouldCapture&&(o?L(t,n,!0):function(t,i){var n;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents)try{t.element.setPointerCapture(i.id)}catch(t){return void e.console.warn("setPointerCapture() called on invalid pointer ID")}else t.element.setCapture(!0);else n=p(t,e.MouseTracker.havePointerEvents?"pointerevent":i.type),h&&c(window.top)&&e.addEvent(window.top,n.upName,n.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,n.upName,n.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,n.moveName,n.moveHandler,!0);L(t,i,!0)}(t,n))}function D(e,t){I(e,t)}function I(t,i){var n,o={originalEvent:i,eventType:"pointerup",pointerType:(n={id:m(i),type:v(i),isPrimary:f(i),currentPos:y(i),currentTime:e.now()}).type,isEmulated:!1};z(t,o),A(t,o,n,i.button),o.preventDefault&&!o.defaultPrevented&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i),o.shouldReleaseCapture&&(i.target===t.element?g(t,n):L(t,n,!1))}function k(e,t){O(e,t)}function O(t,i){var n={id:m(i),type:v(i),isPrimary:f(i),currentPos:y(i),currentTime:e.now()},o={originalEvent:i,eventType:"pointermove",pointerType:n.type,isEmulated:!1};z(t,o),U(t,o,n),o.preventDefault&&!o.defaultPrevented&&e.cancelEvent(i),o.stopPropagation&&e.stopEvent(i)}function H(e,t){return t.speed=0,t.direction=0,t.contactPos=t.currentPos,t.contactTime=t.currentTime,t.lastPos=t.currentPos,t.lastTime=t.currentTime,e.add(t)}function B(t,i,n){var o,r=i.getById(n.id);return r?(r.captured&&(e.console.warn("stopTrackingPointer() called on captured pointer"),g(t,r)),i.removeContact(),o=i.removeById(n.id)):o=i.getLength(),o}function z(t,i){i.eventSource=t,i.eventPhase=i.originalEvent&&void 0!==i.originalEvent.eventPhase?i.originalEvent.eventPhase:0,i.defaultPrevented=e.eventIsCanceled(i.originalEvent),i.shouldCapture=!1,i.shouldReleaseCapture=!1,i.userData=t.userData,function(e,t){switch(t.eventType){case"pointermove":case"pointerdown":case"pointerup":t.isStoppable=!0,t.isCancelable=!0,t.preventDefault=!1,t.preventGesture=!e.hasGestureHandlers,t.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":t.isStoppable=!0,t.isCancelable=!0,t.preventDefault=!1,t.preventGesture=!1,t.stopPropagation=!1;break;case"wheel":t.isStoppable=!0,t.isCancelable=!0,t.preventDefault=!1,t.preventGesture=!e.hasScrollHandler,t.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":t.isStoppable=!0,t.isCancelable=!1,t.preventDefault=!1,t.preventGesture=!1,t.stopPropagation=!1;break;case"click":t.isStoppable=!0,t.isCancelable=!0,t.preventDefault=!!e.clickHandler,t.preventGesture=!1,t.stopPropagation=!1;break;case"dblclick":t.isStoppable=!0,t.isCancelable=!0,t.preventDefault=!!e.dblClickHandler,t.preventGesture=!1,t.stopPropagation=!1;break;default:t.isStoppable=!1,t.isCancelable=!1,t.preventDefault=!1,t.preventGesture=!1,t.stopPropagation=!1}}(t,i),t.preProcessEventHandler&&t.preProcessEventHandler(i)}function L(t,i,n){var o=t.getActivePointersListByType(i.type),r=o.getById(i.id);r?n&&!r.captured?(r.captured=!0,o.captureCount++):!n&&r.captured&&(r.captured=!1,o.captureCount--,o.captureCount<0&&(o.captureCount=0,e.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):e.console.warn("updatePointerCaptured() called on untracked pointer")}function F(e,t,i){var n,o=e.getActivePointersListByType(i.type);(n=o.getById(i.id))?(n.insideElement=!0,n.lastPos=n.currentPos,n.lastTime=n.currentTime,n.currentPos=i.currentPos,n.currentTime=i.currentTime,i=n):(i.captured=!1,i.insideElementPressed=!1,i.insideElement=!0,H(o,i)),e.enterHandler&&e.enterHandler({eventSource:e,pointerType:i.type,position:T(i.currentPos,e.element),buttons:o.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==o.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData})}function M(e,t,i){var n,o,r=e.getActivePointersListByType(i.type);(n=r.getById(i.id))?(n.captured?(n.insideElement=!1,n.lastPos=n.currentPos,n.lastTime=n.currentTime,n.currentPos=i.currentPos,n.currentTime=i.currentTime):B(e,r,n),i=n):(i.captured=!1,i.insideElementPressed=!1),(e.leaveHandler||e.exitHandler)&&(o={eventSource:e,pointerType:i.type,position:i.currentPos&&T(i.currentPos,e.element),buttons:r.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==r.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData},e.leaveHandler&&e.leaveHandler(o),e.exitHandler&&e.exitHandler(o))}function N(t,n,o,r){var s,a=i[t.hash],l=t.getActivePointersListByType(o.type);if(void 0!==n.originalEvent.buttons?l.buttons=n.originalEvent.buttons:0===r?l.buttons|=1:1===r?l.buttons|=4:2===r?l.buttons|=2:3===r?l.buttons|=8:4===r?l.buttons|=16:5===r&&(l.buttons|=32),0!==r)return n.shouldCapture=!1,n.shouldReleaseCapture=!1,void(!t.nonPrimaryPressHandler||n.preventGesture||n.defaultPrevented||(n.preventDefault=!0,t.nonPrimaryPressHandler({eventSource:t,pointerType:o.type,position:T(o.currentPos,t.element),button:r,buttons:l.buttons,isTouchEvent:"touch"===o.type,originalEvent:n.originalEvent,userData:t.userData})));(s=l.getById(o.id))?(s.insideElementPressed=!0,s.insideElement=!0,s.originalTarget=n.originalEvent.target,s.contactPos=o.currentPos,s.contactTime=o.currentTime,s.lastPos=s.currentPos,s.lastTime=s.currentTime,s.currentPos=o.currentPos,s.currentTime=o.currentTime,o=s):(o.captured=!1,o.insideElementPressed=!0,o.insideElement=!0,o.originalTarget=n.originalEvent.target,H(l,o)),l.addContact(),n.preventGesture||n.defaultPrevented?(n.shouldCapture=!1,n.shouldReleaseCapture=!1):(n.shouldCapture=!0,n.shouldReleaseCapture=!1,n.preventDefault=!0,(t.dragHandler||t.dragEndHandler||t.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.addPoint(t,o),1===l.contacts?t.pressHandler&&!n.preventGesture&&t.pressHandler({eventSource:t,pointerType:o.type,position:T(o.contactPos,t.element),buttons:l.buttons,isTouchEvent:"touch"===o.type,originalEvent:n.originalEvent,userData:t.userData}):2===l.contacts&&t.pinchHandler&&"touch"===o.type&&(a.pinchGPoints=l.asArray(),a.lastPinchDist=a.currentPinchDist=a.pinchGPoints[0].currentPos.distanceTo(a.pinchGPoints[1].currentPos),a.lastPinchCenter=a.currentPinchCenter=x(a.pinchGPoints[0].currentPos,a.pinchGPoints[1].currentPos)))}function A(t,n,o,r){var s,a,l,h,c=i[t.hash],u=t.getActivePointersListByType(o.type),d=!1;if(void 0!==n.originalEvent.buttons?u.buttons=n.originalEvent.buttons:0===r?u.buttons^=-2:1===r?u.buttons^=-5:2===r?u.buttons^=-3:3===r?u.buttons^=-9:4===r?u.buttons^=-17:5===r&&(u.buttons^=-33),n.shouldCapture=!1,0!==r)return n.shouldReleaseCapture=!1,void(!t.nonPrimaryReleaseHandler||n.preventGesture||n.defaultPrevented||(n.preventDefault=!0,t.nonPrimaryReleaseHandler({eventSource:t,pointerType:o.type,position:T(o.currentPos,t.element),button:r,buttons:u.buttons,isTouchEvent:"touch"===o.type,originalEvent:n.originalEvent,userData:t.userData})));(l=u.getById(o.id))?(u.removeContact(),l.captured&&(d=!0),l.lastPos=l.currentPos,l.lastTime=l.currentTime,l.currentPos=o.currentPos,l.currentTime=o.currentTime,l.insideElement||B(t,u,l),s=l.currentPos,a=l.currentTime):(o.captured=!1,o.insideElementPressed=!1,o.insideElement=!0,H(u,o),l=o),n.preventGesture||n.defaultPrevented||(d?(n.shouldReleaseCapture=!0,n.preventDefault=!0,(t.dragHandler||t.dragEndHandler||t.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.removePoint(t,l),0===u.contacts?(t.releaseHandler&&s&&t.releaseHandler({eventSource:t,pointerType:l.type,position:T(s,t.element),buttons:u.buttons,insideElementPressed:l.insideElementPressed,insideElementReleased:l.insideElement,isTouchEvent:"touch"===l.type,originalEvent:n.originalEvent,userData:t.userData}),t.dragEndHandler&&c.sentDragEvent&&t.dragEndHandler({eventSource:t,pointerType:l.type,position:T(l.currentPos,t.element),speed:l.speed,direction:l.direction,shift:n.originalEvent.shiftKey,isTouchEvent:"touch"===l.type,originalEvent:n.originalEvent,userData:t.userData}),c.sentDragEvent=!1,(t.clickHandler||t.dblClickHandler)&&l.insideElement&&(h=a-l.contactTime<=t.clickTimeThreshold&&l.contactPos.distanceTo(s)<=t.clickDistThreshold,t.clickHandler&&t.clickHandler({eventSource:t,pointerType:l.type,position:T(l.currentPos,t.element),quick:h,shift:n.originalEvent.shiftKey,isTouchEvent:"touch"===l.type,originalEvent:n.originalEvent,originalTarget:l.originalTarget,userData:t.userData}),t.dblClickHandler&&h&&(u.clicks++,1===u.clicks?(c.lastClickPos=s,c.dblClickTimeOut=setTimeout((function(){u.clicks=0}),t.dblClickTimeThreshold)):2===u.clicks&&(clearTimeout(c.dblClickTimeOut),u.clicks=0,c.lastClickPos.distanceTo(s)<=t.dblClickDistThreshold&&t.dblClickHandler({eventSource:t,pointerType:l.type,position:T(l.currentPos,t.element),shift:n.originalEvent.shiftKey,isTouchEvent:"touch"===l.type,originalEvent:n.originalEvent,userData:t.userData}),c.lastClickPos=null)))):2===u.contacts&&t.pinchHandler&&"touch"===l.type&&(c.pinchGPoints=u.asArray(),c.lastPinchDist=c.currentPinchDist=c.pinchGPoints[0].currentPos.distanceTo(c.pinchGPoints[1].currentPos),c.lastPinchCenter=c.currentPinchCenter=x(c.pinchGPoints[0].currentPos,c.pinchGPoints[1].currentPos))):(n.shouldReleaseCapture=!1,t.releaseHandler&&s&&(t.releaseHandler({eventSource:t,pointerType:l.type,position:T(s,t.element),buttons:u.buttons,insideElementPressed:l.insideElementPressed,insideElementReleased:l.insideElement,isTouchEvent:"touch"===l.type,originalEvent:n.originalEvent,userData:t.userData}),n.preventDefault=!0)))}function U(e,t,n){var o,r,s,a=i[e.hash],l=e.getActivePointersListByType(n.type);void 0!==t.originalEvent.buttons&&(l.buttons=t.originalEvent.buttons),(o=l.getById(n.id))&&(o.lastPos=o.currentPos,o.lastTime=o.currentTime,o.currentPos=n.currentPos,o.currentTime=n.currentTime,t.shouldCapture=!1,t.shouldReleaseCapture=!1,e.stopHandler&&"mouse"===n.type&&(clearTimeout(e.stopTimeOut),e.stopTimeOut=setTimeout((function(){!function(e,t,i){e.stopHandler&&e.stopHandler({eventSource:e,pointerType:i,position:w(t,e.element),buttons:e.getActivePointersListByType(i).buttons,isTouchEvent:"touch"===i,originalEvent:t,userData:e.userData})}(e,t.originalEvent,n.type)}),e.stopDelay)),0===l.contacts?e.moveHandler&&e.moveHandler({eventSource:e,pointerType:n.type,position:T(n.currentPos,e.element),buttons:l.buttons,isTouchEvent:"touch"===n.type,originalEvent:t.originalEvent,userData:e.userData}):1===l.contacts?(e.moveHandler&&(o=l.asArray()[0],e.moveHandler({eventSource:e,pointerType:o.type,position:T(o.currentPos,e.element),buttons:l.buttons,isTouchEvent:"touch"===o.type,originalEvent:t.originalEvent,userData:e.userData})),!e.dragHandler||t.preventGesture||t.defaultPrevented||(s=(o=l.asArray()[0]).currentPos.minus(o.lastPos),e.dragHandler({eventSource:e,pointerType:o.type,position:T(o.currentPos,e.element),buttons:l.buttons,delta:s,speed:o.speed,direction:o.direction,shift:t.originalEvent.shiftKey,isTouchEvent:"touch"===o.type,originalEvent:t.originalEvent,userData:e.userData}),t.preventDefault=!0,a.sentDragEvent=!0)):2===l.contacts&&(e.moveHandler&&(r=l.asArray(),e.moveHandler({eventSource:e,pointerType:r[0].type,position:T(x(r[0].currentPos,r[1].currentPos),e.element),buttons:l.buttons,isTouchEvent:"touch"===r[0].type,originalEvent:t.originalEvent,userData:e.userData})),!e.pinchHandler||"touch"!==n.type||t.preventGesture||t.defaultPrevented||(s=a.pinchGPoints[0].currentPos.distanceTo(a.pinchGPoints[1].currentPos))!==a.currentPinchDist&&(a.lastPinchDist=a.currentPinchDist,a.currentPinchDist=s,a.lastPinchCenter=a.currentPinchCenter,a.currentPinchCenter=x(a.pinchGPoints[0].currentPos,a.pinchGPoints[1].currentPos),e.pinchHandler({eventSource:e,pointerType:"touch",gesturePoints:a.pinchGPoints,lastCenter:T(a.lastPinchCenter,e.element),center:T(a.currentPinchCenter,e.element),lastDistance:a.lastPinchDist,distance:a.currentPinchDist,shift:t.originalEvent.shiftKey,originalEvent:t.originalEvent,userData:e.userData}),t.preventDefault=!0)))}function V(e,t,i){var n,o=e.getActivePointersListByType(i.type);(n=o.getById(i.id))&&B(e,o,n)}e.MouseTracker.gesturePointVelocityTracker=(n=[],o=0,r=0,s=function(e,t){return e.hash.toString()+t.type+t.id.toString()},a=function(){var t,i,o,s,a,l,h=n.length,c=e.now();for(s=c-r,r=c,t=0;t<h;t++)(o=(i=n[t]).gPoint).direction=Math.atan2(o.currentPos.y-i.lastPos.y,o.currentPos.x-i.lastPos.x),a=i.lastPos.distanceTo(o.currentPos),i.lastPos=o.currentPos,l=1e3*a/(s+1),o.speed=.75*l+.25*o.speed},{addPoint:function(t,i){var l=s(t,i);n.push({guid:l,gPoint:i,lastPos:i.currentPos}),1===n.length&&(r=e.now(),o=window.setInterval(a,50))},removePoint:function(e,t){var i,r=s(e,t),a=n.length;for(i=0;i<a;i++)if(n[i].guid===r){n.splice(i,1),0==--a&&window.clearInterval(o);break}}}),e.MouseTracker.captureElement=document,e.MouseTracker.wheelEventName=e.Browser.vendor===e.BROWSERS.IE&&e.Browser.version>8||"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll",e.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",e.MouseTracker.wheelEventName],"DOMMouseScroll"===e.MouseTracker.wheelEventName&&e.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(e.MouseTracker.havePointerEvents=!0,e.MouseTracker.subscribeEvents.push("pointerenter","pointerleave","pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),e.MouseTracker.havePointerCapture=(l=document.createElement("div"),e.isFunction(l.setPointerCapture)&&e.isFunction(l.releasePointerCapture)),e.MouseTracker.havePointerCapture&&e.MouseTracker.subscribeEvents.push("gotpointercapture","lostpointercapture")):(e.MouseTracker.havePointerEvents=!1,e.MouseTracker.subscribeEvents.push("mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","mousemove"),e.MouseTracker.mousePointerId="legacy-mouse",e.MouseTracker.havePointerCapture=function(){var t=document.createElement("div");return e.isFunction(t.setCapture)&&e.isFunction(t.releaseCapture)}(),e.MouseTracker.havePointerCapture&&e.MouseTracker.subscribeEvents.push("losecapture"),"ontouchstart"in window&&e.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ongesturestart"in window&&e.MouseTracker.subscribeEvents.push("gesturestart","gesturechange")),e.MouseTracker.GesturePointList=function(e){this._gPoints=[],this.type=e,this.buttons=0,this.contacts=0,this.clicks=0,this.captureCount=0},e.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(e){return this._gPoints.push(e)},removeById:function(e){var t,i=this._gPoints.length;for(t=0;t<i;t++)if(this._gPoints[t].id===e){this._gPoints.splice(t,1);break}return this._gPoints.length},getByIndex:function(e){return e<this._gPoints.length?this._gPoints[e]:null},getById:function(e){var t,i=this._gPoints.length;for(t=0;t<i;t++)if(this._gPoints[t].id===e)return this._gPoints[t];return null},getPrimary:function(e){var t,i=this._gPoints.length;for(t=0;t<i;t++)if(this._gPoints[t].isPrimary)return this._gPoints[t];return null},addContact:function(){++this.contacts,this.contacts>1&&("mouse"===this.type||"pen"===this.type)&&(e.console.warn("GesturePointList.addContact() Implausible contacts value"),this.contacts=1)},removeContact:function(){--this.contacts,this.contacts<0&&(this.contacts=0)}}}(s),function(e){e.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},e.Control=function(t,i,n){var o=t.parentNode;"number"==typeof i&&(e.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"),i={anchor:i}),i.attachToViewer=void 0===i.attachToViewer||i.attachToViewer,this.autoFade=void 0===i.autoFade||i.autoFade,this.element=t,this.anchor=i.anchor,this.container=n,this.anchor===e.ControlAnchor.ABSOLUTE?(this.wrapper=e.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top="number"==typeof i.top?i.top+"px":i.top,this.wrapper.style.left="number"==typeof i.left?i.left+"px":i.left,this.wrapper.style.height="number"==typeof i.height?i.height+"px":i.height,this.wrapper.style.width="number"==typeof i.width?i.width+"px":i.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=e.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor===e.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),i.attachToViewer?this.anchor===e.ControlAnchor.TOP_RIGHT||this.anchor===e.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):o.appendChild(this.wrapper)},e.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.anchor!==e.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return"none"!==this.wrapper.style.display},setVisible:function(t){this.wrapper.style.display=t?this.anchor===e.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(t){this.element[e.SIGNAL]&&e.Browser.vendor===e.BROWSERS.IE?e.setElementOpacity(this.element,t,!0):e.setElementOpacity(this.wrapper,t,!0)}}}(s),function(e){function t(e,t){var i,n=e.controls;for(i=n.length-1;i>=0;i--)if(n[i].element===t)return i;return-1}e.ControlDock=function(t){var i,n,o=["topleft","topright","bottomright","bottomleft"];for(e.extend(!0,this,{id:"controldock-"+e.now()+"-"+Math.floor(1e6*Math.random()),container:e.makeNeutralElement("div"),controls:[]},t),this.container.onsubmit=function(){return!1},this.element&&(this.element=e.getElement(this.element),this.element.appendChild(this.container),this.element.style.position="relative",this.container.style.width="100%",this.container.style.height="100%"),n=0;n<o.length;n++)i=o[n],this.controls[i]=e.makeNeutralElement("div"),this.controls[i].style.position="absolute",i.match("left")&&(this.controls[i].style.left="0px"),i.match("right")&&(this.controls[i].style.right="0px"),i.match("top")&&(this.controls[i].style.top="0px"),i.match("bottom")&&(this.controls[i].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)},e.ControlDock.prototype={addControl:function(i,n){var o=null;if(!(t(this,i=e.getElement(i))>=0)){switch(n.anchor){case e.ControlAnchor.TOP_RIGHT:o=this.controls.topright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.BOTTOM_RIGHT:o=this.controls.bottomright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.BOTTOM_LEFT:o=this.controls.bottomleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.TOP_LEFT:o=this.controls.topleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.ABSOLUTE:default:case e.ControlAnchor.NONE:o=this.container,i.style.margin="0px",i.style.padding="0px"}this.controls.push(new e.Control(i,n,o)),i.style.display="inline-block"}},removeControl:function(i){var n=t(this,i=e.getElement(i));return n>=0&&(this.controls[n].destroy(),this.controls.splice(n,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var e;for(e=this.controls.length-1;e>=0;e--)if(this.controls[e].isVisible())return!0;return!1},setControlsEnabled:function(e){var t;for(t=this.controls.length-1;t>=0;t--)this.controls[t].setVisible(e);return this}}}(s),function(e){e.Placement=e.freezeObject({CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8,properties:{0:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1},1:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},2:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},3:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!0,isVerticallyCentered:!1,isBottom:!1},4:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!0,isBottom:!1},5:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!1,isBottom:!0},6:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},7:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},8:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1}}})}(s),function(e){var t={},i=1;function n(t){return t=e.getElement(t),new e.Point(0===t.clientWidth?1:t.clientWidth,0===t.clientHeight?1:t.clientHeight)}function o(t,i){if(i instanceof e.Overlay)return i;var n=null;if(i.element)n=e.getElement(i.element);else{var o=i.id?i.id:"openseadragon-overlay-"+Math.floor(1e7*Math.random());(n=e.getElement(i.id))||((n=document.createElement("a")).href="#/overlay/"+o),n.id=o,e.addClass(n,i.className?i.className:"openseadragon-overlay")}var r=i.location,s=i.width,a=i.height;if(!r){var l=i.x,h=i.y;if(void 0!==i.px){var c=t.viewport.imageToViewportRectangle(new e.Rect(i.px,i.py,s||0,a||0));l=c.x,h=c.y,s=void 0!==s?c.width:void 0,a=void 0!==a?c.height:void 0}r=new e.Point(l,h)}var u=i.placement;return u&&"string"===e.type(u)&&(u=e.Placement[i.placement.toUpperCase()]),new e.Overlay({element:n,location:r,placement:u,onDraw:i.onDraw,checkResize:i.checkResize,width:s,height:a,rotationMode:i.rotationMode})}function r(e,t){var i;for(i=e.length-1;i>=0;i--)if(e[i].element===t)return i;return-1}function s(t,i){return e.requestAnimationFrame((function(){i(t)}))}function a(t){e.requestAnimationFrame((function(){!function(t){var i,n;if(t.controlsShouldFade){for(i=1-(e.now()-t.controlsFadeBeginTime)/t.controlsFadeLength,i=Math.min(1,i),i=Math.max(0,i),n=t.controls.length-1;n>=0;n--)t.controls[n].autoFade&&t.controls[n].setOpacity(i);i>0&&a(t)}}(t)}))}function l(t){t.autoHideControls&&(t.controlsShouldFade=!0,t.controlsFadeBeginTime=e.now()+t.controlsFadeDelay,window.setTimeout((function(){a(t)}),t.controlsFadeDelay))}function h(e){var t;for(e.controlsShouldFade=!1,t=e.controls.length-1;t>=0;t--)e.controls[t].setOpacity(1)}function c(){h(this)}function u(){l(this)}function d(e){var t={tracker:e.eventSource,position:e.position,originalEvent:e.originalEvent,preventDefault:e.preventDefault};this.raiseEvent("canvas-contextmenu",t),e.preventDefault=t.preventDefault}function p(t){var i={originalEvent:t.originalEvent,preventDefaultAction:!1,preventVerticalPan:t.preventVerticalPan||!this.panVertical,preventHorizontalPan:t.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",i),i.preventDefaultAction||t.ctrl||t.alt||t.meta)t.preventDefault=!1;else switch(t.keyCode){case 38:i.preventVerticalPan||(t.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),t.preventDefault=!0;break;case 40:i.preventVerticalPan||(t.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),t.preventDefault=!0;break;case 37:i.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),t.preventDefault=!0;break;case 39:i.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),t.preventDefault=!0;break;default:t.preventDefault=!1}}function g(t){var i={originalEvent:t.originalEvent,preventDefaultAction:!1,preventVerticalPan:t.preventVerticalPan||!this.panVertical,preventHorizontalPan:t.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",i),i.preventDefaultAction||t.ctrl||t.alt||t.meta)t.preventDefault=!1;else switch(t.keyCode){case 43:case 61:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),t.preventDefault=!0;break;case 45:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),t.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),t.preventDefault=!0;break;case 119:case 87:i.preventVerticalPan||(t.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-40))),this.viewport.applyConstraints()),t.preventDefault=!0;break;case 115:case 83:i.preventVerticalPan||(t.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,40))),this.viewport.applyConstraints()),t.preventDefault=!0;break;case 97:i.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-40,0))),this.viewport.applyConstraints()),t.preventDefault=!0;break;case 100:i.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(40,0))),this.viewport.applyConstraints()),t.preventDefault=!0;break;case 114:this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement),this.viewport.applyConstraints(),t.preventDefault=!0;break;case 82:this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement),this.viewport.applyConstraints(),t.preventDefault=!0;break;case 102:this.viewport.toggleFlip(),t.preventDefault=!0;break;case 106:this.goToPreviousPage();break;case 107:this.goToNextPage();break;default:t.preventDefault=!1}}function m(i){var n;document.activeElement===this.canvas||this.canvas.focus(),this.viewport.flipped&&(i.position.x=this.viewport.getContainerSize().x-i.position.x);var o={tracker:i.eventSource,position:i.position,quick:i.quick,shift:i.shift,originalEvent:i.originalEvent,originalTarget:i.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",o),!o.preventDefaultAction&&this.viewport&&i.quick&&(!0===(n=this.gestureSettingsByDeviceType(i.pointerType)).clickToZoom&&(this.viewport.zoomBy(i.shift?1/this.zoomPerClick:this.zoomPerClick,n.zoomToRefPoint?this.viewport.pointFromPixel(i.position,!0):null),this.viewport.applyConstraints()),n.dblClickDragToZoom&&(!0===t[this.hash].draggingToZoom?(t[this.hash].lastClickTime=null,t[this.hash].draggingToZoom=!1):t[this.hash].lastClickTime=e.now()))}function v(e){var t,i={tracker:e.eventSource,position:e.position,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",i),!i.preventDefaultAction&&this.viewport&&(t=this.gestureSettingsByDeviceType(e.pointerType)).dblClickToZoom&&(this.viewport.zoomBy(e.shift?1/this.zoomPerClick:this.zoomPerClick,t.zoomToRefPoint?this.viewport.pointFromPixel(e.position,!0):null),this.viewport.applyConstraints())}function f(e){var i,n={tracker:e.eventSource,pointerType:e.pointerType,position:e.position,delta:e.delta,speed:e.speed,direction:e.direction,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",n),i=this.gestureSettingsByDeviceType(e.pointerType),!n.preventDefaultAction&&this.viewport)if(i.dblClickDragToZoom&&t[this.hash].draggingToZoom){var o=Math.pow(this.zoomPerDblClickDrag,e.delta.y/50);this.viewport.zoomBy(o)}else if(i.dragToPan&&!t[this.hash].draggingToZoom){if(this.panHorizontal||(e.delta.x=0),this.panVertical||(e.delta.y=0),this.viewport.flipped&&(e.delta.x=-e.delta.x),this.constrainDuringPan){var r=this.viewport.deltaPointsFromPixels(e.delta.negate());this.viewport.centerSpringX.target.value+=r.x,this.viewport.centerSpringY.target.value+=r.y;var s=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=r.x,this.viewport.centerSpringY.target.value-=r.y,s.xConstrained&&(e.delta.x=0),s.yConstrained&&(e.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(e.delta.negate()),i.flickEnabled&&!this.constrainDuringPan)}}function y(i){var n,o={tracker:i.eventSource,pointerType:i.pointerType,position:i.position,speed:i.speed,direction:i.direction,shift:i.shift,originalEvent:i.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",o),n=this.gestureSettingsByDeviceType(i.pointerType),!o.preventDefaultAction&&this.viewport){if(!t[this.hash].draggingToZoom&&n.flickEnabled&&i.speed>=n.flickMinSpeed){var r=0;this.panHorizontal&&(r=n.flickMomentum*i.speed*Math.cos(i.direction));var s=0;this.panVertical&&(s=n.flickMomentum*i.speed*Math.sin(i.direction));var a=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),l=this.viewport.pointFromPixel(new e.Point(a.x-r,a.y-s));this.viewport.panTo(l,!1)}this.viewport.applyConstraints()}n.dblClickDragToZoom&&!0===t[this.hash].draggingToZoom&&(t[this.hash].draggingToZoom=!1)}function w(e){this.raiseEvent("canvas-enter",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function T(e){this.raiseEvent("canvas-exit",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function x(i){if(this.raiseEvent("canvas-press",{tracker:i.eventSource,pointerType:i.pointerType,position:i.position,insideElementPressed:i.insideElementPressed,insideElementReleased:i.insideElementReleased,originalEvent:i.originalEvent}),this.gestureSettingsByDeviceType(i.pointerType).dblClickDragToZoom){var n=t[this.hash].lastClickTime,o=e.now();if(null===n)return;o-n<this.dblClickTimeThreshold&&(t[this.hash].draggingToZoom=!0),t[this.hash].lastClickTime=null}}function S(e){this.raiseEvent("canvas-release",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,insideElementPressed:e.insideElementPressed,insideElementReleased:e.insideElementReleased,originalEvent:e.originalEvent})}function E(e){this.raiseEvent("canvas-nonprimary-press",{tracker:e.eventSource,position:e.position,pointerType:e.pointerType,button:e.button,buttons:e.buttons,originalEvent:e.originalEvent})}function P(e){this.raiseEvent("canvas-nonprimary-release",{tracker:e.eventSource,position:e.position,pointerType:e.pointerType,button:e.button,buttons:e.buttons,originalEvent:e.originalEvent})}function _(e){var t,i,n,o={tracker:e.eventSource,pointerType:e.pointerType,gesturePoints:e.gesturePoints,lastCenter:e.lastCenter,center:e.center,lastDistance:e.lastDistance,distance:e.distance,shift:e.shift,originalEvent:e.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",o),this.viewport&&(!(t=this.gestureSettingsByDeviceType(e.pointerType)).pinchToZoom||o.preventDefaultPanAction&&o.preventDefaultZoomAction||(i=this.viewport.pointFromPixel(e.center,!0),t.zoomToRefPoint&&!o.preventDefaultPanAction&&(n=this.viewport.pointFromPixel(e.lastCenter,!0).minus(i),this.panHorizontal||(n.x=0),this.panVertical||(n.y=0),this.viewport.panBy(n,!0)),o.preventDefaultZoomAction||this.viewport.zoomBy(e.distance/e.lastDistance,i,!0),this.viewport.applyConstraints()),t.pinchRotate&&!o.preventDefaultRotateAction)){var r=Math.atan2(e.gesturePoints[0].currentPos.y-e.gesturePoints[1].currentPos.y,e.gesturePoints[0].currentPos.x-e.gesturePoints[1].currentPos.x),s=Math.atan2(e.gesturePoints[0].lastPos.y-e.gesturePoints[1].lastPos.y,e.gesturePoints[0].lastPos.x-e.gesturePoints[1].lastPos.x);this.viewport.setRotation(this.viewport.getRotation()+(r-s)*(180/Math.PI))}}function R(t){var i,n,o,r;(r=e.now())-this._lastScrollTime>this.minScrollDeltaTime?(this._lastScrollTime=r,i={tracker:t.eventSource,position:t.position,scroll:t.scroll,shift:t.shift,originalEvent:t.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",i),!i.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(t.position.x=this.viewport.getContainerSize().x-t.position.x),(n=this.gestureSettingsByDeviceType(t.pointerType)).scrollToZoom&&(o=Math.pow(this.zoomPerScroll,t.scroll),this.viewport.zoomBy(o,n.zoomToRefPoint?this.viewport.pointFromPixel(t.position,!0):null),this.viewport.applyConstraints())),t.preventDefault=i.preventDefault):t.preventDefault=!0}function C(e){t[this.hash].mouseInside=!0,h(this),this.raiseEvent("container-enter",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function b(e){e.pointers<1&&(t[this.hash].mouseInside=!1,t[this.hash].animating||l(this)),this.raiseEvent("container-exit",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function D(i){!function(i){if(!i._opening&&t[i.hash]){if(i.autoResize||t[i.hash].forceResize){var o;if(i._autoResizePolling){o=n(i.container);var r=t[i.hash].prevContainerSize;o.equals(r)||(t[i.hash].needsResize=!0)}t[i.hash].needsResize&&function(i,n){var o,r=i.viewport,s=r.getZoom(),a=r.getCenter();if(r.resize(n,i.preserveImageSizeOnResize),r.panTo(a,!0),i.preserveImageSizeOnResize)o=t[i.hash].prevContainerSize.x/n.x;else{var l=new e.Point(0,0),h=new e.Point(t[i.hash].prevContainerSize.x,t[i.hash].prevContainerSize.y).distanceTo(l);o=new e.Point(n.x,n.y).distanceTo(l)/h*t[i.hash].prevContainerSize.x/n.x}r.zoomTo(s*o,null,!0),t[i.hash].prevContainerSize=n,t[i.hash].forceRedraw=!0,t[i.hash].needsResize=!1,t[i.hash].forceResize=!1}(i,o||n(i.container))}var s=i.viewport.update(),a=i.world.update()||s;s&&i.raiseEvent("viewport-change"),i.referenceStrip&&(a=i.referenceStrip.update(i.viewport)||a);var c=t[i.hash].animating;!c&&a&&(i.raiseEvent("animation-start"),h(i));var u=c&&!a;u&&(t[i.hash].animating=!1),(a||u||t[i.hash].forceRedraw||i.world.needsDraw())&&(function(e){e.imageLoader.clear(),e.drawer.clear(),e.world.draw(),e.raiseEvent("update-viewport",{})}(i),i._drawOverlays(),i.navigator&&i.navigator.update(i.viewport),t[i.hash].forceRedraw=!1,a&&i.raiseEvent("animation")),u&&(i.raiseEvent("animation-finish"),t[i.hash].mouseInside||l(i)),t[i.hash].animating=a}}(i),i.isOpen()?i._updateRequestId=s(i,D):i._updateRequestId=!1}function I(e,t){return e?e+t:t}function k(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=this.zoomPerSecond,t[this.hash].zooming=!0,B(this)}function O(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=1/this.zoomPerSecond,t[this.hash].zooming=!0,B(this)}function H(){t[this.hash].zooming=!1}function B(t){e.requestAnimationFrame(e.delegate(t,z))}function z(){var i,n,o;t[this.hash].zooming&&this.viewport&&(n=(i=e.now())-t[this.hash].lastZoomTime,o=Math.pow(t[this.hash].zoomFactor,n/1e3),this.viewport.zoomBy(o),this.viewport.applyConstraints(),t[this.hash].lastZoomTime=i,B(this))}function L(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function F(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function M(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function N(){this.viewport&&this.viewport.goHome()}function A(){this.isFullPage()&&!e.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttonGroup&&this.buttonGroup.emulateLeave(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function U(){if(this.viewport){var e=this.viewport.getRotation();this.viewport.flipped?e+=this.rotationIncrement:e-=this.rotationIncrement,this.viewport.setRotation(e)}}function V(){if(this.viewport){var e=this.viewport.getRotation();this.viewport.flipped?e-=this.rotationIncrement:e+=this.rotationIncrement,this.viewport.setRotation(e)}}function W(){this.viewport.toggleFlip()}e.Viewer=function(o){var r,a,h=arguments,c=this;if(e.isPlainObject(o)||(o={id:h[0],xmlPath:h.length>1?h[1]:void 0,prefixUrl:h.length>2?h[2]:void 0,controls:h.length>3?h[3]:void 0,overlays:h.length>4?h[4]:void 0}),o.config&&(e.extend(!0,o,o.config),delete o.config),e.extend(!0,this,{id:o.id,hash:o.hash||i++,initialPage:0,element:null,container:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttonGroup:null,profiler:null},e.DEFAULT_SETTINGS,o),void 0===this.hash)throw new Error("A hash must be defined, either by specifying options.id or options.hash.");for(void 0!==t[this.hash]&&e.console.warn("Hash "+this.hash+" has already been used."),t[this.hash]={fsBoundsDelta:new e.Point(1,1),prevContainerSize:null,animating:!1,forceRedraw:!1,needsResize:!1,forceResize:!1,mouseInside:!1,group:null,zooming:!1,zoomFactor:null,lastZoomTime:null,fullPage:!1,onfullscreenchange:null,lastClickTime:null,draggingToZoom:!1},this._sequenceIndex=0,this._firstOpen=!0,this._updateRequestId=null,this._loadQueue=[],this.currentOverlays=[],this._updatePixelDensityRatioBind=null,this._lastScrollTime=e.now(),e.EventSource.call(this),this.addHandler("open-failed",(function(t){var i=e.getString("Errors.OpenFailed",t.eventSource,t.message);c._showMessage(i)})),e.ControlDock.call(this,o),this.xmlPath&&(this.tileSources=[this.xmlPath]),this.element=this.element||document.getElementById(this.id),this.canvas=e.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",(a=this.canvas.style).width="100%",a.height="100%",a.overflow="hidden",a.position="absolute",a.top="0px",a.left="0px",e.setElementTouchActionNone(this.canvas),""!==o.tabIndex&&(this.canvas.tabIndex=void 0===o.tabIndex?0:o.tabIndex),this.container.className="openseadragon-container",function(e){e.width="100%",e.height="100%",e.position="relative",e.overflow="hidden",e.left="0px",e.top="0px",e.textAlign="left"}(this.container.style),e.setElementTouchActionNone(this.container),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 e.MouseTracker({userData:"Viewer.innerTracker",element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,contextMenuHandler:e.delegate(this,d),keyDownHandler:e.delegate(this,p),keyHandler:e.delegate(this,g),clickHandler:e.delegate(this,m),dblClickHandler:e.delegate(this,v),dragHandler:e.delegate(this,f),dragEndHandler:e.delegate(this,y),enterHandler:e.delegate(this,w),leaveHandler:e.delegate(this,T),pressHandler:e.delegate(this,x),releaseHandler:e.delegate(this,S),nonPrimaryPressHandler:e.delegate(this,E),nonPrimaryReleaseHandler:e.delegate(this,P),scrollHandler:e.delegate(this,R),pinchHandler:e.delegate(this,_)}),this.outerTracker=new e.MouseTracker({userData:"Viewer.outerTracker",element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:e.delegate(this,C),leaveHandler:e.delegate(this,b)}),this.toolbar&&(this.toolbar=new e.ControlDock({element:this.toolbar})),this.bindStandardControls(),t[this.hash].prevContainerSize=n(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver((function(){t[c.hash].needsResize=!0})),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new e.World({viewer:this}),this.world.addHandler("add-item",(function(e){c.source=c.world.getItemAt(0).source,t[c.hash].forceRedraw=!0,c._updateRequestId||(c._updateRequestId=s(c,D))})),this.world.addHandler("remove-item",(function(e){c.world.getItemCount()?c.source=c.world.getItemAt(0).source:c.source=null,t[c.hash].forceRedraw=!0})),this.world.addHandler("metrics-change",(function(e){c.viewport&&c.viewport._setContentBounds(c.world.getHomeBounds(),c.world.getContentFactor())})),this.world.addHandler("item-index-change",(function(e){c.source=c.world.getItemAt(0).source})),this.viewport=new e.Viewport({containerSize:t[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,flipped:this.flipped,navigatorRotate:this.navigatorRotate,homeFillsViewer:this.homeFillsViewer,margins:this.viewportMargins,silenceMultiImageWarnings:this.silenceMultiImageWarnings}),this.viewport._setContentBounds(this.world.getHomeBounds(),this.world.getContentFactor()),this.imageLoader=new e.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:o.timeout}),this.tileCache=new e.TileCache({maxImageCacheCount:this.maxImageCacheCount}),this.drawer=new e.Drawer({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor}),this.overlaysContainer=e.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(r=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(r,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(r=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(r,1),this.buttonGroup.element.removeChild(this.rotateRight.element))),this._addUpdatePixelDensityRatioEvent(),this.showNavigator&&(this.navigator=new e.Navigator({element:this.navigatorElement,id:this.navigatorId,position:this.navigatorPosition,sizeRatio:this.navigatorSizeRatio,maintainSizeRatio:this.navigatorMaintainSizeRatio,top:this.navigatorTop,left:this.navigatorLeft,width:this.navigatorWidth,height:this.navigatorHeight,autoResize:this.navigatorAutoResize,autoFade:this.navigatorAutoFade,prefixUrl:this.prefixUrl,viewer:this,navigatorRotate:this.navigatorRotate,background:this.navigatorBackground,opacity:this.navigatorOpacity,borderColor:this.navigatorBorderColor,displayRegionColor:this.navigatorDisplayRegionColor,crossOriginPolicy:this.crossOriginPolicy,animationTime:this.animationTime})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),r=0;r<this.customControls.length;r++)this.addControl(this.customControls[r].id,{anchor:this.customControls[r].anchor});e.requestAnimationFrame((function(){l(c)})),void 0===this.imageSmoothingEnabled||this.imageSmoothingEnabled||this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),e._viewers.set(this.element,this)},e.extend(e.Viewer.prototype,e.EventSource.prototype,e.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},openDzi:function(t){return e.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(t)},openTileSource:function(t){return e.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(t)},get buttons(){return e.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(t,i){var n=this;if(this.close(),!t)return this;if(this.sequenceMode&&e.isArray(t))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),void 0===i||isNaN(i)||(this.initialPage=i),this.tileSources=t,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.addReferenceStrip()),this._updateSequenceButtons(this._sequenceIndex),this;if(e.isArray(t)||(t=[t]),!t.length)return this;this._opening=!0;for(var r,s=t.length,a=0,l=0,h=function(){if(a+l===s)if(a){!n._firstOpen&&n.preserveViewport||(n.viewport.goHome(!0),n.viewport.update()),n._firstOpen=!1;var e=t[0];if(e.tileSource&&(e=e.tileSource),n.overlays&&!n.preserveOverlays)for(var i=0;i<n.overlays.length;i++)n.currentOverlays[i]=o(n,n.overlays[i]);n._drawOverlays(),n._opening=!1,n.raiseEvent("open",{source:e})}else n._opening=!1,n.raiseEvent("open-failed",r)},c=function(t){e.isPlainObject(t)&&t.tileSource||(t={tileSource:t}),void 0!==t.index&&(e.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete t.index),void 0===t.collectionImmediately&&(t.collectionImmediately=!0);var i=t.success;t.success=function(e){if(a++,t.tileSource.overlays)for(var o=0;o<t.tileSource.overlays.length;o++)n.addOverlay(t.tileSource.overlays[o]);i&&i(e),h()};var o=t.error;t.error=function(e){l++,r||(r=e),o&&o(e),h()},n.addTiledImage(t)},u=0;u<t.length;u++)c(t[u]);return this},close:function(){return t[this.hash]?(this._opening=!1,this.navigator&&this.navigator.close(),this.preserveOverlays||(this.clearOverlays(),this.overlaysContainer.innerHTML=""),t[this.hash].animating=!1,this.world.removeAll(),this.imageLoader.clear(),this.raiseEvent("close"),this):this},destroy:function(){if(t[this.hash]){if(this.raiseEvent("before-destroy"),this._removeUpdatePixelDensityRatioEvent(),this.close(),this.clearOverlays(),this.overlaysContainer.innerHTML="",this._resizeObserver&&this._resizeObserver.disconnect(),this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),null!==this._updateRequestId&&(e.cancelAnimationFrame(this._updateRequestId),this._updateRequestId=null),this.drawer&&this.drawer.destroy(),this.navigator&&(this.navigator.destroy(),t[this.navigator.hash]=null,delete t[this.navigator.hash],this.navigator=null),this.buttonGroup)this.buttonGroup.destroy();else if(this.customButtons)for(;this.customButtons.length;)this.customButtons.pop().destroy();if(this.paging&&this.paging.destroy(),this.element)for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.container.onsubmit=null,this.clearControls(),this.innerTracker&&this.innerTracker.destroy(),this.outerTracker&&this.outerTracker.destroy(),t[this.hash]=null,delete t[this.hash],this.canvas=null,this.container=null,e._viewers.delete(this.element),this.element=null,this.raiseEvent("destroy"),this.removeAllHandlers()}},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(e){return this.innerTracker.setTracking(e),this.outerTracker.setTracking(e),this.raiseEvent("mouse-enabled",{enabled:e}),this},areControlsEnabled:function(){var e,t=this.controls.length;for(e=0;e<this.controls.length;e++)t=t&&this.controls[e].isVisible();return t},setControlsEnabled:function(e){return e?h(this):l(this),this.raiseEvent("controls-enabled",{enabled:e}),this},setDebugMode:function(e){for(var t=0;t<this.world.getItemCount();t++)this.world.getItemAt(t).debugMode=e;this.debugMode=e,this.forceRedraw()},isFullPage:function(){return t[this.hash].fullPage},setFullPage:function(i){var n,o,r=document.body,s=r.style,a=document.documentElement.style,l=this;if(i===this.isFullPage())return this;var h={fullPage:i,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",h),h.preventDefaultAction)return this;if(i){for(this.elementSize=e.getElementSize(this.element),this.pageScroll=e.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=s.margin,this.docMargin=a.margin,s.margin="0",a.margin="0",this.bodyPadding=s.padding,this.docPadding=a.padding,s.padding="0",a.padding="0",this.bodyWidth=s.width,this.docWidth=a.width,s.width="100%",a.width="100%",this.bodyHeight=s.height,this.docHeight=a.height,s.height="100%",a.height="100%",this.bodyDisplay=s.display,s.display="block",this.previousBody=[],t[this.hash].prevElementParent=this.element.parentNode,t[this.hash].prevNextSibling=this.element.nextSibling,t[this.hash].prevElementWidth=this.element.style.width,t[this.hash].prevElementHeight=this.element.style.height,n=r.childNodes.length,o=0;o<n;o++)this.previousBody.push(r.childNodes[0]),r.removeChild(r.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,r.appendChild(this.toolbar.element),e.addClass(this.toolbar.element,"fullpage")),e.addClass(this.element,"fullpage"),r.appendChild(this.element),this.element.style.height="100vh",this.element.style.width="100vw",this.toolbar&&this.toolbar.element&&(this.element.style.height=e.getElementSize(this.element).y-e.getElementSize(this.toolbar.element).y+"px"),t[this.hash].fullPage=!0,e.delegate(this,C)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,s.margin=this.bodyMargin,a.margin=this.docMargin,s.padding=this.bodyPadding,a.padding=this.docPadding,s.width=this.bodyWidth,a.width=this.docWidth,s.height=this.bodyHeight,a.height=this.docHeight,s.display=this.bodyDisplay,r.removeChild(this.element),n=this.previousBody.length,o=0;o<n;o++)r.appendChild(this.previousBody.shift());e.removeClass(this.element,"fullpage"),t[this.hash].prevElementParent.insertBefore(this.element,t[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(r.removeChild(this.toolbar.element),e.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=t[this.hash].prevElementWidth,this.element.style.height=t[this.hash].prevElementHeight;var c=0,u=function(){e.setPageScroll(l.pageScroll);var t=e.getPageScroll();++c<10&&(t.x!==l.pageScroll.x||t.y!==l.pageScroll.y)&&e.requestAnimationFrame(u)};e.requestAnimationFrame(u),t[this.hash].fullPage=!1,e.delegate(this,b)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:i}),this},setFullScreen:function(t){var i=this;if(!e.supportsFullScreen)return this.setFullPage(t);if(e.isFullScreen()===t)return this;var n={fullScreen:t,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",n),n.preventDefaultAction)return this;if(t){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 o=function(){var t=e.isFullScreen();t||(e.removeEvent(document,e.fullScreenEventName,o),e.removeEvent(document,e.fullScreenErrorEventName,o),i.setFullPage(!1),i.isFullPage()&&(i.element.style.width=i.fullPageStyleWidth,i.element.style.height=i.fullPageStyleHeight)),i.navigator&&i.viewport&&setTimeout((function(){i.navigator.update(i.viewport)})),i.raiseEvent("full-screen",{fullScreen:t})};e.addEvent(document,e.fullScreenEventName,o),e.addEvent(document,e.fullScreenErrorEventName,o),e.requestFullScreen(document.body)}else e.exitFullScreen();return this},isVisible:function(){return"hidden"!==this.container.style.visibility},isFullScreen:function(){return e.isFullScreen()&&this.isFullPage()},setVisible:function(e){return this.container.style.visibility=e?"":"hidden",this.raiseEvent("visible",{visible:e}),this},addTiledImage:function(t){e.console.assert(t,"[Viewer.addTiledImage] options is required"),e.console.assert(t.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),e.console.assert(!t.replace||t.index>-1&&t.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var i=this;t.replace&&(t.replaceItem=i.world.getItemAt(t.index)),this._hideMessage(),void 0===t.placeholderFillStyle&&(t.placeholderFillStyle=this.placeholderFillStyle),void 0===t.opacity&&(t.opacity=this.opacity),void 0===t.preload&&(t.preload=this.preload),void 0===t.compositeOperation&&(t.compositeOperation=this.compositeOperation),void 0===t.crossOriginPolicy&&(t.crossOriginPolicy=void 0!==t.tileSource.crossOriginPolicy?t.tileSource.crossOriginPolicy:this.crossOriginPolicy),void 0===t.ajaxWithCredentials&&(t.ajaxWithCredentials=this.ajaxWithCredentials),void 0===t.loadTilesWithAjax&&(t.loadTilesWithAjax=this.loadTilesWithAjax),void 0===t.ajaxHeaders||null===t.ajaxHeaders?t.ajaxHeaders=this.ajaxHeaders:e.isPlainObject(t.ajaxHeaders)&&e.isPlainObject(this.ajaxHeaders)&&(t.ajaxHeaders=e.extend({},this.ajaxHeaders,t.ajaxHeaders));var n={options:t};function o(e){for(var o=0;o<i._loadQueue.length;o++)if(i._loadQueue[o]===n){i._loadQueue.splice(o,1);break}0===i._loadQueue.length&&r(n),i.raiseEvent("add-item-failed",e),t.error&&t.error(e)}function r(e){i.collectionMode&&(i.world.arrange({immediately:e.options.collectionImmediately,rows:i.collectionRows,columns:i.collectionColumns,layout:i.collectionLayout,tileSize:i.collectionTileSize,tileMargin:i.collectionTileMargin}),i.world.setAutoRefigureSizes(!0))}function s(){for(var t,n,o;i._loadQueue.length&&(t=i._loadQueue[0]).tileSource;){if(i._loadQueue.splice(0,1),t.options.replace){var s=i.world.getIndexOfItem(t.options.replaceItem);-1!==s&&(t.options.index=s),i.world.removeItem(t.options.replaceItem)}n=new e.TiledImage({viewer:i,source:t.tileSource,viewport:i.viewport,drawer:i.drawer,tileCache:i.tileCache,imageLoader:i.imageLoader,x:t.options.x,y:t.options.y,width:t.options.width,height:t.options.height,fitBounds:t.options.fitBounds,fitBoundsPlacement:t.options.fitBoundsPlacement,clip:t.options.clip,placeholderFillStyle:t.options.placeholderFillStyle,opacity:t.options.opacity,preload:t.options.preload,degrees:t.options.degrees,flipped:t.options.flipped,compositeOperation:t.options.compositeOperation,springStiffness:i.springStiffness,animationTime:i.animationTime,minZoomImageRatio:i.minZoomImageRatio,wrapHorizontal:i.wrapHorizontal,wrapVertical:i.wrapVertical,immediateRender:i.immediateRender,blendTime:i.blendTime,alwaysBlend:i.alwaysBlend,minPixelRatio:i.minPixelRatio,smoothTileEdgesMinZoom:i.smoothTileEdgesMinZoom,iOSDevice:i.iOSDevice,crossOriginPolicy:t.options.crossOriginPolicy,ajaxWithCredentials:t.options.ajaxWithCredentials,loadTilesWithAjax:t.options.loadTilesWithAjax,ajaxHeaders:t.options.ajaxHeaders,debugMode:i.debugMode,subPixelRoundingForTransparency:i.subPixelRoundingForTransparency}),i.collectionMode&&i.world.setAutoRefigureSizes(!1),i.navigator&&(o=e.extend({},t.options,{replace:!1,originalTiledImage:n,tileSource:t.tileSource}),i.navigator.addTiledImage(o)),i.world.addItem(n,{index:t.options.index}),0===i._loadQueue.length&&r(t),1!==i.world.getItemCount()||i.preserveViewport||i.viewport.goHome(!0),t.options.success&&t.options.success({item:n})}}e.isArray(t.tileSource)?setTimeout((function(){o({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:t.tileSource,options:t})})):(this._loadQueue.push(n),function(t,i,n,o,r){var s=t;if("string"===e.type(i))if(i.match(/^\s*<.*>\s*$/))i=e.parseXml(i);else if(i.match(/^\s*[{[].*[}\]]\s*$/))try{var a=e.parseJSON(i);i=a}catch(e){}function l(e,t){e.ready?o(e):(e.addHandler("ready",(function(){o(e)})),e.addHandler("open-failed",(function(e){r({message:e.message,source:t})})))}setTimeout((function(){if("string"===e.type(i))(i=new e.TileSource({url:i,crossOriginPolicy:void 0!==n.crossOriginPolicy?n.crossOriginPolicy:t.crossOriginPolicy,ajaxWithCredentials:t.ajaxWithCredentials,ajaxHeaders:n.ajaxHeaders?n.ajaxHeaders:t.ajaxHeaders,splitHashDataForPost:t.splitHashDataForPost,useCanvas:t.useCanvas,success:function(e){o(e.tileSource)}})).addHandler("open-failed",(function(e){r(e)}));else if(e.isPlainObject(i)||i.nodeType)if(void 0!==i.crossOriginPolicy||void 0===n.crossOriginPolicy&&void 0===t.crossOriginPolicy||(i.crossOriginPolicy=void 0!==n.crossOriginPolicy?n.crossOriginPolicy:t.crossOriginPolicy),void 0===i.ajaxWithCredentials&&(i.ajaxWithCredentials=t.ajaxWithCredentials),void 0===i.useCanvas&&(i.useCanvas=t.useCanvas),e.isFunction(i.getTileUrl)){var a=new e.TileSource(i);a.getTileUrl=i.getTileUrl,o(a)}else{var h=e.TileSource.determineType(s,i);if(!h)return void r({message:"Unable to load TileSource",source:i});var c=h.prototype.configure.apply(s,[i]);l(new h(c),i)}else l(i,i)}))}(this,t.tileSource,t,(function(e){n.tileSource=e,s()}),(function(e){e.options=t,o(e),s()})))},addSimpleImage:function(t){e.console.assert(t,"[Viewer.addSimpleImage] options is required"),e.console.assert(t.url,"[Viewer.addSimpleImage] options.url is required");var i=e.extend({},t,{tileSource:{type:"image",url:t.url}});delete i.url,this.addTiledImage(i)},addLayer:function(t){var i=this;e.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var n=e.extend({},t,{success:function(e){i.raiseEvent("add-layer",{options:t,drawer:e.item})},error:function(e){i.raiseEvent("add-layer-failed",e)}});return this.addTiledImage(n),this},getLayerAtLevel:function(t){return e.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(t)},getLevelOfLayer:function(t){return e.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(t)},getLayersCount:function(){return e.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(t,i){return e.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(t,i)},removeLayer:function(t){return e.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(t)},forceRedraw:function(){return t[this.hash].forceRedraw=!0,this},forceResize:function(){t[this.hash].needsResize=!0,t[this.hash].forceResize=!0},bindSequenceControls:function(){var t=e.delegate(this,c),i=e.delegate(this,u),n=e.delegate(this,this.goToNextPage),o=e.delegate(this,this.goToPreviousPage),r=this.navImages,s=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(s=!1),this.previousButton=new e.Button({element:this.previousButton?e.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.PreviousPage"),srcRest:I(this.prefixUrl,r.previous.REST),srcGroup:I(this.prefixUrl,r.previous.GROUP),srcHover:I(this.prefixUrl,r.previous.HOVER),srcDown:I(this.prefixUrl,r.previous.DOWN),onRelease:o,onFocus:t,onBlur:i}),this.nextButton=new e.Button({element:this.nextButton?e.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.NextPage"),srcRest:I(this.prefixUrl,r.next.REST),srcGroup:I(this.prefixUrl,r.next.GROUP),srcHover:I(this.prefixUrl,r.next.HOVER),srcDown:I(this.prefixUrl,r.next.DOWN),onRelease:n,onFocus:t,onBlur:i}),this.navPrevNextWrap||this.previousButton.disable(),this.tileSources&&this.tileSources.length||this.nextButton.disable(),s&&(this.paging=new e.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:e.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||e.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var t=e.delegate(this,k),i=e.delegate(this,H),n=e.delegate(this,L),o=e.delegate(this,O),r=e.delegate(this,F),s=e.delegate(this,N),a=e.delegate(this,A),l=e.delegate(this,U),h=e.delegate(this,V),d=e.delegate(this,W),p=e.delegate(this,c),g=e.delegate(this,u),m=this.navImages,v=[],f=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(f=!1),this.showZoomControl&&(v.push(this.zoomInButton=new e.Button({element:this.zoomInButton?e.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.ZoomIn"),srcRest:I(this.prefixUrl,m.zoomIn.REST),srcGroup:I(this.prefixUrl,m.zoomIn.GROUP),srcHover:I(this.prefixUrl,m.zoomIn.HOVER),srcDown:I(this.prefixUrl,m.zoomIn.DOWN),onPress:t,onRelease:i,onClick:n,onEnter:t,onExit:i,onFocus:p,onBlur:g})),v.push(this.zoomOutButton=new e.Button({element:this.zoomOutButton?e.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.ZoomOut"),srcRest:I(this.prefixUrl,m.zoomOut.REST),srcGroup:I(this.prefixUrl,m.zoomOut.GROUP),srcHover:I(this.prefixUrl,m.zoomOut.HOVER),srcDown:I(this.prefixUrl,m.zoomOut.DOWN),onPress:o,onRelease:i,onClick:r,onEnter:o,onExit:i,onFocus:p,onBlur:g}))),this.showHomeControl&&v.push(this.homeButton=new e.Button({element:this.homeButton?e.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.Home"),srcRest:I(this.prefixUrl,m.home.REST),srcGroup:I(this.prefixUrl,m.home.GROUP),srcHover:I(this.prefixUrl,m.home.HOVER),srcDown:I(this.prefixUrl,m.home.DOWN),onRelease:s,onFocus:p,onBlur:g})),this.showFullPageControl&&v.push(this.fullPageButton=new e.Button({element:this.fullPageButton?e.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.FullPage"),srcRest:I(this.prefixUrl,m.fullpage.REST),srcGroup:I(this.prefixUrl,m.fullpage.GROUP),srcHover:I(this.prefixUrl,m.fullpage.HOVER),srcDown:I(this.prefixUrl,m.fullpage.DOWN),onRelease:a,onFocus:p,onBlur:g})),this.showRotationControl&&(v.push(this.rotateLeftButton=new e.Button({element:this.rotateLeftButton?e.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.RotateLeft"),srcRest:I(this.prefixUrl,m.rotateleft.REST),srcGroup:I(this.prefixUrl,m.rotateleft.GROUP),srcHover:I(this.prefixUrl,m.rotateleft.HOVER),srcDown:I(this.prefixUrl,m.rotateleft.DOWN),onRelease:l,onFocus:p,onBlur:g})),v.push(this.rotateRightButton=new e.Button({element:this.rotateRightButton?e.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.RotateRight"),srcRest:I(this.prefixUrl,m.rotateright.REST),srcGroup:I(this.prefixUrl,m.rotateright.GROUP),srcHover:I(this.prefixUrl,m.rotateright.HOVER),srcDown:I(this.prefixUrl,m.rotateright.DOWN),onRelease:h,onFocus:p,onBlur:g}))),this.showFlipControl&&v.push(this.flipButton=new e.Button({element:this.flipButton?e.getElement(this.flipButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.Flip"),srcRest:I(this.prefixUrl,m.flip.REST),srcGroup:I(this.prefixUrl,m.flip.GROUP),srcHover:I(this.prefixUrl,m.flip.HOVER),srcDown:I(this.prefixUrl,m.flip.DOWN),onRelease:d,onFocus:p,onBlur:g})),f?(this.buttonGroup=new e.ButtonGroup({buttons:v,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",e.delegate(this,M)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:this.navigationControlAnchor||e.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||e.ControlAnchor.TOP_LEFT})):this.customButtons=v),this},currentPage:function(){return this._sequenceIndex},goToPage:function(e){return this.tileSources&&e>=0&&e<this.tileSources.length&&(this._sequenceIndex=e,this._updateSequenceButtons(e),this.open(this.tileSources[e]),this.referenceStrip&&this.referenceStrip.setFocus(e),this.raiseEvent("page",{page:e})),this},addOverlay:function(t,i,n,s){var a;if(a=e.isPlainObject(t)?t:{element:t,location:i,placement:n,onDraw:s},t=e.getElement(a.element),r(this.currentOverlays,t)>=0)return this;var l=o(this,a);return this.currentOverlays.push(l),l.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:t,location:a.location,placement:a.placement}),this},updateOverlay:function(i,n,o){var s;return i=e.getElement(i),(s=r(this.currentOverlays,i))>=0&&(this.currentOverlays[s].update(n,o),t[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:i,location:n,placement:o})),this},removeOverlay:function(i){var n;return i=e.getElement(i),(n=r(this.currentOverlays,i))>=0&&(this.currentOverlays[n].destroy(),this.currentOverlays.splice(n,1),t[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:i})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return t[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},getOverlayById:function(t){var i;return t=e.getElement(t),(i=r(this.currentOverlays,t))>=0?this.currentOverlays[i]:null},_updateSequenceButtons:function(e){this.nextButton&&(this.tileSources&&this.tileSources.length-1!==e?this.nextButton.enable():this.navPrevNextWrap||this.nextButton.disable()),this.previousButton&&(e>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(t){this._hideMessage();var i=e.makeNeutralElement("div");i.appendChild(document.createTextNode(t)),this.messageDiv=e.makeCenteredNode(i),e.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var e=this.messageDiv;e&&(e.parentNode.removeChild(e),delete this.messageDiv)},gestureSettingsByDeviceType:function(e){switch(e){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var e,t=this.currentOverlays.length;for(e=0;e<t;e++)this.currentOverlays[e].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]},removeReferenceStrip:function(){this.showReferenceStrip=!1,this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null)},addReferenceStrip:function(){if(this.showReferenceStrip=!0,this.sequenceMode){if(this.referenceStrip)return;this.tileSources.length&&this.tileSources.length>1&&(this.referenceStrip=new e.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,useCanvas:this.useCanvas,viewer:this}),this.referenceStrip.setFocus(this._sequenceIndex))}else e.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')},_addUpdatePixelDensityRatioEvent:function(){this._updatePixelDensityRatioBind=this._updatePixelDensityRatio.bind(this),e.addEvent(window,"resize",this._updatePixelDensityRatioBind)},_removeUpdatePixelDensityRatioEvent:function(){e.removeEvent(window,"resize",this._updatePixelDensityRatioBind)},_updatePixelDensityRatio:function(){var t=e.pixelDensityRatio,i=e.getCurrentPixelDensityRatio();t!==i&&(e.pixelDensityRatio=i,this.world.resetItems(),this.forceRedraw())},goToPreviousPage:function(){var e=this._sequenceIndex-1;this.navPrevNextWrap&&e<0&&(e+=this.tileSources.length),this.goToPage(e)},goToNextPage:function(){var e=this._sequenceIndex+1;this.navPrevNextWrap&&e>=this.tileSources.length&&(e=0),this.goToPage(e)},isAnimating:function(){return t[this.hash].animating}})}(s),function(e){function t(e){var t={tracker:e.eventSource,position:e.position,quick:e.quick,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",t),!t.preventDefaultAction&&e.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(e.position.x=this.viewport.getContainerSize().x-e.position.x);var i=this.viewport.pointFromPixel(e.position);this.panVertical?this.panHorizontal||(i.x=this.viewer.viewport.getCenter(!0).x):i.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(i),this.viewer.viewport.applyConstraints()}}function i(e){var t={tracker:e.eventSource,position:e.position,delta:e.delta,speed:e.speed,direction:e.direction,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",t),!t.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(e.delta.x=0),this.panVertical||(e.delta.y=0),this.viewer.viewport.flipped&&(e.delta.x=-e.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(e.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function n(e){e.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function o(e){var t={tracker:e.eventSource,position:e.position,scroll:e.scroll,shift:e.shift,originalEvent:e.originalEvent,preventDefault:e.preventDefault};this.viewer.raiseEvent("navigator-scroll",t),e.preventDefault=t.preventDefault}function r(e,t){s(e,"rotate("+t+"deg)")}function s(e,t){e.style.webkitTransform=t,e.style.mozTransform=t,e.style.msTransform=t,e.style.oTransform=t,e.style.transform=t}e.Navigator=function(s){var a,l,h,c,u=s.viewer,d=this;function p(e){r(d.displayRegionContainer,e),r(d.displayRegion,-e),d.viewport.setRotation(e)}s.element||s.id?(s.element?(s.id&&e.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),s.element.id?s.id=s.element.id:s.id="navigator-"+e.now(),this.element=s.element):this.element=document.getElementById(s.id),s.controlOptions={anchor:e.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(s.id="navigator-"+e.now(),this.element=e.makeNeutralElement("div"),s.controlOptions={anchor:e.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:s.autoFade},s.position&&("BOTTOM_RIGHT"===s.position?s.controlOptions.anchor=e.ControlAnchor.BOTTOM_RIGHT:"BOTTOM_LEFT"===s.position?s.controlOptions.anchor=e.ControlAnchor.BOTTOM_LEFT:"TOP_RIGHT"===s.position?s.controlOptions.anchor=e.ControlAnchor.TOP_RIGHT:"TOP_LEFT"===s.position?s.controlOptions.anchor=e.ControlAnchor.TOP_LEFT:"ABSOLUTE"===s.position&&(s.controlOptions.anchor=e.ControlAnchor.ABSOLUTE,s.controlOptions.top=s.top,s.controlOptions.left=s.left,s.controlOptions.height=s.height,s.controlOptions.width=s.width))),this.element.id=s.id,this.element.className+=" navigator",(s=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.navigatorSizeRatio},s,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:s.animationTime,autoResize:!1,minZoomImageRatio:1,background:s.background,opacity:s.opacity,borderColor:s.borderColor,displayRegionColor:s.displayRegionColor})).minPixelRatio=this.minPixelRatio=u.minPixelRatio,e.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new e.Point(1,1),this.totalBorderWidths=new e.Point(2*this.borderWidth,2*this.borderWidth).minus(this.fudge),s.controlOptions.anchor!==e.ControlAnchor.NONE&&(h=this.element.style,c=this.borderWidth,h.margin="0px",h.border=c+"px solid "+s.borderColor,h.padding="0px",h.background=s.background,h.opacity=s.opacity,h.overflow="hidden"),this.displayRegion=e.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",function(e,t){e.position="relative",e.top="0px",e.left="0px",e.fontSize="0px",e.overflow="hidden",e.border=t+"px solid "+s.displayRegionColor,e.margin="0px",e.padding="0px",e.background="transparent",e.float="left",e.cssFloat="left",e.styleFloat="left",e.zIndex=999999999,e.cursor="default"}(this.displayRegion.style,this.borderWidth),e.setElementPointerEventsNone(this.displayRegion),e.setElementTouchActionNone(this.displayRegion),this.displayRegionContainer=e.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",e.setElementPointerEventsNone(this.displayRegionContainer),e.setElementTouchActionNone(this.displayRegionContainer),u.addControl(this.element,s.controlOptions),this._resizeWithViewer=s.controlOptions.anchor!==e.ControlAnchor.ABSOLUTE&&s.controlOptions.anchor!==e.ControlAnchor.NONE,s.width&&s.height?(this.setWidth(s.width),this.setHeight(s.height)):this._resizeWithViewer&&(a=e.getElementSize(u.element),this.element.style.height=Math.round(a.y*s.sizeRatio)+"px",this.element.style.width=Math.round(a.x*s.sizeRatio)+"px",this.oldViewerSize=a,l=e.getElementSize(this.element),this.elementArea=l.x*l.y),this.oldContainerSize=new e.Point(0,0),e.Viewer.apply(this,[s]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer),s.navigatorRotate&&(p(s.viewer.viewport?s.viewer.viewport.getRotation():s.viewer.degrees||0),s.viewer.addHandler("rotate",(function(e){p(e.degrees)}))),this.innerTracker.destroy(),this.innerTracker=new e.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:e.delegate(this,i),clickHandler:e.delegate(this,t),releaseHandler:e.delegate(this,n),scrollHandler:e.delegate(this,o),preProcessEventHandler:function(e){"wheel"===e.eventType&&(e.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",e.setElementPointerEventsNone(this.canvas),e.setElementPointerEventsNone(this.container),this.addHandler("reset-size",(function(){d.viewport&&d.viewport.goHome(!0)})),u.world.addHandler("item-index-change",(function(e){window.setTimeout((function(){var t=d.world.getItemAt(e.previousIndex);d.world.setItemIndex(t,e.newIndex)}),1)})),u.world.addHandler("remove-item",(function(e){var t=e.item,i=d._getMatchingItem(t);i&&d.world.removeItem(i)})),this.update(u.viewport)},e.extend(e.Navigator.prototype,e.EventSource.prototype,e.Viewer.prototype,{updateSize:function(){if(this.viewport){var t=new e.Point(0===this.container.clientWidth?1:this.container.clientWidth,0===this.container.clientHeight?1:this.container.clientHeight);t.equals(this.oldContainerSize)||(this.viewport.resize(t,!0),this.viewport.goHome(!0),this.oldContainerSize=t,this.drawer.clear(),this.world.draw())}},setWidth:function(e){this.width=e,this.element.style.width="number"==typeof e?e+"px":e,this._resizeWithViewer=!1},setHeight:function(e){this.height=e,this.element.style.height="number"==typeof e?e+"px":e,this._resizeWithViewer=!1},setFlip:function(e){return this.viewport.setFlip(e),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(e){s(this.displayRegion,e),s(this.canvas,e),s(this.element,e)},update:function(t){var i,n,o,r,s,a;if(i=e.getElementSize(this.viewer.element),this._resizeWithViewer&&i.x&&i.y&&!i.equals(this.oldViewerSize)&&(this.oldViewerSize=i,this.maintainSizeRatio||!this.elementArea?(n=i.x*this.sizeRatio,o=i.y*this.sizeRatio):(n=Math.sqrt(this.elementArea*(i.x/i.y)),o=this.elementArea/n),this.element.style.width=Math.round(n)+"px",this.element.style.height=Math.round(o)+"px",this.elementArea||(this.elementArea=n*o),this.updateSize()),t&&this.viewport){r=t.getBoundsNoRotate(!0),s=this.viewport.pixelFromPointNoRotate(r.getTopLeft(),!1),a=this.viewport.pixelFromPointNoRotate(r.getBottomRight(),!1).minus(this.totalBorderWidths);var l=this.displayRegion.style;l.display=this.world.getItemCount()?"block":"none",l.top=Math.round(s.y)+"px",l.left=Math.round(s.x)+"px";var h=Math.abs(s.x-a.x),c=Math.abs(s.y-a.y);l.width=Math.round(Math.max(h,0))+"px",l.height=Math.round(Math.max(c,0))+"px"}},addTiledImage:function(t){var i=this,n=t.originalTiledImage;delete t.original;var o=e.extend({},t,{success:function(e){var t=e.item;function o(){i._matchBounds(t,n)}t._originalForNavigator=n,i._matchBounds(t,n,!0),i._matchOpacity(t,n),i._matchCompositeOperation(t,n),n.addHandler("bounds-change",o),n.addHandler("clip-change",o),n.addHandler("opacity-change",(function(){i._matchOpacity(t,n)})),n.addHandler("composite-operation-change",(function(){i._matchCompositeOperation(t,n)}))}});return e.Viewer.prototype.addTiledImage.apply(this,[o])},destroy:function(){return e.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(e){for(var t,i=this.world.getItemCount(),n=0;n<i;n++)if((t=this.world.getItemAt(n))._originalForNavigator===e)return t;return null},_matchBounds:function(e,t,i){var n=t.getBoundsNoRotate();e.setPosition(n.getTopLeft(),i),e.setWidth(n.width,i),e.setRotation(t.getRotation(),i),e.setClip(t.getClip()),e.setFlip(t.getFlip())},_matchOpacity:function(e,t){e.setOpacity(t.opacity)},_matchCompositeOperation:function(e,t){e.setCompositeOperation(t.compositeOperation)}})}(s),function(e){var t={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",Flip:"Flip Horizontally"}};e.extend(e,{getString:function(i){var n,o=i.split("."),r=null,s=arguments,a=t;for(n=0;n<o.length-1;n++)a=a[o[n]]||{};return"string"!=typeof(r=a[o[n]])&&(e.console.error("Untranslated source string:",i),r=""),r.replace(/\{\d+\}/g,(function(e){var t=parseInt(e.match(/\d+/),10)+1;return t<s.length?s[t]:""}))},setString:function(e,i){var n,o=e.split("."),r=t;for(n=0;n<o.length-1;n++)r[o[n]]||(r[o[n]]={}),r=r[o[n]];r[o[n]]=i}})}(s),function(e){e.Point=function(e,t){this.x="number"==typeof e?e:0,this.y="number"==typeof t?t:0},e.Point.prototype={clone:function(){return new e.Point(this.x,this.y)},plus:function(t){return new e.Point(this.x+t.x,this.y+t.y)},minus:function(t){return new e.Point(this.x-t.x,this.y-t.y)},times:function(t){return new e.Point(this.x*t,this.y*t)},divide:function(t){return new e.Point(this.x/t,this.y/t)},negate:function(){return new e.Point(-this.x,-this.y)},distanceTo:function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},squaredDistanceTo:function(e){return Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2)},apply:function(t){return new e.Point(t(this.x),t(this.y))},equals:function(t){return t instanceof e.Point&&this.x===t.x&&this.y===t.y},rotate:function(t,i){var n,o;if(i=i||new e.Point(0,0),t%90==0)switch(e.positiveModulo(t,360)){case 0:n=1,o=0;break;case 90:n=0,o=1;break;case 180:n=-1,o=0;break;case 270:n=0,o=-1}else{var r=t*Math.PI/180;n=Math.cos(r),o=Math.sin(r)}var s=n*(this.x-i.x)-o*(this.y-i.y)+i.x,a=o*(this.x-i.x)+n*(this.y-i.y)+i.y;return new e.Point(s,a)},toString:function(){return"("+Math.round(100*this.x)/100+","+Math.round(100*this.y)/100+")"}}}(s),function(e){e.TileSource=function(t,i,n,o,r,s){var a,l,h=this,c=arguments;if(a=e.isPlainObject(t)?t:{width:c[0],height:c[1],tileSize:c[2],tileOverlap:c[3],minLevel:c[4],maxLevel:c[5]},e.EventSource.call(this),e.extend(!0,this,a),!this.success)for(l=0;l<arguments.length;l++)if(e.isFunction(arguments[l])){this.success=arguments[l];break}this.success&&this.addHandler("ready",(function(e){h.success(e)})),"string"===e.type(arguments[0])&&(this.url=arguments[0]),this.url?(this.aspectRatio=1,this.dimensions=new e.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=a.width&&a.height?a.width/a.height:1,this.dimensions=new e.Point(a.width,a.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=a.tileOverlap?a.tileOverlap:0,this.minLevel=a.minLevel?a.minLevel:0,this.maxLevel=void 0!==a.maxLevel&&null!==a.maxLevel?a.maxLevel:a.width&&a.height?Math.ceil(Math.log(Math.max(a.width,a.height))/Math.log(2)):0,this.success&&e.isFunction(this.success)&&this.success(this))},e.TileSource.prototype={getTileSize:function(t){return e.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(e){return this._tileWidth?this._tileWidth:this.getTileSize(e)},getTileHeight:function(e){return this._tileHeight?this._tileHeight:this.getTileSize(e)},setMaxLevel:function(e){this.maxLevel=e,this._memoizeLevelScale()},getLevelScale:function(e){return this._memoizeLevelScale(),this.getLevelScale(e)},_memoizeLevelScale:function(){var e,t={};for(e=0;e<=this.maxLevel;e++)t[e]=1/Math.pow(2,this.maxLevel-e);this.getLevelScale=function(e){return t[e]}},getNumTiles:function(t){var i=this.getLevelScale(t),n=Math.ceil(i*this.dimensions.x/this.getTileWidth(t)),o=Math.ceil(i*this.dimensions.y/this.getTileHeight(t));return new e.Point(n,o)},getPixelRatio:function(t){var i=this.dimensions.times(this.getLevelScale(t)),n=1/i.x*e.pixelDensityRatio,o=1/i.y*e.pixelDensityRatio;return new e.Point(n,o)},getClosestLevel:function(){var e,t;for(e=this.minLevel+1;e<=this.maxLevel&&!((t=this.getNumTiles(e)).x>1||t.y>1);e++);return e-1},getTileAtPoint:function(t,i){var n=i.x>=0&&i.x<=1&&i.y>=0&&i.y<=1/this.aspectRatio;e.console.assert(n,"[TileSource.getTileAtPoint] must be called with a valid point.");var o=this.dimensions.x*this.getLevelScale(t),r=i.x*o,s=i.y*o,a=Math.floor(r/this.getTileWidth(t)),l=Math.floor(s/this.getTileHeight(t));return i.x>=1&&(a=this.getNumTiles(t).x-1),i.y>=1/this.aspectRatio-1e-15&&(l=this.getNumTiles(t).y-1),new e.Point(a,l)},getTileBounds:function(t,i,n,o){var r=this.dimensions.times(this.getLevelScale(t)),s=this.getTileWidth(t),a=this.getTileHeight(t),l=0===i?0:s*i-this.tileOverlap,h=0===n?0:a*n-this.tileOverlap,c=s+(0===i?1:2)*this.tileOverlap,u=a+(0===n?1:2)*this.tileOverlap,d=1/r.x;return c=Math.min(c,r.x-l),u=Math.min(u,r.y-h),o?new e.Rect(0,0,c,u):new e.Rect(l*d,h*d,c*d,u*d)},getImageInfo:function(t){var i,n,o,r,s,a,l,h=this;t&&(l=(a=(s=t.split("/"))[s.length-1]).lastIndexOf("."))>-1&&(s[s.length-1]=a.slice(0,l));var c=null;if(this.splitHashDataForPost){var u=t.indexOf("#");-1!==u&&(c=t.substring(u+1),t=t.substr(0,u))}n=function(i){"string"==typeof i&&(i=e.parseXml(i));var n=e.TileSource.determineType(h,i,t);n?(void 0===(r=n.prototype.configure.apply(h,[i,t,c])).ajaxWithCredentials&&(r.ajaxWithCredentials=h.ajaxWithCredentials),o=new n(r),h.ready=!0,h.raiseEvent("ready",{tileSource:o})):h.raiseEvent("open-failed",{message:"Unable to load TileSource",source:t})},t.match(/\.js$/)?(i=t.split("/").pop().replace(".js",""),e.jsonp({url:t,async:!1,callbackName:i,callback:n})):e.makeAjaxRequest({url:t,postData:c,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(t){var i=function(t){var i,n,o=t.responseText,r=t.status;if(!t)throw new Error(e.getString("Errors.Security"));if(200!==t.status&&0!==t.status)throw i=404===(r=t.status)?"Not Found":t.statusText,new Error(e.getString("Errors.Status",r,i));if(o.match(/\s*<.*/))try{n=t.responseXML&&t.responseXML.documentElement?t.responseXML:e.parseXml(o)}catch(e){n=t.responseText}else if(o.match(/\s*[{[].*/))try{n=e.parseJSON(o)}catch(e){n=o}else n=o;return n}(t);n(i)},error:function(i,n){var o;try{o="HTTP "+i.status+" attempting to load TileSource: "+t}catch(e){o=(void 0!==n&&n.toString?n.toString():"Unknown error")+" attempting to load TileSource: "+t}e.console.error(o),h.raiseEvent("open-failed",{message:o,source:t,postData:c})}})},supports:function(e,t){return!1},configure:function(e,t,i){throw new Error("Method not implemented.")},getTileUrl:function(e,t,i){throw new Error("Method not implemented.")},getTilePostData:function(e,t,i){return null},getTileAjaxHeaders:function(e,t,i){return{}},getTileHashKey:function(e,t,i,n,o,r){return s="string"!=typeof n?e+"/"+t+"_"+i:n,o?s+"+"+JSON.stringify(o):s;var s},tileExists:function(e,t,i){var n=this.getNumTiles(e);return e>=this.minLevel&&e<=this.maxLevel&&t>=0&&i>=0&&t<n.x&&i<n.y},hasTransparency:function(e,t,i,n){return!!e||t.match(".png")},downloadTileStart:function(t){var i=t.userData,n=new Image;i.image=n,i.request=null;var o=function(e){n?(n.onload=n.onerror=n.onabort=null,t.finish(e?null:n,i.request,e)):t.finish(null,i.request,"Image load failed: undefined Image instance.")};n.onload=function(){o()},n.onabort=n.onerror=function(){o("Image load aborted.")},t.loadWithAjax?i.request=e.makeAjaxRequest({url:t.src,withCredentials:t.ajaxWithCredentials,headers:t.ajaxHeaders,responseType:"arraybuffer",postData:t.postData,success:function(e){var t;try{t=new window.Blob([e.response])}catch(n){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"===n.name&&i){var r=new i;r.append(e.response),t=r.getBlob()}}0===t.size?o("Empty image response."):n.src=(window.URL||window.webkitURL).createObjectURL(t)},error:function(e){o("Image load aborted - XHR error")}}):(!1!==t.crossOriginPolicy&&(n.crossOrigin=t.crossOriginPolicy),n.src=t.src)},downloadTileAbort:function(e){e.userData.request&&e.userData.request.abort();var t=e.userData.image;e.userData.image&&(t.onload=t.onerror=t.onabort=null)},createTileCache:function(e,t,i){e._data=t},destroyTileCache:function(e){e._data=null,e._renderedContext=null},getTileCacheData:function(e){return e._data},getTileCacheDataAsImage:function(e){return e._data},getTileCacheDataAsContext2D:function(e){if(!e._renderedContext){var t=document.createElement("canvas");t.width=e._data.width,t.height=e._data.height,e._renderedContext=t.getContext("2d"),e._renderedContext.drawImage(e._data,0,0),e._data=null}return e._renderedContext}},e.extend(!0,e.TileSource.prototype,e.EventSource.prototype),e.TileSource.determineType=function(t,i,n){var o;for(o in s)if(o.match(/.+TileSource$/)&&e.isFunction(s[o])&&e.isFunction(s[o].prototype.supports)&&s[o].prototype.supports.call(t,i,n))return s[o];return e.console.error("No TileSource was able to open %s %s",n,i),null}}(s),function(e){function t(t,i){var n,o,r=i.Image,s=r.Url,a=r.Format,l=r.Size,h=r.DisplayRect||[],c=parseInt(l.Width,10),u=parseInt(l.Height,10),d=parseInt(r.TileSize,10),p=parseInt(r.Overlap,10),g=[];for(o=0;o<h.length;o++)n=h[o].Rect,g.push(new e.DisplayRect(parseInt(n.X,10),parseInt(n.Y,10),parseInt(n.Width,10),parseInt(n.Height,10),parseInt(n.MinLevel,10),parseInt(n.MaxLevel,10)));return e.extend(!0,{width:c,height:u,tileSize:d,tileOverlap:p,minLevel:null,maxLevel:null,tilesUrl:s,fileFormat:a,displayRects:g},i)}e.DziTileSource=function(t,i,n,o,r,s,a,l,h){var c,u,d,p;if(p=e.isPlainObject(t)?t:{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=p.tilesUrl,this.fileFormat=p.fileFormat,this.displayRects=p.displayRects,this.displayRects)for(c=this.displayRects.length-1;c>=0;c--)for(d=(u=this.displayRects[c]).minLevel;d<=u.maxLevel;d++)this._levelRects[d]||(this._levelRects[d]=[]),this._levelRects[d].push(u);e.TileSource.apply(this,[p])},e.extend(e.DziTileSource.prototype,e.TileSource.prototype,{supports:function(e,t){var i;return e.Image?i=e.Image.xmlns:e.documentElement&&("Image"!==e.documentElement.localName&&"Image"!==e.documentElement.tagName||(i=e.documentElement.namespaceURI)),-1!==(i=(i||"").toLowerCase()).indexOf("schemas.microsoft.com/deepzoom/2008")||-1!==i.indexOf("schemas.microsoft.com/deepzoom/2009")},configure:function(i,n,o){var r;return r=e.isPlainObject(i)?t(0,i):function(i,n){if(!n||!n.documentElement)throw new Error(e.getString("Errors.Xml"));var o,r,s,a,l,h=n.documentElement,c=h.localName||h.tagName,u=n.documentElement.namespaceURI,d=null,p=[];if("Image"===c)try{if(void 0===(a=h.getElementsByTagName("Size")[0])&&(a=h.getElementsByTagNameNS(u,"Size")[0]),d={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:h.getAttribute("Url"),Format:h.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(h.getAttribute("Overlap"),10),TileSize:parseInt(h.getAttribute("TileSize"),10),Size:{Height:parseInt(a.getAttribute("Height"),10),Width:parseInt(a.getAttribute("Width"),10)}}},!e.imageFormatSupported(d.Image.Format))throw new Error(e.getString("Errors.ImageFormat",d.Image.Format.toUpperCase()));for(void 0===(o=h.getElementsByTagName("DisplayRect"))&&(o=h.getElementsByTagNameNS(u,"DisplayRect")[0]),l=0;l<o.length;l++)void 0===(s=(r=o[l]).getElementsByTagName("Rect")[0])&&(s=r.getElementsByTagNameNS(u,"Rect")[0]),p.push({Rect:{X:parseInt(s.getAttribute("X"),10),Y:parseInt(s.getAttribute("Y"),10),Width:parseInt(s.getAttribute("Width"),10),Height:parseInt(s.getAttribute("Height"),10),MinLevel:parseInt(r.getAttribute("MinLevel"),10),MaxLevel:parseInt(r.getAttribute("MaxLevel"),10)}});return p.length&&(d.Image.DisplayRect=p),t(0,d)}catch(t){throw t instanceof Error?t:new Error(e.getString("Errors.Dzi"))}else{if("Collection"===c)throw new Error(e.getString("Errors.Dzc"));if("Error"===c){var g=h.getElementsByTagName("Message")[0].firstChild.nodeValue;throw new Error(g)}}throw new Error(e.getString("Errors.Dzi"))}(0,i),n&&!r.tilesUrl&&(r.tilesUrl=n.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),-1!==n.search(/\.(dzi|xml|js)\?/)?r.queryParams=n.match(/\?.*/):r.queryParams=""),r},getTileUrl:function(e,t,i){return[this.tilesUrl,e,"/",t,"_",i,".",this.fileFormat,this.queryParams].join("")},tileExists:function(e,t,i){var n,o,r,s,a,l,h,c=this._levelRects[e];if(this.minLevel&&e<this.minLevel||this.maxLevel&&e>this.maxLevel)return!1;if(!c||!c.length)return!0;for(h=c.length-1;h>=0;h--)if(!(e<(n=c[h]).minLevel||e>n.maxLevel)&&(o=this.getLevelScale(e),r=n.x*o,s=n.y*o,a=r+n.width*o,l=s+n.height*o,r=Math.floor(r/this._tileWidth),s=Math.floor(s/this._tileWidth),a=Math.ceil(a/this._tileWidth),l=Math.ceil(l/this._tileWidth),r<=t&&t<a&&s<=i&&i<l))return!0;return!1}})}(s),function(e){function t(e){var t=Array.isArray(e.profile)?e.profile[0]:e.profile,i=-1!==["http://library.stanford.edu/iiif/image-api/compliance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0","http://iiif.io/api/image/2/level0.json","level0","https://iiif.io/api/image/3/level0.json"].indexOf(t),n=!1;return 2===e.version&&e.profile.length>1&&e.profile[1].supports&&(n=-1!==e.profile[1].supports.indexOf("sizeByW")),3===e.version&&e.extraFeatures&&(n=-1!==e.extraFeatures.indexOf("sizeByWh")),!i||n}function i(e){for(var t=[],i=0;i<e.sizes.length;i++)t.push({url:e._id+"/full/"+e.sizes[i].width+","+(3===e.version?e.sizes[i].height:"")+"/0/default."+e.tileFormat,width:e.sizes[i].width,height:e.sizes[i].height});return t.sort((function(e,t){return e.width-t.width}))}function n(t,i,o){var r,s;if(3===t.nodeType&&o)(s=t.nodeValue.trim()).match(/^\d*$/)&&(s=Number(s)),i[o]?(e.isArray(i[o])||(i[o]=[i[o]]),i[o].push(s)):i[o]=s;else if(1===t.nodeType)for(r=0;r<t.childNodes.length;r++)n(t.childNodes[r],i,t.nodeName)}e.IIIFTileSource=function(n){if(e.extend(!0,this,n),this._id=this["@id"]||this.id||this.identifier||null,!(this.height&&this.width&&this._id))throw new Error("IIIF required parameters (width, height, or id) not provided.");if(n.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=n.version,this.tile_width&&this.tile_height)n.tileWidth=this.tile_width,n.tileHeight=this.tile_height;else if(this.tile_width)n.tileSize=this.tile_width;else if(this.tile_height)n.tileSize=this.tile_height;else if(this.tiles)if(1===this.tiles.length)n.tileWidth=this.tiles[0].width,n.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var o=0;o<this.tiles.length;o++)for(var r=0;r<this.tiles[o].scaleFactors.length;r++){var s=this.tiles[o].scaleFactors[r];this.scale_factors.push(s),n.tileSizePerScaleFactor[s]={width:this.tiles[o].width,height:this.tiles[o].height||this.tiles[o].width}}}else if(t(n)){for(var a=Math.min(this.height,this.width),l=[256,512,1024],h=[],c=0;c<l.length;c++)l[c]<=a&&h.push(l[c]);h.length>0?n.tileSize=Math.max.apply(null,h):n.tileSize=a}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,n.levels=i(this),e.extend(!0,n,{width:n.levels[n.levels.length-1].width,height:n.levels[n.levels.length-1].height,tileSize:Math.max(n.height,n.width),tileOverlap:0,minLevel:0,maxLevel:n.levels.length-1}),this.levels=n.levels):e.console.error("Nothing in the info.json to construct image pyramids from");if(!n.maxLevel&&!this.emulateLegacyImagePyramid)if(this.scale_factors){var u=Math.max.apply(null,this.scale_factors);n.maxLevel=Math.round(Math.log(u)*Math.LOG2E)}else n.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));e.TileSource.apply(this,[n])},e.extend(e.IIIFTileSource.prototype,e.TileSource.prototype,{supports:function(e,t){return!!(e.protocol&&"http://iiif.io/api/image"===e.protocol||e["@context"]&&("http://library.stanford.edu/iiif/image-api/1.1/context.json"===e["@context"]||"http://iiif.io/api/image/1/context.json"===e["@context"])||e.profile&&0===e.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")||e.identifier&&e.width&&e.height||e.documentElement&&"info"===e.documentElement.tagName&&"http://library.stanford.edu/iiif/image-api/ns/"===e.documentElement.namespaceURI)},configure:function(t,i,o){if(e.isPlainObject(t)){if(t["@context"]){var r=t["@context"];if(Array.isArray(r))for(var a=0;a<r.length;a++)if("string"==typeof r[a]&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(r[a])||"http://library.stanford.edu/iiif/image-api/1.1/context.json"===r[a])){r=r[a];break}switch(r){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":t.version=1;break;case"http://iiif.io/api/image/2/context.json":t.version=2;break;case"http://iiif.io/api/image/3/context.json":t.version=3;break;default:e.console.error("Data has a @context property which contains no known IIIF context URI.")}}else t["@context"]="http://iiif.io/api/image/1.0/context.json",t["@id"]=i.replace("/info.json",""),t.version=1;if(t.preferredFormats)for(var l=0;l<t.preferredFormats.length;l++)if(s.imageFormatSupported(t.preferredFormats[l])){t.tileFormat=t.preferredFormats[l];break}return t}var h=function(t){if(!t||!t.documentElement)throw new Error(e.getString("Errors.Xml"));var i=t.documentElement,o=null;if("info"===i.tagName)try{return n(i,o={}),o}catch(t){throw t instanceof Error?t:new Error(e.getString("Errors.IIIF"))}throw new Error(e.getString("Errors.IIIF"))}(t);return h["@context"]="http://iiif.io/api/image/1.0/context.json",h["@id"]=i.replace("/info.xml",""),h.version=1,h},getTileWidth:function(t){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileWidth.call(this,t);var i=Math.pow(2,this.maxLevel-t);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[i]?this.tileSizePerScaleFactor[i].width:this._tileWidth},getTileHeight:function(t){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileHeight.call(this,t);var i=Math.pow(2,this.maxLevel-t);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[i]?this.tileSizePerScaleFactor[i].height:this._tileHeight},getLevelScale:function(t){if(this.emulateLegacyImagePyramid){var i=NaN;return this.levels.length>0&&t>=this.minLevel&&t<=this.maxLevel&&(i=this.levels[t].width/this.levels[this.maxLevel].width),i}return e.TileSource.prototype.getLevelScale.call(this,t)},getNumTiles:function(t){return this.emulateLegacyImagePyramid?this.getLevelScale(t)?new e.Point(1,1):new e.Point(0,0):e.TileSource.prototype.getNumTiles.call(this,t)},getTileAtPoint:function(t,i){return this.emulateLegacyImagePyramid?new e.Point(0,0):e.TileSource.prototype.getTileAtPoint.call(this,t,i)},getTileUrl:function(e,t,i){if(this.emulateLegacyImagePyramid){var n=null;return this.levels.length>0&&e>=this.minLevel&&e<=this.maxLevel&&(n=this.levels[e].url),n}var o,r,s,a,l,h,c,u,d,p,g,m,v,f=Math.pow(.5,this.maxLevel-e),y=Math.round(this.width*f),w=Math.round(this.height*f);return o=this.getTileWidth(e),r=this.getTileHeight(e),s=Math.round(o/f),a=Math.round(r/f),v=1===this.version?"native."+this.tileFormat:"default."+this.tileFormat,y<o&&w<r?(p=2===this.version&&y===this.width?"full":3===this.version&&y===this.width&&w===this.height?"max":3===this.version?y+","+w:y+",",l="full"):(h=t*s,c=i*a,u=Math.min(s,this.width-h),d=Math.min(a,this.height-c),l=0===t&&0===i&&u===this.width&&d===this.height?"full":[h,c,u,d].join(","),g=Math.round(u*f),m=Math.round(d*f),p=2===this.version&&g===this.width?"full":3===this.version&&g===this.width&&m===this.height?"max":3===this.version?g+","+m:g+","),[this._id,l,p,"0",v].join("/")},__testonly__:{canBeTiled:t,constructLevels:i}})}(s),function(e){e.OsmTileSource=function(t,i,n,o,r){var s;(s=e.isPlainObject(t)?t:{width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]}).width&&s.height||(s.width=65572864,s.height=65572864),s.tileSize||(s.tileSize=256,s.tileOverlap=0),s.tilesUrl||(s.tilesUrl="http://tile.openstreetmap.org/"),s.minLevel=8,e.TileSource.apply(this,[s])},e.extend(e.OsmTileSource.prototype,e.TileSource.prototype,{supports:function(e,t){return e.type&&"openstreetmaps"===e.type},configure:function(e,t,i){return e},getTileUrl:function(e,t,i){return this.tilesUrl+(e-8)+"/"+t+"/"+i+".png"}})}(s),function(e){e.TmsTileSource=function(t,i,n,o,r){var s;s=e.isPlainObject(t)?t:{width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var a,l=256*Math.ceil(s.width/256),h=256*Math.ceil(s.height/256);a=l>h?l/256:h/256,s.maxLevel=Math.ceil(Math.log(a)/Math.log(2))-1,s.tileSize=256,s.width=l,s.height=h,e.TileSource.apply(this,[s])},e.extend(e.TmsTileSource.prototype,e.TileSource.prototype,{supports:function(e,t){return e.type&&"tiledmapservice"===e.type},configure:function(e,t,i){return e},getTileUrl:function(e,t,i){var n=this.getNumTiles(e).y-1;return this.tilesUrl+e+"/"+t+"/"+(n-i)+".png"}})}(s),function(e){e.ZoomifyTileSource=function(e){void 0===e.tileSize&&(e.tileSize=256),void 0===e.fileFormat&&(e.fileFormat="jpg",this.fileFormat=e.fileFormat);var t={x:e.width,y:e.height};for(e.imageSizes=[{x:e.width,y:e.height}],e.gridSize=[this._getGridSize(e.width,e.height,e.tileSize)];parseInt(t.x,10)>e.tileSize||parseInt(t.y,10)>e.tileSize;)t.x=Math.floor(t.x/2),t.y=Math.floor(t.y/2),e.imageSizes.push({x:t.x,y:t.y}),e.gridSize.push(this._getGridSize(t.x,t.y,e.tileSize));e.imageSizes.reverse(),e.gridSize.reverse(),e.minLevel=0,e.maxLevel=e.gridSize.length-1,s.TileSource.apply(this,[e])},e.extend(e.ZoomifyTileSource.prototype,e.TileSource.prototype,{_getGridSize:function(e,t,i){return{x:Math.ceil(e/i),y:Math.ceil(t/i)}},_calculateAbsoluteTileNumber:function(e,t,i){for(var n=0,o={},r=0;r<e;r++)n+=(o=this.gridSize[r]).x*o.y;return n+((o=this.gridSize[e]).x*i+t)},supports:function(e,t){return e.type&&"zoomifytileservice"===e.type},configure:function(e,t,i){return e},getTileUrl:function(e,t,i){var n,o=this._calculateAbsoluteTileNumber(e,t,i);return n=Math.floor(o/256),this.tilesUrl+"TileGroup"+n+"/"+e+"-"+t+"-"+i+"."+this.fileFormat}})}(s),function(e){function t(e,t){return t.levels}e.LegacyTileSource=function(t){var i,n,o;e.isArray(t)&&(i={type:"legacy-image-pyramid",levels:t}),i.levels=function(t){var i,n,o=[];for(n=0;n<t.length;n++)(i=t[n]).height&&i.width&&i.url?o.push({url:i.url,width:Number(i.width),height:Number(i.height)}):e.console.error("Unsupported image format: %s",i.url?i.url:"<no URL>");return o.sort((function(e,t){return e.height-t.height}))}(i.levels),i.levels.length>0?(n=i.levels[i.levels.length-1].width,o=i.levels[i.levels.length-1].height):(n=0,o=0,e.console.error("No supported image formats found")),e.extend(!0,i,{width:n,height:o,tileSize:Math.max(o,n),tileOverlap:0,minLevel:0,maxLevel:i.levels.length>0?i.levels.length-1:0}),e.TileSource.apply(this,[i]),this.levels=i.levels},e.extend(e.LegacyTileSource.prototype,e.TileSource.prototype,{supports:function(e,t){return e.type&&"legacy-image-pyramid"===e.type||e.documentElement&&"legacy-image-pyramid"===e.documentElement.getAttribute("type")},configure:function(i,n,o){return e.isPlainObject(i)?t(0,i):function(i,n){if(!n||!n.documentElement)throw new Error(e.getString("Errors.Xml"));var o,r,s=n.documentElement,a=s.tagName,l=null,h=[];if("image"===a)try{for(l={type:s.getAttribute("type"),levels:[]},h=s.getElementsByTagName("level"),r=0;r<h.length;r++)o=h[r],l.levels.push({url:o.getAttribute("url"),width:parseInt(o.getAttribute("width"),10),height:parseInt(o.getAttribute("height"),10)});return t(0,l)}catch(e){throw e instanceof Error?e:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if("collection"===a)throw new Error("Legacy Image Pyramid Collections not yet supported.");if("error"===a)throw new Error("Error: "+n)}throw new Error("Unknown element "+a)}(0,i)},getLevelScale:function(e){var t=NaN;return this.levels.length>0&&e>=this.minLevel&&e<=this.maxLevel&&(t=this.levels[e].width/this.levels[this.maxLevel].width),t},getNumTiles:function(t){return this.getLevelScale(t)?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(e,t,i){var n=null;return this.levels.length>0&&e>=this.minLevel&&e<=this.maxLevel&&(n=this.levels[e].url),n}})}(s),function(e){e.ImageTileSource=function(t){t=e.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1,useCanvas:!0},t),e.TileSource.apply(this,[t])},e.extend(e.ImageTileSource.prototype,e.TileSource.prototype,{supports:function(e,t){return e.type&&"image"===e.type},configure:function(e,t,i){return e},getImageInfo:function(t){var i=this._image=new Image,n=this;this.crossOriginPolicy&&(i.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(i.useCredentials=this.ajaxWithCredentials),e.addEvent(i,"load",(function(){n.width=i.naturalWidth,n.height=i.naturalHeight,n.aspectRatio=n.width/n.height,n.dimensions=new e.Point(n.width,n.height),n._tileWidth=n.width,n._tileHeight=n.height,n.tileOverlap=0,n.minLevel=0,n.levels=n._buildLevels(),n.maxLevel=n.levels.length-1,n.ready=!0,n.raiseEvent("ready",{tileSource:n})})),e.addEvent(i,"error",(function(){n.raiseEvent("open-failed",{message:"Error loading image at "+t,source:t})})),i.src=t},getLevelScale:function(e){var t=NaN;return e>=this.minLevel&&e<=this.maxLevel&&(t=this.levels[e].width/this.levels[this.maxLevel].width),t},getNumTiles:function(t){return this.getLevelScale(t)?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(e,t,i){var n=null;return e>=this.minLevel&&e<=this.maxLevel&&(n=this.levels[e].url),n},getContext2D:function(e,t,i){var n=null;return e>=this.minLevel&&e<=this.maxLevel&&(n=this.levels[e].context2D),n},destroy:function(){this._freeupCanvasMemory()},_buildLevels:function(){var t=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!e.supportsCanvas||!this.useCanvas)return delete this._image,t;var i=this._image.naturalWidth,n=this._image.naturalHeight,o=document.createElement("canvas"),r=o.getContext("2d");if(o.width=i,o.height=n,r.drawImage(this._image,0,0,i,n),t[0].context2D=r,delete this._image,e.isCanvasTainted(o))return t;for(;i>=2&&n>=2;){i=Math.floor(i/2),n=Math.floor(n/2);var s=document.createElement("canvas"),a=s.getContext("2d");s.width=i,s.height=n,a.drawImage(o,0,0,i,n),t.splice(0,0,{context2D:a,width:i,height:n}),o=s,r=a}return t},_freeupCanvasMemory:function(){for(var e=0;e<this.levels.length;e++)this.levels[e].context2D&&(this.levels[e].context2D.canvas.height=0,this.levels[e].context2D.canvas.width=0)}})}(s),function(e){e.TileSourceCollection=function(t,i,n,o){e.console.error("TileSourceCollection is deprecated; use World instead")}}(s),function(e){function t(i){e.requestAnimationFrame((function(){!function(i){var n;i.shouldFade&&(n=1-(e.now()-i.fadeBeginTime)/i.fadeLength,n=Math.min(1,n),n=Math.max(0,n),i.imgGroup&&e.setElementOpacity(i.imgGroup,n,!0),n>0&&t(i))}(i)}))}function i(t,i){t.element.disabled||(i>=e.ButtonState.GROUP&&t.currentState===e.ButtonState.REST&&(function(t){t.shouldFade=!1,t.imgGroup&&e.setElementOpacity(t.imgGroup,1,!0)}(t),t.currentState=e.ButtonState.GROUP),i>=e.ButtonState.HOVER&&t.currentState===e.ButtonState.GROUP&&(t.imgHover&&(t.imgHover.style.visibility=""),t.currentState=e.ButtonState.HOVER),i>=e.ButtonState.DOWN&&t.currentState===e.ButtonState.HOVER&&(t.imgDown&&(t.imgDown.style.visibility=""),t.currentState=e.ButtonState.DOWN))}function n(i,n){i.element.disabled||(n<=e.ButtonState.HOVER&&i.currentState===e.ButtonState.DOWN&&(i.imgDown&&(i.imgDown.style.visibility="hidden"),i.currentState=e.ButtonState.HOVER),n<=e.ButtonState.GROUP&&i.currentState===e.ButtonState.HOVER&&(i.imgHover&&(i.imgHover.style.visibility="hidden"),i.currentState=e.ButtonState.GROUP),n<=e.ButtonState.REST&&i.currentState===e.ButtonState.GROUP&&(function(i){i.shouldFade=!0,i.fadeBeginTime=e.now()+i.fadeDelay,window.setTimeout((function(){t(i)}),i.fadeDelay)}(i),i.currentState=e.ButtonState.REST))}e.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},e.Button=function(t){var o=this;e.EventSource.call(this),e.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null,userData:null},t),this.element=t.element||e.makeNeutralElement("div"),t.element||(this.imgRest=e.makeTransparentImage(this.srcRest),this.imgGroup=e.makeTransparentImage(this.srcGroup),this.imgHover=e.makeTransparentImage(this.srcHover),this.imgDown=e.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,e.setElementPointerEventsNone(this.imgRest),e.setElementPointerEventsNone(this.imgGroup),e.setElementPointerEventsNone(this.imgHover),e.setElementPointerEventsNone(this.imgDown),this.element.style.position="relative",e.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",e.Browser.vendor===e.BROWSERS.FIREFOX&&e.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=e.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 e.MouseTracker({userData:"Button.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(t){t.insideElementPressed?(i(o,e.ButtonState.DOWN),o.raiseEvent("enter",{originalEvent:t.originalEvent})):t.buttonDownAny||i(o,e.ButtonState.HOVER)},focusHandler:function(e){o.tracker.enterHandler(e),o.raiseEvent("focus",{originalEvent:e.originalEvent})},leaveHandler:function(t){n(o,e.ButtonState.GROUP),t.insideElementPressed&&o.raiseEvent("exit",{originalEvent:t.originalEvent})},blurHandler:function(e){o.tracker.leaveHandler(e),o.raiseEvent("blur",{originalEvent:e.originalEvent})},pressHandler:function(t){i(o,e.ButtonState.DOWN),o.raiseEvent("press",{originalEvent:t.originalEvent})},releaseHandler:function(t){t.insideElementPressed&&t.insideElementReleased?(n(o,e.ButtonState.HOVER),o.raiseEvent("release",{originalEvent:t.originalEvent})):t.insideElementPressed?n(o,e.ButtonState.GROUP):i(o,e.ButtonState.HOVER)},clickHandler:function(e){e.quick&&o.raiseEvent("click",{originalEvent:e.originalEvent})},keyHandler:function(e){13===e.keyCode?(o.raiseEvent("click",{originalEvent:e.originalEvent}),o.raiseEvent("release",{originalEvent:e.originalEvent}),e.preventDefault=!0):e.preventDefault=!1}}),n(this,e.ButtonState.REST)},e.extend(e.Button.prototype,e.EventSource.prototype,{notifyGroupEnter:function(){i(this,e.ButtonState.GROUP)},notifyGroupExit:function(){n(this,e.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,this.tracker.setTracking(!1),e.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,this.tracker.setTracking(!0),e.setElementOpacity(this.element,1,!0),this.notifyGroupEnter()},destroy:function(){this.imgRest&&(this.element.removeChild(this.imgRest),this.imgRest=null),this.imgGroup&&(this.element.removeChild(this.imgGroup),this.imgGroup=null),this.imgHover&&(this.element.removeChild(this.imgHover),this.imgHover=null),this.imgDown&&(this.element.removeChild(this.imgDown),this.imgDown=null),this.removeAllHandlers(),this.tracker.destroy(),this.element=null}})}(s),function(e){e.ButtonGroup=function(t){e.extend(!0,this,{buttons:[],clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},t);var i,n=this.buttons.concat([]),o=this;if(this.element=t.element||e.makeNeutralElement("div"),!t.group)for(this.element.style.display="inline-block",i=0;i<n.length;i++)this.element.appendChild(n[i].element);e.setElementTouchActionNone(this.element),this.tracker=new e.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(e){var t;for(t=0;t<o.buttons.length;t++)o.buttons[t].notifyGroupEnter()},leaveHandler:function(e){var t;if(!e.insideElementPressed)for(t=0;t<o.buttons.length;t++)o.buttons[t].notifyGroupExit()}})},e.ButtonGroup.prototype={emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){var e=this.buttons.pop();this.element.removeChild(e.element),e.destroy()}this.tracker.destroy(),this.element=null}}}(s),function(e){e.Rect=function(t,i,n,o,r){var s,a;this.x="number"==typeof t?t:0,this.y="number"==typeof i?i:0,this.width="number"==typeof n?n:0,this.height="number"==typeof o?o:0,this.degrees="number"==typeof r?r:0,this.degrees=e.positiveModulo(this.degrees,360),this.degrees>=270?(s=this.getTopRight(),this.x=s.x,this.y=s.y,a=this.height,this.height=this.width,this.width=a,this.degrees-=270):this.degrees>=180?(s=this.getBottomRight(),this.x=s.x,this.y=s.y,this.degrees-=180):this.degrees>=90&&(s=this.getBottomLeft(),this.x=s.x,this.y=s.y,a=this.height,this.height=this.width,this.width=a,this.degrees-=90)},e.Rect.fromSummits=function(t,i,n){var o=t.distanceTo(i),r=t.distanceTo(n),s=i.minus(t),a=Math.atan(s.y/s.x);return s.x<0?a+=Math.PI:s.y<0&&(a+=2*Math.PI),new e.Rect(t.x,t.y,o,r,a/Math.PI*180)},e.Rect.prototype={clone:function(){return new e.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new e.Point(this.x,this.y)},getBottomRight:function(){return new e.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new e.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new e.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new e.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new e.Point(this.width,this.height)},equals:function(t){return t instanceof e.Rect&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height&&this.degrees===t.degrees},times:function(t){return new e.Rect(this.x*t,this.y*t,this.width*t,this.height*t,this.degrees)},translate:function(t){return new e.Rect(this.x+t.x,this.y+t.y,this.width,this.height,this.degrees)},union:function(t){var i=this.getBoundingBox(),n=t.getBoundingBox(),o=Math.min(i.x,n.x),r=Math.min(i.y,n.y),s=Math.max(i.x+i.width,n.x+n.width),a=Math.max(i.y+i.height,n.y+n.height);return new e.Rect(o,r,s-o,a-r)},intersection:function(t){var i=1e-10,n=[],o=this.getTopLeft();t.containsPoint(o,i)&&n.push(o);var r=this.getTopRight();t.containsPoint(r,i)&&n.push(r);var s=this.getBottomLeft();t.containsPoint(s,i)&&n.push(s);var a=this.getBottomRight();t.containsPoint(a,i)&&n.push(a);var l=t.getTopLeft();this.containsPoint(l,i)&&n.push(l);var h=t.getTopRight();this.containsPoint(h,i)&&n.push(h);var c=t.getBottomLeft();this.containsPoint(c,i)&&n.push(c);var u=t.getBottomRight();this.containsPoint(u,i)&&n.push(u);for(var d=this._getSegments(),p=t._getSegments(),g=0;g<d.length;g++)for(var m=d[g],v=0;v<p.length;v++){var f=p[v],y=w(m[0],m[1],f[0],f[1]);y&&n.push(y)}function w(t,n,o,r){var s=n.minus(t),a=r.minus(o),l=-a.x*s.y+s.x*a.y;if(0===l)return null;var h=(s.x*(t.y-o.y)-s.y*(t.x-o.x))/l,c=(a.x*(t.y-o.y)-a.y*(t.x-o.x))/l;return-1e-10<=h&&h<=1-i&&-1e-10<=c&&c<=1-i?new e.Point(t.x+c*s.x,t.y+c*s.y):null}if(0===n.length)return null;for(var T=n[0].x,x=n[0].x,S=n[0].y,E=n[0].y,P=1;P<n.length;P++){var _=n[P];_.x<T&&(T=_.x),_.x>x&&(x=_.x),_.y<S&&(S=_.y),_.y>E&&(E=_.y)}return new e.Rect(T,S,x-T,E-S)},_getSegments:function(){var e=this.getTopLeft(),t=this.getTopRight(),i=this.getBottomLeft(),n=this.getBottomRight();return[[e,t],[t,n],[n,i],[i,e]]},rotate:function(t,i){if(0===(t=e.positiveModulo(t,360)))return this.clone();i=i||this.getCenter();var n=this.getTopLeft().rotate(t,i),o=this.getTopRight().rotate(t,i).minus(n);o=o.apply((function(e){return Math.abs(e)<1e-15?0:e}));var r=Math.atan(o.y/o.x);return o.x<0?r+=Math.PI:o.y<0&&(r+=2*Math.PI),new e.Rect(n.x,n.y,this.width,this.height,r/Math.PI*180)},getBoundingBox:function(){if(0===this.degrees)return this.clone();var t=this.getTopLeft(),i=this.getTopRight(),n=this.getBottomLeft(),o=this.getBottomRight(),r=Math.min(t.x,i.x,n.x,o.x),s=Math.max(t.x,i.x,n.x,o.x),a=Math.min(t.y,i.y,n.y,o.y),l=Math.max(t.y,i.y,n.y,o.y);return new e.Rect(r,a,s-r,l-a)},getIntegerBoundingBox:function(){var t=this.getBoundingBox(),i=Math.floor(t.x),n=Math.floor(t.y),o=Math.ceil(t.width+t.x-i),r=Math.ceil(t.height+t.y-n);return new e.Rect(i,n,o,r)},containsPoint:function(e,t){t=t||0;var i=this.getTopLeft(),n=this.getTopRight(),o=this.getBottomLeft(),r=n.minus(i),s=o.minus(i);return(e.x-i.x)*r.x+(e.y-i.y)*r.y>=-t&&(e.x-n.x)*r.x+(e.y-n.y)*r.y<=t&&(e.x-i.x)*s.x+(e.y-i.y)*s.y>=-t&&(e.x-o.x)*s.x+(e.y-o.y)*s.y<=t},toString:function(){return"["+Math.round(100*this.x)/100+", "+Math.round(100*this.y)/100+", "+Math.round(100*this.width)/100+"x"+Math.round(100*this.height)/100+", "+Math.round(100*this.degrees)/100+"deg]"}}}(s),function(e){var t={};function i(e){var t;e.quick&&(t="horizontal"===this.scroll?Math.floor(e.position.x/this.panelWidth):Math.floor(e.position.y/this.panelHeight),this.viewer.goToPage(t)),this.element.focus()}function n(t){if(this.dragging=!0,this.element){var i=Number(this.element.style.marginLeft.replace("px","")),n=Number(this.element.style.marginTop.replace("px","")),o=Number(this.element.style.width.replace("px","")),s=Number(this.element.style.height.replace("px","")),a=e.getElementSize(this.viewer.canvas);"horizontal"===this.scroll?-t.delta.x>0?i>-(o-a.x)&&(this.element.style.marginLeft=i+2*t.delta.x+"px",r(this,a.x,i+2*t.delta.x)):-t.delta.x<0&&i<0&&(this.element.style.marginLeft=i+2*t.delta.x+"px",r(this,a.x,i+2*t.delta.x)):-t.delta.y>0?n>-(s-a.y)&&(this.element.style.marginTop=n+2*t.delta.y+"px",r(this,a.y,n+2*t.delta.y)):-t.delta.y<0&&n<0&&(this.element.style.marginTop=n+2*t.delta.y+"px",r(this,a.y,n+2*t.delta.y))}}function o(t){if(this.element){var i=Number(this.element.style.marginLeft.replace("px","")),n=Number(this.element.style.marginTop.replace("px","")),o=Number(this.element.style.width.replace("px","")),s=Number(this.element.style.height.replace("px","")),a=e.getElementSize(this.viewer.canvas);"horizontal"===this.scroll?t.scroll>0?i>-(o-a.x)&&(this.element.style.marginLeft=i-60*t.scroll+"px",r(this,a.x,i-60*t.scroll)):t.scroll<0&&i<0&&(this.element.style.marginLeft=i-60*t.scroll+"px",r(this,a.x,i-60*t.scroll)):t.scroll<0?n>a.y-s&&(this.element.style.marginTop=n+60*t.scroll+"px",r(this,a.y,n+60*t.scroll)):t.scroll>0&&n<0&&(this.element.style.marginTop=n+60*t.scroll+"px",r(this,a.y,n+60*t.scroll)),t.preventDefault=!0}}function r(t,i,n){var o,r,s,a,l,h;for(o="horizontal"===t.scroll?t.panelWidth:t.panelHeight,r=Math.ceil(i/o)+5,l=r=(r=(s=Math.ceil((Math.abs(n)+i)/o)+1)-r)<0?0:r;l<s&&l<t.panels.length;l++)if(!(h=t.panels[l]).activePanel){var c,u=t.viewer.tileSources[l];c=u.referenceStripThumbnailUrl?{type:"image",url:u.referenceStripThumbnailUrl}:u,a=new e.Viewer({id:h.id,tileSources:[c],element:h,navigatorSizeRatio:t.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:t.viewer.loadTilesWithAjax,ajaxHeaders:t.viewer.ajaxHeaders,useCanvas:t.useCanvas}),e.setElementPointerEventsNone(a.canvas),e.setElementPointerEventsNone(a.container),a.innerTracker.setTracking(!1),a.outerTracker.setTracking(!1),t.miniViewers[h.id]=a,h.activePanel=!0}}function s(e){var t=e.eventSource.element;"horizontal"===this.scroll?t.style.marginBottom="0px":t.style.marginLeft="0px"}function a(t){var i=t.eventSource.element;"horizontal"===this.scroll?i.style.marginBottom="-"+e.getElementSize(i).y/2+"px":i.style.marginLeft="-"+e.getElementSize(i).x/2+"px"}function l(e){if(e.ctrl||e.alt||e.meta)e.preventDefault=!1;else switch(e.keyCode){case 38:case 39:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),e.preventDefault=!0;break;case 40:case 37:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),e.preventDefault=!0;break;default:e.preventDefault=!1}}function h(e){if(e.ctrl||e.alt||e.meta)e.preventDefault=!1;else switch(e.keyCode){case 61:case 48:case 119:case 87:case 100:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),e.preventDefault=!0;break;case 45:case 115:case 83:case 97:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),e.preventDefault=!0;break;default:e.preventDefault=!1}}e.ReferenceStrip=function(c){var u,d,p,g=c.viewer,m=e.getElementSize(g.element);for(c.id||(c.id="referencestrip-"+e.now(),this.element=e.makeNeutralElement("div"),this.element.id=c.id,this.element.className="referencestrip"),c=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.referenceStripSizeRatio,position:e.DEFAULT_SETTINGS.referenceStripPosition,scroll:e.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold},c,{element:this.element}),e.extend(this,c),t[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,(d=this.element.style).marginTop="0px",d.marginRight="0px",d.marginBottom="0px",d.marginLeft="0px",d.left="0px",d.bottom="0px",d.border="0px",d.background="#000",d.position="relative",e.setElementTouchActionNone(this.element),e.setElementOpacity(this.element,.8),this.viewer=g,this.tracker=new e.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:e.delegate(this,i),dragHandler:e.delegate(this,n),scrollHandler:e.delegate(this,o),enterHandler:e.delegate(this,s),leaveHandler:e.delegate(this,a),keyDownHandler:e.delegate(this,l),keyHandler:e.delegate(this,h),preProcessEventHandler:function(e){"wheel"===e.eventType&&(e.preventDefault=!0)}}),c.width&&c.height?(this.element.style.width=c.width+"px",this.element.style.height=c.height+"px",g.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):"horizontal"===c.scroll?(this.element.style.width=m.x*c.sizeRatio*g.tileSources.length+12*g.tileSources.length+"px",this.element.style.height=m.y*c.sizeRatio+"px",g.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=m.y*c.sizeRatio*g.tileSources.length+12*g.tileSources.length+"px",this.element.style.width=m.x*c.sizeRatio+"px",g.addControl(this.element,{anchor:e.ControlAnchor.TOP_LEFT})),this.panelWidth=m.x*this.sizeRatio+8,this.panelHeight=m.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},p=0;p<g.tileSources.length;p++)(u=e.makeNeutralElement("div")).id=this.element.id+"-"+p,u.style.width=this.panelWidth+"px",u.style.height=this.panelHeight+"px",u.style.display="inline",u.style.float="left",u.style.cssFloat="left",u.style.styleFloat="left",u.style.padding="2px",e.setElementTouchActionNone(u),e.setElementPointerEventsNone(u),this.element.appendChild(u),u.activePanel=!1,this.panels.push(u);r(this,"vertical"===this.scroll?m.y:m.x,0),this.setFocus(0)},e.ReferenceStrip.prototype={setFocus:function(t){var i,n=this.element.querySelector("#"+this.element.id+"-"+t),o=e.getElementSize(this.viewer.canvas),a=Number(this.element.style.width.replace("px","")),l=Number(this.element.style.height.replace("px","")),h=-Number(this.element.style.marginLeft.replace("px","")),c=-Number(this.element.style.marginTop.replace("px",""));this.currentSelected!==n&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=n,this.currentSelected.style.background="#999","horizontal"===this.scroll?(i=Number(t)*(this.panelWidth+3))>h+o.x-this.panelWidth?(i=Math.min(i,a-o.x),this.element.style.marginLeft=-i+"px",r(this,o.x,-i)):i<h&&(i=Math.max(0,i-o.x/2),this.element.style.marginLeft=-i+"px",r(this,o.x,-i)):(i=Number(t)*(this.panelHeight+3))>c+o.y-this.panelHeight?(i=Math.min(i,l-o.y),this.element.style.marginTop=-i+"px",r(this,o.y,-i)):i<c&&(i=Math.max(0,i-o.y/2),this.element.style.marginTop=-i+"px",r(this,o.y,-i)),this.currentPage=t,s.call(this,{eventSource:this.tracker}))},update:function(){return!!t[this.id].animating},destroy:function(){if(this.miniViewers)for(var e in this.miniViewers)this.miniViewers[e].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}}}(s),function(e){e.DisplayRect=function(t,i,n,o,r,s){e.Rect.apply(this,[t,i,n,o]),this.minLevel=r,this.maxLevel=s},e.extend(e.DisplayRect.prototype,e.Rect.prototype)}(s),function(e){e.Spring=function(t){var i=arguments;"object"!=typeof t&&(t={initial:i.length&&"number"==typeof i[0]?i[0]:void 0,springStiffness:i.length>1?i[1].springStiffness:5,animationTime:i.length>1?i[1].animationTime:1.5}),e.console.assert("number"==typeof t.springStiffness&&0!==t.springStiffness,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),e.console.assert("number"==typeof t.animationTime&&t.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),t.exponential&&(this._exponential=!0,delete t.exponential),e.extend(!0,this,t),this.current={value:"number"==typeof this.initial?this.initial:this._exponential?0:1,time:e.now()},e.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))},e.Spring.prototype={resetTo:function(t){e.console.assert(!this._exponential||0!==t,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=t,this.start.time=this.target.time=this.current.time=e.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(t){e.console.assert(!this._exponential||0!==t,"[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=t,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(t){this.start.value+=t,this.target.value+=t,this._exponential&&(e.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(t){this._exponential=t,this._exponential&&(e.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(){var t,i;this.current.time=e.now(),this._exponential?(t=this.start._logValue,i=this.target._logValue):(t=this.start.value,i=this.target.value);var n,o,r=this.current.time>=this.target.time?i:t+(i-t)*(n=this.springStiffness,o=(this.current.time-this.start.time)/(this.target.time-this.start.time),(1-Math.exp(n*-o))/(1-Math.exp(-n))),s=this.current.value;return this._exponential?this.current.value=Math.exp(r):this.current.value=r,s!==this.current.value},isAtTargetValue:function(){return this.current.value===this.target.value}}}(s),function(e){e.ImageJob=function(t){e.extend(!0,this,{timeout:e.DEFAULT_SETTINGS.timeout,jobId:null},t),this.data=null,this.userData={},this.errorMsg=null},e.ImageJob.prototype={start:function(){var e=this,t=this.abort;this.jobId=window.setTimeout((function(){e.finish(null,null,"Image load exceeded timeout ("+e.timeout+" ms)")}),this.timeout),this.abort=function(){e.source.downloadTileAbort(e),"function"==typeof t&&t()},this.source.downloadTileStart(this)},finish:function(e,t,i){this.data=e,this.request=t,this.errorMsg=i,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},e.ImageLoader=function(t){e.extend(!0,this,{jobLimit:e.DEFAULT_SETTINGS.imageLoaderLimit,timeout:e.DEFAULT_SETTINGS.timeout,jobQueue:[],jobsInProgress:0},t)},e.ImageLoader.prototype={addJob:function(t){if(!t.source){e.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var i=e.TileSource.prototype;t.source={downloadTileStart:i.downloadTileStart,downloadTileAbort:i.downloadTileAbort}}var n=this,o={src:t.src,tile:t.tile||{},source:t.source,loadWithAjax:t.loadWithAjax,ajaxHeaders:t.loadWithAjax?t.ajaxHeaders:null,crossOriginPolicy:t.crossOriginPolicy,ajaxWithCredentials:t.ajaxWithCredentials,postData:t.postData,callback:function(e){!function(e,t,i){e.jobsInProgress--,(!e.jobLimit||e.jobsInProgress<e.jobLimit)&&e.jobQueue.length>0&&(e.jobQueue.shift().start(),e.jobsInProgress++),i(t.data,t.errorMsg,t.request)}(n,e,t.callback)},abort:t.abort,timeout:this.timeout},r=new e.ImageJob(o);!this.jobLimit||this.jobsInProgress<this.jobLimit?(r.start(),this.jobsInProgress++):this.jobQueue.push(r)},clear:function(){for(var e=0;e<this.jobQueue.length;e++){var t=this.jobQueue[e];"function"==typeof t.abort&&t.abort()}this.jobQueue=[]}}}(s),function(e){e.Tile=function(t,i,n,o,r,s,a,l,h,c,u,d){this.level=t,this.x=i,this.y=n,this.bounds=o,this.sourceBounds=c,this.exists=r,this._url=s,this.postData=u,this.context2D=a,this.loadWithAjax=l,this.ajaxHeaders=h,void 0===d&&(e.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),d=e.TileSource.prototype.getTileHashKey(t,i,n,s,h,u)),this.cacheKey=d,this.loaded=!1,this.loading=!1,this.element=null,this.imgElement=null,this.style=null,this.position=null,this.size=null,this.flipped=!1,this.blendStart=null,this.opacity=null,this.squaredDistance=null,this.visibility=null,this.hasTransparency=!1,this.beingDrawn=!1,this.lastTouchTime=0,this.isRightMost=!1,this.isBottomMost=!1},e.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},_hasTransparencyChannel:function(){return console.warn("Tile.prototype._hasTransparencyChannel() has been deprecated and will be removed in the future. Use TileSource.prototype.hasTransparency() instead."),!!this.context2D||this.getUrl().match(".png")},drawHTML:function(t){if(this.cacheImageRecord)if(this.loaded){if(!this.element){var i=this.getImage();if(!i)return;this.element=e.makeNeutralElement("div"),this.imgElement=i.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!==t&&t.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",this.flipped&&(this.style.transform="scaleX(-1)"),e.setElementOpacity(this.element,this.opacity)}else e.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString());else e.console.warn("[Tile.drawHTML] attempting to draw tile %s when it's not cached",this.toString())},get image(){return e.console.error("[Tile.image] property has been deprecated. Use [Tile.prototype.getImage] instead."),this.getImage()},get url(){return e.console.error("[Tile.url] property has been deprecated. Use [Tile.prototype.getUrl] instead."),this.getUrl()},getImage:function(){return this.cacheImageRecord.getImage()},getUrl:function(){return"function"==typeof this._url?this._url():this._url},getCanvasContext:function(){return this.context2D||this.cacheImageRecord.getRenderedContext()},drawCanvas:function(t,i,n,o,r,s){var a,l,h,c=this.position.times(e.pixelDensityRatio),u=this.size.times(e.pixelDensityRatio);this.context2D||this.cacheImageRecord?(a=this.getCanvasContext(),this.loaded&&a?(t.save(),t.globalAlpha=this.opacity,"number"==typeof n&&1!==n&&(c=c.times(n),u=u.times(n)),o instanceof e.Point&&(c=c.plus(o)),1===t.globalAlpha&&this.hasTransparency&&(r&&(c.x=Math.round(c.x),c.y=Math.round(c.y),u.x=Math.round(u.x),u.y=Math.round(u.y)),t.clearRect(c.x,c.y,u.x,u.y)),i({context:t,tile:this,rendered:a}),this.sourceBounds?(l=Math.min(this.sourceBounds.width,a.canvas.width),h=Math.min(this.sourceBounds.height,a.canvas.height)):(l=a.canvas.width,h=a.canvas.height),t.translate(c.x+u.x/2,0),this.flipped&&t.scale(-1,1),t.drawImage(a.canvas,0,0,l,h,-u.x/2,c.y,u.x,u.y),t.restore()):e.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString())):e.console.warn("[Tile.drawCanvas] attempting to draw tile %s when it's not cached",this.toString())},getScaleForEdgeSmoothing:function(){var t;if(this.cacheImageRecord)t=this.cacheImageRecord.getRenderedContext();else{if(!this.context2D)return e.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString()),1;t=this.context2D}return t.canvas.width/(this.size.x*e.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(t,i,n){var o=Math.max(1,Math.ceil((n.x-i.x)/2)),r=Math.max(1,Math.ceil((n.y-i.y)/2));return new e.Point(o,r).minus(this.position.times(e.pixelDensityRatio).times(t||1).apply((function(e){return e%1})))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.imgElement=null,this.loaded=!1,this.loading=!1}}}(s),function(e){e.OverlayPlacement=e.Placement,e.OverlayRotationMode=e.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),e.Overlay=function(t,i,n){var o;o=e.isPlainObject(t)?t:{element:t,location:i,placement:n},this.element=o.element,this.style=o.element.style,this._init(o)},e.Overlay.prototype={_init:function(t){this.location=t.location,this.placement=void 0===t.placement?e.Placement.TOP_LEFT:t.placement,this.onDraw=t.onDraw,this.checkResize=void 0===t.checkResize||t.checkResize,this.width=void 0===t.width?null:t.width,this.height=void 0===t.height?null:t.height,this.rotationMode=t.rotationMode||e.OverlayRotationMode.EXACT,this.location instanceof e.Rect&&(this.width=this.location.width,this.height=this.location.height,this.location=this.location.getTopLeft(),this.placement=e.Placement.TOP_LEFT),this.scales=null!==this.width&&null!==this.height,this.bounds=new e.Rect(this.location.x,this.location.y,this.width,this.height),this.position=this.location},adjust:function(t,i){var n=e.Placement.properties[this.placement];n&&(n.isHorizontallyCentered?t.x-=i.x/2:n.isRight&&(t.x-=i.x),n.isVerticallyCentered?t.y-=i.y/2:n.isBottom&&(t.y-=i.y))},destroy:function(){var t=this.element,i=this.style;t.parentNode&&(t.parentNode.removeChild(t),t.prevElementParent&&(i.display="none",document.body.appendChild(t))),this.onDraw=null,i.top="",i.left="",i.position="",null!==this.width&&(i.width=""),null!==this.height&&(i.height="");var n=e.getCssPropertyWithVendorPrefix("transformOrigin"),o=e.getCssPropertyWithVendorPrefix("transform");n&&o&&(i[n]="",i[o]="")},drawHTML:function(t,i){var n=this.element;n.parentNode!==t&&(n.prevElementParent=n.parentNode,n.prevNextSibling=n.nextSibling,t.appendChild(n),this.style.position="absolute",this.size=e.getElementSize(n));var o=this._getOverlayPositionAndSize(i),r=o.position,s=this.size=o.size,a=o.rotate;if(this.onDraw)this.onDraw(r,s,this.element);else{var l=this.style;l.left=r.x+"px",l.top=r.y+"px",null!==this.width&&(l.width=s.x+"px"),null!==this.height&&(l.height=s.y+"px");var h=e.getCssPropertyWithVendorPrefix("transformOrigin"),c=e.getCssPropertyWithVendorPrefix("transform");h&&c&&(a?(l[h]=this._getTransformOrigin(),l[c]="rotate("+a+"deg)"):(l[h]="",l[c]="")),l.display="block"}},_getOverlayPositionAndSize:function(t){var i=t.pixelFromPoint(this.location,!0),n=this._getSizeInPixels(t);this.adjust(i,n);var o=0;if(t.getRotation(!0)&&this.rotationMode!==e.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX&&null!==this.width&&null!==this.height){var r=new e.Rect(i.x,i.y,n.x,n.y),s=this._getBoundingBox(r,t.getRotation(!0));i=s.getTopLeft(),n=s.getSize()}else o=t.getRotation(!0);return{position:i,size:n,rotate:o}},_getSizeInPixels:function(t){var i=this.size.x,n=this.size.y;if(null!==this.width||null!==this.height){var o=t.deltaPixelsFromPointsNoRotate(new e.Point(this.width||0,this.height||0),!0);null!==this.width&&(i=o.x),null!==this.height&&(n=o.y)}if(this.checkResize&&(null===this.width||null===this.height)){var r=this.size=e.getElementSize(this.element);null===this.width&&(i=r.x),null===this.height&&(n=r.y)}return new e.Point(i,n)},_getBoundingBox:function(e,t){var i=this._getPlacementPoint(e);return e.rotate(t,i).getBoundingBox()},_getPlacementPoint:function(t){var i=new e.Point(t.x,t.y),n=e.Placement.properties[this.placement];return n&&(n.isHorizontallyCentered?i.x+=t.width/2:n.isRight&&(i.x+=t.width),n.isVerticallyCentered?i.y+=t.height/2:n.isBottom&&(i.y+=t.height)),i},_getTransformOrigin:function(){var t="",i=e.Placement.properties[this.placement];return i?(i.isLeft?t="left":i.isRight&&(t="right"),i.isTop?t+=" top":i.isBottom&&(t+=" bottom"),t):t},update:function(t,i){var n=e.isPlainObject(t)?t:{location:t,placement:i};this._init({location:n.location||this.location,placement:void 0!==n.placement?n.placement:this.placement,onDraw:n.onDraw||this.onDraw,checkResize:n.checkResize||this.checkResize,width:void 0!==n.width?n.width:this.width,height:void 0!==n.height?n.height:this.height,rotationMode:n.rotationMode||this.rotationMode})},getBounds:function(t){e.console.assert(t,"A viewport must now be passed to Overlay.getBounds.");var i=this.width,n=this.height;if(null===i||null===n){var o=t.deltaPointsFromPixelsNoRotate(this.size,!0);null===i&&(i=o.x),null===n&&(n=o.y)}var r=this.location.clone();return this.adjust(r,new e.Point(i,n)),this._adjustBoundsForRotation(t,new e.Rect(r.x,r.y,i,n))},_adjustBoundsForRotation:function(t,i){if(!t||0===t.getRotation(!0)||this.rotationMode===e.OverlayRotationMode.EXACT)return i;if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX){if(null===this.width||null===this.height)return i;var n=this._getOverlayPositionAndSize(t);return t.viewerElementToViewportRectangle(new e.Rect(n.position.x,n.position.y,n.size.x,n.size.y))}return i.rotate(-t.getRotation(!0),this._getPlacementPoint(i))}}}(s),function(e){e.Drawer=function(t){e.console.assert(t.viewer,"[Drawer] options.viewer is required");var i=arguments;if(e.isPlainObject(t)||(t={source:i[0],viewport:i[1],element:i[2]}),e.console.assert(t.viewport,"[Drawer] options.viewport is required"),e.console.assert(t.element,"[Drawer] options.element is required"),t.source&&e.console.error("[Drawer] options.source is no longer accepted; use TiledImage instead"),this.viewer=t.viewer,this.viewport=t.viewport,this.debugGridColor="string"==typeof t.debugGridColor?[t.debugGridColor]:t.debugGridColor||e.DEFAULT_SETTINGS.debugGridColor,t.opacity&&e.console.error("[Drawer] options.opacity is no longer accepted; set the opacity on the TiledImage instead"),this.useCanvas=e.supportsCanvas&&(!this.viewer||this.viewer.useCanvas),this.container=e.getElement(t.element),this.canvas=e.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 n=this._calculateCanvasSize();this.canvas.width=n.x,this.canvas.height=n.y}this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="absolute",e.setElementOpacity(this.canvas,this.opacity,!0),e.setElementPointerEventsNone(this.canvas),e.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._imageSmoothingEnabled=!0},e.Drawer.prototype={addOverlay:function(t,i,n,o){return e.console.error("drawer.addOverlay is deprecated. Use viewer.addOverlay instead."),this.viewer.addOverlay(t,i,n,o),this},updateOverlay:function(t,i,n){return e.console.error("drawer.updateOverlay is deprecated. Use viewer.updateOverlay instead."),this.viewer.updateOverlay(t,i,n),this},removeOverlay:function(t){return e.console.error("drawer.removeOverlay is deprecated. Use viewer.removeOverlay instead."),this.viewer.removeOverlay(t),this},clearOverlays:function(){return e.console.error("drawer.clearOverlays is deprecated. Use viewer.clearOverlays instead."),this.viewer.clearOverlays(),this},viewportCoordToDrawerCoord:function(t){var i=this.viewport.pixelFromPointNoRotate(t,!0);return new e.Point(i.x*e.pixelDensityRatio,i.y*e.pixelDensityRatio)},clipWithPolygons:function(e,t){if(this.useCanvas){var i=this._getContext(t);i.beginPath(),e.forEach((function(e){e.forEach((function(e,t){i[0===t?"moveTo":"lineTo"](e.x,e.y)}))})),i.clip()}},setOpacity:function(t){e.console.error("drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.");for(var i=this.viewer.world,n=0;n<i.getItemCount();n++)i.getItemAt(n).setOpacity(t);return this},getOpacity:function(){e.console.error("drawer.getOpacity is deprecated. Use tiledImage.getOpacity instead.");for(var t=this.viewer.world,i=0,n=0;n<t.getItemCount();n++){var o=t.getItemAt(n).getOpacity();o>i&&(i=o)}return i},needsUpdate:function(){return e.console.error("[Drawer.needsUpdate] this function is deprecated. Use World.needsDraw instead."),this.viewer.world.needsDraw()},numTilesLoaded:function(){return e.console.error("[Drawer.numTilesLoaded] this function is deprecated. Use TileCache.numTilesLoaded instead."),this.viewer.tileCache.numTilesLoaded()},reset:function(){return e.console.error("[Drawer.reset] this function is deprecated. Use World.resetItems instead."),this.viewer.world.resetItems(),this},update:function(){return e.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 e=this._calculateCanvasSize();if((this.canvas.width!==e.x||this.canvas.height!==e.y)&&(this.canvas.width=e.x,this.canvas.height=e.y,this._updateImageSmoothingEnabled(this.context),null!==this.sketchCanvas)){var t=this._calculateSketchCanvasSize();this.sketchCanvas.width=t.x,this.sketchCanvas.height=t.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}},_clear:function(e,t){if(this.useCanvas){var i=this._getContext(e);if(t)i.clearRect(t.x,t.y,t.width,t.height);else{var n=i.canvas;i.clearRect(0,0,n.width,n.height)}}},viewportToDrawerRectangle:function(t){var i=this.viewport.pixelFromPointNoRotate(t.getTopLeft(),!0),n=this.viewport.deltaPixelsFromPointsNoRotate(t.getSize(),!0);return new e.Rect(i.x*e.pixelDensityRatio,i.y*e.pixelDensityRatio,n.x*e.pixelDensityRatio,n.y*e.pixelDensityRatio)},drawTile:function(t,i,n,o,r,s,a){if(e.console.assert(t,"[Drawer.drawTile] tile is required"),e.console.assert(i,"[Drawer.drawTile] drawingHandler is required"),this.useCanvas){var l=this._getContext(n);o=o||1,t.drawCanvas(l,i,o,r,s,a)}else t.drawHTML(this.canvas)},_getContext:function(e){var t=this.context;if(e){if(null===this.sketchCanvas){this.sketchCanvas=document.createElement("canvas");var i=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=i.x,this.sketchCanvas.height=i.y,this.sketchContext=this.sketchCanvas.getContext("2d"),0===this.viewport.getRotation()){var n=this;this.viewer.addHandler("rotate",(function e(){if(0!==n.viewport.getRotation()){n.viewer.removeHandler("rotate",e);var t=n._calculateSketchCanvasSize();n.sketchCanvas.width=t.x,n.sketchCanvas.height=t.y}}))}this._updateImageSmoothingEnabled(this.sketchContext)}t=this.sketchContext}return t},saveContext:function(e){this.useCanvas&&this._getContext(e).save()},restoreContext:function(e){this.useCanvas&&this._getContext(e).restore()},setClip:function(e,t){if(this.useCanvas){var i=this._getContext(t);i.beginPath(),i.rect(e.x,e.y,e.width,e.height),i.clip()}},drawRectangle:function(e,t,i){if(this.useCanvas){var n=this._getContext(i);n.save(),n.fillStyle=t,n.fillRect(e.x,e.y,e.width,e.height),n.restore()}},blendSketch:function(t,i,n,o){var r=t;if(e.isPlainObject(r)||(r={opacity:t,scale:i,translate:n,compositeOperation:o}),this.useCanvas&&this.sketchCanvas){t=r.opacity,o=r.compositeOperation;var s=r.bounds;if(this.context.save(),this.context.globalAlpha=t,o&&(this.context.globalCompositeOperation=o),s)s.x<0&&(s.width+=s.x,s.x=0),s.x+s.width>this.canvas.width&&(s.width=this.canvas.width-s.x),s.y<0&&(s.height+=s.y,s.y=0),s.y+s.height>this.canvas.height&&(s.height=this.canvas.height-s.y),this.context.drawImage(this.sketchCanvas,s.x,s.y,s.width,s.height,s.x,s.y,s.width,s.height);else{i=r.scale||1;var a=(n=r.translate)instanceof e.Point?n:new e.Point(0,0),l=0,h=0;if(n){var c=this.sketchCanvas.width-this.canvas.width,u=this.sketchCanvas.height-this.canvas.height;l=Math.round(c/2),h=Math.round(u/2)}this.context.drawImage(this.sketchCanvas,a.x-l*i,a.y-h*i,(this.canvas.width+2*l)*i,(this.canvas.height+2*h)*i,-l,-h,this.canvas.width+2*l,this.canvas.height+2*h)}this.context.restore()}},drawDebugInfo:function(t,i,n,o){if(this.useCanvas){var r=this.viewer.world.getIndexOfItem(o)%this.debugGridColor.length,s=this.context;s.save(),s.lineWidth=2*e.pixelDensityRatio,s.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",s.strokeStyle=this.debugGridColor[r],s.fillStyle=this.debugGridColor[r],this.viewport.getRotation(!0)%360!=0&&this._offsetForRotation({degrees:this.viewport.getRotation(!0)}),o.getRotation(!0)%360!=0&&this._offsetForRotation({degrees:o.getRotation(!0),point:o.viewport.pixelFromPointNoRotate(o._getRotationPoint(!0),!0)}),o.viewport.getRotation(!0)%360==0&&o.getRotation(!0)%360==0&&o._drawer.viewer.viewport.getFlip()&&o._drawer._flip(),s.strokeRect(t.position.x*e.pixelDensityRatio,t.position.y*e.pixelDensityRatio,t.size.x*e.pixelDensityRatio,t.size.y*e.pixelDensityRatio);var a=(t.position.x+t.size.x/2)*e.pixelDensityRatio,l=(t.position.y+t.size.y/2)*e.pixelDensityRatio;s.translate(a,l),s.rotate(Math.PI/180*-this.viewport.getRotation(!0)),s.translate(-a,-l),0===t.x&&0===t.y&&(s.fillText("Zoom: "+this.viewport.getZoom(),t.position.x*e.pixelDensityRatio,(t.position.y-30)*e.pixelDensityRatio),s.fillText("Pan: "+this.viewport.getBounds().toString(),t.position.x*e.pixelDensityRatio,(t.position.y-20)*e.pixelDensityRatio)),s.fillText("Level: "+t.level,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+20)*e.pixelDensityRatio),s.fillText("Column: "+t.x,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+30)*e.pixelDensityRatio),s.fillText("Row: "+t.y,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+40)*e.pixelDensityRatio),s.fillText("Order: "+n+" of "+i,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+50)*e.pixelDensityRatio),s.fillText("Size: "+t.size.toString(),(t.position.x+10)*e.pixelDensityRatio,(t.position.y+60)*e.pixelDensityRatio),s.fillText("Position: "+t.position.toString(),(t.position.x+10)*e.pixelDensityRatio,(t.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!=0&&this._restoreRotationChanges(),o.getRotation(!0)%360!=0&&this._restoreRotationChanges(),o.viewport.getRotation(!0)%360==0&&o.getRotation(!0)%360==0&&o._drawer.viewer.viewport.getFlip()&&o._drawer._flip(),s.restore()}},debugRect:function(t){if(this.useCanvas){var i=this.context;i.save(),i.lineWidth=2*e.pixelDensityRatio,i.strokeStyle=this.debugGridColor[0],i.fillStyle=this.debugGridColor[0],i.strokeRect(t.x*e.pixelDensityRatio,t.y*e.pixelDensityRatio,t.width*e.pixelDensityRatio,t.height*e.pixelDensityRatio),i.restore()}},setImageSmoothingEnabled:function(e){this.useCanvas&&(this._imageSmoothingEnabled=e,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw())},_updateImageSmoothingEnabled:function(e){e.msImageSmoothingEnabled=this._imageSmoothingEnabled,e.imageSmoothingEnabled=this._imageSmoothingEnabled},getCanvasSize:function(t){var i=this._getContext(t).canvas;return new e.Point(i.width,i.height)},getCanvasCenter:function(){return new e.Point(this.canvas.width/2,this.canvas.height/2)},_offsetForRotation:function(t){var i=t.point?t.point.times(e.pixelDensityRatio):this.getCanvasCenter(),n=this._getContext(t.useSketch);n.save(),n.translate(i.x,i.y),this.viewer.viewport.flipped?(n.rotate(Math.PI/180*-t.degrees),n.scale(-1,1)):n.rotate(Math.PI/180*t.degrees),n.translate(-i.x,-i.y)},_flip:function(t){var i=(t=t||{}).point?t.point.times(e.pixelDensityRatio):this.getCanvasCenter(),n=this._getContext(t.useSketch);n.translate(i.x,0),n.scale(-1,1),n.translate(-i.x,0)},_restoreRotationChanges:function(e){this._getContext(e).restore()},_calculateCanvasSize:function(){var t=e.pixelDensityRatio,i=this.viewport.getContainerSize();return{x:Math.round(i.x*t),y:Math.round(i.y*t)}},_calculateSketchCanvasSize:function(){var e=this._calculateCanvasSize();if(0===this.viewport.getRotation())return e;var t=Math.ceil(Math.sqrt(e.x*e.x+e.y*e.y));return{x:t,y:t}}}}(s),function(e){e.Viewport=function(t){var i=arguments;i.length&&i[0]instanceof e.Point&&(t={containerSize:i[0],contentSize:i[1],config:i[2]}),t.config&&(e.extend(!0,t,t.config),delete t.config),this._margins=e.extend({left:0,top:0,right:0,bottom:0},t.margins||{}),delete t.margins,t.initialDegrees=t.degrees,delete t.degrees,e.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:e.DEFAULT_SETTINGS.springStiffness,animationTime:e.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:e.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:e.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:e.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:e.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:e.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:e.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:e.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:e.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:e.DEFAULT_SETTINGS.degrees,flipped:e.DEFAULT_SETTINGS.flipped,homeFillsViewer:e.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:e.DEFAULT_SETTINGS.silenceMultiImageWarnings},t),this._updateContainerInnerSize(),this.centerSpringX=new e.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.centerSpringY=new e.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.zoomSpring=new e.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.degreesSpring=new e.Spring({initial:t.initialDegrees,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._oldDegrees=this.degreesSpring.current.value,this._setContentBounds(new e.Rect(0,0,1,1),1),this.goHome(!0),this.update()},e.Viewport.prototype={get degrees(){return e.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead."),this.getRotation()},set degrees(t){e.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead."),this.rotateTo(t)},resetContentSize:function(t){return e.console.assert(t,"[Viewport.resetContentSize] contentSize is required"),e.console.assert(t instanceof e.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"),e.console.assert(t.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),e.console.assert(t.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this._setContentBounds(new e.Rect(0,0,1,t.y/t.x),t.x),this},setHomeBounds:function(t,i){e.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(t,i)},_setContentBounds:function(t,i){e.console.assert(t,"[Viewport._setContentBounds] bounds is required"),e.console.assert(t instanceof e.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect"),e.console.assert(t.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0"),e.console.assert(t.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0"),this._contentBoundsNoRotate=t.clone(),this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(i),this._contentBounds=t.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(i),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:i,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var e=this._contentAspectRatio/this.getAspectRatio();return(this.homeFillsViewer?e>=1?e:1:e>=1?1:e)/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var t=this._contentBounds.getCenter(),i=1/this.getHomeZoom(),n=i/this.getAspectRatio();return new e.Rect(t.x-i/2,t.y-n/2,i,n)},goHome:function(e){return this.viewer&&this.viewer.raiseEvent("home",{immediately:e}),this.fitBounds(this.getHomeBounds(),e)},getMinZoom:function(){var e=this.getHomeZoom();return this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*e},getMaxZoom:function(){var e=this.maxZoomLevel;return e||(e=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,e/=this._contentBounds.width),Math.max(e,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new e.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return e.extend({},this._margins)},setMargins:function(t){e.console.assert("object"===e.type(t),"[Viewport.setMargins] margins must be an object"),this._margins=e.extend({left:0,top:0,right:0,bottom:0},t),this._updateContainerInnerSize(),this.viewer&&this.viewer.forceRedraw()},getBounds:function(e){return this.getBoundsNoRotate(e).rotate(-this.getRotation(e))},getBoundsNoRotate:function(t){var i=this.getCenter(t),n=1/this.getZoom(t),o=n/this.getAspectRatio();return new e.Rect(i.x-n/2,i.y-o/2,n,o)},getBoundsWithMargins:function(e){return this.getBoundsNoRotateWithMargins(e).rotate(-this.getRotation(e),this.getCenter(e))},getBoundsNoRotateWithMargins:function(e){var t=this.getBoundsNoRotate(e),i=this._containerInnerSize.x*this.getZoom(e);return t.x-=this._margins.left/i,t.y-=this._margins.top/i,t.width+=(this._margins.left+this._margins.right)/i,t.height+=(this._margins.top+this._margins.bottom)/i,t},getCenter:function(t){var i,n,o,r,s,a,l=new e.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),h=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return t?l:this.zoomPoint?(i=this.pixelFromPoint(this.zoomPoint,!0),r=(o=1/(n=this.getZoom()))/this.getAspectRatio(),s=new e.Rect(l.x-o/2,l.y-r/2,o,r),a=this._pixelFromPoint(this.zoomPoint,s).minus(i).rotate(-this.getRotation(!0)).divide(this._containerInnerSize.x*n),h.plus(a)):h},getZoom:function(e){return e?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(e){return Math.max(Math.min(e,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(e){var t=this.viewportToViewerElementRectangle(e).getBoundingBox(),i=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),n=!1,o=!1;if(this.wrapHorizontal);else{var r,s,a,l=t.x+t.width,h=i.x+i.width;r=t.width>i.width?this.visibilityRatio*i.width:this.visibilityRatio*t.width,s=i.x-l+r,a=h-t.x-r,r>i.width?(t.x+=(s+a)/2,n=!0):a<0?(t.x+=a,n=!0):s>0&&(t.x+=s,n=!0)}if(this.wrapVertical);else{var c,u,d,p=t.y+t.height,g=i.y+i.height;c=t.height>i.height?this.visibilityRatio*i.height:this.visibilityRatio*t.height,u=i.y-p+c,d=g-t.y-c,c>i.height?(t.y+=(u+d)/2,o=!0):d<0?(t.y+=d,o=!0):u>0&&(t.y+=u,o=!0)}var m=n||o,v=m?this.viewerElementToViewportRectangle(t):e.clone();return v.xConstrained=n,v.yConstrained=o,v.constraintApplied=m,v},_raiseConstraintsEvent:function(e){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:e})},applyConstraints:function(e){var t=this.getZoom(),i=this._applyZoomConstraints(t);t!==i&&this.zoomTo(i,this.zoomPoint,e);var n=this.getConstrainedBounds(!1);return n.constraintApplied&&(this.fitBounds(n,e),this._raiseConstraintsEvent(e)),this},ensureVisible:function(e){return this.applyConstraints(e)},_fitBounds:function(t,i){var n=(i=i||{}).immediately||!1,o=i.constraints||!1,r=this.getAspectRatio(),s=t.getCenter(),a=new e.Rect(t.x,t.y,t.width,t.height,t.degrees+this.getRotation()).getBoundingBox();a.getAspectRatio()>=r?a.height=a.width/r:a.width=a.height*r,a.x=s.x-a.width/2,a.y=s.y-a.height/2;var l=1/a.width;if(n)return this.panTo(s,!0),this.zoomTo(l,null,!0),o&&this.applyConstraints(!0),this;var h=this.getCenter(!0),c=this.getZoom(!0);this.panTo(h,!0),this.zoomTo(c,null,!0);var u=this.getBounds(),d=this.getZoom();if(0===d||Math.abs(l/d-1)<1e-8)return this.zoomTo(l,null,!0),this.panTo(s,n),o&&this.applyConstraints(!1),this;if(o){this.panTo(s,!1),this.zoomTo(l,null,!1);var p=this.getConstrainedBounds();this.panTo(h,!0),this.zoomTo(c,null,!0),this.fitBounds(p)}else{var g=a.rotate(-this.getRotation()).getTopLeft().times(l).minus(u.getTopLeft().times(d)).divide(l-d);this.zoomTo(l,g,n)}return this},fitBounds:function(e,t){return this._fitBounds(e,{immediately:t,constraints:!1})},fitBoundsWithConstraints:function(e,t){return this._fitBounds(e,{immediately:t,constraints:!0})},fitVertically:function(t){var i=new e.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(i,t)},fitHorizontally:function(t){var i=new e.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(i,t)},getConstrainedBounds:function(e){var t;return t=this.getBounds(e),this._applyBoundaryConstraints(t)},panBy:function(t,i){var n=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(n.plus(t),i)},panTo:function(e,t){return t?(this.centerSpringX.resetTo(e.x),this.centerSpringY.resetTo(e.y)):(this.centerSpringX.springTo(e.x),this.centerSpringY.springTo(e.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:e,immediately:t}),this},zoomBy:function(e,t,i){return this.zoomTo(this.zoomSpring.target.value*e,t,i)},zoomTo:function(t,i,n){var o=this;return this.zoomPoint=i instanceof e.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null,n?this._adjustCenterSpringsForZoomPoint((function(){o.zoomSpring.resetTo(t)})):this.zoomSpring.springTo(t),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:t,refPoint:i,immediately:n}),this},setRotation:function(e,t){return this.rotateTo(e,null,t)},getRotation:function(e){return e?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(e,t,i){return this.rotateTo(e,t,i)},rotateTo:function(t,i,n){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===t&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=i instanceof e.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null,n)if(this.rotationPivot){if(!(t-this._oldDegrees))return this.rotationPivot=null,this;this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var o=e.positiveModulo(this.degreesSpring.current.value,360),r=e.positiveModulo(t,360),s=r-o;s>180?r-=360:s<-180&&(r+=360);var a=o-r;this.degreesSpring.resetTo(t+a),this.degreesSpring.springTo(t)}return this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor()),this.viewer.forceRedraw(),this.viewer.raiseEvent("rotate",{degrees:t,immediately:!!n,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(e,t,i){return this.rotateTo(this.degreesSpring.target.value+e,t,i)},resize:function(e,t){var i,n=this.getBoundsNoRotate(),o=n;return this.containerSize.x=e.x,this.containerSize.y=e.y,this._updateContainerInnerSize(),t&&(i=e.x/this.containerSize.x,o.width=n.width*i,o.height=o.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:e,maintain:t}),this.fitBounds(o,!0)},_updateContainerInnerSize:function(){this._containerInnerSize=new e.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 e=this;this._adjustCenterSpringsForZoomPoint((function(){e.zoomSpring.update()})),this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null),this.centerSpringX.update(),this.centerSpringY.update(),this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var t=this.centerSpringX.current.value!==this._oldCenterX||this.centerSpringY.current.value!==this._oldCenterY||this.zoomSpring.current.value!==this._oldZoom||this.degreesSpring.current.value!==this._oldDegrees;return this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value,t},_rotateAboutPivot:function(e){var t=!0===e,i=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(i.x),this.centerSpringY.shiftBy(i.y),t?this.degreesSpring.update():this.degreesSpring.resetTo(e);var n=this.degreesSpring.current.value-this._oldDegrees,o=i.rotate(-1*n).times(-1);this.centerSpringX.shiftBy(o.x),this.centerSpringY.shiftBy(o.y)},_adjustCenterSpringsForZoomPoint:function(e){if(this.zoomPoint){var t=this.pixelFromPoint(this.zoomPoint,!0);e();var i=this.pixelFromPoint(this.zoomPoint,!0).minus(t),n=this.deltaPointsFromPixels(i,!0);this.centerSpringX.shiftBy(n.x),this.centerSpringY.shiftBy(n.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else e()},deltaPixelsFromPointsNoRotate:function(e,t){return e.times(this._containerInnerSize.x*this.getZoom(t))},deltaPixelsFromPoints:function(e,t){return this.deltaPixelsFromPointsNoRotate(e.rotate(this.getRotation(t)),t)},deltaPointsFromPixelsNoRotate:function(e,t){return e.divide(this._containerInnerSize.x*this.getZoom(t))},deltaPointsFromPixels:function(e,t){return this.deltaPointsFromPixelsNoRotate(e,t).rotate(-this.getRotation(t))},pixelFromPointNoRotate:function(e,t){return this._pixelFromPointNoRotate(e,this.getBoundsNoRotate(t))},pixelFromPoint:function(e,t){return this._pixelFromPoint(e,this.getBoundsNoRotate(t))},_pixelFromPointNoRotate:function(t,i){return t.minus(i.getTopLeft()).times(this._containerInnerSize.x/i.width).plus(new e.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(e,t){return this._pixelFromPointNoRotate(e.rotate(this.getRotation(!0),this.getCenter(!0)),t)},pointFromPixelNoRotate:function(t,i){var n=this.getBoundsNoRotate(i);return t.minus(new e.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/n.width).plus(n.getTopLeft())},pointFromPixel:function(e,t){return this.pointFromPixelNoRotate(e,t).rotate(-this.getRotation(t),this.getCenter(t))},_viewportToImageDelta:function(t,i){var n=this._contentBoundsNoRotate.width;return new e.Point(t*this._contentSizeNoRotate.x/n,i*this._contentSizeNoRotate.x/n)},viewportToImageCoordinates:function(t,i){if(t instanceof e.Point)return this.viewportToImageCoordinates(t.x,t.y);if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(1===n)return this.viewer.world.getItemAt(0).viewportToImageCoordinates(t,i,!0)}return this._viewportToImageDelta(t-this._contentBoundsNoRotate.x,i-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(t,i){var n=this._contentBoundsNoRotate.width;return new e.Point(t/this._contentSizeNoRotate.x*n,i/this._contentSizeNoRotate.x*n)},imageToViewportCoordinates:function(t,i){if(t instanceof e.Point)return this.imageToViewportCoordinates(t.x,t.y);if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(1===n)return this.viewer.world.getItemAt(0).imageToViewportCoordinates(t,i,!0)}var o=this._imageToViewportDelta(t,i);return o.x+=this._contentBoundsNoRotate.x,o.y+=this._contentBoundsNoRotate.y,o},imageToViewportRectangle:function(t,i,n,o){var r=t;if(r instanceof e.Rect||(r=new e.Rect(t,i,n,o)),this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(1===s)return this.viewer.world.getItemAt(0).imageToViewportRectangle(t,i,n,o,!0)}var a=this.imageToViewportCoordinates(r.x,r.y),l=this._imageToViewportDelta(r.width,r.height);return new e.Rect(a.x,a.y,l.x,l.y,r.degrees)},viewportToImageRectangle:function(t,i,n,o){var r=t;if(r instanceof e.Rect||(r=new e.Rect(t,i,n,o)),this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(1===s)return this.viewer.world.getItemAt(0).viewportToImageRectangle(t,i,n,o,!0)}var a=this.viewportToImageCoordinates(r.x,r.y),l=this._viewportToImageDelta(r.width,r.height);return new e.Rect(a.x,a.y,l.x,l.y,r.degrees)},viewerElementToImageCoordinates:function(e){var t=this.pointFromPixel(e,!0);return this.viewportToImageCoordinates(t)},imageToViewerElementCoordinates:function(e){var t=this.imageToViewportCoordinates(e);return this.pixelFromPoint(t,!0)},windowToImageCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var i=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(i)},imageToWindowCoordinates:function(t){return e.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer."),this.imageToViewerElementCoordinates(t).plus(e.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(e){return this.pointFromPixel(e,!0)},viewportToViewerElementCoordinates:function(e){return this.pixelFromPoint(e,!0)},viewerElementToViewportRectangle:function(t){return e.Rect.fromSummits(this.pointFromPixel(t.getTopLeft(),!0),this.pointFromPixel(t.getTopRight(),!0),this.pointFromPixel(t.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(t){return e.Rect.fromSummits(this.pixelFromPoint(t.getTopLeft(),!0),this.pixelFromPoint(t.getTopRight(),!0),this.pixelFromPoint(t.getBottomLeft(),!0))},windowToViewportCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");var i=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(i)},viewportToWindowCoordinates:function(t){return e.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer."),this.viewportToViewerElementCoordinates(t).plus(e.getElementPosition(this.viewer.element))},viewportToImageZoom:function(t){if(this.viewer){var i=this.viewer.world.getItemCount();if(i>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(1===i)return this.viewer.world.getItemAt(0).viewportToImageZoom(t)}var n=this._contentSizeNoRotate.x;return t*(this._containerInnerSize.x/n*this._contentBoundsNoRotate.width)},imageToViewportZoom:function(t){if(this.viewer){var i=this.viewer.world.getItemCount();if(i>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image.");else if(1===i)return this.viewer.world.getItemAt(0).imageToViewportZoom(t)}return t*(this._contentSizeNoRotate.x/this._containerInnerSize.x/this._contentBoundsNoRotate.width)},toggleFlip:function(){return this.setFlip(!this.getFlip()),this},getFlip:function(){return this.flipped},setFlip:function(e){return this.flipped===e||(this.flipped=e,this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip()),this.viewer.forceRedraw(),this.viewer.raiseEvent("flip",{flipped:e})),this}}}(s),function(e){e.TiledImage=function(t){var i=this;e.console.assert(t.tileCache,"[TiledImage] options.tileCache is required"),e.console.assert(t.drawer,"[TiledImage] options.drawer is required"),e.console.assert(t.viewer,"[TiledImage] options.viewer is required"),e.console.assert(t.imageLoader,"[TiledImage] options.imageLoader is required"),e.console.assert(t.source,"[TiledImage] options.source is required"),e.console.assert(!t.clip||t.clip instanceof e.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),e.EventSource.call(this),this._tileCache=t.tileCache,delete t.tileCache,this._drawer=t.drawer,delete t.drawer,this._imageLoader=t.imageLoader,delete t.imageLoader,t.clip instanceof e.Rect&&(this._clip=t.clip.clone()),delete t.clip;var n=t.x||0;delete t.x;var o=t.y||0;delete t.y,this.normHeight=t.source.dimensions.y/t.source.dimensions.x,this.contentAspectX=t.source.dimensions.x/t.source.dimensions.y;var r=1;t.width?(r=t.width,delete t.width,t.height&&(e.console.error("specifying both width and height to a tiledImage is not supported"),delete t.height)):t.height&&(r=t.height/this.normHeight,delete t.height);var a=t.fitBounds;delete t.fitBounds;var l=t.fitBoundsPlacement||s.Placement.CENTER;delete t.fitBoundsPlacement;var h=t.degrees||0;delete t.degrees,e.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_midDraw:!1,_needsDraw:!0,_hasOpaqueTile:!1,_tilesLoading:0,springStiffness:e.DEFAULT_SETTINGS.springStiffness,animationTime:e.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:e.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:e.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:e.DEFAULT_SETTINGS.wrapVertical,immediateRender:e.DEFAULT_SETTINGS.immediateRender,blendTime:e.DEFAULT_SETTINGS.blendTime,alwaysBlend:e.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:e.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:e.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:e.DEFAULT_SETTINGS.iOSDevice,debugMode:e.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:e.DEFAULT_SETTINGS.crossOriginPolicy,ajaxWithCredentials:e.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:e.DEFAULT_SETTINGS.placeholderFillStyle,opacity:e.DEFAULT_SETTINGS.opacity,preload:e.DEFAULT_SETTINGS.preload,compositeOperation:e.DEFAULT_SETTINGS.compositeOperation,subPixelRoundingForTransparency:e.DEFAULT_SETTINGS.subPixelRoundingForTransparency},t),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new e.Spring({initial:n,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new e.Spring({initial:o,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new e.Spring({initial:r,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new e.Spring({initial:h,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),a&&this.fitBounds(a,l,!0),this._drawingHandler=function(t){i.viewer.raiseEvent("tile-drawing",e.extend({tiledImage:i},t))}},e.extend(e.TiledImage.prototype,e.EventSource.prototype,{needsDraw:function(){return this._needsDraw},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(e){e!==this._fullyLoaded&&(this._fullyLoaded=e,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=e.now(),this._needsDraw=!0},update:function(){var e=this._xSpring.update(),t=this._ySpring.update(),i=this._scaleSpring.update(),n=this._degreesSpring.update();return!!(e||t||i||n)&&(this._updateForScale(),this._needsDraw=!0,!0)},draw:function(){0!==this.opacity||this._preload?(this._midDraw=!0,this._updateViewport(),this._midDraw=!1):this._needsDraw=!1},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy()},getBounds:function(e){return this.getBoundsNoRotate(e).rotate(this.getRotation(e),this._getRotationPoint(e))},getBoundsNoRotate:function(t){return t?new e.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new e.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return e.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(t){var i=this.getBoundsNoRotate(t);if(this._clip){var n=(t?this._worldWidthCurrent:this._worldWidthTarget)/this.source.dimensions.x,o=this._clip.times(n);i=new e.Rect(i.x+o.x,i.y+o.y,o.width,o.height)}return i.rotate(this.getRotation(t),this._getRotationPoint(t))},getTileBounds:function(e,t,i){var n=this.source.getNumTiles(e),o=(n.x+t%n.x)%n.x,r=(n.y+i%n.y)%n.y,s=this.source.getTileBounds(e,o,r);return this.getFlip()&&(s.x=1-s.x-s.width),s.x+=(t-o)/n.x,s.y+=this._worldHeightCurrent/this._worldWidthCurrent*((i-r)/n.y),s},getContentSize:function(){return new e.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var t=this.imageToWindowCoordinates(new e.Point(0,0)),i=this.imageToWindowCoordinates(this.getContentSize());return new e.Point(i.x-t.x,i.y-t.y)},_viewportToImageDelta:function(t,i,n){var o=n?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t*(this.source.dimensions.x/o),i*(this.source.dimensions.y*this.contentAspectX/o))},viewportToImageCoordinates:function(t,i,n){var o;return t instanceof e.Point?(n=i,o=t):o=new e.Point(t,i),o=o.rotate(-this.getRotation(n),this._getRotationPoint(n)),n?this._viewportToImageDelta(o.x-this._xSpring.current.value,o.y-this._ySpring.current.value):this._viewportToImageDelta(o.x-this._xSpring.target.value,o.y-this._ySpring.target.value)},_imageToViewportDelta:function(t,i,n){var o=n?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t/this.source.dimensions.x*o,i/this.source.dimensions.y/this.contentAspectX*o)},imageToViewportCoordinates:function(t,i,n){t instanceof e.Point&&(n=i,i=t.y,t=t.x);var o=this._imageToViewportDelta(t,i);return n?(o.x+=this._xSpring.current.value,o.y+=this._ySpring.current.value):(o.x+=this._xSpring.target.value,o.y+=this._ySpring.target.value),o.rotate(this.getRotation(n),this._getRotationPoint(n))},imageToViewportRectangle:function(t,i,n,o,r){var s=t;s instanceof e.Rect?r=i:s=new e.Rect(t,i,n,o);var a=this.imageToViewportCoordinates(s.getTopLeft(),r),l=this._imageToViewportDelta(s.width,s.height,r);return new e.Rect(a.x,a.y,l.x,l.y,s.degrees+this.getRotation(r))},viewportToImageRectangle:function(t,i,n,o,r){var s=t;t instanceof e.Rect?r=i:s=new e.Rect(t,i,n,o);var a=this.viewportToImageCoordinates(s.getTopLeft(),r),l=this._viewportToImageDelta(s.width,s.height,r);return new e.Rect(a.x,a.y,l.x,l.y,s.degrees-this.getRotation(r))},viewerElementToImageCoordinates:function(e){var t=this.viewport.pointFromPixel(e,!0);return this.viewportToImageCoordinates(t)},imageToViewerElementCoordinates:function(e){var t=this.imageToViewportCoordinates(e);return this.viewport.pixelFromPoint(t,!0)},windowToImageCoordinates:function(e){var t=e.minus(s.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(t)},imageToWindowCoordinates:function(e){return this.imageToViewerElementCoordinates(e).plus(s.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(t){var i=this._scaleSpring.current.value;return t=t.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new e.Rect((t.x-this._xSpring.current.value)/i,(t.y-this._ySpring.current.value)/i,t.width/i,t.height/i,t.degrees)},viewportToImageZoom:function(e){return this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x*e},imageToViewportZoom:function(e){return e/(this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x)},setPosition:function(e,t){var i=this._xSpring.target.value===e.x&&this._ySpring.target.value===e.y;if(t){if(i&&this._xSpring.current.value===e.x&&this._ySpring.current.value===e.y)return;this._xSpring.resetTo(e.x),this._ySpring.resetTo(e.y),this._needsDraw=!0}else{if(i)return;this._xSpring.springTo(e.x),this._ySpring.springTo(e.y),this._needsDraw=!0}i||this._raiseBoundsChange()},setWidth:function(e,t){this._setScale(e,t)},setHeight:function(e,t){this._setScale(e/this.normHeight,t)},setCroppingPolygons:function(t){try{if(!e.isArray(t))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=t.map((function(t){return t.map((function(t){try{if(function(t){return t instanceof e.Point||"number"==typeof t.x&&"number"==typeof t.y}(t))return{x:t.x,y:t.y};throw new Error}catch(e){throw new Error("A Provided cropping polygon point is not supported")}}))}))}catch(t){e.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),e.console.error(t),this._croppingPolygons=null}},resetCroppingPolygons:function(){this._croppingPolygons=null},fitBounds:function(t,i,n){i=i||e.Placement.CENTER;var o=e.Placement.properties[i],r=this.contentAspectX,s=0,a=0,l=1,h=1;if(this._clip&&(r=this._clip.getAspectRatio(),l=this._clip.width/this.source.dimensions.x,h=this._clip.height/this.source.dimensions.y,t.getAspectRatio()>r?(s=this._clip.x/this._clip.height*t.height,a=this._clip.y/this._clip.height*t.height):(s=this._clip.x/this._clip.width*t.width,a=this._clip.y/this._clip.width*t.width)),t.getAspectRatio()>r){var c=t.height/h,u=0;o.isHorizontallyCentered?u=(t.width-t.height*r)/2:o.isRight&&(u=t.width-t.height*r),this.setPosition(new e.Point(t.x-s+u,t.y-a),n),this.setHeight(c,n)}else{var d=t.width/l,p=0;o.isVerticallyCentered?p=(t.height-t.width/r)/2:o.isBottom&&(p=t.height-t.width/r),this.setPosition(new e.Point(t.x-s,t.y-a+p),n),this.setWidth(d,n)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(t){e.console.assert(!t||t instanceof e.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),t instanceof e.Rect?this._clip=t.clone():this._clip=null,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return!!this.flipped},setFlip:function(e){this.flipped=!!e,this._needsDraw=!0,this._raiseBoundsChange()},getOpacity:function(){return this.opacity},setOpacity:function(e){e!==this.opacity&&(this.opacity=e,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(e){this._preload=!!e,this._needsDraw=!0},getRotation:function(e){return e?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(e,t){this._degreesSpring.target.value===e&&this._degreesSpring.isAtTargetValue()||(t?this._degreesSpring.resetTo(e):this._degreesSpring.springTo(e),this._needsDraw=!0,this._raiseBoundsChange())},_getRotationPoint:function(e){return this.getBoundsNoRotate(e).getCenter()},getCompositeOperation:function(){return this.compositeOperation},setCompositeOperation:function(e){e!==this.compositeOperation&&(this.compositeOperation=e,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this.compositeOperation}))},_setScale:function(e,t){var i=this._scaleSpring.target.value===e;if(t){if(i&&this._scaleSpring.current.value===e)return;this._scaleSpring.resetTo(e),this._updateForScale(),this._needsDraw=!0}else{if(i)return;this._scaleSpring.springTo(e),this._updateForScale(),this._needsDraw=!0}i||this._raiseBoundsChange()},_updateForScale:function(){this._worldWidthTarget=this._scaleSpring.target.value,this._worldHeightTarget=this.normHeight*this._scaleSpring.target.value,this._worldWidthCurrent=this._scaleSpring.current.value,this._worldHeightCurrent=this.normHeight*this._scaleSpring.current.value},_raiseBoundsChange:function(){this.raiseEvent("bounds-change")},_isBottomItem:function(){return this.viewer.world.getItemAt(0)===this},_getLevelsInterval:function(){var e=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),t=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,i=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(t/this.minPixelRatio)/Math.log(2))));return i=Math.max(i,this.source.minLevel||0),{lowestLevel:e=Math.min(e,i),highestLevel:i}},_updateViewport:function(){for(this._needsDraw=!1,this._tilesLoading=0,this.loadingCoverage={};this.lastDrawn.length>0;)this.lastDrawn.pop().beingDrawn=!1;var t=this.viewport,i=this._viewportToTiledImageRectangle(t.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var n=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));if(null===(i=i.intersection(n)))return}for(var o=this._getLevelsInterval(),r=o.lowestLevel,s=o.highestLevel,a=null,l=!1,h=e.now(),c=s;c>=r;c--){var u=!1,d=t.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(c),!0).x*this._scaleSpring.current.value;if(c===r||!l&&d>=this.minPixelRatio)u=!0,l=!0;else if(!l)continue;var p=t.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(c),!1).x*this._scaleSpring.current.value,g=t.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,m=this.immediateRender?1:g,v=Math.min(1,(d-.5)/.5),f=m/Math.abs(m-p);if(a=this._updateLevel(l,u,c,v,f,i,h,a),this._providesCoverage(this.coverage,c))break}this._drawTiles(this.lastDrawn),a&&!a.context2D?(this._loadTile(a,h),this._needsDraw=!0,this._setFullyLoaded(!1)):this._setFullyLoaded(0===this._tilesLoading)},_getCornerTiles:function(t,i,n){var o,r,s,a;this.wrapHorizontal?(o=e.positiveModulo(i.x,1),r=e.positiveModulo(n.x,1)):(o=Math.max(0,i.x),r=Math.min(1,n.x));var l=1/this.source.aspectRatio;this.wrapVertical?(s=e.positiveModulo(i.y,l),a=e.positiveModulo(n.y,l)):(s=Math.max(0,i.y),a=Math.min(l,n.y));var h=this.source.getTileAtPoint(t,new e.Point(o,s)),c=this.source.getTileAtPoint(t,new e.Point(r,a)),u=this.source.getNumTiles(t);return this.wrapHorizontal&&(h.x+=u.x*Math.floor(i.x),c.x+=u.x*Math.floor(n.x)),this.wrapVertical&&(h.y+=u.y*Math.floor(i.y/l),c.y+=u.y*Math.floor(n.y/l)),{topLeft:h,bottomRight:c}},_updateLevel:function(e,t,i,n,o,r,s,a){var l=r.getBoundingBox().getTopLeft(),h=r.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:e,level:i,opacity:n,visibility:o,drawArea:r,topleft:l,bottomright:h,currenttime:s,best:a}),this._resetCoverage(this.coverage,i),this._resetCoverage(this.loadingCoverage,i);var c=this._getCornerTiles(i,l,h),u=c.topLeft,d=c.bottomRight,p=this.source.getNumTiles(i),g=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(d.x+=1,this.wrapHorizontal||(d.x=Math.min(d.x,p.x-1)));for(var m=u.x;m<=d.x;m++)for(var v=u.y;v<=d.y;v++){var f;if(this.getFlip()){var y=(p.x+m%p.x)%p.x;f=m+p.x-y-y-1}else f=m;null!==r.intersection(this.getTileBounds(i,f,v))&&(a=this._updateTile(t,e,f,v,i,n,o,g,p,s,a))}return a},_updateTile:function(e,t,i,n,o,r,s,a,l,h,c){var u=this._getTile(i,n,o,h,l,this._worldWidthCurrent,this._worldHeightCurrent),d=t;this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:u}),this._setCoverage(this.coverage,o,i,n,!1);var p=u.loaded||u.loading||this._isCovered(this.loadingCoverage,o,i,n);if(this._setCoverage(this.loadingCoverage,o,i,n,p),!u.exists)return c;if(e&&!d&&(this._isCovered(this.coverage,o,i,n)?this._setCoverage(this.coverage,o,i,n,!0):d=!0),!d)return c;if(this._positionTile(u,this.source.tileOverlap,this.viewport,a,s),!u.loaded)if(u.context2D)this._setTileLoaded(u);else{var g=this._tileCache.getImageRecord(u.cacheKey);g&&this._setTileLoaded(u,g.getData())}return u.loaded?this._blendTile(u,i,n,o,r,h)&&(this._needsDraw=!0):u.loading?this._tilesLoading++:p||(c=this._compareTiles(c,u)),c},_getTile:function(t,i,n,o,r,s,a){var l,h,c,u,d,p,g,m,v,f,y=this.tilesMatrix,w=this.source;return y[n]||(y[n]={}),y[n][t]||(y[n][t]={}),y[n][t][i]&&!y[n][t][i].flipped==!this.flipped||(l=(r.x+t%r.x)%r.x,h=(r.y+i%r.y)%r.y,c=this.getTileBounds(n,t,i),u=w.getTileBounds(n,l,h,!0),d=w.tileExists(n,l,h),p=w.getTileUrl(n,l,h),g=w.getTilePostData(n,l,h),this.loadTilesWithAjax?(m=w.getTileAjaxHeaders(n,l,h),e.isPlainObject(this.ajaxHeaders)&&(m=e.extend({},this.ajaxHeaders,m))):m=null,v=w.getContext2D?w.getContext2D(n,l,h):void 0,f=new e.Tile(n,t,i,c,d,p,v,this.loadTilesWithAjax,m,u,g,w.getTileHashKey(n,l,h,p,m,g)),this.getFlip()?0===l&&(f.isRightMost=!0):l===r.x-1&&(f.isRightMost=!0),h===r.y-1&&(f.isBottomMost=!0),f.flipped=this.flipped,y[n][t][i]=f),(f=y[n][t][i]).lastTouchTime=o,f},_loadTile:function(e,t){var i=this;e.loading=!0,this._imageLoader.addJob({src:e.getUrl(),tile:e,source:this.source,postData:e.postData,loadWithAjax:e.loadWithAjax,ajaxHeaders:e.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(n,o,r){i._onTileLoad(e,t,n,o,r)},abort:function(){e.loading=!1}})},_onTileLoad:function(t,i,n,o,r){if(!n)return e.console.error("Tile %s failed to load: %s - error: %s",t,t.getUrl(),o),this.viewer.raiseEvent("tile-load-failed",{tile:t,tiledImage:this,time:i,message:o,tileRequest:r}),t.loading=!1,void(t.exists=!1);if(i<this.lastResetTime)return e.console.warn("Ignoring tile %s loaded before reset: %s",t,t.getUrl()),void(t.loading=!1);var s=this,a=function(){var e=s.source.getClosestLevel();s._setTileLoaded(t,n,e,r)};this._midDraw?window.setTimeout(a,1):a()},_setTileLoaded:function(t,i,n,o){var r=0,s=this;function a(){return r++,l}function l(){0==--r&&(t.loading=!1,t.loaded=!0,t.hasTransparency=s.source.hasTransparency(t.context2D,t.getUrl(),t.ajaxHeaders,t.postData),t.context2D||s._tileCache.cacheTile({data:i,tile:t,cutoff:n,tiledImage:s}),s._needsDraw=!0)}this.viewer.raiseEvent("tile-loaded",{tile:t,tiledImage:this,tileRequest:o,get image(){return e.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),i},data:i,getCompletionCallback:a}),a()()},_positionTile:function(t,i,n,o,r){var s=t.bounds.getTopLeft();s.x*=this._scaleSpring.current.value,s.y*=this._scaleSpring.current.value,s.x+=this._xSpring.current.value,s.y+=this._ySpring.current.value;var a=t.bounds.getSize();a.x*=this._scaleSpring.current.value,a.y*=this._scaleSpring.current.value;var l=n.pixelFromPointNoRotate(s,!0),h=n.pixelFromPointNoRotate(s,!1),c=n.deltaPixelsFromPointsNoRotate(a,!0),u=n.deltaPixelsFromPointsNoRotate(a,!1),d=h.plus(u.divide(2)),p=o.squaredDistanceTo(d);i||(c=c.plus(new e.Point(1,1))),t.isRightMost&&this.wrapHorizontal&&(c.x+=.75),t.isBottomMost&&this.wrapVertical&&(c.y+=.75),t.position=l,t.size=c,t.squaredDistance=p,t.visibility=r},_blendTile:function(e,t,i,n,o,r){var s,a,l=1e3*this.blendTime;if(e.blendStart||(e.blendStart=r),s=r-e.blendStart,a=l?Math.min(1,s/l):1,this.alwaysBlend&&(a*=o),e.opacity=a,this.lastDrawn.push(e),1===a)this._setCoverage(this.coverage,n,t,i,!0),this._hasOpaqueTile=!0;else if(s<l)return!0;return!1},_compareTiles:function(e,t){return e?t.visibility>e.visibility||t.visibility===e.visibility&&t.squaredDistance<e.squaredDistance?t:e:t},_drawTiles:function(o){if(0!==this.opacity&&(0!==o.length||this.placeholderFillStyle)){var r,s,a,l=o[0];l&&(r=this.opacity<1||this.compositeOperation&&"source-over"!==this.compositeOperation||!this._isBottomItem()&&this.source.hasTransparency(l.context2D,l.getUrl(),l.ajaxHeaders,l.postData));var h,c=this.viewport.getZoom(!0),u=this.viewportToImageZoom(c);o.length>1&&u>this.smoothTileEdgesMinZoom&&!this.iOSDevice&&this.getRotation(!0)%360==0&&e.supportsCanvas&&this.viewer.useCanvas&&(r=!0,s=l.getScaleForEdgeSmoothing(),a=l.getTranslationForEdgeSmoothing(s,this._drawer.getCanvasSize(!1),this._drawer.getCanvasSize(!0))),r&&(s||(h=this.viewport.viewportToViewerElementRectangle(this.getClippedBounds(!0)).getIntegerBoundingBox(),this._drawer.viewer.viewport.getFlip()&&(this.viewport.getRotation(!0)%360==0&&this.getRotation(!0)%360==0||(h.x=this._drawer.viewer.container.clientWidth-(h.x+h.width))),h=h.times(e.pixelDensityRatio)),this._drawer._clear(!0,h)),s||(this.viewport.getRotation(!0)%360!=0&&this._drawer._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:r}),this.getRotation(!0)%360!=0&&this._drawer._offsetForRotation({degrees:this.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(this._getRotationPoint(!0),!0),useSketch:r}),this.viewport.getRotation(!0)%360==0&&this.getRotation(!0)%360==0&&this._drawer.viewer.viewport.getFlip()&&this._drawer._flip());var d=!1;if(this._clip){this._drawer.saveContext(r);var p=this.imageToViewportRectangle(this._clip,!0);p=p.rotate(-this.getRotation(!0),this._getRotationPoint(!0));var g=this._drawer.viewportToDrawerRectangle(p);s&&(g=g.times(s)),a&&(g=g.translate(a)),this._drawer.setClip(g,r),d=!0}if(this._croppingPolygons){var m=this;this._drawer.saveContext(r);try{var v=this._croppingPolygons.map((function(e){return e.map((function(e){var t=m.imageToViewportCoordinates(e.x,e.y,!0).rotate(-m.getRotation(!0),m._getRotationPoint(!0)),i=m._drawer.viewportCoordToDrawerCoord(t);return s&&(i=i.times(s)),i}))}));this._drawer.clipWithPolygons(v,r)}catch(t){e.console.error(t)}d=!0}if(this.placeholderFillStyle&&!1===this._hasOpaqueTile){var f=this._drawer.viewportToDrawerRectangle(this.getBounds(!0));s&&(f=f.times(s)),a&&(f=f.translate(a));var y;y="function"==typeof this.placeholderFillStyle?this.placeholderFillStyle(this,this._drawer.context):this.placeholderFillStyle,this._drawer.drawRectangle(f,y,r)}var w=function(o){if("number"==typeof o)return n(o);if(!o||!e.Browser)return t;var r=o[e.Browser.vendor];return i(r)&&(r=o["*"]),n(r)}(this.subPixelRoundingForTransparency),T=!1;w===e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS?T=!0:w===e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&(T=!(this.viewer&&this.viewer.isAnimating()));for(var x=o.length-1;x>=0;x--)l=o[x],this._drawer.drawTile(l,this._drawingHandler,r,s,a,T,this.source),l.beingDrawn=!0,this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:this,tile:l});d&&this._drawer.restoreContext(r),s||(this.getRotation(!0)%360!=0&&this._drawer._restoreRotationChanges(r),this.viewport.getRotation(!0)%360!=0&&this._drawer._restoreRotationChanges(r)),r&&(s&&(this.viewport.getRotation(!0)%360!=0&&this._drawer._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:!1}),this.getRotation(!0)%360!=0&&this._drawer._offsetForRotation({degrees:this.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(this._getRotationPoint(!0),!0),useSketch:!1})),this._drawer.blendSketch({opacity:this.opacity,scale:s,translate:a,compositeOperation:this.compositeOperation,bounds:h}),s&&(this.getRotation(!0)%360!=0&&this._drawer._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!=0&&this._drawer._restoreRotationChanges(!1))),s||this.viewport.getRotation(!0)%360==0&&this.getRotation(!0)%360==0&&this._drawer.viewer.viewport.getFlip()&&this._drawer._flip(),this._drawDebugInfo(o)}},_drawDebugInfo:function(t){if(this.debugMode)for(var i=t.length-1;i>=0;i--){var n=t[i];try{this._drawer.drawDebugInfo(n,t.length,i,this)}catch(t){e.console.error(t)}}},_providesCoverage:function(e,t,i,n){var o,r,s,a;if(!e[t])return!1;if(void 0===i||void 0===n){for(s in o=e[t])if(Object.prototype.hasOwnProperty.call(o,s))for(a in r=o[s])if(Object.prototype.hasOwnProperty.call(r,a)&&!r[a])return!1;return!0}return void 0===e[t][i]||void 0===e[t][i][n]||!0===e[t][i][n]},_isCovered:function(e,t,i,n){return void 0===i||void 0===n?this._providesCoverage(e,t+1):this._providesCoverage(e,t+1,2*i,2*n)&&this._providesCoverage(e,t+1,2*i,2*n+1)&&this._providesCoverage(e,t+1,2*i+1,2*n)&&this._providesCoverage(e,t+1,2*i+1,2*n+1)},_setCoverage:function(t,i,n,o,r){t[i]?(t[i][n]||(t[i][n]={}),t[i][n][o]=r):e.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",i)},_resetCoverage:function(e,t){e[t]={}}});var t=e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function i(t){return t!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&t!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&t!==e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function n(e){return i(e)?t:e}}(s),function(e){var t=function(t){e.console.assert(t,"[TileCache.cacheTile] options is required"),e.console.assert(t.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(t.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=t.tile,this.tiledImage=t.tiledImage},i=function(t){e.console.assert(t,"[ImageRecord] options is required"),e.console.assert(t.data,"[ImageRecord] options.data is required"),this._tiles=[],t.create.apply(null,[this,t.data,t.ownerTile]),this._destroyImplementation=t.destroy.bind(null,this),this.getImage=t.getImage.bind(null,this),this.getData=t.getData.bind(null,this),this.getRenderedContext=t.getRenderedContext.bind(null,this)};i.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(t){e.console.assert(t,"[ImageRecord.addTile] tile is required"),this._tiles.push(t)},removeTile:function(t){for(var i=0;i<this._tiles.length;i++)if(this._tiles[i]===t)return void this._tiles.splice(i,1);e.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",t)},getTileCount:function(){return this._tiles.length}},e.TileCache=function(t){t=t||{},this._maxImageCacheCount=t.maxImageCacheCount||e.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},e.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(n){e.console.assert(n,"[TileCache.cacheTile] options is required"),e.console.assert(n.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(n.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),e.console.assert(n.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var o=n.cutoff||0,r=this._tilesLoaded.length,s=this._imagesLoaded[n.tile.cacheKey];if(s||(n.data||(e.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future."),n.data=n.image),e.console.assert(n.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),s=this._imagesLoaded[n.tile.cacheKey]=new i({data:n.data,ownerTile:n.tile,create:n.tiledImage.source.createTileCache,destroy:n.tiledImage.source.destroyTileCache,getImage:n.tiledImage.source.getTileCacheDataAsImage,getData:n.tiledImage.source.getTileCacheData,getRenderedContext:n.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),s.addTile(n.tile),n.tile.cacheImageRecord=s,this._imagesLoadedCount>this._maxImageCacheCount){for(var a,l,h,c,u,d,p=null,g=-1,m=null,v=this._tilesLoaded.length-1;v>=0;v--)(a=(d=this._tilesLoaded[v]).tile).level<=o||a.beingDrawn||(p?(c=a.lastTouchTime,l=p.lastTouchTime,u=a.level,h=p.level,(c<l||c===l&&u>h)&&(p=a,g=v,m=d)):(p=a,g=v,m=d));p&&g>=0&&(this._unloadTile(m),r=g)}this._tilesLoaded[r]=new t({tile:n.tile,tiledImage:n.tiledImage})},clearTilesFor:function(t){var i;e.console.assert(t,"[TileCache.clearTilesFor] tiledImage is required");for(var n=0;n<this._tilesLoaded.length;++n)(i=this._tilesLoaded[n]).tiledImage===t&&(this._unloadTile(i),this._tilesLoaded.splice(n,1),n--)},getImageRecord:function(t){return e.console.assert(t,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[t]},_unloadTile:function(t){e.console.assert(t,"[TileCache._unloadTile] tileRecord is required");var i=t.tile,n=t.tiledImage;i.unload(),i.cacheImageRecord=null;var o=this._imagesLoaded[i.cacheKey];o.removeTile(i),o.getTileCount()||(o.destroy(),delete this._imagesLoaded[i.cacheKey],this._imagesLoadedCount--),n.viewer.raiseEvent("tile-unloaded",{tile:i,tiledImage:n})}}}(s),function(e){e.World=function(t){var i=this;e.console.assert(t.viewer,"[World] options.viewer is required"),e.EventSource.call(this),this.viewer=t.viewer,this._items=[],this._needsDraw=!1,this._autoRefigureSizes=!0,this._needsSizesFigured=!1,this._delegatedFigureSizes=function(e){i._autoRefigureSizes?i._figureSizes():i._needsSizesFigured=!0},this._figureSizes()},e.extend(e.World.prototype,e.EventSource.prototype,{addItem:function(t,i){if(e.console.assert(t,"[World.addItem] item is required"),e.console.assert(t instanceof e.TiledImage,"[World.addItem] only TiledImages supported at this time"),void 0!==(i=i||{}).index){var n=Math.max(0,Math.min(this._items.length,i.index));this._items.splice(n,0,t)}else this._items.push(t);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0,this._needsDraw=!0,t.addHandler("bounds-change",this._delegatedFigureSizes),t.addHandler("clip-change",this._delegatedFigureSizes),this.raiseEvent("add-item",{item:t})},getItemAt:function(t){return e.console.assert(void 0!==t,"[World.getItemAt] index is required"),this._items[t]},getIndexOfItem:function(t){return e.console.assert(t,"[World.getIndexOfItem] item is required"),e.indexOf(this._items,t)},getItemCount:function(){return this._items.length},setItemIndex:function(t,i){e.console.assert(t,"[World.setItemIndex] item is required"),e.console.assert(void 0!==i,"[World.setItemIndex] index is required");var n=this.getIndexOfItem(t);if(i>=this._items.length)throw new Error("Index bigger than number of layers.");i!==n&&-1!==n&&(this._items.splice(n,1),this._items.splice(i,0,t),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:t,previousIndex:n,newIndex:i}))},removeItem:function(t){e.console.assert(t,"[World.removeItem] item is required");var i=e.indexOf(this._items,t);-1!==i&&(t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy(),this._items.splice(i,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(t))},removeAll:function(){var e,t;for(this.viewer._cancelPendingImages(),t=0;t<this._items.length;t++)(e=this._items[t]).removeHandler("bounds-change",this._delegatedFigureSizes),e.removeHandler("clip-change",this._delegatedFigureSizes),e.destroy();var i=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,t=0;t<i.length;t++)e=i[t],this._raiseRemoveItem(e)},resetItems:function(){for(var e=0;e<this._items.length;e++)this._items[e].reset()},update:function(){for(var e=!1,t=0;t<this._items.length;t++)e=this._items[t].update()||e;return e},draw:function(){for(var e=0;e<this._items.length;e++)this._items[e].draw();this._needsDraw=!1},needsDraw:function(){for(var e=0;e<this._items.length;e++)if(this._items[e].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(e){this._autoRefigureSizes=e,e&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(t){var i,n=(t=t||{}).immediately||!1,o=t.layout||e.DEFAULT_SETTINGS.collectionLayout,r=t.rows||e.DEFAULT_SETTINGS.collectionRows,s=t.columns||e.DEFAULT_SETTINGS.collectionColumns,a=t.tileSize||e.DEFAULT_SETTINGS.collectionTileSize,l=a+(t.tileMargin||e.DEFAULT_SETTINGS.collectionTileMargin);i=!t.rows&&s?s:Math.ceil(this._items.length/r);var h,c,u,d,p,g=0,m=0;this.setAutoRefigureSizes(!1);for(var v=0;v<this._items.length;v++)v&&v%i==0&&("horizontal"===o?(m+=l,g=0):(g+=l,m=0)),d=(u=(c=(h=this._items[v]).getBounds()).width>c.height?a:a*(c.width/c.height))*(c.height/c.width),p=new e.Point(g+(a-u)/2,m+(a-d)/2),h.setPosition(p,n),h.setWidth(u,n),"horizontal"===o?g+=l:m+=l;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var t=this._homeBounds?this._homeBounds.clone():null,i=this._contentSize?this._contentSize.clone():null,n=this._contentFactor||0;if(this._items.length){var o=this._items[0],r=o.getBounds();this._contentFactor=o.getContentSize().x/r.width;for(var s=o.getClippedBounds().getBoundingBox(),a=s.x,l=s.y,h=s.x+s.width,c=s.y+s.height,u=1;u<this._items.length;u++)r=(o=this._items[u]).getBounds(),this._contentFactor=Math.max(this._contentFactor,o.getContentSize().x/r.width),s=o.getClippedBounds().getBoundingBox(),a=Math.min(a,s.x),l=Math.min(l,s.y),h=Math.max(h,s.x+s.width),c=Math.max(c,s.y+s.height);this._homeBounds=new e.Rect(a,l,h-a,c-l),this._contentSize=new e.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}else this._homeBounds=new e.Rect(0,0,1,1),this._contentSize=new e.Point(1,1),this._contentFactor=1;this._contentFactor===n&&this._homeBounds.equals(t)&&this._contentSize.equals(i)||this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(e){this.raiseEvent("remove-item",{item:e})}})}(s)},7283:(e,t,i)=>{"use strict";i.d(t,{y:()=>o});const n=e=>{let t;const i=new Set,n=(e,n)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=n?n:"object"!=typeof o||null===o)?o:Object.assign({},t,o),i.forEach((i=>i(t,e)))}},o=()=>t,r={setState:n,getState:o,getInitialState:()=>s,subscribe:e=>(i.add(e),()=>i.delete(e))},s=t=e(n,o,r);return r},o=e=>e?n(e):n}}]);