import{c6 as st,q as ot,aE as K,u as te,F as Xe,ao as We,b3 as ve,t as ae,c3 as it,I as F,bx as q,bX as le,s as Pe,v as ge,c9 as he,aR as Ye,bz as He,bp as Be,c7 as fe,c8 as Fe,H as Ke,cz as at,cb as lt,d7 as ht}from"./index-pVvkWKzi.js";import{c as ut,a as ct}from"./_commonjsHelpers-C4iS2aBk.js";import{V as dt}from"./ChildTreeSearchButton-DaF4HIkT.js";import{L as ft}from"./LoadingSpinner-BjU99GiU.js";import{V as gt}from"./VSlider-R4SIfaMv.js";let Ge,nt;function pt({from_date:E,to_date:_},e){return E=Qe(E,e),_=Qe(_,e),E===null&&_!==null?E=_:E!==null&&_===null&&(_=E),{from:E,to:_}}function Qe(E,_=609){if(E)if(E.charAt(0)=="-"){let e;return E.match(/-00\d{4}-\d{2}-\d{2}T./)?(e=Ue(mt(E)),e.setFullYear(e.getFullYear()-1)):(e=Ue(E.substring(1)),e.setFullYear(e.getFullYear()+1)),{date:e,bc_ad:"before"}}else{let e=Ue(E);return e.getFullYear()==0?(e.setFullYear(e.getFullYear()-1),{date:e,bc_ad:"before"}):e.getFullYear()>_?{date:e,bc_ad:"none"}:{date:e,bc_ad:"after"}}return null}function Ue(E){return new Date(E)}function mt(E){if(console.log(E),E.length<=5&&E.charAt(0)=="-"){let _=parseInt(E.substring(1));return _+=1,String(_).padStart(4,"0")}else return E}function vt({from:E,to:_,txt:e},t){if(/^-?\d{4}$/.test(e)||t||yt(E,_)){let o=!wt(E.date,_.date);return Je(o,xt,E,_)}else{let o=!Tt(E.date,_.date);return Je(o,_t,E,_)}}function yt(E,_){return E.date.getMonth()==0&&E.date.getDate()==1&&_.date.getMonth()==11&&_.date.getDate()==31}function Je(E,_,e,t){return E?_(e)+" - "+_(t):_(e)}function wt(E,_){return E&&_&&E.getFullYear()==_.getFullYear()}function Tt(E,_){return E&&_&&E.getFullYear()==_.getFullYear()&&E.getMonth()==_.getMonth()&&E.getDate()==_.getDate()}function xt(E){return(Math.abs(E.date.getFullYear())+Ge("dating."+E.bc_ad)).trim()}function _t(E){return E.date.toLocaleDateString(nt)+Ge("dating."+E.bc_ad)}const St=609;function Et(E,_,e,t){Ge=e,nt=t;const{from:i,to:o}=pt(E,St);return i===null&&o===null?"":vt({from:i,to:o,txt:E.from_txt},_)}const Pt={key:0},Ct={key:1},bt={key:0},Rt={key:1},Jt={__name:"Dating",props:{data:{type:Object,default:()=>{}},yearOnly:{type:Boolean,default:!1},asHeading:{type:Boolean,default:!1},inline:{type:Boolean,default:!1}},setup(E){const{t:_,locale:e}=st(),t=E,i=ot(()=>Et(t.data,t.yearOnly,_,e));return(o,h)=>E.data?(K(),te("span",Pt,[E.asHeading?(K(),te(Xe,{key:0},[E.data.text?(K(),te("h5",{key:0,class:We(E.inline?"d-inline":"")},ve(E.data.text),3)):(K(),te("h5",Ct,ve(i.value),1))],64)):(K(),te(Xe,{key:1},[E.data.text?(K(),te("span",bt,ve(E.data.text),1)):(K(),te("span",Rt,ve(i.value),1))],64))])):ae("",!0)}};var rt={exports:{}};(function(E){//! openseadragon 4.1.1
//! Built on 2024-04-01
//! Git commit: v4.1.1-0-f90d9814
//! http://openseadragon.github.io
//! License: http://openseadragon.github.io/license/
function _(e){return new _.Viewer(e)}(function(e){e.version={versionStr:"4.1.1",major:parseInt("4",10),minor:parseInt("1",10),revision:parseInt("1",10)};var t={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object AsyncFunction]":"function","[object Promise]":"promise","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;e.isFunction=function(h){return e.type(h)==="function"},e.isArray=Array.isArray||function(h){return e.type(h)==="array"},e.isWindow=function(h){return h&&typeof h=="object"&&"setInterval"in h},e.type=function(h){return h==null?String(h):t[i.call(h)]||"object"},e.isPlainObject=function(h){if(!h||_.type(h)!=="object"||h.nodeType||e.isWindow(h)||h.constructor&&!o.call(h,"constructor")&&!o.call(h.constructor.prototype,"isPrototypeOf"))return!1;var n;for(var r in h)n=r;return n===void 0||o.call(h,n)},e.isEmptyObject=function(h){for(var n in h)return!1;return!0},e.freezeObject=function(h){return Object.freeze?e.freezeObject=Object.freeze:e.freezeObject=function(n){return n},e.freezeObject(h)},e.supportsCanvas=function(){var h=document.createElement("canvas");return!!(e.isFunction(h.getContext)&&h.getContext("2d"))}(),e.isCanvasTainted=function(h){var n=!1;try{h.getContext("2d").getImageData(0,0,1,1)}catch{n=!0}return n},e.supportsAddEventListener=function(){return!!(document.documentElement.addEventListener&&document.addEventListener)}(),e.supportsRemoveEventListener=function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)}(),e.supportsEventListenerOptions=function(){var h=0;if(e.supportsAddEventListener)try{var n={get capture(){return h++,!1},get once(){return h++,!1},get passive(){return h++,!1}};window.addEventListener("test",null,n),window.removeEventListener("test",null,n)}catch{h=0}return h>=3}(),e.getCurrentPixelDensityRatio=function(){if(e.supportsCanvas){var h=document.createElement("canvas").getContext("2d"),n=window.devicePixelRatio||1,r=h.webkitBackingStorePixelRatio||h.mozBackingStorePixelRatio||h.msBackingStorePixelRatio||h.oBackingStorePixelRatio||h.backingStorePixelRatio||1;return Math.max(n,1)/r}else return 1},e.pixelDensityRatio=e.getCurrentPixelDensityRatio()})(_),function(e){e.extend=function(){var r,s,l,d,f,v,y=arguments[0]||{},T=arguments.length,w=!1,x=1;for(typeof y=="boolean"&&(w=y,y=arguments[1]||{},x=2),typeof y!="object"&&!_.isFunction(y)&&(y={}),T===x&&(y=this,--x);x<T;x++)if(r=arguments[x],r!==null||r!==void 0)for(s in r){var C=Object.getOwnPropertyDescriptor(r,s);if(C!==void 0){if(C.get||C.set){Object.defineProperty(y,s,C);continue}d=C.value}else{e.console.warn('Could not copy inherited property "'+s+'".');continue}y!==d&&(w&&d&&(_.isPlainObject(d)||(f=_.isArray(d)))?(l=y[s],f?(f=!1,v=l&&_.isArray(l)?l:[]):v=l&&_.isPlainObject(l)?l:{},y[s]=_.extend(w,v,d)):d!==void 0&&(y[s]=d))}return y};var t=function(){if(typeof navigator!="object")return!1;var r=navigator.userAgent;return typeof r!="string"?!1:r.indexOf("iPhone")!==-1||r.indexOf("iPad")!==-1||r.indexOf("iPod")!==-1};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:t(),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,tileRetryMax:0,tileRetryDelay:2500,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(r,s){return function(){var l=arguments;return l===void 0&&(l=[]),s.apply(r,l)}},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(r){return e._viewers.get(this.getElement(r))},getElement:function(r){return typeof r=="string"&&(r=document.getElementById(r)),r},getElementPosition:function(r){var s=new e.Point,l,d;for(r=e.getElement(r),l=e.getElementStyle(r).position==="fixed",d=n(r,l);d;)s.x+=r.offsetLeft,s.y+=r.offsetTop,l&&(s=s.plus(e.getPageScroll())),r=d,l=e.getElementStyle(r).position==="fixed",d=n(r,l);return s},getElementOffset:function(r){r=e.getElement(r);var s=r&&r.ownerDocument,l,d,f={top:0,left:0};return s?(l=s.documentElement,typeof r.getBoundingClientRect<"u"&&(f=r.getBoundingClientRect()),d=s===s.window?s:s.nodeType===9?s.defaultView||s.parentWindow:!1,new e.Point(f.left+(d.pageXOffset||l.scrollLeft)-(l.clientLeft||0),f.top+(d.pageYOffset||l.scrollTop)-(l.clientTop||0))):new e.Point},getElementSize:function(r){return r=e.getElement(r),new e.Point(r.clientWidth,r.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(r){return r=e.getElement(r),r.currentStyle}:function(r){return r=e.getElement(r),window.getComputedStyle(r,"")},getCssPropertyWithVendorPrefix:function(r){var s={};return e.getCssPropertyWithVendorPrefix=function(l){if(s[l]!==void 0)return s[l];var d=document.createElement("div").style,f=null;if(d[l]!==void 0)f=l;else for(var v=["Webkit","Moz","MS","O","webkit","moz","ms","o"],y=e.capitalizeFirstLetter(l),T=0;T<v.length;T++){var w=v[T]+y;if(d[w]!==void 0){f=w;break}}return s[l]=f,f},e.getCssPropertyWithVendorPrefix(r)},capitalizeFirstLetter:function(r){return r.charAt(0).toUpperCase()+r.slice(1)},positiveModulo:function(r,s){var l=r%s;return l<0&&(l+=s),l},pointInElement:function(r,s){r=e.getElement(r);var l=e.getElementOffset(r),d=e.getElementSize(r);return s.x>=l.x&&s.x<l.x+d.x&&s.y<l.y+d.y&&s.y>=l.y},getMousePosition:function(r){if(typeof r.pageX=="number")e.getMousePosition=function(s){var l=new e.Point;return l.x=s.pageX,l.y=s.pageY,l};else if(typeof r.clientX=="number")e.getMousePosition=function(s){var l=new e.Point;return l.x=s.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,l.y=s.clientY+document.body.scrollTop+document.documentElement.scrollTop,l};else throw new Error("Unknown event mouse position, no known technique.");return e.getMousePosition(r)},getPageScroll:function(){var r=document.documentElement||{},s=document.body||{};if(typeof window.pageXOffset=="number")e.getPageScroll=function(){return new e.Point(window.pageXOffset,window.pageYOffset)};else if(s.scrollLeft||s.scrollTop)e.getPageScroll=function(){return new e.Point(document.body.scrollLeft,document.body.scrollTop)};else if(r.scrollLeft||r.scrollTop)e.getPageScroll=function(){return new e.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)};else return new e.Point(0,0);return e.getPageScroll()},setPageScroll:function(r){if(typeof window.scrollTo<"u")e.setPageScroll=function(d){window.scrollTo(d.x,d.y)};else{var s=e.getPageScroll();if(s.x===r.x&&s.y===r.y)return;document.body.scrollLeft=r.x,document.body.scrollTop=r.y;var l=e.getPageScroll();if(l.x!==s.x&&l.y!==s.y){e.setPageScroll=function(d){document.body.scrollLeft=d.x,document.body.scrollTop=d.y};return}if(document.documentElement.scrollLeft=r.x,document.documentElement.scrollTop=r.y,l=e.getPageScroll(),l.x!==s.x&&l.y!==s.y){e.setPageScroll=function(d){document.documentElement.scrollLeft=d.x,document.documentElement.scrollTop=d.y};return}e.setPageScroll=function(d){}}e.setPageScroll(r)},getWindowSize:function(){var r=document.documentElement||{},s=document.body||{};if(typeof window.innerWidth=="number")e.getWindowSize=function(){return new e.Point(window.innerWidth,window.innerHeight)};else if(r.clientWidth||r.clientHeight)e.getWindowSize=function(){return new e.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(s.clientWidth||s.clientHeight)e.getWindowSize=function(){return new e.Point(document.body.clientWidth,document.body.clientHeight)};else throw new Error("Unknown window size, no known technique.");return e.getWindowSize()},makeCenteredNode:function(r){r=e.getElement(r);var s=[e.makeNeutralElement("div"),e.makeNeutralElement("div"),e.makeNeutralElement("div")];return e.extend(s[0].style,{display:"table",height:"100%",width:"100%"}),e.extend(s[1].style,{display:"table-row"}),e.extend(s[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),s[0].appendChild(s[1]),s[1].appendChild(s[2]),s[2].appendChild(r),s[0]},makeNeutralElement:function(r){var s=document.createElement(r),l=s.style;return l.background="transparent none",l.border="none",l.margin="0px",l.padding="0px",l.position="static",s},now:function(){return Date.now?e.now=Date.now:e.now=function(){return new Date().getTime()},e.now()},makeTransparentImage:function(r){var s=e.makeNeutralElement("img");return s.src=r,s},setElementOpacity:function(r,s,l){var d,f;r=e.getElement(r),l&&!e.Browser.alpha&&(s=Math.round(s)),e.Browser.opacity?r.style.opacity=s<1?s:"":s<1?(d=Math.round(100*s),f="alpha(opacity="+d+")",r.style.filter=f):r.style.filter=""},setElementTouchActionNone:function(r){r=e.getElement(r),typeof r.style.touchAction<"u"?r.style.touchAction="none":typeof r.style.msTouchAction<"u"&&(r.style.msTouchAction="none")},setElementPointerEvents:function(r,s){r=e.getElement(r),typeof r.style<"u"&&typeof r.style.pointerEvents<"u"&&(r.style.pointerEvents=s)},setElementPointerEventsNone:function(r){e.setElementPointerEvents(r,"none")},addClass:function(r,s){r=e.getElement(r),r.className?(" "+r.className+" ").indexOf(" "+s+" ")===-1&&(r.className+=" "+s):r.className=s},indexOf:function(r,s,l){return Array.prototype.indexOf?this.indexOf=function(d,f,v){return d.indexOf(f,v)}:this.indexOf=function(d,f,v){var y,T=v||0,w;if(!d)throw new TypeError;if(w=d.length,w===0||T>=w)return-1;for(T<0&&(T=w-Math.abs(T)),y=T;y<w;y++)if(d[y]===f)return y;return-1},this.indexOf(r,s,l)},removeClass:function(r,s){var l,d=[],f;for(r=e.getElement(r),l=r.className.split(/\s+/),f=0;f<l.length;f++)l[f]&&l[f]!==s&&d.push(l[f]);r.className=d.join(" ")},normalizeEventListenerOptions:function(r){var s;return typeof r<"u"?typeof r=="boolean"?s=e.supportsEventListenerOptions?{capture:r}:r:s=e.supportsEventListenerOptions?r:typeof r.capture<"u"?r.capture:!1:s=e.supportsEventListenerOptions?{capture:!1}:!1,s},addEvent:function(){if(e.supportsAddEventListener)return function(r,s,l,d){d=e.normalizeEventListenerOptions(d),r=e.getElement(r),r.addEventListener(s,l,d)};if(document.documentElement.attachEvent&&document.attachEvent)return function(r,s,l){r=e.getElement(r),r.attachEvent("on"+s,l)};throw new Error("No known event model.")}(),removeEvent:function(){if(e.supportsRemoveEventListener)return function(r,s,l,d){d=e.normalizeEventListenerOptions(d),r=e.getElement(r),r.removeEventListener(s,l,d)};if(document.documentElement.detachEvent&&document.detachEvent)return function(r,s,l){r=e.getElement(r),r.detachEvent("on"+s,l)};throw new Error("No known event model.")}(),cancelEvent:function(r){r.preventDefault()},eventIsCanceled:function(r){return r.defaultPrevented},stopEvent:function(r){r.stopPropagation()},createCallback:function(r,s){var l=[],d;for(d=2;d<arguments.length;d++)l.push(arguments[d]);return function(){var f=l.concat([]),v;for(v=0;v<arguments.length;v++)f.push(arguments[v]);return s.apply(r,f)}},getUrlParameter:function(r){var s=h[r];return s||null},getUrlProtocol:function(r){var s=r.match(/^([a-z]+:)\/\//i);return s===null?window.location.protocol:s[1].toLowerCase()},createAjaxRequest:function(r){var s;try{s=!!new ActiveXObject("Microsoft.XMLHTTP")}catch{s=!1}if(s)window.XMLHttpRequest?e.createAjaxRequest=function(l){return l?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest}:e.createAjaxRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP")};else if(window.XMLHttpRequest)e.createAjaxRequest=function(){return new XMLHttpRequest};else throw new Error("Browser doesn't support XMLHttpRequest.");return e.createAjaxRequest(r)},makeAjaxRequest:function(r,s,l){var d,f,v,y;e.isPlainObject(r)&&(s=r.success,l=r.error,d=r.withCredentials,f=r.headers,v=r.responseType||null,y=r.postData||null,r=r.url);var T=e.getUrlProtocol(r),w=e.createAjaxRequest(T==="file:");if(!e.isFunction(s))throw new Error("makeAjaxRequest requires a success callback");w.onreadystatechange=function(){w.readyState===4&&(w.onreadystatechange=function(){},w.status>=200&&w.status<300||w.status===0&&T!=="http:"&&T!=="https:"?s(w):e.isFunction(l)?l(w):e.console.error("AJAX request returned %d: %s",w.status,r))};var x=y?"POST":"GET";try{if(w.open(x,r,!0),v&&(w.responseType=v),f)for(var C in f)Object.prototype.hasOwnProperty.call(f,C)&&f[C]&&w.setRequestHeader(C,f[C]);d&&(w.withCredentials=!0),w.send(y)}catch(D){e.console.error("%s while making AJAX request: %s",D.name,D.message),w.onreadystatechange=function(){},e.isFunction(l)&&l(w,D)}return w},jsonp:function(r){var s,l=r.url,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement,f=r.callbackName||"openseadragon"+e.now(),v=window[f],y="$1"+f+"$2",T=r.param||"callback",w=r.callback;l=l.replace(/(=)\?(&|$)|\?\?/i,y),l+=(/\?/.test(l)?"&":"?")+T+"="+f,window[f]=function(x){if(v)window[f]=v;else try{delete window[f]}catch{}w&&e.isFunction(w)&&w(x)},s=document.createElement("script"),(r.async!==void 0||r.async!==!1)&&(s.async="async"),r.scriptCharset&&(s.charset=r.scriptCharset),s.src=l,s.onload=s.onreadystatechange=function(x,C){(C||!s.readyState||/loaded|complete/.test(s.readyState))&&(s.onload=s.onreadystatechange=null,d&&s.parentNode&&d.removeChild(s),s=void 0)},d.insertBefore(s,d.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(r){if(window.DOMParser)e.parseXml=function(s){var l=null,d;return d=new DOMParser,l=d.parseFromString(s,"text/xml"),l};else if(window.ActiveXObject)e.parseXml=function(s){var l=null;return l=new ActiveXObject("Microsoft.XMLDOM"),l.async=!1,l.loadXML(s),l};else throw new Error("Browser doesn't support XML DOM.");return e.parseXml(r)},parseJSON:function(r){return e.parseJSON=window.JSON.parse,e.parseJSON(r)},imageFormatSupported:function(r){return r=r||"",!!o[r.toLowerCase()]},setImageFormatsSupported:function(r){e.extend(o,r)}});var i=function(r){};e.console=window.console||{log:i,debug:i,info:i,warn:i,error:i,assert:i},e.Browser={vendor:e.BROWSERS.UNKNOWN,version:0,alpha:!0};var o={bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1},h={};(function(){var r=navigator.appVersion,s=navigator.userAgent,l;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(s.substring(s.indexOf("MSIE")+5,s.indexOf(";",s.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(s.indexOf("Edge")>=0?(e.Browser.vendor=e.BROWSERS.EDGE,e.Browser.version=parseFloat(s.substring(s.indexOf("Edge")+5))):s.indexOf("Edg")>=0?(e.Browser.vendor=e.BROWSERS.CHROMEEDGE,e.Browser.version=parseFloat(s.substring(s.indexOf("Edg")+4))):s.indexOf("Firefox")>=0?(e.Browser.vendor=e.BROWSERS.FIREFOX,e.Browser.version=parseFloat(s.substring(s.indexOf("Firefox")+8))):s.indexOf("Safari")>=0?(e.Browser.vendor=s.indexOf("Chrome")>=0?e.BROWSERS.CHROME:e.BROWSERS.SAFARI,e.Browser.version=parseFloat(s.substring(s.substring(0,s.indexOf("Safari")).lastIndexOf("/")+1,s.indexOf("Safari")))):(l=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),l.exec(s)!==null&&(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(r);break}var d=window.location.search.substring(1),f=d.split("&"),v,y,T;for(T=0;T<f.length;T++)if(v=f[T],y=v.indexOf("="),y>0){var w=v.substring(0,y),x=v.substring(y+1);try{h[w]=decodeURIComponent(x)}catch{e.console.error("Ignoring malformed URL parameter: %s=%s",w,x)}}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(r){var s=r.requestAnimationFrame||r.mozRequestAnimationFrame||r.webkitRequestAnimationFrame||r.msRequestAnimationFrame,l=r.cancelAnimationFrame||r.mozCancelAnimationFrame||r.webkitCancelAnimationFrame||r.msCancelAnimationFrame;if(s&&l)e.requestAnimationFrame=function(){return s.apply(r,arguments)},e.cancelAnimationFrame=function(){return l.apply(r,arguments)};else{var d=[],f=[],v=0,y;e.requestAnimationFrame=function(T){return d.push([++v,T]),y||(y=setInterval(function(){if(d.length){var w=e.now(),x=f;for(f=d,d=x;f.length;)f.shift()[1](w)}else clearInterval(y),y=void 0},1e3/50)),v},e.cancelAnimationFrame=function(T){var w,x;for(w=0,x=d.length;w<x;w+=1)if(d[w][0]===T){d.splice(w,1);return}for(w=0,x=f.length;w<x;w+=1)if(f[w][0]===T){f.splice(w,1);return}}}}(window);function n(r,s){return s&&r!==document.body?document.body:r.offsetParent}}(_),function(e,t){E.exports?E.exports=t():e.OpenSeadragon=t()}(ut,function(){return _}),function(e){var t={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.fullscreenElement},t.requestFullScreen=function(i){return i.requestFullscreen()},t.exitFullScreen=function(){document.exitFullscreen()},t.fullScreenEventName="fullscreenchange",t.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.msFullscreenElement},t.requestFullScreen=function(i){return i.msRequestFullscreen()},t.exitFullScreen=function(){document.msExitFullscreen()},t.fullScreenEventName="MSFullscreenChange",t.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.webkitFullscreenElement},t.requestFullScreen=function(i){return i.webkitRequestFullscreen()},t.exitFullScreen=function(){document.webkitExitFullscreen()},t.fullScreenEventName="webkitfullscreenchange",t.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},t.requestFullScreen=function(i){return i.webkitRequestFullScreen()},t.exitFullScreen=function(){document.webkitCancelFullScreen()},t.fullScreenEventName="webkitfullscreenchange",t.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.mozFullScreenElement},t.requestFullScreen=function(i){return i.mozRequestFullScreen()},t.exitFullScreen=function(){document.mozCancelFullScreen()},t.fullScreenEventName="mozfullscreenchange",t.fullScreenErrorEventName="mozfullscreenerror"),t.isFullScreen=function(){return t.getFullScreenElement()!==null},t.cancelFullScreen=function(){e.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),t.exitFullScreen()},e.extend(e,t)}(_),function(e){e.EventSource=function(){this.events={}},e.EventSource.prototype={addOnceHandler:function(t,i,o,h,n){var r=this;h=h||1;var s=0,l=function(d){return s++,s===h&&r.removeHandler(t,l),i(d)};this.addHandler(t,l,o,n)},addHandler:function(t,i,o,h){var n=this.events[t];if(n||(this.events[t]=n=[]),i&&e.isFunction(i)){var r=n.length,s={handler:i,userData:o||null,priority:h||0};for(n[r]=s;r>0&&n[r-1].priority<n[r].priority;)n[r]=n[r-1],n[r-1]=s,r--}},removeHandler:function(t,i){var o=this.events[t],h=[],n;if(o&&e.isArray(o)){for(n=0;n<o.length;n++)o[n].handler!==i&&h.push(o[n]);this.events[t]=h}},numberOfHandlers:function(t){var i=this.events[t];return i?i.length:0},removeAllHandlers:function(t){if(t)this.events[t]=[];else for(var i in this.events)this.events[i]=[]},getHandler:function(t){var i=this.events[t];return!i||!i.length?null:(i=i.length===1?[i[0]]:Array.apply(null,i),function(o,h){var n,r=i.length;for(n=0;n<r;n++)i[n]&&(h.eventSource=o,h.userData=i[n].userData,i[n].handler(h))})},raiseEvent:function(t,i){var o=this.getHandler(t);if(o)return o(this,i||{})}}}(_),function(e){var t={};e.MouseTracker=function(c){var u=arguments;e.isPlainObject(c)||(c={element:u[0],clickTimeThreshold:u[1],clickDistThreshold:u[2]}),this.hash=Math.random(),this.element=e.getElement(c.element),this.clickTimeThreshold=c.clickTimeThreshold||e.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=c.clickDistThreshold||e.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=c.dblClickTimeThreshold||e.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=c.dblClickDistThreshold||e.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=c.userData||null,this.stopDelay=c.stopDelay||50,this.preProcessEventHandler=c.preProcessEventHandler||null,this.contextMenuHandler=c.contextMenuHandler||null,this.enterHandler=c.enterHandler||null,this.leaveHandler=c.leaveHandler||null,this.exitHandler=c.exitHandler||null,this.overHandler=c.overHandler||null,this.outHandler=c.outHandler||null,this.pressHandler=c.pressHandler||null,this.nonPrimaryPressHandler=c.nonPrimaryPressHandler||null,this.releaseHandler=c.releaseHandler||null,this.nonPrimaryReleaseHandler=c.nonPrimaryReleaseHandler||null,this.moveHandler=c.moveHandler||null,this.scrollHandler=c.scrollHandler||null,this.clickHandler=c.clickHandler||null,this.dblClickHandler=c.dblClickHandler||null,this.dragHandler=c.dragHandler||null,this.dragEndHandler=c.dragEndHandler||null,this.pinchHandler=c.pinchHandler||null,this.stopHandler=c.stopHandler||null,this.keyDownHandler=c.keyDownHandler||null,this.keyUpHandler=c.keyUpHandler||null,this.keyHandler=c.keyHandler||null,this.focusHandler=c.focusHandler||null,this.blurHandler=c.blurHandler||null;var g=this;t[this.hash]={click:function(m){D(g,m)},dblclick:function(m){M(g,m)},keydown:function(m){V(g,m)},keyup:function(m){N(g,m)},keypress:function(m){U(g,m)},focus:function(m){k(g,m)},blur:function(m){G(g,m)},contextmenu:function(m){ee(g,m)},wheel:function(m){Q(g,m)},mousewheel:function(m){J(g,m)},DOMMouseScroll:function(m){J(g,m)},MozMousePixelScroll:function(m){J(g,m)},losecapture:function(m){ce(g,m)},mouseenter:function(m){A(g,m)},mouseleave:function(m){Ce(g,m)},mouseover:function(m){be(g,m)},mouseout:function(m){Re(g,m)},mousedown:function(m){Te(g,m)},mouseup:function(m){De(g,m)},mousemove:function(m){ze(g,m)},touchstart:function(m){Se(g,m)},touchend:function(m){ue(g,m)},touchmove:function(m){de(g,m)},touchcancel:function(m){pe(g,m)},gesturestart:function(m){ye(g,m)},gesturechange:function(m){me(g,m)},gotpointercapture:function(m){Le(g,m)},lostpointercapture:function(m){Me(g,m)},pointerenter:function(m){A(g,m)},pointerleave:function(m){Ce(g,m)},pointerover:function(m){be(g,m)},pointerout:function(m){Re(g,m)},pointerdown:function(m){Te(g,m)},pointerup:function(m){De(g,m)},pointermove:function(m){ze(g,m)},pointercancel:function(m){Ne(g,m)},pointerupcaptured:function(m){Ae(g,m)},pointermovecaptured:function(m){ke(g,m)},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."),c.startDisabled||this.setTracking(!0)},e.MouseTracker.prototype={destroy:function(){r(this),this.element=null,t[this.hash]=null,delete t[this.hash]},isTracking:function(){return t[this.hash].tracking},setTracking:function(c){return c?n(this):r(this),this},getActivePointersListByType:function(c){var u=t[this.hash],g,m=u.activePointersLists.length,P;for(g=0;g<m;g++)if(u.activePointersLists[g].type===c)return u.activePointersLists[g];return P=new e.MouseTracker.GesturePointList(c),u.activePointersLists.push(P),P},getActivePointerCount:function(){var c=t[this.hash],u,g=c.activePointersLists.length,m=0;for(u=0;u<g;u++)m+=c.activePointersLists[u].getLength();return m},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 i=function(){try{return window.self!==window.top}catch{return!0}}();function o(c){try{return c.addEventListener&&c.removeEventListener}catch{return!1}}e.MouseTracker.gesturePointVelocityTracker=function(){var c=[],u=0,g=0,m=function(j,B){return j.hash.toString()+B.type+B.id.toString()},P=function(){var j,B=c.length,ne,$,_e=e.now(),je,qe,Ze;for(je=_e-g,g=_e,j=0;j<B;j++)ne=c[j],$=ne.gPoint,$.direction=Math.atan2($.currentPos.y-ne.lastPos.y,$.currentPos.x-ne.lastPos.x),qe=ne.lastPos.distanceTo($.currentPos),ne.lastPos=$.currentPos,Ze=1e3*qe/(je+1),$.speed=.75*Ze+.25*$.speed},R=function(j,B){var ne=m(j,B);c.push({guid:ne,gPoint:B,lastPos:B.currentPos}),c.length===1&&(g=e.now(),u=window.setInterval(P,50))},H=function(j,B){var ne=m(j,B),$,_e=c.length;for($=0;$<_e;$++)if(c[$].guid===ne){c.splice($,1),_e--,_e===0&&window.clearInterval(u);break}};return{addPoint:R,removePoint:H}}(),e.MouseTracker.captureElement=document,e.MouseTracker.wheelEventName=e.Browser.vendor===e.BROWSERS.IE&&e.Browser.version>8||"onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll",e.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",e.MouseTracker.wheelEventName],e.MouseTracker.wheelEventName==="DOMMouseScroll"&&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=function(){var c=document.createElement("div");return e.isFunction(c.setPointerCapture)&&e.isFunction(c.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 c=document.createElement("div");return e.isFunction(c.setCapture)&&e.isFunction(c.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(c){this._gPoints=[],this.type=c,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(c){return this._gPoints.push(c)},removeById:function(c){var u,g=this._gPoints.length;for(u=0;u<g;u++)if(this._gPoints[u].id===c){this._gPoints.splice(u,1);break}return this._gPoints.length},getByIndex:function(c){return c<this._gPoints.length?this._gPoints[c]:null},getById:function(c){var u,g=this._gPoints.length;for(u=0;u<g;u++)if(this._gPoints[u].id===c)return this._gPoints[u];return null},getPrimary:function(c){var u,g=this._gPoints.length;for(u=0;u<g;u++)if(this._gPoints[u].isPrimary)return this._gPoints[u];return null},addContact:function(){++this.contacts,this.contacts>1&&(this.type==="mouse"||this.type==="pen")&&(e.console.warn("GesturePointList.addContact() Implausible contacts value"),this.contacts=1)},removeContact:function(){--this.contacts,this.contacts<0&&(this.contacts=0)}};function h(c){var u=t[c.hash],g,m,P,R,H,j=u.activePointersLists.length;for(g=0;g<j;g++)if(P=u.activePointersLists[g],P.getLength()>0){for(H=[],R=P.asArray(),m=0;m<R.length;m++)H.push(R[m]);for(m=0;m<H.length;m++)xe(c,P,H[m])}for(g=0;g<j;g++)u.activePointersLists.pop();u.sentDragEvent=!1}function n(c){var u=t[c.hash],g,m;if(!u.tracking){for(m=0;m<e.MouseTracker.subscribeEvents.length;m++)g=e.MouseTracker.subscribeEvents[m],e.addEvent(c.element,g,u[g],g===e.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);h(c),u.tracking=!0}}function r(c){var u=t[c.hash],g,m;if(u.tracking){for(m=0;m<e.MouseTracker.subscribeEvents.length;m++)g=e.MouseTracker.subscribeEvents[m],e.removeEvent(c.element,g,u[g],!1);h(c),u.tracking=!1}}function s(c,u){var g=t[c.hash];if(u==="pointerevent")return{upName:"pointerup",upHandler:g.pointerupcaptured,moveName:"pointermove",moveHandler:g.pointermovecaptured};if(u==="mouse")return{upName:"pointerup",upHandler:g.pointerupcaptured,moveName:"pointermove",moveHandler:g.pointermovecaptured};if(u==="touch")return{upName:"touchend",upHandler:g.touchendcaptured,moveName:"touchmove",moveHandler:g.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function l(c,u){var g;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents)try{c.element.setPointerCapture(u.id)}catch{e.console.warn("setPointerCapture() called on invalid pointer ID");return}else c.element.setCapture(!0);else g=s(c,e.MouseTracker.havePointerEvents?"pointerevent":u.type),i&&o(window.top)&&e.addEvent(window.top,g.upName,g.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,g.upName,g.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,g.moveName,g.moveHandler,!0);S(c,u,!0)}function d(c,u){var g,m,P;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents){if(m=c.getActivePointersListByType(u.type),P=m.getById(u.id),!P||!P.captured)return;try{c.element.releasePointerCapture(u.id)}catch{}}else c.element.releaseCapture();else g=s(c,e.MouseTracker.havePointerEvents?"pointerevent":u.type),i&&o(window.top)&&e.removeEvent(window.top,g.upName,g.upHandler,!0),e.removeEvent(e.MouseTracker.captureElement,g.moveName,g.moveHandler,!0),e.removeEvent(e.MouseTracker.captureElement,g.upName,g.upHandler,!0);S(c,u,!1)}function f(c){return e.MouseTracker.havePointerEvents?c.pointerId:e.MouseTracker.mousePointerId}function v(c){return e.MouseTracker.havePointerEvents?c.pointerType||(e.Browser.vendor===e.BROWSERS.IE?"mouse":""):"mouse"}function y(c){return e.MouseTracker.havePointerEvents?c.isPrimary:!0}function T(c){return e.getMousePosition(c)}function w(c,u){return x(T(c),u)}function x(c,u){var g=e.getElementOffset(u);return c.minus(g)}function C(c,u){return new e.Point((c.x+u.x)/2,(c.y+u.y)/2)}function D(c,u){var g={originalEvent:u,eventType:"click",pointerType:"mouse",isEmulated:!1};p(c,g),g.preventDefault&&!g.defaultPrevented&&e.cancelEvent(u),g.stopPropagation&&e.stopEvent(u)}function M(c,u){var g={originalEvent:u,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};p(c,g),g.preventDefault&&!g.defaultPrevented&&e.cancelEvent(u),g.stopPropagation&&e.stopEvent(u)}function V(c,u){var g=null,m={originalEvent:u,eventType:"keydown",pointerType:"",isEmulated:!1};p(c,m),c.keyDownHandler&&!m.preventGesture&&!m.defaultPrevented&&(g={eventSource:c,keyCode:u.keyCode?u.keyCode:u.charCode,ctrl:u.ctrlKey,shift:u.shiftKey,alt:u.altKey,meta:u.metaKey,originalEvent:u,preventDefault:m.preventDefault||m.defaultPrevented,userData:c.userData},c.keyDownHandler(g)),(g&&g.preventDefault||m.preventDefault&&!m.defaultPrevented)&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u)}function N(c,u){var g=null,m={originalEvent:u,eventType:"keyup",pointerType:"",isEmulated:!1};p(c,m),c.keyUpHandler&&!m.preventGesture&&!m.defaultPrevented&&(g={eventSource:c,keyCode:u.keyCode?u.keyCode:u.charCode,ctrl:u.ctrlKey,shift:u.shiftKey,alt:u.altKey,meta:u.metaKey,originalEvent:u,preventDefault:m.preventDefault||m.defaultPrevented,userData:c.userData},c.keyUpHandler(g)),(g&&g.preventDefault||m.preventDefault&&!m.defaultPrevented)&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u)}function U(c,u){var g=null,m={originalEvent:u,eventType:"keypress",pointerType:"",isEmulated:!1};p(c,m),c.keyHandler&&!m.preventGesture&&!m.defaultPrevented&&(g={eventSource:c,keyCode:u.keyCode?u.keyCode:u.charCode,ctrl:u.ctrlKey,shift:u.shiftKey,alt:u.altKey,meta:u.metaKey,originalEvent:u,preventDefault:m.preventDefault||m.defaultPrevented,userData:c.userData},c.keyHandler(g)),(g&&g.preventDefault||m.preventDefault&&!m.defaultPrevented)&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u)}function k(c,u){var g={originalEvent:u,eventType:"focus",pointerType:"",isEmulated:!1};p(c,g),c.focusHandler&&!g.preventGesture&&c.focusHandler({eventSource:c,originalEvent:u,userData:c.userData})}function G(c,u){var g={originalEvent:u,eventType:"blur",pointerType:"",isEmulated:!1};p(c,g),c.blurHandler&&!g.preventGesture&&c.blurHandler({eventSource:c,originalEvent:u,userData:c.userData})}function ee(c,u){var g=null,m={originalEvent:u,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};p(c,m),c.contextMenuHandler&&!m.preventGesture&&!m.defaultPrevented&&(g={eventSource:c,position:x(T(u),c.element),originalEvent:m.originalEvent,preventDefault:m.preventDefault||m.defaultPrevented,userData:c.userData},c.contextMenuHandler(g)),(g&&g.preventDefault||m.preventDefault&&!m.defaultPrevented)&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u)}function Q(c,u){se(c,u,u)}function J(c,u){var g={target:u.target||u.srcElement,type:"wheel",shiftKey:u.shiftKey||!1,clientX:u.clientX,clientY:u.clientY,pageX:u.pageX?u.pageX:u.clientX,pageY:u.pageY?u.pageY:u.clientY,deltaMode:u.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};e.MouseTracker.wheelEventName==="mousewheel"?g.deltaY=-u.wheelDelta/e.DEFAULT_SETTINGS.pixelsPerWheelLine:g.deltaY=u.detail,se(c,g,u)}function se(c,u,g){var m=0,P,R=null;m=u.deltaY<0?1:-1,P={originalEvent:u,eventType:"wheel",pointerType:"mouse",isEmulated:u!==g},p(c,P),c.scrollHandler&&!P.preventGesture&&!P.defaultPrevented&&(R={eventSource:c,pointerType:"mouse",position:w(u,c.element),scroll:m,shift:u.shiftKey,isTouchEvent:!1,originalEvent:g,preventDefault:P.preventDefault||P.defaultPrevented,userData:c.userData},c.scrollHandler(R)),P.stopPropagation&&e.stopEvent(g),(R&&R.preventDefault||P.preventDefault&&!P.defaultPrevented)&&e.cancelEvent(g)}function ce(c,u){var g={id:e.MouseTracker.mousePointerId,type:"mouse"},m={originalEvent:u,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};p(c,m),u.target===c.element&&S(c,g,!1),m.stopPropagation&&e.stopEvent(u)}function Se(c,u){var g,m,P=u.changedTouches.length,R,H=c.getActivePointersListByType("touch");g=e.now(),H.getLength()>u.touches.length-P&&e.console.warn("Tracked touch contact count doesn't match event.touches.length");var j={originalEvent:u,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(p(c,j),m=0;m<P;m++)R={id:u.changedTouches[m].identifier,type:"touch",isPrimary:H.getLength()===0,currentPos:T(u.changedTouches[m]),currentTime:g},I(c,j,R),W(c,j,R,0),S(c,R,!0);j.preventDefault&&!j.defaultPrevented&&e.cancelEvent(u),j.stopPropagation&&e.stopEvent(u)}function ue(c,u){var g,m,P=u.changedTouches.length,R;g=e.now();var H={originalEvent:u,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(p(c,H),m=0;m<P;m++)R={id:u.changedTouches[m].identifier,type:"touch",currentPos:T(u.changedTouches[m]),currentTime:g},Z(c,H,R,0),S(c,R,!1),b(c,H,R);H.preventDefault&&!H.defaultPrevented&&e.cancelEvent(u),H.stopPropagation&&e.stopEvent(u)}function de(c,u){var g,m,P=u.changedTouches.length,R;g=e.now();var H={originalEvent:u,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(p(c,H),m=0;m<P;m++)R={id:u.changedTouches[m].identifier,type:"touch",currentPos:T(u.changedTouches[m]),currentTime:g},X(c,H,R);H.preventDefault&&!H.defaultPrevented&&e.cancelEvent(u),H.stopPropagation&&e.stopEvent(u)}function pe(c,u){var g=u.changedTouches.length,m,P,R={originalEvent:u,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(p(c,R),m=0;m<g;m++)P={id:u.changedTouches[m].identifier,type:"touch"},L(c,R,P);R.stopPropagation&&e.stopEvent(u)}function ye(c,u){return e.eventIsCanceled(u)||u.preventDefault(),!1}function me(c,u){return e.eventIsCanceled(u)||u.preventDefault(),!1}function Le(c,u){var g={originalEvent:u,eventType:"gotpointercapture",pointerType:v(u),isEmulated:!1};p(c,g),u.target===c.element&&S(c,{id:u.pointerId,type:v(u)},!0),g.stopPropagation&&e.stopEvent(u)}function Me(c,u){var g={originalEvent:u,eventType:"lostpointercapture",pointerType:v(u),isEmulated:!1};p(c,g),u.target===c.element&&S(c,{id:u.pointerId,type:v(u)},!1),g.stopPropagation&&e.stopEvent(u)}function A(c,u){var g={id:f(u),type:v(u),isPrimary:y(u),currentPos:T(u),currentTime:e.now()},m={originalEvent:u,eventType:"pointerenter",pointerType:g.type,isEmulated:!1};p(c,m),I(c,m,g)}function Ce(c,u){var g={id:f(u),type:v(u),isPrimary:y(u),currentPos:T(u),currentTime:e.now()},m={originalEvent:u,eventType:"pointerleave",pointerType:g.type,isEmulated:!1};p(c,m),b(c,m,g)}function be(c,u){var g={id:f(u),type:v(u),isPrimary:y(u),currentPos:T(u),currentTime:e.now()},m={originalEvent:u,eventType:"pointerover",pointerType:g.type,isEmulated:!1};p(c,m),O(c,m,g),m.preventDefault&&!m.defaultPrevented&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u)}function Re(c,u){var g={id:f(u),type:v(u),isPrimary:y(u),currentPos:T(u),currentTime:e.now()},m={originalEvent:u,eventType:"pointerout",pointerType:g.type,isEmulated:!1};p(c,m),z(c,m,g),m.preventDefault&&!m.defaultPrevented&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u)}function Te(c,u){var g={id:f(u),type:v(u),isPrimary:y(u),currentPos:T(u),currentTime:e.now()},m=e.MouseTracker.havePointerEvents&&g.type==="touch"&&e.Browser.vendor!==e.BROWSERS.IE,P={originalEvent:u,eventType:"pointerdown",pointerType:g.type,isEmulated:!1};p(c,P),W(c,P,g,u.button),P.preventDefault&&!P.defaultPrevented&&e.cancelEvent(u),P.stopPropagation&&e.stopEvent(u),P.shouldCapture&&(m?S(c,g,!0):l(c,g))}function De(c,u){Ie(c,u)}function Ae(c,u){var g=c.getActivePointersListByType(v(u));g.getById(u.pointerId)&&Ie(c,u),e.stopEvent(u)}function Ie(c,u){var g;g={id:f(u),type:v(u),isPrimary:y(u),currentPos:T(u),currentTime:e.now()};var m={originalEvent:u,eventType:"pointerup",pointerType:g.type,isEmulated:!1};p(c,m),Z(c,m,g,u.button),m.preventDefault&&!m.defaultPrevented&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u),m.shouldReleaseCapture&&(u.target===c.element?d(c,g):S(c,g,!1))}function ze(c,u){Oe(c,u)}function ke(c,u){var g=c.getActivePointersListByType(v(u));g.getById(u.pointerId)&&Oe(c,u),e.stopEvent(u)}function Oe(c,u){var g={id:f(u),type:v(u),isPrimary:y(u),currentPos:T(u),currentTime:e.now()},m={originalEvent:u,eventType:"pointermove",pointerType:g.type,isEmulated:!1};p(c,m),X(c,m,g),m.preventDefault&&!m.defaultPrevented&&e.cancelEvent(u),m.stopPropagation&&e.stopEvent(u)}function Ne(c,u){var g={id:u.pointerId,type:v(u)},m={originalEvent:u,eventType:"pointercancel",pointerType:g.type,isEmulated:!1};p(c,m),L(c,m,g),m.stopPropagation&&e.stopEvent(u)}function Ee(c,u){return u.speed=0,u.direction=0,u.contactPos=u.currentPos,u.contactTime=u.currentTime,u.lastPos=u.currentPos,u.lastTime=u.currentTime,c.add(u)}function xe(c,u,g){var m,P=u.getById(g.id);return P?(P.captured&&(e.console.warn("stopTrackingPointer() called on captured pointer"),d(c,P)),u.removeContact(),m=u.removeById(g.id)):m=u.getLength(),m}function a(c,u){switch(u.eventType){case"pointermove":u.isStoppable=!0,u.isCancelable=!0,u.preventDefault=!1,u.preventGesture=!c.hasGestureHandlers,u.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":u.isStoppable=!0,u.isCancelable=!0,u.preventDefault=!1,u.preventGesture=!1,u.stopPropagation=!1;break;case"pointerdown":u.isStoppable=!0,u.isCancelable=!0,u.preventDefault=!1,u.preventGesture=!c.hasGestureHandlers,u.stopPropagation=!1;break;case"pointerup":u.isStoppable=!0,u.isCancelable=!0,u.preventDefault=!1,u.preventGesture=!c.hasGestureHandlers,u.stopPropagation=!1;break;case"wheel":u.isStoppable=!0,u.isCancelable=!0,u.preventDefault=!1,u.preventGesture=!c.hasScrollHandler,u.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":u.isStoppable=!0,u.isCancelable=!1,u.preventDefault=!1,u.preventGesture=!1,u.stopPropagation=!1;break;case"click":u.isStoppable=!0,u.isCancelable=!0,u.preventDefault=!!c.clickHandler,u.preventGesture=!1,u.stopPropagation=!1;break;case"dblclick":u.isStoppable=!0,u.isCancelable=!0,u.preventDefault=!!c.dblClickHandler,u.preventGesture=!1,u.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:u.isStoppable=!1,u.isCancelable=!1,u.preventDefault=!1,u.preventGesture=!1,u.stopPropagation=!1;break}}function p(c,u){u.eventSource=c,u.eventPhase=u.originalEvent&&typeof u.originalEvent.eventPhase<"u"?u.originalEvent.eventPhase:0,u.defaultPrevented=e.eventIsCanceled(u.originalEvent),u.shouldCapture=!1,u.shouldReleaseCapture=!1,u.userData=c.userData,a(c,u),c.preProcessEventHandler&&c.preProcessEventHandler(u)}function S(c,u,g){var m=c.getActivePointersListByType(u.type),P=m.getById(u.id);P?g&&!P.captured?(P.captured=!0,m.captureCount++):!g&&P.captured&&(P.captured=!1,m.captureCount--,m.captureCount<0&&(m.captureCount=0,e.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):e.console.warn("updatePointerCaptured() called on untracked pointer")}function I(c,u,g){var m=c.getActivePointersListByType(g.type),P;P=m.getById(g.id),P?(P.insideElement=!0,P.lastPos=P.currentPos,P.lastTime=P.currentTime,P.currentPos=g.currentPos,P.currentTime=g.currentTime,g=P):(g.captured=!1,g.insideElementPressed=!1,g.insideElement=!0,Ee(m,g)),c.enterHandler&&c.enterHandler({eventSource:c,pointerType:g.type,position:x(g.currentPos,c.element),buttons:m.buttons,pointers:c.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:m.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData})}function b(c,u,g){var m=c.getActivePointersListByType(g.type),P,R;P=m.getById(g.id),P?(P.captured?(P.insideElement=!1,P.lastPos=P.currentPos,P.lastTime=P.currentTime,P.currentPos=g.currentPos,P.currentTime=g.currentTime):xe(c,m,P),g=P):(g.captured=!1,g.insideElementPressed=!1),(c.leaveHandler||c.exitHandler)&&(R={eventSource:c,pointerType:g.type,position:g.currentPos&&x(g.currentPos,c.element),buttons:m.buttons,pointers:c.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:m.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData},c.leaveHandler&&c.leaveHandler(R),c.exitHandler&&c.exitHandler(R))}function O(c,u,g){var m,P;m=c.getActivePointersListByType(g.type),P=m.getById(g.id),P?g=P:(g.captured=!1,g.insideElementPressed=!1),c.overHandler&&c.overHandler({eventSource:c,pointerType:g.type,position:x(g.currentPos,c.element),buttons:m.buttons,pointers:c.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:m.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData})}function z(c,u,g){var m,P;m=c.getActivePointersListByType(g.type),P=m.getById(g.id),P?g=P:(g.captured=!1,g.insideElementPressed=!1),c.outHandler&&c.outHandler({eventSource:c,pointerType:g.type,position:g.currentPos&&x(g.currentPos,c.element),buttons:m.buttons,pointers:c.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:m.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData})}function W(c,u,g,m){var P=t[c.hash],R=c.getActivePointersListByType(g.type),H;if(typeof u.originalEvent.buttons<"u"?R.buttons=u.originalEvent.buttons:m===0?R.buttons|=1:m===1?R.buttons|=4:m===2?R.buttons|=2:m===3?R.buttons|=8:m===4?R.buttons|=16:m===5&&(R.buttons|=32),m!==0){u.shouldCapture=!1,u.shouldReleaseCapture=!1,c.nonPrimaryPressHandler&&!u.preventGesture&&!u.defaultPrevented&&(u.preventDefault=!0,c.nonPrimaryPressHandler({eventSource:c,pointerType:g.type,position:x(g.currentPos,c.element),button:m,buttons:R.buttons,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData}));return}H=R.getById(g.id),H?(H.insideElementPressed=!0,H.insideElement=!0,H.originalTarget=u.originalEvent.target,H.contactPos=g.currentPos,H.contactTime=g.currentTime,H.lastPos=H.currentPos,H.lastTime=H.currentTime,H.currentPos=g.currentPos,H.currentTime=g.currentTime,g=H):(g.captured=!1,g.insideElementPressed=!0,g.insideElement=!0,g.originalTarget=u.originalEvent.target,Ee(R,g)),R.addContact(),!u.preventGesture&&!u.defaultPrevented?(u.shouldCapture=!0,u.shouldReleaseCapture=!1,u.preventDefault=!0,(c.dragHandler||c.dragEndHandler||c.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.addPoint(c,g),R.contacts===1?c.pressHandler&&!u.preventGesture&&c.pressHandler({eventSource:c,pointerType:g.type,position:x(g.contactPos,c.element),buttons:R.buttons,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData}):R.contacts===2&&c.pinchHandler&&g.type==="touch"&&(P.pinchGPoints=R.asArray(),P.lastPinchDist=P.currentPinchDist=P.pinchGPoints[0].currentPos.distanceTo(P.pinchGPoints[1].currentPos),P.lastPinchCenter=P.currentPinchCenter=C(P.pinchGPoints[0].currentPos,P.pinchGPoints[1].currentPos))):(u.shouldCapture=!1,u.shouldReleaseCapture=!1)}function Z(c,u,g,m){var P=t[c.hash],R=c.getActivePointersListByType(g.type),H,j,B,ne=!1,$;if(typeof u.originalEvent.buttons<"u"?R.buttons=u.originalEvent.buttons:m===0?R.buttons^=-2:m===1?R.buttons^=-5:m===2?R.buttons^=-3:m===3?R.buttons^=-9:m===4?R.buttons^=-17:m===5&&(R.buttons^=-33),u.shouldCapture=!1,m!==0){u.shouldReleaseCapture=!1,c.nonPrimaryReleaseHandler&&!u.preventGesture&&!u.defaultPrevented&&(u.preventDefault=!0,c.nonPrimaryReleaseHandler({eventSource:c,pointerType:g.type,position:x(g.currentPos,c.element),button:m,buttons:R.buttons,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData}));return}B=R.getById(g.id),B?(R.removeContact(),B.captured&&(ne=!0),B.lastPos=B.currentPos,B.lastTime=B.currentTime,B.currentPos=g.currentPos,B.currentTime=g.currentTime,B.insideElement||xe(c,R,B),H=B.currentPos,j=B.currentTime):(g.captured=!1,g.insideElementPressed=!1,g.insideElement=!0,Ee(R,g),B=g),!u.preventGesture&&!u.defaultPrevented&&(ne?(u.shouldReleaseCapture=!0,u.preventDefault=!0,(c.dragHandler||c.dragEndHandler||c.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.removePoint(c,B),R.contacts===0?(c.releaseHandler&&H&&c.releaseHandler({eventSource:c,pointerType:B.type,position:x(H,c.element),buttons:R.buttons,insideElementPressed:B.insideElementPressed,insideElementReleased:B.insideElement,isTouchEvent:B.type==="touch",originalEvent:u.originalEvent,userData:c.userData}),c.dragEndHandler&&P.sentDragEvent&&c.dragEndHandler({eventSource:c,pointerType:B.type,position:x(B.currentPos,c.element),speed:B.speed,direction:B.direction,shift:u.originalEvent.shiftKey,isTouchEvent:B.type==="touch",originalEvent:u.originalEvent,userData:c.userData}),P.sentDragEvent=!1,(c.clickHandler||c.dblClickHandler)&&B.insideElement&&($=j-B.contactTime<=c.clickTimeThreshold&&B.contactPos.distanceTo(H)<=c.clickDistThreshold,c.clickHandler&&c.clickHandler({eventSource:c,pointerType:B.type,position:x(B.currentPos,c.element),quick:$,shift:u.originalEvent.shiftKey,isTouchEvent:B.type==="touch",originalEvent:u.originalEvent,originalTarget:B.originalTarget,userData:c.userData}),c.dblClickHandler&&$&&(R.clicks++,R.clicks===1?(P.lastClickPos=H,P.dblClickTimeOut=setTimeout(function(){R.clicks=0},c.dblClickTimeThreshold)):R.clicks===2&&(clearTimeout(P.dblClickTimeOut),R.clicks=0,P.lastClickPos.distanceTo(H)<=c.dblClickDistThreshold&&c.dblClickHandler({eventSource:c,pointerType:B.type,position:x(B.currentPos,c.element),shift:u.originalEvent.shiftKey,isTouchEvent:B.type==="touch",originalEvent:u.originalEvent,userData:c.userData}),P.lastClickPos=null)))):R.contacts===2&&c.pinchHandler&&B.type==="touch"&&(P.pinchGPoints=R.asArray(),P.lastPinchDist=P.currentPinchDist=P.pinchGPoints[0].currentPos.distanceTo(P.pinchGPoints[1].currentPos),P.lastPinchCenter=P.currentPinchCenter=C(P.pinchGPoints[0].currentPos,P.pinchGPoints[1].currentPos))):(u.shouldReleaseCapture=!1,c.releaseHandler&&H&&(c.releaseHandler({eventSource:c,pointerType:B.type,position:x(H,c.element),buttons:R.buttons,insideElementPressed:B.insideElementPressed,insideElementReleased:B.insideElement,isTouchEvent:B.type==="touch",originalEvent:u.originalEvent,userData:c.userData}),u.preventDefault=!0)))}function X(c,u,g){var m=t[c.hash],P=c.getActivePointersListByType(g.type),R,H,j;if(typeof u.originalEvent.buttons<"u"&&(P.buttons=u.originalEvent.buttons),R=P.getById(g.id),R)R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=g.currentPos,R.currentTime=g.currentTime;else return;u.shouldCapture=!1,u.shouldReleaseCapture=!1,c.stopHandler&&g.type==="mouse"&&(clearTimeout(c.stopTimeOut),c.stopTimeOut=setTimeout(function(){Y(c,u.originalEvent,g.type)},c.stopDelay)),P.contacts===0?c.moveHandler&&c.moveHandler({eventSource:c,pointerType:g.type,position:x(g.currentPos,c.element),buttons:P.buttons,isTouchEvent:g.type==="touch",originalEvent:u.originalEvent,userData:c.userData}):P.contacts===1?(c.moveHandler&&(R=P.asArray()[0],c.moveHandler({eventSource:c,pointerType:R.type,position:x(R.currentPos,c.element),buttons:P.buttons,isTouchEvent:R.type==="touch",originalEvent:u.originalEvent,userData:c.userData})),c.dragHandler&&!u.preventGesture&&!u.defaultPrevented&&(R=P.asArray()[0],j=R.currentPos.minus(R.lastPos),c.dragHandler({eventSource:c,pointerType:R.type,position:x(R.currentPos,c.element),buttons:P.buttons,delta:j,speed:R.speed,direction:R.direction,shift:u.originalEvent.shiftKey,isTouchEvent:R.type==="touch",originalEvent:u.originalEvent,userData:c.userData}),u.preventDefault=!0,m.sentDragEvent=!0)):P.contacts===2&&(c.moveHandler&&(H=P.asArray(),c.moveHandler({eventSource:c,pointerType:H[0].type,position:x(C(H[0].currentPos,H[1].currentPos),c.element),buttons:P.buttons,isTouchEvent:H[0].type==="touch",originalEvent:u.originalEvent,userData:c.userData})),c.pinchHandler&&g.type==="touch"&&!u.preventGesture&&!u.defaultPrevented&&(j=m.pinchGPoints[0].currentPos.distanceTo(m.pinchGPoints[1].currentPos),j!==m.currentPinchDist&&(m.lastPinchDist=m.currentPinchDist,m.currentPinchDist=j,m.lastPinchCenter=m.currentPinchCenter,m.currentPinchCenter=C(m.pinchGPoints[0].currentPos,m.pinchGPoints[1].currentPos),c.pinchHandler({eventSource:c,pointerType:"touch",gesturePoints:m.pinchGPoints,lastCenter:x(m.lastPinchCenter,c.element),center:x(m.currentPinchCenter,c.element),lastDistance:m.lastPinchDist,distance:m.currentPinchDist,shift:u.originalEvent.shiftKey,originalEvent:u.originalEvent,userData:c.userData}),u.preventDefault=!0)))}function L(c,u,g){var m=c.getActivePointersListByType(g.type),P;P=m.getById(g.id),P&&xe(c,m,P)}function Y(c,u,g){c.stopHandler&&c.stopHandler({eventSource:c,pointerType:g,position:w(u,c.element),buttons:c.getActivePointersListByType(g).buttons,isTouchEvent:g==="touch",originalEvent:u,userData:c.userData})}}(_),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,o){var h=t.parentNode;typeof i=="number"&&(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=typeof i.attachToViewer>"u"?!0:i.attachToViewer,this.autoFade=typeof i.autoFade>"u"?!0:i.autoFade,this.element=t,this.anchor=i.anchor,this.container=o,this.anchor===e.ControlAnchor.ABSOLUTE?(this.wrapper=e.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof i.top=="number"?i.top+"px":i.top,this.wrapper.style.left=typeof i.left=="number"?i.left+"px":i.left,this.wrapper.style.height=typeof i.height=="number"?i.height+"px":i.height,this.wrapper.style.width=typeof i.width=="number"?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):h.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 this.wrapper.style.display!=="none"},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)}}}(_),function(e){e.ControlDock=function(i){var o=["topleft","topright","bottomright","bottomleft"],h,n;for(e.extend(!0,this,{id:"controldock-"+e.now()+"-"+Math.floor(Math.random()*1e6),container:e.makeNeutralElement("div"),controls:[]},i),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++)h=o[n],this.controls[h]=e.makeNeutralElement("div"),this.controls[h].style.position="absolute",h.match("left")&&(this.controls[h].style.left="0px"),h.match("right")&&(this.controls[h].style.right="0px"),h.match("top")&&(this.controls[h].style.top="0px"),h.match("bottom")&&(this.controls[h].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,o){i=e.getElement(i);var h=null;if(!(t(this,i)>=0)){switch(o.anchor){case e.ControlAnchor.TOP_RIGHT:h=this.controls.topright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.BOTTOM_RIGHT:h=this.controls.bottomright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.BOTTOM_LEFT:h=this.controls.bottomleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.TOP_LEFT:h=this.controls.topleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.ABSOLUTE:h=this.container,i.style.margin="0px",i.style.padding="0px";break;default:case e.ControlAnchor.NONE:h=this.container,i.style.margin="0px",i.style.padding="0px";break}this.controls.push(new e.Control(i,o,h)),i.style.display="inline-block"}},removeControl:function(i){i=e.getElement(i);var o=t(this,i);return o>=0&&(this.controls[o].destroy(),this.controls.splice(o,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var i;for(i=this.controls.length-1;i>=0;i--)if(this.controls[i].isVisible())return!0;return!1},setControlsEnabled:function(i){var o;for(o=this.controls.length-1;o>=0;o--)this.controls[o].setVisible(i);return this}};function t(i,o){var h=i.controls,n;for(n=h.length-1;n>=0;n--)if(h[n].element===o)return n;return-1}}(_),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}}})}(_),function(e){var t={},i=1;e.Viewer=function(a){var p=arguments,S=this,I;if(e.isPlainObject(a)||(a={id:p[0],xmlPath:p.length>1?p[1]:void 0,prefixUrl:p.length>2?p[2]:void 0,controls:p.length>3?p[3]:void 0,overlays:p.length>4?p[4]:void 0}),a.config&&(e.extend(!0,a,a.config),delete a.config),e.extend(!0,this,{id:a.id,hash:a.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,a),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");for(typeof t[this.hash]<"u"&&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(b){var O=e.getString("Errors.OpenFailed",b.eventSource,b.message);S._showMessage(O)}),e.ControlDock.call(this,a),this.xmlPath&&(this.tileSources=[this.xmlPath]),this.element=this.element||document.getElementById(this.id),this.canvas=e.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",function(b){b.width="100%",b.height="100%",b.overflow="hidden",b.position="absolute",b.top="0px",b.left="0px"}(this.canvas.style),e.setElementTouchActionNone(this.canvas),a.tabIndex!==""&&(this.canvas.tabIndex=a.tabIndex===void 0?0:a.tabIndex),this.container.className="openseadragon-container",function(b){b.width="100%",b.height="100%",b.position="relative",b.overflow="hidden",b.left="0px",b.top="0px",b.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,w),keyDownHandler:e.delegate(this,x),keyHandler:e.delegate(this,C),clickHandler:e.delegate(this,D),dblClickHandler:e.delegate(this,M),dragHandler:e.delegate(this,V),dragEndHandler:e.delegate(this,N),enterHandler:e.delegate(this,U),leaveHandler:e.delegate(this,k),pressHandler:e.delegate(this,G),releaseHandler:e.delegate(this,ee),nonPrimaryPressHandler:e.delegate(this,Q),nonPrimaryReleaseHandler:e.delegate(this,J),scrollHandler:e.delegate(this,ue),pinchHandler:e.delegate(this,se),focusHandler:e.delegate(this,ce),blurHandler:e.delegate(this,Se)}),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,de),leaveHandler:e.delegate(this,pe)}),this.toolbar&&(this.toolbar=new e.ControlDock({element:this.toolbar})),this.bindStandardControls(),t[this.hash].prevContainerSize=o(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){t[S.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new e.World({viewer:this}),this.world.addHandler("add-item",function(b){S.source=S.world.getItemAt(0).source,t[S.hash].forceRedraw=!0,S._updateRequestId||(S._updateRequestId=s(S,ye))}),this.world.addHandler("remove-item",function(b){S.world.getItemCount()?S.source=S.world.getItemAt(0).source:S.source=null,t[S.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(b){S.viewport&&S.viewport._setContentBounds(S.world.getHomeBounds(),S.world.getContentFactor())}),this.world.addHandler("item-index-change",function(b){S.source=S.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:a.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay}),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&&(I=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(I,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(I=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(I,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),I=0;I<this.customControls.length;I++)this.addControl(this.customControls[I].id,{anchor:this.customControls[I].anchor});e.requestAnimationFrame(function(){d(S)}),this.imageSmoothingEnabled!==void 0&&!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(a){return e.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(a)},openTileSource:function(a){return e.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(a)},get buttons(){return e.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(a,p){var S=this;if(this.close(),!a)return this;if(this.sequenceMode&&e.isArray(a))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof p<"u"&&!isNaN(p)&&(this.initialPage=p),this.tileSources=a,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(a)||(a=[a]),!a.length)return this;this._opening=!0;for(var I=a.length,b=0,O=0,z,W=function(){if(b+O===I)if(b){(S._firstOpen||!S.preserveViewport)&&(S.viewport.goHome(!0),S.viewport.update()),S._firstOpen=!1;var L=a[0];if(L.tileSource&&(L=L.tileSource),S.overlays&&!S.preserveOverlays)for(var Y=0;Y<S.overlays.length;Y++)S.currentOverlays[Y]=n(S,S.overlays[Y]);S._drawOverlays(),S._opening=!1,S.raiseEvent("open",{source:L})}else S._opening=!1,S.raiseEvent("open-failed",z)},Z=function(L){(!e.isPlainObject(L)||!L.tileSource)&&(L={tileSource:L}),L.index!==void 0&&(e.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete L.index),L.collectionImmediately===void 0&&(L.collectionImmediately=!0);var Y=L.success;L.success=function(u){if(b++,L.tileSource.overlays)for(var g=0;g<L.tileSource.overlays.length;g++)S.addOverlay(L.tileSource.overlays[g]);Y&&Y(u),W()};var c=L.error;L.error=function(u){O++,z||(z=u),c&&c(u),W()},S.addTiledImage(L)},X=0;X<a.length;X++)Z(a[X]);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),this._updateRequestId!==null&&(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(a){return this.innerTracker.setTracking(a),this.outerTracker.setTracking(a),this.raiseEvent("mouse-enabled",{enabled:a}),this},areControlsEnabled:function(){var a=this.controls.length,p;for(p=0;p<this.controls.length;p++)a=a&&this.controls[p].isVisible();return a},setControlsEnabled:function(a){return a?v(this):d(this),this.raiseEvent("controls-enabled",{enabled:a}),this},setDebugMode:function(a){for(var p=0;p<this.world.getItemCount();p++)this.world.getItemAt(p).debugMode=a;this.debugMode=a,this.forceRedraw()},setAjaxHeaders:function(a,p){if(a===null&&(a={}),!e.isPlainObject(a)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(p===void 0&&(p=!0),this.ajaxHeaders=a,p){for(var S=0;S<this.world.getItemCount();S++)this.world.getItemAt(S)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var I in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[I].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(a){this.buttonGroup.addButton(a)},isFullPage:function(){return t[this.hash].fullPage},setFullPage:function(a){var p=document.body,S=p.style,I=document.documentElement.style,b=this,O,z;if(a===this.isFullPage())return this;var W={fullPage:a,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",W),W.preventDefaultAction)return this;if(a){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=I.margin,S.margin="0",I.margin="0",this.bodyPadding=S.padding,this.docPadding=I.padding,S.padding="0",I.padding="0",this.bodyWidth=S.width,this.docWidth=I.width,S.width="100%",I.width="100%",this.bodyHeight=S.height,this.docHeight=I.height,S.height="100%",I.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,O=p.childNodes.length,z=0;z<O;z++)this.previousBody.push(p.childNodes[0]),p.removeChild(p.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,p.appendChild(this.toolbar.element),e.addClass(this.toolbar.element,"fullpage")),e.addClass(this.element,"fullpage"),p.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,de)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,S.margin=this.bodyMargin,I.margin=this.docMargin,S.padding=this.bodyPadding,I.padding=this.docPadding,S.width=this.bodyWidth,I.width=this.docWidth,S.height=this.bodyHeight,I.height=this.docHeight,S.display=this.bodyDisplay,p.removeChild(this.element),O=this.previousBody.length,z=0;z<O;z++)p.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&&(p.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 Z=0,X=function(){e.setPageScroll(b.pageScroll);var L=e.getPageScroll();Z++,Z<10&&(L.x!==b.pageScroll.x||L.y!==b.pageScroll.y)&&e.requestAnimationFrame(X)};e.requestAnimationFrame(X),t[this.hash].fullPage=!1,e.delegate(this,pe)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:a}),this},setFullScreen:function(a){var p=this;if(!e.supportsFullScreen)return this.setFullPage(a);if(e.isFullScreen()===a)return this;var S={fullScreen:a,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",S),S.preventDefaultAction)return this;if(a){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 I=function(){var b=e.isFullScreen();b||(e.removeEvent(document,e.fullScreenEventName,I),e.removeEvent(document,e.fullScreenErrorEventName,I),p.setFullPage(!1),p.isFullPage()&&(p.element.style.width=p.fullPageStyleWidth,p.element.style.height=p.fullPageStyleHeight)),p.navigator&&p.viewport&&setTimeout(function(){p.navigator.update(p.viewport)}),p.raiseEvent("full-screen",{fullScreen:b})};e.addEvent(document,e.fullScreenEventName,I),e.addEvent(document,e.fullScreenErrorEventName,I),e.requestFullScreen(document.body)}else e.exitFullScreen();return this},isVisible:function(){return this.container.style.visibility!=="hidden"},isFullScreen:function(){return e.isFullScreen()&&this.isFullPage()},setVisible:function(a){return this.container.style.visibility=a?"":"hidden",this.raiseEvent("visible",{visible:a}),this},addTiledImage:function(a){e.console.assert(a,"[Viewer.addTiledImage] options is required"),e.console.assert(a.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),e.console.assert(!a.replace||a.index>-1&&a.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var p=this;a.replace&&(a.replaceItem=p.world.getItemAt(a.index)),this._hideMessage(),a.placeholderFillStyle===void 0&&(a.placeholderFillStyle=this.placeholderFillStyle),a.opacity===void 0&&(a.opacity=this.opacity),a.preload===void 0&&(a.preload=this.preload),a.compositeOperation===void 0&&(a.compositeOperation=this.compositeOperation),a.crossOriginPolicy===void 0&&(a.crossOriginPolicy=a.tileSource.crossOriginPolicy!==void 0?a.tileSource.crossOriginPolicy:this.crossOriginPolicy),a.ajaxWithCredentials===void 0&&(a.ajaxWithCredentials=this.ajaxWithCredentials),a.loadTilesWithAjax===void 0&&(a.loadTilesWithAjax=this.loadTilesWithAjax),e.isPlainObject(a.ajaxHeaders)||(a.ajaxHeaders={});var S={options:a};function I(z){for(var W=0;W<p._loadQueue.length;W++)if(p._loadQueue[W]===S){p._loadQueue.splice(W,1);break}p._loadQueue.length===0&&b(S),p.raiseEvent("add-item-failed",z),a.error&&a.error(z)}function b(z){p.collectionMode&&(p.world.arrange({immediately:z.options.collectionImmediately,rows:p.collectionRows,columns:p.collectionColumns,layout:p.collectionLayout,tileSize:p.collectionTileSize,tileMargin:p.collectionTileMargin}),p.world.setAutoRefigureSizes(!0))}if(e.isArray(a.tileSource)){setTimeout(function(){I({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:a.tileSource,options:a})});return}this._loadQueue.push(S);function O(){for(var z,W,Z;p._loadQueue.length&&(z=p._loadQueue[0],!!z.tileSource);){if(p._loadQueue.splice(0,1),z.options.replace){var X=p.world.getIndexOfItem(z.options.replaceItem);X!==-1&&(z.options.index=X),p.world.removeItem(z.options.replaceItem)}W=new e.TiledImage({viewer:p,source:z.tileSource,viewport:p.viewport,drawer:p.drawer,tileCache:p.tileCache,imageLoader:p.imageLoader,x:z.options.x,y:z.options.y,width:z.options.width,height:z.options.height,fitBounds:z.options.fitBounds,fitBoundsPlacement:z.options.fitBoundsPlacement,clip:z.options.clip,placeholderFillStyle:z.options.placeholderFillStyle,opacity:z.options.opacity,preload:z.options.preload,degrees:z.options.degrees,flipped:z.options.flipped,compositeOperation:z.options.compositeOperation,springStiffness:p.springStiffness,animationTime:p.animationTime,minZoomImageRatio:p.minZoomImageRatio,wrapHorizontal:p.wrapHorizontal,wrapVertical:p.wrapVertical,immediateRender:p.immediateRender,blendTime:p.blendTime,alwaysBlend:p.alwaysBlend,minPixelRatio:p.minPixelRatio,smoothTileEdgesMinZoom:p.smoothTileEdgesMinZoom,iOSDevice:p.iOSDevice,crossOriginPolicy:z.options.crossOriginPolicy,ajaxWithCredentials:z.options.ajaxWithCredentials,loadTilesWithAjax:z.options.loadTilesWithAjax,ajaxHeaders:z.options.ajaxHeaders,debugMode:p.debugMode,subPixelRoundingForTransparency:p.subPixelRoundingForTransparency}),p.collectionMode&&p.world.setAutoRefigureSizes(!1),p.navigator&&(Z=e.extend({},z.options,{replace:!1,originalTiledImage:W,tileSource:z.tileSource}),p.navigator.addTiledImage(Z)),p.world.addItem(W,{index:z.options.index}),p._loadQueue.length===0&&b(z),p.world.getItemCount()===1&&!p.preserveViewport&&p.viewport.goHome(!0),z.options.success&&z.options.success({item:W})}}h(this,a.tileSource,a,function(z){S.tileSource=z,O()},function(z){z.options=a,I(z),O()})},addSimpleImage:function(a){e.console.assert(a,"[Viewer.addSimpleImage] options is required"),e.console.assert(a.url,"[Viewer.addSimpleImage] options.url is required");var p=e.extend({},a,{tileSource:{type:"image",url:a.url}});delete p.url,this.addTiledImage(p)},addLayer:function(a){var p=this;e.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var S=e.extend({},a,{success:function(I){p.raiseEvent("add-layer",{options:a,drawer:I.item})},error:function(I){p.raiseEvent("add-layer-failed",I)}});return this.addTiledImage(S),this},getLayerAtLevel:function(a){return e.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(a)},getLevelOfLayer:function(a){return e.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(a)},getLayersCount:function(){return e.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(a,p){return e.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(a,p)},removeLayer:function(a){return e.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(a)},forceRedraw:function(){return t[this.hash].forceRedraw=!0,this},forceResize:function(){t[this.hash].needsResize=!0,t[this.hash].forceResize=!0},bindSequenceControls:function(){var a=e.delegate(this,y),p=e.delegate(this,T),S=e.delegate(this,this.goToNextPage),I=e.delegate(this,this.goToPreviousPage),b=this.navImages,O=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(O=!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:A(this.prefixUrl,b.previous.REST),srcGroup:A(this.prefixUrl,b.previous.GROUP),srcHover:A(this.prefixUrl,b.previous.HOVER),srcDown:A(this.prefixUrl,b.previous.DOWN),onRelease:I,onFocus:a,onBlur:p}),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:A(this.prefixUrl,b.next.REST),srcGroup:A(this.prefixUrl,b.next.GROUP),srcHover:A(this.prefixUrl,b.next.HOVER),srcDown:A(this.prefixUrl,b.next.DOWN),onRelease:S,onFocus:a,onBlur:p}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),O&&(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 a=e.delegate(this,Ce),p=e.delegate(this,Re),S=e.delegate(this,Ae),I=e.delegate(this,be),b=e.delegate(this,Ie),O=e.delegate(this,ke),z=e.delegate(this,Oe),W=e.delegate(this,Ne),Z=e.delegate(this,Ee),X=e.delegate(this,xe),L=e.delegate(this,y),Y=e.delegate(this,T),c=this.navImages,u=[],g=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(g=!1),this.showZoomControl&&(u.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:A(this.prefixUrl,c.zoomIn.REST),srcGroup:A(this.prefixUrl,c.zoomIn.GROUP),srcHover:A(this.prefixUrl,c.zoomIn.HOVER),srcDown:A(this.prefixUrl,c.zoomIn.DOWN),onPress:a,onRelease:p,onClick:S,onEnter:a,onExit:p,onFocus:L,onBlur:Y})),u.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:A(this.prefixUrl,c.zoomOut.REST),srcGroup:A(this.prefixUrl,c.zoomOut.GROUP),srcHover:A(this.prefixUrl,c.zoomOut.HOVER),srcDown:A(this.prefixUrl,c.zoomOut.DOWN),onPress:I,onRelease:p,onClick:b,onEnter:I,onExit:p,onFocus:L,onBlur:Y}))),this.showHomeControl&&u.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:A(this.prefixUrl,c.home.REST),srcGroup:A(this.prefixUrl,c.home.GROUP),srcHover:A(this.prefixUrl,c.home.HOVER),srcDown:A(this.prefixUrl,c.home.DOWN),onRelease:O,onFocus:L,onBlur:Y})),this.showFullPageControl&&u.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:A(this.prefixUrl,c.fullpage.REST),srcGroup:A(this.prefixUrl,c.fullpage.GROUP),srcHover:A(this.prefixUrl,c.fullpage.HOVER),srcDown:A(this.prefixUrl,c.fullpage.DOWN),onRelease:z,onFocus:L,onBlur:Y})),this.showRotationControl&&(u.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:A(this.prefixUrl,c.rotateleft.REST),srcGroup:A(this.prefixUrl,c.rotateleft.GROUP),srcHover:A(this.prefixUrl,c.rotateleft.HOVER),srcDown:A(this.prefixUrl,c.rotateleft.DOWN),onRelease:W,onFocus:L,onBlur:Y})),u.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:A(this.prefixUrl,c.rotateright.REST),srcGroup:A(this.prefixUrl,c.rotateright.GROUP),srcHover:A(this.prefixUrl,c.rotateright.HOVER),srcDown:A(this.prefixUrl,c.rotateright.DOWN),onRelease:Z,onFocus:L,onBlur:Y}))),this.showFlipControl&&u.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:A(this.prefixUrl,c.flip.REST),srcGroup:A(this.prefixUrl,c.flip.GROUP),srcHover:A(this.prefixUrl,c.flip.HOVER),srcDown:A(this.prefixUrl,c.flip.DOWN),onRelease:X,onFocus:L,onBlur:Y})),g?(this.buttonGroup=new e.ButtonGroup({buttons:u,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",e.delegate(this,ze)),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=u),this},currentPage:function(){return this._sequenceIndex},goToPage:function(a){return this.tileSources&&a>=0&&a<this.tileSources.length&&(this._sequenceIndex=a,this._updateSequenceButtons(a),this.open(this.tileSources[a]),this.referenceStrip&&this.referenceStrip.setFocus(a),this.raiseEvent("page",{page:a})),this},addOverlay:function(a,p,S,I){var b;if(e.isPlainObject(a)?b=a:b={element:a,location:p,placement:S,onDraw:I},a=e.getElement(b.element),r(this.currentOverlays,a)>=0)return this;var O=n(this,b);return this.currentOverlays.push(O),O.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:a,location:b.location,placement:b.placement}),this},updateOverlay:function(a,p,S){var I;return a=e.getElement(a),I=r(this.currentOverlays,a),I>=0&&(this.currentOverlays[I].update(p,S),t[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:a,location:p,placement:S})),this},removeOverlay:function(a){var p;return a=e.getElement(a),p=r(this.currentOverlays,a),p>=0&&(this.currentOverlays[p].destroy(),this.currentOverlays.splice(p,1),t[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:a})),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(a){var p;return a=e.getElement(a),p=r(this.currentOverlays,a),p>=0?this.currentOverlays[p]:null},_updateSequenceButtons:function(a){this.nextButton&&(!this.tileSources||this.tileSources.length-1===a?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(a>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(a){this._hideMessage();var p=e.makeNeutralElement("div");p.appendChild(document.createTextNode(a)),this.messageDiv=e.makeCenteredNode(p),e.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var a=this.messageDiv;a&&(a.parentNode.removeChild(a),delete this.messageDiv)},gestureSettingsByDeviceType:function(a){switch(a){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var a,p=this.currentOverlays.length;for(a=0;a<p;a++)this.currentOverlays[a].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 a=e.pixelDensityRatio,p=e.getCurrentPixelDensityRatio();a!==p&&(e.pixelDensityRatio=p,this.world.resetItems(),this.forceRedraw())},goToPreviousPage:function(){var a=this._sequenceIndex-1;this.navPrevNextWrap&&a<0&&(a+=this.tileSources.length),this.goToPage(a)},goToNextPage:function(){var a=this._sequenceIndex+1;this.navPrevNextWrap&&a>=this.tileSources.length&&(a=0),this.goToPage(a)},isAnimating:function(){return t[this.hash].animating}});function o(a){return a=e.getElement(a),new e.Point(a.clientWidth===0?1:a.clientWidth,a.clientHeight===0?1:a.clientHeight)}function h(a,p,S,I,b){var O=a;if(e.type(p)==="string"){if(p.match(/^\s*<.*>\s*$/))p=e.parseXml(p);else if(p.match(/^\s*[{[].*[}\]]\s*$/))try{var z=e.parseJSON(p);p=z}catch{}}function W(Z,X){Z.ready?I(Z):(Z.addHandler("ready",function(){I(Z)}),Z.addHandler("open-failed",function(L){b({message:L.message,source:X})}))}setTimeout(function(){if(e.type(p)==="string")p=new e.TileSource({url:p,crossOriginPolicy:S.crossOriginPolicy!==void 0?S.crossOriginPolicy:a.crossOriginPolicy,ajaxWithCredentials:a.ajaxWithCredentials,ajaxHeaders:S.ajaxHeaders?S.ajaxHeaders:a.ajaxHeaders,splitHashDataForPost:a.splitHashDataForPost,useCanvas:a.useCanvas,success:function(Y){I(Y.tileSource)}}),p.addHandler("open-failed",function(Y){b(Y)});else if(e.isPlainObject(p)||p.nodeType)if(p.crossOriginPolicy===void 0&&(S.crossOriginPolicy!==void 0||a.crossOriginPolicy!==void 0)&&(p.crossOriginPolicy=S.crossOriginPolicy!==void 0?S.crossOriginPolicy:a.crossOriginPolicy),p.ajaxWithCredentials===void 0&&(p.ajaxWithCredentials=a.ajaxWithCredentials),p.useCanvas===void 0&&(p.useCanvas=a.useCanvas),e.isFunction(p.getTileUrl)){var Z=new e.TileSource(p);Z.getTileUrl=p.getTileUrl,I(Z)}else{var X=e.TileSource.determineType(O,p);if(!X){b({message:"Unable to load TileSource",source:p});return}var L=X.prototype.configure.apply(O,[p]);W(new X(L),p)}else W(p,p)})}function n(a,p){if(p instanceof e.Overlay)return p;var S=null;if(p.element)S=e.getElement(p.element);else{var I=p.id?p.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);S=e.getElement(p.id),S||(S=document.createElement("a"),S.href="#/overlay/"+I),S.id=I,e.addClass(S,p.className?p.className:"openseadragon-overlay")}var b=p.location,O=p.width,z=p.height;if(!b){var W=p.x,Z=p.y;if(p.px!==void 0){var X=a.viewport.imageToViewportRectangle(new e.Rect(p.px,p.py,O||0,z||0));W=X.x,Z=X.y,O=O!==void 0?X.width:void 0,z=z!==void 0?X.height:void 0}b=new e.Point(W,Z)}var L=p.placement;return L&&e.type(L)==="string"&&(L=e.Placement[p.placement.toUpperCase()]),new e.Overlay({element:S,location:b,placement:L,onDraw:p.onDraw,checkResize:p.checkResize,width:O,height:z,rotationMode:p.rotationMode})}function r(a,p){var S;for(S=a.length-1;S>=0;S--)if(a[S].element===p)return S;return-1}function s(a,p){return e.requestAnimationFrame(function(){p(a)})}function l(a){e.requestAnimationFrame(function(){f(a)})}function d(a){a.autoHideControls&&(a.controlsShouldFade=!0,a.controlsFadeBeginTime=e.now()+a.controlsFadeDelay,window.setTimeout(function(){l(a)},a.controlsFadeDelay))}function f(a){var p,S,I,b;if(a.controlsShouldFade){for(p=e.now(),S=p-a.controlsFadeBeginTime,I=1-S/a.controlsFadeLength,I=Math.min(1,I),I=Math.max(0,I),b=a.controls.length-1;b>=0;b--)a.controls[b].autoFade&&a.controls[b].setOpacity(I);I>0&&l(a)}}function v(a){var p;for(a.controlsShouldFade=!1,p=a.controls.length-1;p>=0;p--)a.controls[p].setOpacity(1)}function y(){v(this)}function T(){d(this)}function w(a){var p={tracker:a.eventSource,position:a.position,originalEvent:a.originalEvent,preventDefault:a.preventDefault};this.raiseEvent("canvas-contextmenu",p),a.preventDefault=p.preventDefault}function x(a){var p={originalEvent:a.originalEvent,preventDefaultAction:!1,preventVerticalPan:a.preventVerticalPan||!this.panVertical,preventHorizontalPan:a.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",p),!p.preventDefaultAction&&!a.ctrl&&!a.alt&&!a.meta)switch(a.keyCode){case 38:p.preventVerticalPan||(a.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 40:p.preventVerticalPan||(a.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 37:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 39:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),a.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),a.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),a.preventDefault=!0;break;case 87:p.preventVerticalPan||(a.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-40))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 83:p.preventVerticalPan||(a.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,40))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 65:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-40,0))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 68:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(40,0))),this.viewport.applyConstraints()),a.preventDefault=!0;break;case 82:a.shift?this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement),this.viewport.applyConstraints(),a.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),a.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:a.preventDefault=!1;break}else a.preventDefault=!1}function C(a){var p={originalEvent:a.originalEvent};this.raiseEvent("canvas-key-press",p)}function D(a){var p,S=document.activeElement===this.canvas;S||this.canvas.focus(),this.viewport.flipped&&(a.position.x=this.viewport.getContainerSize().x-a.position.x);var I={tracker:a.eventSource,position:a.position,quick:a.quick,shift:a.shift,originalEvent:a.originalEvent,originalTarget:a.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",I),!I.preventDefaultAction&&this.viewport&&a.quick&&(p=this.gestureSettingsByDeviceType(a.pointerType),p.clickToZoom===!0&&(this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,p.zoomToRefPoint?this.viewport.pointFromPixel(a.position,!0):null),this.viewport.applyConstraints()),p.dblClickDragToZoom&&(t[this.hash].draggingToZoom===!0?(t[this.hash].lastClickTime=null,t[this.hash].draggingToZoom=!1):t[this.hash].lastClickTime=e.now()))}function M(a){var p,S={tracker:a.eventSource,position:a.position,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",S),!S.preventDefaultAction&&this.viewport&&(p=this.gestureSettingsByDeviceType(a.pointerType),p.dblClickToZoom&&(this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,p.zoomToRefPoint?this.viewport.pointFromPixel(a.position,!0):null),this.viewport.applyConstraints()))}function V(a){var p,S={tracker:a.eventSource,pointerType:a.pointerType,position:a.position,delta:a.delta,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",S),p=this.gestureSettingsByDeviceType(a.pointerType),!S.preventDefaultAction&&this.viewport){if(p.dblClickDragToZoom&&t[this.hash].draggingToZoom){var I=Math.pow(this.zoomPerDblClickDrag,a.delta.y/50);this.viewport.zoomBy(I)}else if(p.dragToPan&&!t[this.hash].draggingToZoom){if(this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewport.flipped&&(a.delta.x=-a.delta.x),this.constrainDuringPan){var b=this.viewport.deltaPointsFromPixels(a.delta.negate());this.viewport.centerSpringX.target.value+=b.x,this.viewport.centerSpringY.target.value+=b.y;var O=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=b.x,this.viewport.centerSpringY.target.value-=b.y,O.xConstrained&&(a.delta.x=0),O.yConstrained&&(a.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta.negate()),p.flickEnabled&&!this.constrainDuringPan)}}}function N(a){var p,S={tracker:a.eventSource,pointerType:a.pointerType,position:a.position,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",S),p=this.gestureSettingsByDeviceType(a.pointerType),!S.preventDefaultAction&&this.viewport){if(!t[this.hash].draggingToZoom&&p.flickEnabled&&a.speed>=p.flickMinSpeed){var I=0;this.panHorizontal&&(I=p.flickMomentum*a.speed*Math.cos(a.direction));var b=0;this.panVertical&&(b=p.flickMomentum*a.speed*Math.sin(a.direction));var O=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),z=this.viewport.pointFromPixel(new e.Point(O.x-I,O.y-b));this.viewport.panTo(z,!1)}this.viewport.applyConstraints()}p.dblClickDragToZoom&&t[this.hash].draggingToZoom===!0&&(t[this.hash].draggingToZoom=!1)}function U(a){this.raiseEvent("canvas-enter",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,buttons:a.buttons,pointers:a.pointers,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function k(a){this.raiseEvent("canvas-exit",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,buttons:a.buttons,pointers:a.pointers,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function G(a){var p;if(this.raiseEvent("canvas-press",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent}),p=this.gestureSettingsByDeviceType(a.pointerType),p.dblClickDragToZoom){var S=t[this.hash].lastClickTime,I=e.now();if(S===null)return;I-S<this.dblClickTimeThreshold&&(t[this.hash].draggingToZoom=!0),t[this.hash].lastClickTime=null}}function ee(a){this.raiseEvent("canvas-release",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent})}function Q(a){this.raiseEvent("canvas-nonprimary-press",{tracker:a.eventSource,position:a.position,pointerType:a.pointerType,button:a.button,buttons:a.buttons,originalEvent:a.originalEvent})}function J(a){this.raiseEvent("canvas-nonprimary-release",{tracker:a.eventSource,position:a.position,pointerType:a.pointerType,button:a.button,buttons:a.buttons,originalEvent:a.originalEvent})}function se(a){var p,S,I,b,O={tracker:a.eventSource,pointerType:a.pointerType,gesturePoints:a.gesturePoints,lastCenter:a.lastCenter,center:a.center,lastDistance:a.lastDistance,distance:a.distance,shift:a.shift,originalEvent:a.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",O),this.viewport&&(p=this.gestureSettingsByDeviceType(a.pointerType),p.pinchToZoom&&(!O.preventDefaultPanAction||!O.preventDefaultZoomAction)&&(S=this.viewport.pointFromPixel(a.center,!0),p.zoomToRefPoint&&!O.preventDefaultPanAction&&(I=this.viewport.pointFromPixel(a.lastCenter,!0),b=I.minus(S),this.panHorizontal||(b.x=0),this.panVertical||(b.y=0),this.viewport.panBy(b,!0)),O.preventDefaultZoomAction||this.viewport.zoomBy(a.distance/a.lastDistance,S,!0),this.viewport.applyConstraints()),p.pinchRotate&&!O.preventDefaultRotateAction)){var z=Math.atan2(a.gesturePoints[0].currentPos.y-a.gesturePoints[1].currentPos.y,a.gesturePoints[0].currentPos.x-a.gesturePoints[1].currentPos.x),W=Math.atan2(a.gesturePoints[0].lastPos.y-a.gesturePoints[1].lastPos.y,a.gesturePoints[0].lastPos.x-a.gesturePoints[1].lastPos.x);S=this.viewport.pointFromPixel(a.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(z-W)*(180/Math.PI),S,!0)}}function ce(a){this.raiseEvent("canvas-focus",{tracker:a.eventSource,originalEvent:a.originalEvent})}function Se(a){this.raiseEvent("canvas-blur",{tracker:a.eventSource,originalEvent:a.originalEvent})}function ue(a){var p,S,I,b,O;b=e.now(),O=b-this._lastScrollTime,O>this.minScrollDeltaTime?(this._lastScrollTime=b,p={tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",p),!p.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(a.position.x=this.viewport.getContainerSize().x-a.position.x),S=this.gestureSettingsByDeviceType(a.pointerType),S.scrollToZoom&&(I=Math.pow(this.zoomPerScroll,a.scroll),this.viewport.zoomBy(I,S.zoomToRefPoint?this.viewport.pointFromPixel(a.position,!0):null),this.viewport.applyConstraints())),a.preventDefault=p.preventDefault):a.preventDefault=!0}function de(a){t[this.hash].mouseInside=!0,v(this),this.raiseEvent("container-enter",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,buttons:a.buttons,pointers:a.pointers,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function pe(a){a.pointers<1&&(t[this.hash].mouseInside=!1,t[this.hash].animating||d(this)),this.raiseEvent("container-exit",{tracker:a.eventSource,pointerType:a.pointerType,position:a.position,buttons:a.buttons,pointers:a.pointers,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function ye(a){Le(a),a.isOpen()?a._updateRequestId=s(a,ye):a._updateRequestId=!1}function me(a,p){var S=a.viewport,I=S.getZoom(),b=S.getCenter();S.resize(p,a.preserveImageSizeOnResize),S.panTo(b,!0);var O;if(a.preserveImageSizeOnResize)O=t[a.hash].prevContainerSize.x/p.x;else{var z=new e.Point(0,0),W=new e.Point(t[a.hash].prevContainerSize.x,t[a.hash].prevContainerSize.y).distanceTo(z),Z=new e.Point(p.x,p.y).distanceTo(z);O=Z/W*t[a.hash].prevContainerSize.x/p.x}S.zoomTo(I*O,null,!0),t[a.hash].prevContainerSize=p,t[a.hash].forceRedraw=!0,t[a.hash].needsResize=!1,t[a.hash].forceResize=!1}function Le(a){if(!(a._opening||!t[a.hash])){if(a.autoResize||t[a.hash].forceResize){var p;if(a._autoResizePolling){p=o(a.container);var S=t[a.hash].prevContainerSize;p.equals(S)||(t[a.hash].needsResize=!0)}t[a.hash].needsResize&&me(a,p||o(a.container))}var I=a.viewport.update(),b=a.world.update()||I;I&&a.raiseEvent("viewport-change"),a.referenceStrip&&(b=a.referenceStrip.update(a.viewport)||b);var O=t[a.hash].animating;!O&&b&&(a.raiseEvent("animation-start"),v(a));var z=O&&!b;z&&(t[a.hash].animating=!1),(b||z||t[a.hash].forceRedraw||a.world.needsDraw())&&(Me(a),a._drawOverlays(),a.navigator&&a.navigator.update(a.viewport),t[a.hash].forceRedraw=!1,b&&a.raiseEvent("animation")),z&&(a.raiseEvent("animation-finish"),t[a.hash].mouseInside||d(a)),t[a.hash].animating=b}}function Me(a){a.imageLoader.clear(),a.drawer.clear(),a.world.draw(),a.raiseEvent("update-viewport",{})}function A(a,p){return a?a+p:p}function Ce(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=this.zoomPerSecond,t[this.hash].zooming=!0,Te(this)}function be(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=1/this.zoomPerSecond,t[this.hash].zooming=!0,Te(this)}function Re(){t[this.hash].zooming=!1}function Te(a){e.requestAnimationFrame(e.delegate(a,De))}function De(){var a,p,S;t[this.hash].zooming&&this.viewport&&(a=e.now(),p=a-t[this.hash].lastZoomTime,S=Math.pow(t[this.hash].zoomFactor,p/1e3),this.viewport.zoomBy(S),this.viewport.applyConstraints(),t[this.hash].lastZoomTime=a,Te(this))}function Ae(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function Ie(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function ze(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function ke(){this.viewport&&this.viewport.goHome()}function Oe(){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 Ne(){if(this.viewport){var a=this.viewport.getRotation();this.viewport.flipped?a+=this.rotationIncrement:a-=this.rotationIncrement,this.viewport.setRotation(a)}}function Ee(){if(this.viewport){var a=this.viewport.getRotation();this.viewport.flipped?a-=this.rotationIncrement:a+=this.rotationIncrement,this.viewport.setRotation(a)}}function xe(){this.viewport.toggleFlip()}}(_),function(e){e.Navigator=function(s){var l=s.viewer,d=this,f,v;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&&(s.position==="BOTTOM_RIGHT"?s.controlOptions.anchor=e.ControlAnchor.BOTTOM_RIGHT:s.position==="BOTTOM_LEFT"?s.controlOptions.anchor=e.ControlAnchor.BOTTOM_LEFT:s.position==="TOP_RIGHT"?s.controlOptions.anchor=e.ControlAnchor.TOP_RIGHT:s.position==="TOP_LEFT"?s.controlOptions.anchor=e.ControlAnchor.TOP_LEFT:s.position==="ABSOLUTE"&&(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}),s.minPixelRatio=this.minPixelRatio=l.minPixelRatio,e.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new e.Point(1,1),this.totalBorderWidths=new e.Point(this.borderWidth*2,this.borderWidth*2).minus(this.fudge),s.controlOptions.anchor!==e.ControlAnchor.NONE&&function(w,x){w.margin="0px",w.border=x+"px solid "+s.borderColor,w.padding="0px",w.background=s.background,w.opacity=s.opacity,w.overflow="hidden"}(this.element.style,this.borderWidth),this.displayRegion=e.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",function(w,x){w.position="relative",w.top="0px",w.left="0px",w.fontSize="0px",w.overflow="hidden",w.border=x+"px solid "+s.displayRegionColor,w.margin="0px",w.padding="0px",w.background="transparent",w.float="left",w.cssFloat="left",w.styleFloat="left",w.zIndex=999999999,w.cursor="default",w.boxSizing="content-box"}(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),l.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&&(f=e.getElementSize(l.element),this.element.style.height=Math.round(f.y*s.sizeRatio)+"px",this.element.style.width=Math.round(f.x*s.sizeRatio)+"px",this.oldViewerSize=f,v=e.getElementSize(this.element),this.elementArea=v.x*v.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);function y(w,x){n(d.displayRegionContainer,w),n(d.displayRegion,-w),d.viewport.setRotation(w,x)}if(s.navigatorRotate){var T=s.viewer.viewport?s.viewer.viewport.getRotation():s.viewer.degrees||0;y(T,!0),s.viewer.addHandler("rotate",function(w){y(w.degrees,w.immediately)})}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,o),scrollHandler:e.delegate(this,h),preProcessEventHandler:function(w){w.eventType==="wheel"&&(w.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)}),l.world.addHandler("item-index-change",function(w){window.setTimeout(function(){var x=d.world.getItemAt(w.previousIndex);d.world.setItemIndex(x,w.newIndex)},1)}),l.world.addHandler("remove-item",function(w){var x=w.item,C=d._getMatchingItem(x);C&&d.world.removeItem(C)}),this.update(l.viewport)},e.extend(e.Navigator.prototype,e.EventSource.prototype,e.Viewer.prototype,{updateSize:function(){if(this.viewport){var s=new e.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);s.equals(this.oldContainerSize)||(this.viewport.resize(s,!0),this.viewport.goHome(!0),this.oldContainerSize=s,this.drawer.clear(),this.world.draw())}},setWidth:function(s){this.width=s,this.element.style.width=typeof s=="number"?s+"px":s,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(s){this.height=s,this.element.style.height=typeof s=="number"?s+"px":s,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(s){return this.viewport.setFlip(s),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(s){r(this.displayRegion,s),r(this.canvas,s),r(this.element,s)},update:function(s){var l,d,f,v,y,T;if(l=e.getElementSize(this.viewer.element),this._resizeWithViewer&&l.x&&l.y&&!l.equals(this.oldViewerSize)&&(this.oldViewerSize=l,this.maintainSizeRatio||!this.elementArea?(d=l.x*this.sizeRatio,f=l.y*this.sizeRatio):(d=Math.sqrt(this.elementArea*(l.x/l.y)),f=this.elementArea/d),this.element.style.width=Math.round(d)+"px",this.element.style.height=Math.round(f)+"px",this.elementArea||(this.elementArea=d*f),this.updateSize()),s&&this.viewport){if(v=s.getBoundsNoRotate(!0),y=this.viewport.pixelFromPointNoRotate(v.getTopLeft(),!1),T=this.viewport.pixelFromPointNoRotate(v.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var w=s.getRotation(!0);n(this.displayRegion,-w)}var x=this.displayRegion.style;x.display=this.world.getItemCount()?"block":"none",x.top=y.y.toFixed(2)+"px",x.left=y.x.toFixed(2)+"px";var C=T.x-y.x,D=T.y-y.y;x.width=Math.round(Math.max(C,0))+"px",x.height=Math.round(Math.max(D,0))+"px"}},addTiledImage:function(s){var l=this,d=s.originalTiledImage;delete s.original;var f=e.extend({},s,{success:function(v){var y=v.item;y._originalForNavigator=d,l._matchBounds(y,d,!0),l._matchOpacity(y,d),l._matchCompositeOperation(y,d);function T(){l._matchBounds(y,d)}function w(){l._matchOpacity(y,d)}function x(){l._matchCompositeOperation(y,d)}d.addHandler("bounds-change",T),d.addHandler("clip-change",T),d.addHandler("opacity-change",w),d.addHandler("composite-operation-change",x)}});return e.Viewer.prototype.addTiledImage.apply(this,[f])},destroy:function(){return e.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(s){for(var l=this.world.getItemCount(),d,f=0;f<l;f++)if(d=this.world.getItemAt(f),d._originalForNavigator===s)return d;return null},_matchBounds:function(s,l,d){var f=l.getBoundsNoRotate();s.setPosition(f.getTopLeft(),d),s.setWidth(f.width,d),s.setRotation(l.getRotation(),d),s.setClip(l.getClip()),s.setFlip(l.getFlip())},_matchOpacity:function(s,l){s.setOpacity(l.opacity)},_matchCompositeOperation:function(s,l){s.setCompositeOperation(l.compositeOperation)}});function t(s){var l={tracker:s.eventSource,position:s.position,quick:s.quick,shift:s.shift,originalEvent:s.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",l),!l.preventDefaultAction&&s.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(s.position.x=this.viewport.getContainerSize().x-s.position.x);var d=this.viewport.pointFromPixel(s.position);this.panVertical?this.panHorizontal||(d.x=this.viewer.viewport.getCenter(!0).x):d.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(d),this.viewer.viewport.applyConstraints()}}function i(s){var l={tracker:s.eventSource,position:s.position,delta:s.delta,speed:s.speed,direction:s.direction,shift:s.shift,originalEvent:s.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",l),!l.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(s.delta.x=0),this.panVertical||(s.delta.y=0),this.viewer.viewport.flipped&&(s.delta.x=-s.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(s.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function o(s){s.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function h(s){var l={tracker:s.eventSource,position:s.position,scroll:s.scroll,shift:s.shift,originalEvent:s.originalEvent,preventDefault:s.preventDefault};this.viewer.raiseEvent("navigator-scroll",l),s.preventDefault=l.preventDefault}function n(s,l){r(s,"rotate("+l+"deg)")}function r(s,l){s.style.webkitTransform=l,s.style.mozTransform=l,s.style.msTransform=l,s.style.oTransform=l,s.style.transform=l}}(_),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 o=i.split("."),h=null,n=arguments,r=t,s;for(s=0;s<o.length-1;s++)r=r[o[s]]||{};return h=r[o[s]],typeof h!="string"&&(e.console.error("Untranslated source string:",i),h=""),h.replace(/\{\d+\}/g,function(l){var d=parseInt(l.match(/\d+/),10)+1;return d<n.length?n[d]:""})},setString:function(i,o){var h=i.split("."),n=t,r;for(r=0;r<h.length-1;r++)n[h[r]]||(n[h[r]]={}),n=n[h[r]];n[h[r]]=o}})}(_),function(e){e.Point=function(t,i){this.x=typeof t=="number"?t:0,this.y=typeof i=="number"?i: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(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},squaredDistanceTo:function(t){return Math.pow(this.x-t.x,2)+Math.pow(this.y-t.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){i=i||new e.Point(0,0);var o,h;if(t%90===0){var n=e.positiveModulo(t,360);switch(n){case 0:o=1,h=0;break;case 90:o=0,h=1;break;case 180:o=-1,h=0;break;case 270:o=0,h=-1;break}}else{var r=t*Math.PI/180;o=Math.cos(r),h=Math.sin(r)}var s=o*(this.x-i.x)-h*(this.y-i.y)+i.x,l=h*(this.x-i.x)+o*(this.y-i.y)+i.y;return new e.Point(s,l)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}}(_),function(e){e.TileSource=function(i,o,h,n,r,s){var l=this,d=arguments,f,v;if(e.isPlainObject(i)?f=i:f={width:d[0],height:d[1],tileSize:d[2],tileOverlap:d[3],minLevel:d[4],maxLevel:d[5]},e.EventSource.call(this),e.extend(!0,this,f),!this.success){for(v=0;v<arguments.length;v++)if(e.isFunction(arguments[v])){this.success=arguments[v];break}}this.success&&this.addHandler("ready",function(y){l.success(y)}),e.type(arguments[0])==="string"&&(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=f.width&&f.height?f.width/f.height:1,this.dimensions=new e.Point(f.width,f.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=f.tileOverlap?f.tileOverlap:0,this.minLevel=f.minLevel?f.minLevel:0,this.maxLevel=f.maxLevel!==void 0&&f.maxLevel!==null?f.maxLevel:f.width&&f.height?Math.ceil(Math.log(Math.max(f.width,f.height))/Math.log(2)):0,this.success&&e.isFunction(this.success)&&this.success(this))},e.TileSource.prototype={getTileSize:function(i){return e.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(i){return this._tileWidth?this._tileWidth:this.getTileSize(i)},getTileHeight:function(i){return this._tileHeight?this._tileHeight:this.getTileSize(i)},setMaxLevel:function(i){this.maxLevel=i,this._memoizeLevelScale()},getLevelScale:function(i){return this._memoizeLevelScale(),this.getLevelScale(i)},_memoizeLevelScale:function(){var i={},o;for(o=0;o<=this.maxLevel;o++)i[o]=1/Math.pow(2,this.maxLevel-o);this.getLevelScale=function(h){return i[h]}},getNumTiles:function(i){var o=this.getLevelScale(i),h=Math.ceil(o*this.dimensions.x/this.getTileWidth(i)),n=Math.ceil(o*this.dimensions.y/this.getTileHeight(i));return new e.Point(h,n)},getPixelRatio:function(i){var o=this.dimensions.times(this.getLevelScale(i)),h=1/o.x*e.pixelDensityRatio,n=1/o.y*e.pixelDensityRatio;return new e.Point(h,n)},getClosestLevel:function(){var i,o;for(i=this.minLevel+1;i<=this.maxLevel&&(o=this.getNumTiles(i),!(o.x>1||o.y>1));i++);return i-1},getTileAtPoint:function(i,o){var h=o.x>=0&&o.x<=1&&o.y>=0&&o.y<=1/this.aspectRatio;e.console.assert(h,"[TileSource.getTileAtPoint] must be called with a valid point.");var n=this.dimensions.x*this.getLevelScale(i),r=o.x*n,s=o.y*n,l=Math.floor(r/this.getTileWidth(i)),d=Math.floor(s/this.getTileHeight(i));o.x>=1&&(l=this.getNumTiles(i).x-1);var f=1e-15;return o.y>=1/this.aspectRatio-f&&(d=this.getNumTiles(i).y-1),new e.Point(l,d)},getTileBounds:function(i,o,h,n){var r=this.dimensions.times(this.getLevelScale(i)),s=this.getTileWidth(i),l=this.getTileHeight(i),d=o===0?0:s*o-this.tileOverlap,f=h===0?0:l*h-this.tileOverlap,v=s+(o===0?1:2)*this.tileOverlap,y=l+(h===0?1:2)*this.tileOverlap,T=1/r.x;return v=Math.min(v,r.x-d),y=Math.min(y,r.y-f),n?new e.Rect(0,0,v,y):new e.Rect(d*T,f*T,v*T,y*T)},getImageInfo:function(i){var o=this,h,n,r,s,l,d,f;i&&(l=i.split("/"),d=l[l.length-1],f=d.lastIndexOf("."),f>-1&&(l[l.length-1]=d.slice(0,f)));var v=null;if(this.splitHashDataForPost){var y=i.indexOf("#");y!==-1&&(v=i.substring(y+1),i=i.substr(0,y))}n=function(T){typeof T=="string"&&(T=e.parseXml(T));var w=e.TileSource.determineType(o,T,i);if(!w){o.raiseEvent("open-failed",{message:"Unable to load TileSource",source:i});return}s=w.prototype.configure.apply(o,[T,i,v]),s.ajaxWithCredentials===void 0&&(s.ajaxWithCredentials=o.ajaxWithCredentials),r=new w(s),o.ready=!0,o.raiseEvent("ready",{tileSource:r})},i.match(/\.js$/)?(h=i.split("/").pop().replace(".js",""),e.jsonp({url:i,async:!1,callbackName:h,callback:n})):e.makeAjaxRequest({url:i,postData:v,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(T){var w=t(T);n(w)},error:function(T,w){var x;try{x="HTTP "+T.status+" attempting to load TileSource: "+i}catch{var C;typeof w>"u"||!w.toString?C="Unknown error":C=w.toString(),x=C+" attempting to load TileSource: "+i}e.console.error(x),o.raiseEvent("open-failed",{message:x,source:i,postData:v})}})},supports:function(i,o){return!1},configure:function(i,o,h){throw new Error("Method not implemented.")},getTileUrl:function(i,o,h){throw new Error("Method not implemented.")},getTilePostData:function(i,o,h){return null},getTileAjaxHeaders:function(i,o,h){return{}},getTileHashKey:function(i,o,h,n,r,s){function l(d){return r?d+"+"+JSON.stringify(r):d}return l(typeof n!="string"?i+"/"+o+"_"+h:n)},tileExists:function(i,o,h){var n=this.getNumTiles(i);return i>=this.minLevel&&i<=this.maxLevel&&o>=0&&h>=0&&o<n.x&&h<n.y},hasTransparency:function(i,o,h,n){return!!i||o.match(".png")},downloadTileStart:function(i){var o=i.userData,h=new Image;o.image=h,o.request=null;var n=function(r){if(!h){i.finish(null,o.request,"Image load failed: undefined Image instance.");return}h.onload=h.onerror=h.onabort=null,i.finish(r?null:h,o.request,r)};h.onload=function(){n()},h.onabort=h.onerror=function(){n("Image load aborted.")},i.loadWithAjax?o.request=e.makeAjaxRequest({url:i.src,withCredentials:i.ajaxWithCredentials,headers:i.ajaxHeaders,responseType:"arraybuffer",postData:i.postData,success:function(r){var s;try{s=new window.Blob([r.response])}catch(f){var l=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(f.name==="TypeError"&&l){var d=new l;d.append(r.response),s=d.getBlob()}}s.size===0?n("Empty image response."):h.src=(window.URL||window.webkitURL).createObjectURL(s)},error:function(r){n("Image load aborted - XHR error")}}):(i.crossOriginPolicy!==!1&&(h.crossOrigin=i.crossOriginPolicy),h.src=i.src)},downloadTileAbort:function(i){i.userData.request&&i.userData.request.abort();var o=i.userData.image;i.userData.image&&(o.onload=o.onerror=o.onabort=null)},createTileCache:function(i,o,h){i._data=o},destroyTileCache:function(i){i._data=null,i._renderedContext=null},getTileCacheData:function(i){return i._data},getTileCacheDataAsImage:function(i){return i._data},getTileCacheDataAsContext2D:function(i){if(!i._renderedContext){var o=document.createElement("canvas");o.width=i._data.width,o.height=i._data.height,i._renderedContext=o.getContext("2d"),i._renderedContext.drawImage(i._data,0,0),i._data=null}return i._renderedContext}},e.extend(!0,e.TileSource.prototype,e.EventSource.prototype);function t(i){var o=i.responseText,h=i.status,n,r;if(i){if(i.status!==200&&i.status!==0)throw h=i.status,n=h===404?"Not Found":i.statusText,new Error(e.getString("Errors.Status",h,n))}else throw new Error(e.getString("Errors.Security"));if(o.match(/^\s*<.*/))try{r=i.responseXML&&i.responseXML.documentElement?i.responseXML:e.parseXml(o)}catch{r=i.responseText}else if(o.match(/\s*[{[].*/))try{r=e.parseJSON(o)}catch{r=o}else r=o;return r}e.TileSource.determineType=function(i,o,h){var n;for(n in _)if(n.match(/.+TileSource$/)&&e.isFunction(_[n])&&e.isFunction(_[n].prototype.supports)&&_[n].prototype.supports.call(i,o,h))return _[n];return e.console.error("No TileSource was able to open %s %s",h,o),null}}(_),function(e){e.DziTileSource=function(o,h,n,r,s,l,d,f,v){var y,T,w,x;if(e.isPlainObject(o)?x=o:x={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=x.tilesUrl,this.fileFormat=x.fileFormat,this.displayRects=x.displayRects,this.displayRects)for(y=this.displayRects.length-1;y>=0;y--)for(T=this.displayRects[y],w=T.minLevel;w<=T.maxLevel;w++)this._levelRects[w]||(this._levelRects[w]=[]),this._levelRects[w].push(T);e.TileSource.apply(this,[x])},e.extend(e.DziTileSource.prototype,e.TileSource.prototype,{supports:function(o,h){var n;return o.Image?n=o.Image.xmlns:o.documentElement&&(o.documentElement.localName==="Image"||o.documentElement.tagName==="Image")&&(n=o.documentElement.namespaceURI),n=(n||"").toLowerCase(),n.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||n.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(o,h,n){var r;return e.isPlainObject(o)?r=i(this,o):r=t(this,o),h&&!r.tilesUrl&&(r.tilesUrl=h.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),h.search(/\.(dzi|xml|js)\?/)!==-1?r.queryParams=h.match(/\?.*/):r.queryParams=""),r},getTileUrl:function(o,h,n){return[this.tilesUrl,o,"/",h,"_",n,".",this.fileFormat,this.queryParams].join("")},tileExists:function(o,h,n){var r=this._levelRects[o],s,l,d,f,v,y,T;if(this.minLevel&&o<this.minLevel||this.maxLevel&&o>this.maxLevel)return!1;if(!r||!r.length)return!0;for(T=r.length-1;T>=0;T--)if(s=r[T],!(o<s.minLevel||o>s.maxLevel)&&(l=this.getLevelScale(o),d=s.x*l,f=s.y*l,v=d+s.width*l,y=f+s.height*l,d=Math.floor(d/this._tileWidth),f=Math.floor(f/this._tileWidth),v=Math.ceil(v/this._tileWidth),y=Math.ceil(y/this._tileWidth),d<=h&&h<v&&f<=n&&n<y))return!0;return!1}});function t(o,h){if(!h||!h.documentElement)throw new Error(e.getString("Errors.Xml"));var n=h.documentElement,r=n.localName||n.tagName,s=h.documentElement.namespaceURI,l=null,d=[],f,v,y,T,w;if(r==="Image")try{if(T=n.getElementsByTagName("Size")[0],T===void 0&&(T=n.getElementsByTagNameNS(s,"Size")[0]),l={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:n.getAttribute("Url"),Format:n.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(n.getAttribute("Overlap"),10),TileSize:parseInt(n.getAttribute("TileSize"),10),Size:{Height:parseInt(T.getAttribute("Height"),10),Width:parseInt(T.getAttribute("Width"),10)}}},!e.imageFormatSupported(l.Image.Format))throw new Error(e.getString("Errors.ImageFormat",l.Image.Format.toUpperCase()));for(f=n.getElementsByTagName("DisplayRect"),f===void 0&&(f=n.getElementsByTagNameNS(s,"DisplayRect")[0]),w=0;w<f.length;w++)v=f[w],y=v.getElementsByTagName("Rect")[0],y===void 0&&(y=v.getElementsByTagNameNS(s,"Rect")[0]),d.push({Rect:{X:parseInt(y.getAttribute("X"),10),Y:parseInt(y.getAttribute("Y"),10),Width:parseInt(y.getAttribute("Width"),10),Height:parseInt(y.getAttribute("Height"),10),MinLevel:parseInt(v.getAttribute("MinLevel"),10),MaxLevel:parseInt(v.getAttribute("MaxLevel"),10)}});return d.length&&(l.Image.DisplayRect=d),i(o,l)}catch(D){throw D instanceof Error?D:new Error(e.getString("Errors.Dzi"))}else{if(r==="Collection")throw new Error(e.getString("Errors.Dzc"));if(r==="Error"){var x=n.getElementsByTagName("Message")[0],C=x.firstChild.nodeValue;throw new Error(C)}}throw new Error(e.getString("Errors.Dzi"))}function i(o,h){var n=h.Image,r=n.Url,s=n.Format,l=n.Size,d=n.DisplayRect||[],f=parseInt(l.Width,10),v=parseInt(l.Height,10),y=parseInt(n.TileSize,10),T=parseInt(n.Overlap,10),w=[],x,C;for(C=0;C<d.length;C++)x=d[C].Rect,w.push(new e.DisplayRect(parseInt(x.X,10),parseInt(x.Y,10),parseInt(x.Width,10),parseInt(x.Height,10),parseInt(x.MinLevel,10),parseInt(x.MaxLevel,10)));return e.extend(!0,{width:f,height:v,tileSize:y,tileOverlap:T,minLevel:null,maxLevel:null,tilesUrl:r,fileFormat:s,displayRects:w},h)}}(_),function(e){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(this.tiles.length===1)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 r=0;r<this.tiles.length;r++)for(var s=0;s<this.tiles[r].scaleFactors.length;s++){var l=this.tiles[r].scaleFactors[s];this.scale_factors.push(l),n.tileSizePerScaleFactor[l]={width:this.tiles[r].width,height:this.tiles[r].height||this.tiles[r].width}}}else if(t(n)){for(var d=Math.min(this.height,this.width),f=[256,512,1024],v=[],y=0;y<f.length;y++)f[y]<=d&&v.push(f[y]);v.length>0?n.tileSize=Math.max.apply(null,v):n.tileSize=d}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)n.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var T=Math.max.apply(null,this.scale_factors);n.maxLevel=Math.round(Math.log(T)*Math.LOG2E)}if(this.sizes){var w=this.sizes.length;(w===n.maxLevel||w===n.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort(function(x,C){return x.width-C.width}),w===n.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}e.TileSource.apply(this,[n])},e.extend(e.IIIFTileSource.prototype,e.TileSource.prototype,{supports:function(n,r){return n.protocol&&n.protocol==="http://iiif.io/api/image"||n["@context"]&&(n["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||n["@context"]==="http://iiif.io/api/image/1/context.json")||n.profile&&n.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||n.identifier&&n.width&&n.height?!0:!!(n.documentElement&&n.documentElement.tagName==="info"&&n.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(n,r,s){if(e.isPlainObject(n)){if(!n["@context"])n["@context"]="http://iiif.io/api/image/1.0/context.json",n["@id"]=r.replace("/info.json",""),n.version=1;else{var d=n["@context"];if(Array.isArray(d)){for(var f=0;f<d.length;f++)if(typeof d[f]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(d[f])||d[f]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){d=d[f];break}}switch(d){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":n.version=1;break;case"http://iiif.io/api/image/2/context.json":n.version=2;break;case"http://iiif.io/api/image/3/context.json":n.version=3;break;default:e.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(n.preferredFormats){for(var v=0;v<n.preferredFormats.length;v++)if(_.imageFormatSupported(n.preferredFormats[v])){n.tileFormat=n.preferredFormats[v];break}}return n}else{var l=o(n);return l["@context"]="http://iiif.io/api/image/1.0/context.json",l["@id"]=r.replace("/info.xml",""),l.version=1,l}},getTileWidth:function(n){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileWidth.call(this,n);var r=Math.pow(2,this.maxLevel-n);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[r]?this.tileSizePerScaleFactor[r].width:this._tileWidth},getTileHeight:function(n){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileHeight.call(this,n);var r=Math.pow(2,this.maxLevel-n);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[r]?this.tileSizePerScaleFactor[r].height:this._tileHeight},getLevelScale:function(n){if(this.emulateLegacyImagePyramid){var r=NaN;return this.levels.length>0&&n>=this.minLevel&&n<=this.maxLevel&&(r=this.levels[n].width/this.levels[this.maxLevel].width),r}return e.TileSource.prototype.getLevelScale.call(this,n)},getNumTiles:function(n){if(this.emulateLegacyImagePyramid){var r=this.getLevelScale(n);return r?new e.Point(1,1):new e.Point(0,0)}if(this.levelSizes){var s=this.levelSizes[n],l=Math.ceil(s.width/this.getTileWidth(n)),d=Math.ceil(s.height/this.getTileHeight(n));return new e.Point(l,d)}else return e.TileSource.prototype.getNumTiles.call(this,n)},getTileAtPoint:function(n,r){if(this.emulateLegacyImagePyramid)return new e.Point(0,0);if(this.levelSizes){var s=r.x>=0&&r.x<=1&&r.y>=0&&r.y<=1/this.aspectRatio;e.console.assert(s,"[TileSource.getTileAtPoint] must be called with a valid point.");var l=this.levelSizes[n].width,d=r.x*l,f=r.y*l,v=Math.floor(d/this.getTileWidth(n)),y=Math.floor(f/this.getTileHeight(n));r.x>=1&&(v=this.getNumTiles(n).x-1);var T=1e-15;return r.y>=1/this.aspectRatio-T&&(y=this.getNumTiles(n).y-1),new e.Point(v,y)}return e.TileSource.prototype.getTileAtPoint.call(this,n,r)},getTileUrl:function(n,r,s){if(this.emulateLegacyImagePyramid){var l=null;return this.levels.length>0&&n>=this.minLevel&&n<=this.maxLevel&&(l=this.levels[n].url),l}var d="0",f=Math.pow(.5,this.maxLevel-n),v,y,T,w,x,C,D,M,V,N,U,k,G,ee,Q,J;return this.levelSizes?(v=this.levelSizes[n].width,y=this.levelSizes[n].height):(v=Math.ceil(this.width*f),y=Math.ceil(this.height*f)),T=this.getTileWidth(n),w=this.getTileHeight(n),x=Math.round(T/f),C=Math.round(w/f),this.version===1?Q="native."+this.tileFormat:Q="default."+this.tileFormat,v<T&&y<w?(this.version===2&&v===this.width?k="full":this.version===3&&v===this.width&&y===this.height?k="max":this.version===3?k=v+","+y:k=v+",",D="full"):(M=r*x,V=s*C,N=Math.min(x,this.width-M),U=Math.min(C,this.height-V),r===0&&s===0&&N===this.width&&U===this.height?D="full":D=[M,V,N,U].join(","),G=Math.min(T,v-r*T),ee=Math.min(w,y-s*w),this.version===2&&G===this.width?k="full":this.version===3&&G===this.width&&ee===this.height?k="max":this.version===3?k=G+","+ee:k=G+","),J=[this._id,D,k,d,Q].join("/"),J},__testonly__:{canBeTiled:t,constructLevels:i}});function t(n){var r=["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"],s=Array.isArray(n.profile)?n.profile[0]:n.profile,l=r.indexOf(s)!==-1,d=!1;return n.version===2&&n.profile.length>1&&n.profile[1].supports&&(d=n.profile[1].supports.indexOf("sizeByW")!==-1),n.version===3&&n.extraFeatures&&(d=n.extraFeatures.indexOf("sizeByWh")!==-1),!l||d}function i(n){for(var r=[],s=0;s<n.sizes.length;s++)r.push({url:n._id+"/full/"+n.sizes[s].width+","+(n.version===3?n.sizes[s].height:"")+"/0/default."+n.tileFormat,width:n.sizes[s].width,height:n.sizes[s].height});return r.sort(function(l,d){return l.width-d.width})}function o(n){if(!n||!n.documentElement)throw new Error(e.getString("Errors.Xml"));var r=n.documentElement,s=r.tagName,l=null;if(s==="info")try{return l={},h(r,l),l}catch(d){throw d instanceof Error?d:new Error(e.getString("Errors.IIIF"))}throw new Error(e.getString("Errors.IIIF"))}function h(n,r,s){var l,d;if(n.nodeType===3&&s)d=n.nodeValue.trim(),d.match(/^\d*$/)&&(d=Number(d)),r[s]?(e.isArray(r[s])||(r[s]=[r[s]]),r[s].push(d)):r[s]=d;else if(n.nodeType===1)for(l=0;l<n.childNodes.length;l++)h(n.childNodes[l],r,n.nodeName)}}(_),function(e){e.OsmTileSource=function(t,i,o,h,n){var r;e.isPlainObject(t)?r=t:r={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!r.width||!r.height)&&(r.width=65572864,r.height=65572864),r.tileSize||(r.tileSize=256,r.tileOverlap=0),r.tilesUrl||(r.tilesUrl="http://tile.openstreetmap.org/"),r.minLevel=8,e.TileSource.apply(this,[r])},e.extend(e.OsmTileSource.prototype,e.TileSource.prototype,{supports:function(t,i){return t.type&&t.type==="openstreetmaps"},configure:function(t,i,o){return t},getTileUrl:function(t,i,o){return this.tilesUrl+(t-8)+"/"+i+"/"+o+".png"}})}(_),function(e){e.TmsTileSource=function(t,i,o,h,n){var r;e.isPlainObject(t)?r=t:r={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var s=Math.ceil(r.width/256)*256,l=Math.ceil(r.height/256)*256,d;s>l?d=s/256:d=l/256,r.maxLevel=Math.ceil(Math.log(d)/Math.log(2))-1,r.tileSize=256,r.width=s,r.height=l,e.TileSource.apply(this,[r])},e.extend(e.TmsTileSource.prototype,e.TileSource.prototype,{supports:function(t,i){return t.type&&t.type==="tiledmapservice"},configure:function(t,i,o){return t},getTileUrl:function(t,i,o){var h=this.getNumTiles(t).y-1;return this.tilesUrl+t+"/"+i+"/"+(h-o)+".png"}})}(_),function(e){e.ZoomifyTileSource=function(t){typeof t.tileSize>"u"&&(t.tileSize=256),typeof t.fileFormat>"u"&&(t.fileFormat="jpg",this.fileFormat=t.fileFormat);var i={x:t.width,y:t.height};for(t.imageSizes=[{x:t.width,y:t.height}],t.gridSize=[this._getGridSize(t.width,t.height,t.tileSize)];parseInt(i.x,10)>t.tileSize||parseInt(i.y,10)>t.tileSize;)i.x=Math.floor(i.x/2),i.y=Math.floor(i.y/2),t.imageSizes.push({x:i.x,y:i.y}),t.gridSize.push(this._getGridSize(i.x,i.y,t.tileSize));t.imageSizes.reverse(),t.gridSize.reverse(),t.minLevel=0,t.maxLevel=t.gridSize.length-1,_.TileSource.apply(this,[t])},e.extend(e.ZoomifyTileSource.prototype,e.TileSource.prototype,{_getGridSize:function(t,i,o){return{x:Math.ceil(t/o),y:Math.ceil(i/o)}},_calculateAbsoluteTileNumber:function(t,i,o){for(var h=0,n={},r=0;r<t;r++)n=this.gridSize[r],h+=n.x*n.y;return n=this.gridSize[t],h+=n.x*o+i,h},supports:function(t,i){return t.type&&t.type==="zoomifytileservice"},configure:function(t,i,o){return t},getTileUrl:function(t,i,o){var h=0,n=this._calculateAbsoluteTileNumber(t,i,o);return h=Math.floor(n/256),this.tilesUrl+"TileGroup"+h+"/"+t+"-"+i+"-"+o+"."+this.fileFormat}})}(_),function(e){e.LegacyTileSource=function(h){var n,r,s;e.isArray(h)&&(n={type:"legacy-image-pyramid",levels:h}),n.levels=t(n.levels),n.levels.length>0?(r=n.levels[n.levels.length-1].width,s=n.levels[n.levels.length-1].height):(r=0,s=0,e.console.error("No supported image formats found")),e.extend(!0,n,{width:r,height:s,tileSize:Math.max(s,r),tileOverlap:0,minLevel:0,maxLevel:n.levels.length>0?n.levels.length-1:0}),e.TileSource.apply(this,[n]),this.levels=n.levels},e.extend(e.LegacyTileSource.prototype,e.TileSource.prototype,{supports:function(h,n){return h.type&&h.type==="legacy-image-pyramid"||h.documentElement&&h.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(h,n,r){var s;return e.isPlainObject(h)?s=o(this,h):s=i(this,h),s},getLevelScale:function(h){var n=NaN;return this.levels.length>0&&h>=this.minLevel&&h<=this.maxLevel&&(n=this.levels[h].width/this.levels[this.maxLevel].width),n},getNumTiles:function(h){var n=this.getLevelScale(h);return n?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(h,n,r){var s=null;return this.levels.length>0&&h>=this.minLevel&&h<=this.maxLevel&&(s=this.levels[h].url),s}});function t(h){var n=[],r,s;for(s=0;s<h.length;s++)r=h[s],r.height&&r.width&&r.url?n.push({url:r.url,width:Number(r.width),height:Number(r.height)}):e.console.error("Unsupported image format: %s",r.url?r.url:"<no URL>");return n.sort(function(l,d){return l.height-d.height})}function i(h,n){if(!n||!n.documentElement)throw new Error(e.getString("Errors.Xml"));var r=n.documentElement,s=r.tagName,l=null,d=[],f,v;if(s==="image")try{for(l={type:r.getAttribute("type"),levels:[]},d=r.getElementsByTagName("level"),v=0;v<d.length;v++)f=d[v],l.levels.push({url:f.getAttribute("url"),width:parseInt(f.getAttribute("width"),10),height:parseInt(f.getAttribute("height"),10)});return o(h,l)}catch(y){throw y instanceof Error?y:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(s==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(s==="error")throw new Error("Error: "+n)}throw new Error("Unknown element "+s)}function o(h,n){return n.levels}}(_),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(t,i){return t.type&&t.type==="image"},configure:function(t,i,o){return t},getImageInfo:function(t){var i=this._image=new Image,o=this;this.crossOriginPolicy&&(i.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(i.useCredentials=this.ajaxWithCredentials),e.addEvent(i,"load",function(){o.width=i.naturalWidth,o.height=i.naturalHeight,o.aspectRatio=o.width/o.height,o.dimensions=new e.Point(o.width,o.height),o._tileWidth=o.width,o._tileHeight=o.height,o.tileOverlap=0,o.minLevel=0,o.levels=o._buildLevels(),o.maxLevel=o.levels.length-1,o.ready=!0,o.raiseEvent("ready",{tileSource:o})}),e.addEvent(i,"error",function(){o.raiseEvent("open-failed",{message:"Error loading image at "+t,source:t})}),i.src=t},getLevelScale:function(t){var i=NaN;return t>=this.minLevel&&t<=this.maxLevel&&(i=this.levels[t].width/this.levels[this.maxLevel].width),i},getNumTiles:function(t){var i=this.getLevelScale(t);return i?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(t,i,o){var h=null;return t>=this.minLevel&&t<=this.maxLevel&&(h=this.levels[t].url),h},getContext2D:function(t,i,o){var h=null;return t>=this.minLevel&&t<=this.maxLevel&&(h=this.levels[t].context2D),h},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,o=this._image.naturalHeight,h=document.createElement("canvas"),n=h.getContext("2d");if(h.width=i,h.height=o,n.drawImage(this._image,0,0,i,o),t[0].context2D=n,delete this._image,e.isCanvasTainted(h))return t;for(;i>=2&&o>=2;){i=Math.floor(i/2),o=Math.floor(o/2);var r=document.createElement("canvas"),s=r.getContext("2d");r.width=i,r.height=o,s.drawImage(h,0,0,i,o),t.splice(0,0,{context2D:s,width:i,height:o}),h=r,n=s}return t},_freeupCanvasMemory:function(){for(var t=0;t<this.levels.length;t++)this.levels[t].context2D&&(this.levels[t].context2D.canvas.height=0,this.levels[t].context2D.canvas.width=0)}})}(_),function(e){e.TileSourceCollection=function(t,i,o,h){e.console.error("TileSourceCollection is deprecated; use World instead")}}(_),function(e){e.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},e.Button=function(s){var l=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},s),this.element=s.element||e.makeNeutralElement("div"),s.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(d){d.insideElementPressed?(n(l,e.ButtonState.DOWN),l.raiseEvent("enter",{originalEvent:d.originalEvent})):d.buttonDownAny||n(l,e.ButtonState.HOVER)},focusHandler:function(d){l.tracker.enterHandler(d),l.raiseEvent("focus",{originalEvent:d.originalEvent})},leaveHandler:function(d){r(l,e.ButtonState.GROUP),d.insideElementPressed&&l.raiseEvent("exit",{originalEvent:d.originalEvent})},blurHandler:function(d){l.tracker.leaveHandler(d),l.raiseEvent("blur",{originalEvent:d.originalEvent})},pressHandler:function(d){n(l,e.ButtonState.DOWN),l.raiseEvent("press",{originalEvent:d.originalEvent})},releaseHandler:function(d){d.insideElementPressed&&d.insideElementReleased?(r(l,e.ButtonState.HOVER),l.raiseEvent("release",{originalEvent:d.originalEvent})):d.insideElementPressed?r(l,e.ButtonState.GROUP):n(l,e.ButtonState.HOVER)},clickHandler:function(d){d.quick&&l.raiseEvent("click",{originalEvent:d.originalEvent})},keyHandler:function(d){d.keyCode===13?(l.raiseEvent("click",{originalEvent:d.originalEvent}),l.raiseEvent("release",{originalEvent:d.originalEvent}),d.preventDefault=!0):d.preventDefault=!1}}),r(this,e.ButtonState.REST)},e.extend(e.Button.prototype,e.EventSource.prototype,{notifyGroupEnter:function(){n(this,e.ButtonState.GROUP)},notifyGroupExit:function(){r(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}});function t(s){e.requestAnimationFrame(function(){i(s)})}function i(s){var l,d,f;s.shouldFade&&(l=e.now(),d=l-s.fadeBeginTime,f=1-d/s.fadeLength,f=Math.min(1,f),f=Math.max(0,f),s.imgGroup&&e.setElementOpacity(s.imgGroup,f,!0),f>0&&t(s))}function o(s){s.shouldFade=!0,s.fadeBeginTime=e.now()+s.fadeDelay,window.setTimeout(function(){t(s)},s.fadeDelay)}function h(s){s.shouldFade=!1,s.imgGroup&&e.setElementOpacity(s.imgGroup,1,!0)}function n(s,l){s.element.disabled||(l>=e.ButtonState.GROUP&&s.currentState===e.ButtonState.REST&&(h(s),s.currentState=e.ButtonState.GROUP),l>=e.ButtonState.HOVER&&s.currentState===e.ButtonState.GROUP&&(s.imgHover&&(s.imgHover.style.visibility=""),s.currentState=e.ButtonState.HOVER),l>=e.ButtonState.DOWN&&s.currentState===e.ButtonState.HOVER&&(s.imgDown&&(s.imgDown.style.visibility=""),s.currentState=e.ButtonState.DOWN))}function r(s,l){s.element.disabled||(l<=e.ButtonState.HOVER&&s.currentState===e.ButtonState.DOWN&&(s.imgDown&&(s.imgDown.style.visibility="hidden"),s.currentState=e.ButtonState.HOVER),l<=e.ButtonState.GROUP&&s.currentState===e.ButtonState.HOVER&&(s.imgHover&&(s.imgHover.style.visibility="hidden"),s.currentState=e.ButtonState.GROUP),l<=e.ButtonState.REST&&s.currentState===e.ButtonState.GROUP&&(o(s),s.currentState=e.ButtonState.REST))}}(_),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=this.buttons.concat([]),o=this,h;if(this.element=t.element||e.makeNeutralElement("div"),!t.group)for(this.element.style.display="inline-block",h=0;h<i.length;h++)this.element.appendChild(i[h].element);e.setElementTouchActionNone(this.element),this.tracker=new e.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(n){var r;for(r=0;r<o.buttons.length;r++)o.buttons[r].notifyGroupEnter()},leaveHandler:function(n){var r;if(!n.insideElementPressed)for(r=0;r<o.buttons.length;r++)o.buttons[r].notifyGroupExit()}})},e.ButtonGroup.prototype={addButton:function(t){this.buttons.push(t),this.element.appendChild(t.element)},emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){var t=this.buttons.pop();this.element.removeChild(t.element),t.destroy()}this.tracker.destroy(),this.element=null}}}(_),function(e){e.Rect=function(t,i,o,h,n){this.x=typeof t=="number"?t:0,this.y=typeof i=="number"?i:0,this.width=typeof o=="number"?o:0,this.height=typeof h=="number"?h:0,this.degrees=typeof n=="number"?n:0,this.degrees=e.positiveModulo(this.degrees,360);var r,s;this.degrees>=270?(r=this.getTopRight(),this.x=r.x,this.y=r.y,s=this.height,this.height=this.width,this.width=s,this.degrees-=270):this.degrees>=180?(r=this.getBottomRight(),this.x=r.x,this.y=r.y,this.degrees-=180):this.degrees>=90&&(r=this.getBottomLeft(),this.x=r.x,this.y=r.y,s=this.height,this.height=this.width,this.width=s,this.degrees-=90)},e.Rect.fromSummits=function(t,i,o){var h=t.distanceTo(i),n=t.distanceTo(o),r=i.minus(t),s=Math.atan(r.y/r.x);return r.x<0?s+=Math.PI:r.y<0&&(s+=2*Math.PI),new e.Rect(t.x,t.y,h,n,s/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(),o=t.getBoundingBox(),h=Math.min(i.x,o.x),n=Math.min(i.y,o.y),r=Math.max(i.x+i.width,o.x+o.width),s=Math.max(i.y+i.height,o.y+o.height);return new e.Rect(h,n,r-h,s-n)},intersection:function(t){var i=1e-10,o=[],h=this.getTopLeft();t.containsPoint(h,i)&&o.push(h);var n=this.getTopRight();t.containsPoint(n,i)&&o.push(n);var r=this.getBottomLeft();t.containsPoint(r,i)&&o.push(r);var s=this.getBottomRight();t.containsPoint(s,i)&&o.push(s);var l=t.getTopLeft();this.containsPoint(l,i)&&o.push(l);var d=t.getTopRight();this.containsPoint(d,i)&&o.push(d);var f=t.getBottomLeft();this.containsPoint(f,i)&&o.push(f);var v=t.getBottomRight();this.containsPoint(v,i)&&o.push(v);for(var y=this._getSegments(),T=t._getSegments(),w=0;w<y.length;w++)for(var x=y[w],C=0;C<T.length;C++){var D=T[C],M=V(x[0],x[1],D[0],D[1]);M&&o.push(M)}function V(J,se,ce,Se){var ue=se.minus(J),de=Se.minus(ce),pe=-de.x*ue.y+ue.x*de.y;if(pe===0)return null;var ye=(ue.x*(J.y-ce.y)-ue.y*(J.x-ce.x))/pe,me=(de.x*(J.y-ce.y)-de.y*(J.x-ce.x))/pe;return-i<=ye&&ye<=1-i&&-i<=me&&me<=1-i?new e.Point(J.x+me*ue.x,J.y+me*ue.y):null}if(o.length===0)return null;for(var N=o[0].x,U=o[0].x,k=o[0].y,G=o[0].y,ee=1;ee<o.length;ee++){var Q=o[ee];Q.x<N&&(N=Q.x),Q.x>U&&(U=Q.x),Q.y<k&&(k=Q.y),Q.y>G&&(G=Q.y)}return new e.Rect(N,k,U-N,G-k)},_getSegments:function(){var t=this.getTopLeft(),i=this.getTopRight(),o=this.getBottomLeft(),h=this.getBottomRight();return[[t,i],[i,h],[h,o],[o,t]]},rotate:function(t,i){if(t=e.positiveModulo(t,360),t===0)return this.clone();i=i||this.getCenter();var o=this.getTopLeft().rotate(t,i),h=this.getTopRight().rotate(t,i),n=h.minus(o);n=n.apply(function(s){var l=1e-15;return Math.abs(s)<l?0:s});var r=Math.atan(n.y/n.x);return n.x<0?r+=Math.PI:n.y<0&&(r+=2*Math.PI),new e.Rect(o.x,o.y,this.width,this.height,r/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var t=this.getTopLeft(),i=this.getTopRight(),o=this.getBottomLeft(),h=this.getBottomRight(),n=Math.min(t.x,i.x,o.x,h.x),r=Math.max(t.x,i.x,o.x,h.x),s=Math.min(t.y,i.y,o.y,h.y),l=Math.max(t.y,i.y,o.y,h.y);return new e.Rect(n,s,r-n,l-s)},getIntegerBoundingBox:function(){var t=this.getBoundingBox(),i=Math.floor(t.x),o=Math.floor(t.y),h=Math.ceil(t.width+t.x-i),n=Math.ceil(t.height+t.y-o);return new e.Rect(i,o,h,n)},containsPoint:function(t,i){i=i||0;var o=this.getTopLeft(),h=this.getTopRight(),n=this.getBottomLeft(),r=h.minus(o),s=n.minus(o);return(t.x-o.x)*r.x+(t.y-o.y)*r.y>=-i&&(t.x-h.x)*r.x+(t.y-h.y)*r.y<=i&&(t.x-o.x)*s.x+(t.y-o.y)*s.y>=-i&&(t.x-n.x)*s.x+(t.y-n.y)*s.y<=i},toString:function(){return"["+Math.round(this.x*100)/100+", "+Math.round(this.y*100)/100+", "+Math.round(this.width*100)/100+"x"+Math.round(this.height*100)/100+", "+Math.round(this.degrees*100)/100+"deg]"}}}(_),function(e){var t={};e.ReferenceStrip=function(f){var v=this,y=f.viewer,T=e.getElementSize(y.element),w,x,C;for(f.id||(f.id="referencestrip-"+e.now(),this.element=e.makeNeutralElement("div"),this.element.id=f.id,this.element.className="referencestrip"),f=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.referenceStripSizeRatio,position:e.DEFAULT_SETTINGS.referenceStripPosition,scroll:e.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold},f,{element:this.element}),e.extend(this,f),t[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,x=this.element.style,x.marginTop="0px",x.marginRight="0px",x.marginBottom="0px",x.marginLeft="0px",x.left="0px",x.bottom="0px",x.border="0px",x.background="#000",x.position="relative",e.setElementTouchActionNone(this.element),e.setElementOpacity(this.element,.8),this.viewer=y,this.tracker=new e.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:e.delegate(this,i),dragHandler:e.delegate(this,o),scrollHandler:e.delegate(this,h),enterHandler:e.delegate(this,r),leaveHandler:e.delegate(this,s),keyDownHandler:e.delegate(this,l),keyHandler:e.delegate(this,d),preProcessEventHandler:function(D){D.eventType==="wheel"&&(D.preventDefault=!0)}}),f.width&&f.height?(this.element.style.width=f.width+"px",this.element.style.height=f.height+"px",y.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):f.scroll==="horizontal"?(this.element.style.width=T.x*f.sizeRatio*y.tileSources.length+12*y.tileSources.length+"px",this.element.style.height=T.y*f.sizeRatio+"px",y.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=T.y*f.sizeRatio*y.tileSources.length+12*y.tileSources.length+"px",this.element.style.width=T.x*f.sizeRatio+"px",y.addControl(this.element,{anchor:e.ControlAnchor.TOP_LEFT})),this.panelWidth=T.x*this.sizeRatio+8,this.panelHeight=T.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},C=0;C<y.tileSources.length;C++)w=e.makeNeutralElement("div"),w.id=this.element.id+"-"+C,w.style.width=v.panelWidth+"px",w.style.height=v.panelHeight+"px",w.style.display="inline",w.style.float="left",w.style.cssFloat="left",w.style.styleFloat="left",w.style.padding="2px",e.setElementTouchActionNone(w),e.setElementPointerEventsNone(w),this.element.appendChild(w),w.activePanel=!1,this.panels.push(w);n(this,this.scroll==="vertical"?T.y:T.x,0),this.setFocus(0)},e.ReferenceStrip.prototype={setFocus:function(f){var v=this.element.querySelector("#"+this.element.id+"-"+f),y=e.getElementSize(this.viewer.canvas),T=Number(this.element.style.width.replace("px","")),w=Number(this.element.style.height.replace("px","")),x=-Number(this.element.style.marginLeft.replace("px","")),C=-Number(this.element.style.marginTop.replace("px","")),D;this.currentSelected!==v&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=v,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(D=Number(f)*(this.panelWidth+3),D>x+y.x-this.panelWidth?(D=Math.min(D,T-y.x),this.element.style.marginLeft=-D+"px",n(this,y.x,-D)):D<x&&(D=Math.max(0,D-y.x/2),this.element.style.marginLeft=-D+"px",n(this,y.x,-D))):(D=Number(f)*(this.panelHeight+3),D>C+y.y-this.panelHeight?(D=Math.min(D,w-y.y),this.element.style.marginTop=-D+"px",n(this,y.y,-D)):D<C&&(D=Math.max(0,D-y.y/2),this.element.style.marginTop=-D+"px",n(this,y.y,-D))),this.currentPage=f,r.call(this,{eventSource:this.tracker}))},update:function(){return!!t[this.id].animating},destroy:function(){if(this.miniViewers)for(var f in this.miniViewers)this.miniViewers[f].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}};function i(f){if(f.quick){var v;this.scroll==="horizontal"?v=Math.floor(f.position.x/(this.panelWidth+4)):v=Math.floor(f.position.y/this.panelHeight),this.viewer.goToPage(v)}this.element.focus()}function o(f){if(this.dragging=!0,this.element){var v=Number(this.element.style.marginLeft.replace("px","")),y=Number(this.element.style.marginTop.replace("px","")),T=Number(this.element.style.width.replace("px","")),w=Number(this.element.style.height.replace("px","")),x=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-f.delta.x>0?v>-(T-x.x)&&(this.element.style.marginLeft=v+f.delta.x*2+"px",n(this,x.x,v+f.delta.x*2)):-f.delta.x<0&&v<0&&(this.element.style.marginLeft=v+f.delta.x*2+"px",n(this,x.x,v+f.delta.x*2)):-f.delta.y>0?y>-(w-x.y)&&(this.element.style.marginTop=y+f.delta.y*2+"px",n(this,x.y,y+f.delta.y*2)):-f.delta.y<0&&y<0&&(this.element.style.marginTop=y+f.delta.y*2+"px",n(this,x.y,y+f.delta.y*2))}}function h(f){if(this.element){var v=Number(this.element.style.marginLeft.replace("px","")),y=Number(this.element.style.marginTop.replace("px","")),T=Number(this.element.style.width.replace("px","")),w=Number(this.element.style.height.replace("px","")),x=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?f.scroll>0?v>-(T-x.x)&&(this.element.style.marginLeft=v-f.scroll*60+"px",n(this,x.x,v-f.scroll*60)):f.scroll<0&&v<0&&(this.element.style.marginLeft=v-f.scroll*60+"px",n(this,x.x,v-f.scroll*60)):f.scroll<0?y>x.y-w&&(this.element.style.marginTop=y+f.scroll*60+"px",n(this,x.y,y+f.scroll*60)):f.scroll>0&&y<0&&(this.element.style.marginTop=y+f.scroll*60+"px",n(this,x.y,y+f.scroll*60)),f.preventDefault=!0}}function n(f,v,y){var T,w,x,C,D,M;for(f.scroll==="horizontal"?T=f.panelWidth:T=f.panelHeight,w=Math.ceil(v/T)+5,x=Math.ceil((Math.abs(y)+v)/T)+1,w=x-w,w=w<0?0:w,D=w;D<x&&D<f.panels.length;D++)if(M=f.panels[D],!M.activePanel){var V,N=f.viewer.tileSources[D];N.referenceStripThumbnailUrl?V={type:"image",url:N.referenceStripThumbnailUrl}:V=N,C=new e.Viewer({id:M.id,tileSources:[V],element:M,navigatorSizeRatio:f.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:f.viewer.loadTilesWithAjax,ajaxHeaders:f.viewer.ajaxHeaders,useCanvas:f.useCanvas}),e.setElementPointerEventsNone(C.canvas),e.setElementPointerEventsNone(C.container),C.innerTracker.setTracking(!1),C.outerTracker.setTracking(!1),f.miniViewers[M.id]=C,M.activePanel=!0}}function r(f){var v=f.eventSource.element;this.scroll==="horizontal"?v.style.marginBottom="0px":v.style.marginLeft="0px"}function s(f){var v=f.eventSource.element;this.scroll==="horizontal"?v.style.marginBottom="-"+e.getElementSize(v).y/2+"px":v.style.marginLeft="-"+e.getElementSize(v).x/2+"px"}function l(f){if(!f.ctrl&&!f.alt&&!f.meta)switch(f.keyCode){case 38:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),f.preventDefault=!0;break;case 40:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),f.preventDefault=!0;break;case 37:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),f.preventDefault=!0;break;case 39:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),f.preventDefault=!0;break;default:f.preventDefault=!1;break}else f.preventDefault=!1}function d(f){if(!f.ctrl&&!f.alt&&!f.meta)switch(f.keyCode){case 61:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),f.preventDefault=!0;break;case 45:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),f.preventDefault=!0;break;case 48:case 119:case 87:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),f.preventDefault=!0;break;case 115:case 83:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),f.preventDefault=!0;break;case 97:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),f.preventDefault=!0;break;case 100:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),f.preventDefault=!0;break;default:f.preventDefault=!1;break}else f.preventDefault=!1}}(_),function(e){e.DisplayRect=function(t,i,o,h,n,r){e.Rect.apply(this,[t,i,o,h]),this.minLevel=n,this.maxLevel=r},e.extend(e.DisplayRect.prototype,e.Rect.prototype)}(_),function(e){e.Spring=function(i){var o=arguments;typeof i!="object"&&(i={initial:o.length&&typeof o[0]=="number"?o[0]:void 0,springStiffness:o.length>1?o[1].springStiffness:5,animationTime:o.length>1?o[1].animationTime:1.5}),e.console.assert(typeof i.springStiffness=="number"&&i.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),e.console.assert(typeof i.animationTime=="number"&&i.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),i.exponential&&(this._exponential=!0,delete i.exponential),e.extend(!0,this,i),this.current={value:typeof this.initial=="number"?this.initial:this._exponential?0:1,time:e.now()},e.console.assert(!this._exponential||this.current.value!==0,"[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(i){e.console.assert(!this._exponential||i!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=i,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(i){e.console.assert(!this._exponential||i!==0,"[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=i,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(i){this.start.value+=i,this.target.value+=i,this._exponential&&(e.console.assert(this.target.value!==0&&this.start.value!==0,"[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(i){this._exponential=i,this._exponential&&(e.console.assert(this.current.value!==0&&this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.setExponential] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},update:function(){this.current.time=e.now();var i,o;this._exponential?(i=this.start._logValue,o=this.target._logValue):(i=this.start.value,o=this.target.value);var h=this.current.time>=this.target.time?o:i+(o-i)*t(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time)),n=this.current.value;return this._exponential?this.current.value=Math.exp(h):this.current.value=h,n!==this.current.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function t(i,o){return(1-Math.exp(i*-o))/(1-Math.exp(-i))}}(_),function(e){e.ImageJob=function(i){e.extend(!0,this,{timeout:e.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},i),this.data=null,this.userData={},this.errorMsg=null},e.ImageJob.prototype={start:function(){this.tries++;var i=this,o=this.abort;this.jobId=window.setTimeout(function(){i.finish(null,null,"Image load exceeded timeout ("+i.timeout+" ms)")},this.timeout),this.abort=function(){i.source.downloadTileAbort(i),typeof o=="function"&&o()},this.source.downloadTileStart(this)},finish:function(i,o,h){this.data=i,this.request=o,this.errorMsg=h,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},e.ImageLoader=function(i){e.extend(!0,this,{jobLimit:e.DEFAULT_SETTINGS.imageLoaderLimit,timeout:e.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},i)},e.ImageLoader.prototype={addJob:function(i){if(!i.source){e.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var o=e.TileSource.prototype;i.source={downloadTileStart:o.downloadTileStart,downloadTileAbort:o.downloadTileAbort}}var h=this,n=function(l){t(h,l,i.callback)},r={src:i.src,tile:i.tile||{},source:i.source,loadWithAjax:i.loadWithAjax,ajaxHeaders:i.loadWithAjax?i.ajaxHeaders:null,crossOriginPolicy:i.crossOriginPolicy,ajaxWithCredentials:i.ajaxWithCredentials,postData:i.postData,callback:n,abort:i.abort,timeout:this.timeout},s=new e.ImageJob(r);!this.jobLimit||this.jobsInProgress<this.jobLimit?(s.start(),this.jobsInProgress++):this.jobQueue.push(s)},clear:function(){for(var i=0;i<this.jobQueue.length;i++){var o=this.jobQueue[i];typeof o.abort=="function"&&o.abort()}this.jobQueue=[]}};function t(i,o,h){o.errorMsg!==""&&(o.data===null||o.data===void 0)&&o.tries<1+i.tileRetryMax&&i.failedTiles.push(o);var n;i.jobsInProgress--,(!i.jobLimit||i.jobsInProgress<i.jobLimit)&&i.jobQueue.length>0&&(n=i.jobQueue.shift(),n.start(),i.jobsInProgress++),i.tileRetryMax>0&&i.jobQueue.length===0&&(!i.jobLimit||i.jobsInProgress<i.jobLimit)&&i.failedTiles.length>0&&(n=i.failedTiles.shift(),setTimeout(function(){n.start()},i.tileRetryDelay),i.jobsInProgress++),h(o.data,o.errorMsg,o.request)}}(_),function(e){e.Tile=function(t,i,o,h,n,r,s,l,d,f,v,y){this.level=t,this.x=i,this.y=o,this.bounds=h,this.sourceBounds=f,this.exists=n,this._url=r,this.postData=v,this.context2D=s,this.loadWithAjax=l,this.ajaxHeaders=d,y===void 0&&(e.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),y=e.TileSource.prototype.getTileHashKey(t,i,o,r,d,v)),this.cacheKey=y,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){e.console.warn("[Tile.drawHTML] attempting to draw tile %s when it's not cached",this.toString());return}if(!this.loaded){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString());return}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)},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 typeof this._url=="function"?this._url():this._url},getCanvasContext:function(){return this.context2D||this.cacheImageRecord.getRenderedContext()},drawCanvas:function(t,i,o,h,n,r){var s=this.position.times(e.pixelDensityRatio),l=this.size.times(e.pixelDensityRatio),d;if(!this.context2D&&!this.cacheImageRecord){e.console.warn("[Tile.drawCanvas] attempting to draw tile %s when it's not cached",this.toString());return}if(d=this.getCanvasContext(),!this.loaded||!d){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString());return}t.save(),t.globalAlpha=this.opacity,typeof o=="number"&&o!==1&&(s=s.times(o),l=l.times(o)),h instanceof e.Point&&(s=s.plus(h)),t.globalAlpha===1&&this.hasTransparency&&(n&&(s.x=Math.round(s.x),s.y=Math.round(s.y),l.x=Math.round(l.x),l.y=Math.round(l.y)),t.clearRect(s.x,s.y,l.x,l.y)),i({context:t,tile:this,rendered:d});var f,v;this.sourceBounds?(f=Math.min(this.sourceBounds.width,d.canvas.width),v=Math.min(this.sourceBounds.height,d.canvas.height)):(f=d.canvas.width,v=d.canvas.height),t.translate(s.x+l.x/2,0),this.flipped&&t.scale(-1,1),t.drawImage(d.canvas,0,0,f,v,-l.x/2,s.y,l.x,l.y),t.restore()},getScaleForEdgeSmoothing:function(){var t;if(this.cacheImageRecord)t=this.cacheImageRecord.getRenderedContext();else if(this.context2D)t=this.context2D;else return e.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString()),1;return t.canvas.width/(this.size.x*e.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(t,i,o){var h=Math.max(1,Math.ceil((o.x-i.x)/2)),n=Math.max(1,Math.ceil((o.y-i.y)/2));return new e.Point(h,n).minus(this.position.times(e.pixelDensityRatio).times(t||1).apply(function(r){return r%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}}}(_),function(e){e.OverlayPlacement=e.Placement,e.OverlayRotationMode=e.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),e.Overlay=function(t,i,o){var h;e.isPlainObject(t)?h=t:h={element:t,location:i,placement:o},this.element=h.element,this.style=h.element.style,this._init(h)},e.Overlay.prototype={_init:function(t){this.location=t.location,this.placement=t.placement===void 0?e.Placement.TOP_LEFT:t.placement,this.onDraw=t.onDraw,this.checkResize=t.checkResize===void 0?!0:t.checkResize,this.width=t.width===void 0?null:t.width,this.height=t.height===void 0?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=this.width!==null&&this.height!==null,this.bounds=new e.Rect(this.location.x,this.location.y,this.width,this.height),this.position=this.location},adjust:function(t,i){var o=e.Placement.properties[this.placement];o&&(o.isHorizontallyCentered?t.x-=i.x/2:o.isRight&&(t.x-=i.x),o.isVerticallyCentered?t.y-=i.y/2:o.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="",this.width!==null&&(i.width=""),this.height!==null&&(i.height="");var o=e.getCssPropertyWithVendorPrefix("transformOrigin"),h=e.getCssPropertyWithVendorPrefix("transform");o&&h&&(i[o]="",i[h]="")},drawHTML:function(t,i){var o=this.element;o.parentNode!==t&&(o.prevElementParent=o.parentNode,o.prevNextSibling=o.nextSibling,t.appendChild(o),this.style.position="absolute",this.size=e.getElementSize(o));var h=this._getOverlayPositionAndSize(i),n=h.position,r=this.size=h.size,s=h.rotate;if(this.onDraw)this.onDraw(n,r,this.element);else{var l=this.style;l.left=n.x+"px",l.top=n.y+"px",this.width!==null&&(l.width=r.x+"px"),this.height!==null&&(l.height=r.y+"px");var d=e.getCssPropertyWithVendorPrefix("transformOrigin"),f=e.getCssPropertyWithVendorPrefix("transform");d&&f&&(s?(l[d]=this._getTransformOrigin(),l[f]="rotate("+s+"deg)"):(l[d]="",l[f]="")),l.display="block"}},_getOverlayPositionAndSize:function(t){var i=t.pixelFromPoint(this.location,!0),o=this._getSizeInPixels(t);this.adjust(i,o);var h=0;if(t.getRotation(!0)&&this.rotationMode!==e.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX&&this.width!==null&&this.height!==null){var n=new e.Rect(i.x,i.y,o.x,o.y),r=this._getBoundingBox(n,t.getRotation(!0));i=r.getTopLeft(),o=r.getSize()}else h=t.getRotation(!0);return{position:i,size:o,rotate:h}},_getSizeInPixels:function(t){var i=this.size.x,o=this.size.y;if(this.width!==null||this.height!==null){var h=t.deltaPixelsFromPointsNoRotate(new e.Point(this.width||0,this.height||0),!0);this.width!==null&&(i=h.x),this.height!==null&&(o=h.y)}if(this.checkResize&&(this.width===null||this.height===null)){var n=this.size=e.getElementSize(this.element);this.width===null&&(i=n.x),this.height===null&&(o=n.y)}return new e.Point(i,o)},_getBoundingBox:function(t,i){var o=this._getPlacementPoint(t);return t.rotate(i,o).getBoundingBox()},_getPlacementPoint:function(t){var i=new e.Point(t.x,t.y),o=e.Placement.properties[this.placement];return o&&(o.isHorizontallyCentered?i.x+=t.width/2:o.isRight&&(i.x+=t.width),o.isVerticallyCentered?i.y+=t.height/2:o.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},update:function(t,i){var o=e.isPlainObject(t)?t:{location:t,placement:i};this._init({location:o.location||this.location,placement:o.placement!==void 0?o.placement:this.placement,onDraw:o.onDraw||this.onDraw,checkResize:o.checkResize||this.checkResize,width:o.width!==void 0?o.width:this.width,height:o.height!==void 0?o.height:this.height,rotationMode:o.rotationMode||this.rotationMode})},getBounds:function(t){e.console.assert(t,"A viewport must now be passed to Overlay.getBounds.");var i=this.width,o=this.height;if(i===null||o===null){var h=t.deltaPointsFromPixelsNoRotate(this.size,!0);i===null&&(i=h.x),o===null&&(o=h.y)}var n=this.location.clone();return this.adjust(n,new e.Point(i,o)),this._adjustBoundsForRotation(t,new e.Rect(n.x,n.y,i,o))},_adjustBoundsForRotation:function(t,i){if(!t||t.getRotation(!0)===0||this.rotationMode===e.OverlayRotationMode.EXACT)return i;if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return i;var o=this._getOverlayPositionAndSize(t);return t.viewerElementToViewportRectangle(new e.Rect(o.position.x,o.position.y,o.size.x,o.size.y))}return i.rotate(-t.getRotation(!0),this._getPlacementPoint(i))}}}(_),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=typeof t.debugGridColor=="string"?[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:!0),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 o=this._calculateCanvasSize();this.canvas.width=o.x,this.canvas.height=o.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,o,h){return e.console.error("drawer.addOverlay is deprecated. Use viewer.addOverlay instead."),this.viewer.addOverlay(t,i,o,h),this},updateOverlay:function(t,i,o){return e.console.error("drawer.updateOverlay is deprecated. Use viewer.updateOverlay instead."),this.viewer.updateOverlay(t,i,o),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(t,i){if(this.useCanvas){var o=this._getContext(i);o.beginPath(),t.forEach(function(h){h.forEach(function(n,r){o[r===0?"moveTo":"lineTo"](n.x,n.y)})}),o.clip()}},setOpacity:function(t){e.console.error("drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.");for(var i=this.viewer.world,o=0;o<i.getItemCount();o++)i.getItemAt(o).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,o=0;o<t.getItemCount();o++){var h=t.getItemAt(o).getOpacity();h>i&&(i=h)}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 t=this._calculateCanvasSize();if((this.canvas.width!==t.x||this.canvas.height!==t.y)&&(this.canvas.width=t.x,this.canvas.height=t.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var i=this._calculateSketchCanvasSize();this.sketchCanvas.width=i.x,this.sketchCanvas.height=i.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}},_clear:function(t,i){if(this.useCanvas){var o=this._getContext(t);if(i)o.clearRect(i.x,i.y,i.width,i.height);else{var h=o.canvas;o.clearRect(0,0,h.width,h.height)}}},viewportToDrawerRectangle:function(t){var i=this.viewport.pixelFromPointNoRotate(t.getTopLeft(),!0),o=this.viewport.deltaPixelsFromPointsNoRotate(t.getSize(),!0);return new e.Rect(i.x*e.pixelDensityRatio,i.y*e.pixelDensityRatio,o.x*e.pixelDensityRatio,o.y*e.pixelDensityRatio)},drawTile:function(t,i,o,h,n,r,s){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(o);h=h||1,t.drawCanvas(l,i,h,n,r,s)}else t.drawHTML(this.canvas)},_getContext:function(t){var i=this.context;if(t){if(this.sketchCanvas===null){this.sketchCanvas=document.createElement("canvas");var o=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=o.x,this.sketchCanvas.height=o.y,this.sketchContext=this.sketchCanvas.getContext("2d"),this.viewport.getRotation()===0){var h=this;this.viewer.addHandler("rotate",function n(){if(h.viewport.getRotation()!==0){h.viewer.removeHandler("rotate",n);var r=h._calculateSketchCanvasSize();h.sketchCanvas.width=r.x,h.sketchCanvas.height=r.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}i=this.sketchContext}return i},saveContext:function(t){this.useCanvas&&this._getContext(t).save()},restoreContext:function(t){this.useCanvas&&this._getContext(t).restore()},setClip:function(t,i){if(this.useCanvas){var o=this._getContext(i);o.beginPath(),o.rect(t.x,t.y,t.width,t.height),o.clip()}},drawRectangle:function(t,i,o){if(this.useCanvas){var h=this._getContext(o);h.save(),h.fillStyle=i,h.fillRect(t.x,t.y,t.width,t.height),h.restore()}},blendSketch:function(t,i,o,h){var n=t;if(e.isPlainObject(n)||(n={opacity:t,scale:i,translate:o,compositeOperation:h}),!(!this.useCanvas||!this.sketchCanvas)){t=n.opacity,h=n.compositeOperation;var r=n.bounds;if(this.context.save(),this.context.globalAlpha=t,h&&(this.context.globalCompositeOperation=h),r)r.x<0&&(r.width+=r.x,r.x=0),r.x+r.width>this.canvas.width&&(r.width=this.canvas.width-r.x),r.y<0&&(r.height+=r.y,r.y=0),r.y+r.height>this.canvas.height&&(r.height=this.canvas.height-r.y),this.context.drawImage(this.sketchCanvas,r.x,r.y,r.width,r.height,r.x,r.y,r.width,r.height);else{i=n.scale||1,o=n.translate;var s=o instanceof e.Point?o:new e.Point(0,0),l=0,d=0;if(o){var f=this.sketchCanvas.width-this.canvas.width,v=this.sketchCanvas.height-this.canvas.height;l=Math.round(f/2),d=Math.round(v/2)}this.context.drawImage(this.sketchCanvas,s.x-l*i,s.y-d*i,(this.canvas.width+2*l)*i,(this.canvas.height+2*d)*i,-l,-d,this.canvas.width+2*l,this.canvas.height+2*d)}this.context.restore()}},drawDebugInfo:function(t,i,o,h){if(this.useCanvas){var n=this.viewer.world.getIndexOfItem(h)%this.debugGridColor.length,r=this.context;r.save(),r.lineWidth=2*e.pixelDensityRatio,r.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",r.strokeStyle=this.debugGridColor[n],r.fillStyle=this.debugGridColor[n],this.viewport.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:this.viewport.getRotation(!0)}),h.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:h.getRotation(!0),point:h.viewport.pixelFromPointNoRotate(h._getRotationPoint(!0),!0)}),h.viewport.getRotation(!0)%360===0&&h.getRotation(!0)%360===0&&h._drawer.viewer.viewport.getFlip()&&h._drawer._flip(),r.strokeRect(t.position.x*e.pixelDensityRatio,t.position.y*e.pixelDensityRatio,t.size.x*e.pixelDensityRatio,t.size.y*e.pixelDensityRatio);var s=(t.position.x+t.size.x/2)*e.pixelDensityRatio,l=(t.position.y+t.size.y/2)*e.pixelDensityRatio;r.translate(s,l),r.rotate(Math.PI/180*-this.viewport.getRotation(!0)),r.translate(-s,-l),t.x===0&&t.y===0&&(r.fillText("Zoom: "+this.viewport.getZoom(),t.position.x*e.pixelDensityRatio,(t.position.y-30)*e.pixelDensityRatio),r.fillText("Pan: "+this.viewport.getBounds().toString(),t.position.x*e.pixelDensityRatio,(t.position.y-20)*e.pixelDensityRatio)),r.fillText("Level: "+t.level,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+20)*e.pixelDensityRatio),r.fillText("Column: "+t.x,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+30)*e.pixelDensityRatio),r.fillText("Row: "+t.y,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+40)*e.pixelDensityRatio),r.fillText("Order: "+o+" of "+i,(t.position.x+10)*e.pixelDensityRatio,(t.position.y+50)*e.pixelDensityRatio),r.fillText("Size: "+t.size.toString(),(t.position.x+10)*e.pixelDensityRatio,(t.position.y+60)*e.pixelDensityRatio),r.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(),h.getRotation(!0)%360!==0&&this._restoreRotationChanges(),h.viewport.getRotation(!0)%360===0&&h.getRotation(!0)%360===0&&h._drawer.viewer.viewport.getFlip()&&h._drawer._flip(),r.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(t){this.useCanvas&&(this._imageSmoothingEnabled=t,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw())},_updateImageSmoothingEnabled:function(t){t.msImageSmoothingEnabled=this._imageSmoothingEnabled,t.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(),o=this._getContext(t.useSketch);o.save(),o.translate(i.x,i.y),this.viewer.viewport.flipped?(o.rotate(Math.PI/180*-t.degrees),o.scale(-1,1)):o.rotate(Math.PI/180*t.degrees),o.translate(-i.x,-i.y)},_flip:function(t){t=t||{};var i=t.point?t.point.times(e.pixelDensityRatio):this.getCanvasCenter(),o=this._getContext(t.useSketch);o.translate(i.x,0),o.scale(-1,1),o.translate(-i.x,0)},_restoreRotationChanges:function(t){var i=this._getContext(t);i.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 t=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return t;var i=Math.ceil(Math.sqrt(t.x*t.x+t.y*t.y));return{x:i,y:i}}}}(_),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 t=this._contentAspectRatio/this.getAspectRatio(),i;return this.homeFillsViewer?i=t>=1?t:1:i=t>=1?1:t,i/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var t=this._contentBounds.getCenter(),i=1/this.getHomeZoom(),o=i/this.getAspectRatio();return new e.Rect(t.x-i/2,t.y-o/2,i,o)},goHome:function(t){return this.viewer&&this.viewer.raiseEvent("home",{immediately:t}),this.fitBounds(this.getHomeBounds(),t)},getMinZoom:function(){var t=this.getHomeZoom(),i=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*t;return i},getMaxZoom:function(){var t=this.maxZoomLevel;return t||(t=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,t/=this._contentBounds.width),Math.max(t,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(e.type(t)==="object","[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(t){return this.getBoundsNoRotate(t).rotate(-this.getRotation(t))},getBoundsNoRotate:function(t){var i=this.getCenter(t),o=1/this.getZoom(t),h=o/this.getAspectRatio();return new e.Rect(i.x-o/2,i.y-h/2,o,h)},getBoundsWithMargins:function(t){return this.getBoundsNoRotateWithMargins(t).rotate(-this.getRotation(t),this.getCenter(t))},getBoundsNoRotateWithMargins:function(t){var i=this.getBoundsNoRotate(t),o=this._containerInnerSize.x*this.getZoom(t);return i.x-=this._margins.left/o,i.y-=this._margins.top/o,i.width+=(this._margins.left+this._margins.right)/o,i.height+=(this._margins.top+this._margins.bottom)/o,i},getCenter:function(t){var i=new e.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),o=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),h,n,r,s,l,d,f,v;return t?i:this.zoomPoint?(h=this.pixelFromPoint(this.zoomPoint,!0),n=this.getZoom(),r=1/n,s=r/this.getAspectRatio(),l=new e.Rect(i.x-r/2,i.y-s/2,r,s),d=this._pixelFromPoint(this.zoomPoint,l),f=d.minus(h).rotate(-this.getRotation(!0)),v=f.divide(this._containerInnerSize.x*n),o.plus(v)):o},getZoom:function(t){return t?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(t){return Math.max(Math.min(t,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(t){var i=this.viewportToViewerElementRectangle(t).getBoundingBox(),o=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),h=!1,n=!1;if(!this.wrapHorizontal){var r=i.x+i.width,s=o.x+o.width,l,d,f;i.width>o.width?l=this.visibilityRatio*o.width:l=this.visibilityRatio*i.width,d=o.x-r+l,f=s-i.x-l,l>o.width?(i.x+=(d+f)/2,h=!0):f<0?(i.x+=f,h=!0):d>0&&(i.x+=d,h=!0)}if(!this.wrapVertical){var v=i.y+i.height,y=o.y+o.height,T,w,x;i.height>o.height?T=this.visibilityRatio*o.height:T=this.visibilityRatio*i.height,w=o.y-v+T,x=y-i.y-T,T>o.height?(i.y+=(w+x)/2,n=!0):x<0?(i.y+=x,n=!0):w>0&&(i.y+=w,n=!0)}var C=h||n,D=C?this.viewerElementToViewportRectangle(i):t.clone();return D.xConstrained=h,D.yConstrained=n,D.constraintApplied=C,D},_raiseConstraintsEvent:function(t){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:t})},applyConstraints:function(t){var i=this.getZoom(),o=this._applyZoomConstraints(i);i!==o&&this.zoomTo(o,this.zoomPoint,t);var h=this.getConstrainedBounds(!1);return h.constraintApplied&&(this.fitBounds(h,t),this._raiseConstraintsEvent(t)),this},ensureVisible:function(t){return this.applyConstraints(t)},_fitBounds:function(t,i){i=i||{};var o=i.immediately||!1,h=i.constraints||!1,n=this.getAspectRatio(),r=t.getCenter(),s=new e.Rect(t.x,t.y,t.width,t.height,t.degrees+this.getRotation()).getBoundingBox();s.getAspectRatio()>=n?s.height=s.width/n:s.width=s.height*n,s.x=r.x-s.width/2,s.y=r.y-s.height/2;var l=1/s.width;if(o)return this.panTo(r,!0),this.zoomTo(l,null,!0),h&&this.applyConstraints(!0),this;var d=this.getCenter(!0),f=this.getZoom(!0);this.panTo(d,!0),this.zoomTo(f,null,!0);var v=this.getBounds(),y=this.getZoom();if(y===0||Math.abs(l/y-1)<1e-8)return this.zoomTo(l,null,!0),this.panTo(r,o),h&&this.applyConstraints(!1),this;if(h){this.panTo(r,!1),l=this._applyZoomConstraints(l),this.zoomTo(l,null,!1);var T=this.getConstrainedBounds();this.panTo(d,!0),this.zoomTo(f,null,!0),this.fitBounds(T)}else{var w=s.rotate(-this.getRotation()),x=w.getTopLeft().times(l).minus(v.getTopLeft().times(y)).divide(l-y);this.zoomTo(l,x,o)}return this},fitBounds:function(t,i){return this._fitBounds(t,{immediately:i,constraints:!1})},fitBoundsWithConstraints:function(t,i){return this._fitBounds(t,{immediately:i,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(t){var i,o;return i=this.getBounds(t),o=this._applyBoundaryConstraints(i),o},panBy:function(t,i){var o=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(o.plus(t),i)},panTo:function(t,i){return i?(this.centerSpringX.resetTo(t.x),this.centerSpringY.resetTo(t.y)):(this.centerSpringX.springTo(t.x),this.centerSpringY.springTo(t.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:t,immediately:i}),this},zoomBy:function(t,i,o){return this.zoomTo(this.zoomSpring.target.value*t,i,o)},zoomTo:function(t,i,o){var h=this;return this.zoomPoint=i instanceof e.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null,o?this._adjustCenterSpringsForZoomPoint(function(){h.zoomSpring.resetTo(t)}):this.zoomSpring.springTo(t),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:t,refPoint:i,immediately:o}),this},setRotation:function(t,i){return this.rotateTo(t,null,i)},getRotation:function(t){return t?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(t,i,o){return this.rotateTo(t,i,o)},rotateTo:function(t,i,o){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,o)if(this.rotationPivot){var h=t-this._oldDegrees;if(!h)return this.rotationPivot=null,this;this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var n=e.positiveModulo(this.degreesSpring.current.value,360),r=e.positiveModulo(t,360),s=r-n;s>180?r-=360:s<-180&&(r+=360);var l=n-r;this.degreesSpring.resetTo(t+l),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:!!o,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(t,i,o){return this.rotateTo(this.degreesSpring.target.value+t,i,o)},resize:function(t,i){var o=this.getBoundsNoRotate(),h=o,n;this.containerSize.x=t.x,this.containerSize.y=t.y,this._updateContainerInnerSize(),i&&(n=t.x/this.containerSize.x,h.width=o.width*n,h.height=h.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:t,maintain:i});var r=this.fitBounds(h,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:t,maintain:i}),r},_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 t=this;this._adjustCenterSpringsForZoomPoint(function(){t.zoomSpring.update()}),this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null),this.centerSpringX.update(),this.centerSpringY.update(),this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var i=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,i},_rotateAboutPivot:function(t){var i=t===!0,o=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(o.x),this.centerSpringY.shiftBy(o.y),i?this.degreesSpring.update():this.degreesSpring.resetTo(t);var h=this.degreesSpring.current.value-this._oldDegrees,n=o.rotate(h*-1).times(-1);this.centerSpringX.shiftBy(n.x),this.centerSpringY.shiftBy(n.y)},_adjustCenterSpringsForZoomPoint:function(t){if(this.zoomPoint){var i=this.pixelFromPoint(this.zoomPoint,!0);t();var o=this.pixelFromPoint(this.zoomPoint,!0),h=o.minus(i),n=this.deltaPointsFromPixels(h,!0);this.centerSpringX.shiftBy(n.x),this.centerSpringY.shiftBy(n.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else t()},deltaPixelsFromPointsNoRotate:function(t,i){return t.times(this._containerInnerSize.x*this.getZoom(i))},deltaPixelsFromPoints:function(t,i){return this.deltaPixelsFromPointsNoRotate(t.rotate(this.getRotation(i)),i)},deltaPointsFromPixelsNoRotate:function(t,i){return t.divide(this._containerInnerSize.x*this.getZoom(i))},deltaPointsFromPixels:function(t,i){return this.deltaPointsFromPixelsNoRotate(t,i).rotate(-this.getRotation(i))},pixelFromPointNoRotate:function(t,i){return this._pixelFromPointNoRotate(t,this.getBoundsNoRotate(i))},pixelFromPoint:function(t,i){return this._pixelFromPoint(t,this.getBoundsNoRotate(i))},_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(t,i){return this._pixelFromPointNoRotate(t.rotate(this.getRotation(!0),this.getCenter(!0)),i)},pointFromPixelNoRotate:function(t,i){var o=this.getBoundsNoRotate(i);return t.minus(new e.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/o.width).plus(o.getTopLeft())},pointFromPixel:function(t,i){return this.pointFromPixelNoRotate(t,i).rotate(-this.getRotation(i),this.getCenter(i))},_viewportToImageDelta:function(t,i){var o=this._contentBoundsNoRotate.width;return new e.Point(t*this._contentSizeNoRotate.x/o,i*this._contentSizeNoRotate.x/o)},viewportToImageCoordinates:function(t,i){if(t instanceof e.Point)return this.viewportToImageCoordinates(t.x,t.y);if(this.viewer){var o=this.viewer.world.getItemCount();if(o>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(o===1){var h=this.viewer.world.getItemAt(0);return h.viewportToImageCoordinates(t,i,!0)}}return this._viewportToImageDelta(t-this._contentBoundsNoRotate.x,i-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(t,i){var o=this._contentBoundsNoRotate.width;return new e.Point(t/this._contentSizeNoRotate.x*o,i/this._contentSizeNoRotate.x*o)},imageToViewportCoordinates:function(t,i){if(t instanceof e.Point)return this.imageToViewportCoordinates(t.x,t.y);if(this.viewer){var o=this.viewer.world.getItemCount();if(o>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(o===1){var h=this.viewer.world.getItemAt(0);return h.imageToViewportCoordinates(t,i,!0)}}var n=this._imageToViewportDelta(t,i);return n.x+=this._contentBoundsNoRotate.x,n.y+=this._contentBoundsNoRotate.y,n},imageToViewportRectangle:function(t,i,o,h){var n=t;if(n instanceof e.Rect||(n=new e.Rect(t,i,o,h)),this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(r===1){var s=this.viewer.world.getItemAt(0);return s.imageToViewportRectangle(t,i,o,h,!0)}}var l=this.imageToViewportCoordinates(n.x,n.y),d=this._imageToViewportDelta(n.width,n.height);return new e.Rect(l.x,l.y,d.x,d.y,n.degrees)},viewportToImageRectangle:function(t,i,o,h){var n=t;if(n instanceof e.Rect||(n=new e.Rect(t,i,o,h)),this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(r===1){var s=this.viewer.world.getItemAt(0);return s.viewportToImageRectangle(t,i,o,h,!0)}}var l=this.viewportToImageCoordinates(n.x,n.y),d=this._viewportToImageDelta(n.width,n.height);return new e.Rect(l.x,l.y,d.x,d.y,n.degrees)},viewerElementToImageCoordinates:function(t){var i=this.pointFromPixel(t,!0);return this.viewportToImageCoordinates(i)},imageToViewerElementCoordinates:function(t){var i=this.imageToViewportCoordinates(t);return this.pixelFromPoint(i,!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){e.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var i=this.imageToViewerElementCoordinates(t);return i.plus(e.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(t){return this.pointFromPixel(t,!0)},viewportToViewerElementCoordinates:function(t){return this.pixelFromPoint(t,!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){e.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var i=this.viewportToViewerElementCoordinates(t);return i.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(i===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageZoom(t)}}var h=this._contentSizeNoRotate.x,n=this._containerInnerSize.x,r=this._contentBoundsNoRotate.width,s=n/h*r;return t*s},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(i===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportZoom(t)}}var h=this._contentSizeNoRotate.x,n=this._containerInnerSize.x,r=this._contentBoundsNoRotate.width,s=h/n/r;return t*s},toggleFlip:function(){return this.setFlip(!this.getFlip()),this},getFlip:function(){return this.flipped},setFlip:function(t){return this.flipped===t?this:(this.flipped=t,this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip()),this.viewer.forceRedraw(),this.viewer.raiseEvent("flip",{flipped:t}),this)}}}(_),function(e){e.TiledImage=function(n){var r=this;e.console.assert(n.tileCache,"[TiledImage] options.tileCache is required"),e.console.assert(n.drawer,"[TiledImage] options.drawer is required"),e.console.assert(n.viewer,"[TiledImage] options.viewer is required"),e.console.assert(n.imageLoader,"[TiledImage] options.imageLoader is required"),e.console.assert(n.source,"[TiledImage] options.source is required"),e.console.assert(!n.clip||n.clip instanceof e.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),e.EventSource.call(this),this._tileCache=n.tileCache,delete n.tileCache,this._drawer=n.drawer,delete n.drawer,this._imageLoader=n.imageLoader,delete n.imageLoader,n.clip instanceof e.Rect&&(this._clip=n.clip.clone()),delete n.clip;var s=n.x||0;delete n.x;var l=n.y||0;delete n.y,this.normHeight=n.source.dimensions.y/n.source.dimensions.x,this.contentAspectX=n.source.dimensions.x/n.source.dimensions.y;var d=1;n.width?(d=n.width,delete n.width,n.height&&(e.console.error("specifying both width and height to a tiledImage is not supported"),delete n.height)):n.height&&(d=n.height/this.normHeight,delete n.height);var f=n.fitBounds;delete n.fitBounds;var v=n.fitBoundsPlacement||_.Placement.CENTER;delete n.fitBoundsPlacement;var y=n.degrees||0;delete n.degrees;var T=n.ajaxHeaders;delete n.ajaxHeaders,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},n),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new e.Spring({initial:s,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new e.Spring({initial:l,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new e.Spring({initial:d,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new e.Spring({initial:y,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),f&&this.fitBounds(f,v,!0),this._drawingHandler=function(w){r.viewer.raiseEvent("tile-drawing",e.extend({tiledImage:r},w))},this._ownAjaxHeaders={},this.setAjaxHeaders(T,!1)},e.extend(e.TiledImage.prototype,e.EventSource.prototype,{needsDraw:function(){return this._needsDraw},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(n){n!==this._fullyLoaded&&(this._fullyLoaded=n,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=e.now(),this._needsDraw=!0},update:function(){var n=this._xSpring.update(),r=this._ySpring.update(),s=this._scaleSpring.update(),l=this._degreesSpring.update();return n||r||s||l?(this._updateForScale(),this._needsDraw=!0,!0):!1},draw:function(){this.opacity!==0||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(n){return this.getBoundsNoRotate(n).rotate(this.getRotation(n),this._getRotationPoint(n))},getBoundsNoRotate:function(n){return n?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(n){var r=this.getBoundsNoRotate(n);if(this._clip){var s=n?this._worldWidthCurrent:this._worldWidthTarget,l=s/this.source.dimensions.x,d=this._clip.times(l);r=new e.Rect(r.x+d.x,r.y+d.y,d.width,d.height)}return r.rotate(this.getRotation(n),this._getRotationPoint(n))},getTileBounds:function(n,r,s){var l=this.source.getNumTiles(n),d=(l.x+r%l.x)%l.x,f=(l.y+s%l.y)%l.y,v=this.source.getTileBounds(n,d,f);return this.getFlip()&&(v.x=1-v.x-v.width),v.x+=(r-d)/l.x,v.y+=this._worldHeightCurrent/this._worldWidthCurrent*((s-f)/l.y),v},getContentSize:function(){return new e.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var n=this.imageToWindowCoordinates(new e.Point(0,0)),r=this.imageToWindowCoordinates(this.getContentSize());return new e.Point(r.x-n.x,r.y-n.y)},_viewportToImageDelta:function(n,r,s){var l=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(n*(this.source.dimensions.x/l),r*(this.source.dimensions.y*this.contentAspectX/l))},viewportToImageCoordinates:function(n,r,s){var l;return n instanceof e.Point?(s=r,l=n):l=new e.Point(n,r),l=l.rotate(-this.getRotation(s),this._getRotationPoint(s)),s?this._viewportToImageDelta(l.x-this._xSpring.current.value,l.y-this._ySpring.current.value):this._viewportToImageDelta(l.x-this._xSpring.target.value,l.y-this._ySpring.target.value)},_imageToViewportDelta:function(n,r,s){var l=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(n/this.source.dimensions.x*l,r/this.source.dimensions.y/this.contentAspectX*l)},imageToViewportCoordinates:function(n,r,s){n instanceof e.Point&&(s=r,r=n.y,n=n.x);var l=this._imageToViewportDelta(n,r);return s?(l.x+=this._xSpring.current.value,l.y+=this._ySpring.current.value):(l.x+=this._xSpring.target.value,l.y+=this._ySpring.target.value),l.rotate(this.getRotation(s),this._getRotationPoint(s))},imageToViewportRectangle:function(n,r,s,l,d){var f=n;f instanceof e.Rect?d=r:f=new e.Rect(n,r,s,l);var v=this.imageToViewportCoordinates(f.getTopLeft(),d),y=this._imageToViewportDelta(f.width,f.height,d);return new e.Rect(v.x,v.y,y.x,y.y,f.degrees+this.getRotation(d))},viewportToImageRectangle:function(n,r,s,l,d){var f=n;n instanceof e.Rect?d=r:f=new e.Rect(n,r,s,l);var v=this.viewportToImageCoordinates(f.getTopLeft(),d),y=this._viewportToImageDelta(f.width,f.height,d);return new e.Rect(v.x,v.y,y.x,y.y,f.degrees-this.getRotation(d))},viewerElementToImageCoordinates:function(n){var r=this.viewport.pointFromPixel(n,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(n){var r=this.imageToViewportCoordinates(n);return this.viewport.pixelFromPoint(r,!0)},windowToImageCoordinates:function(n){var r=n.minus(_.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(n){var r=this.imageToViewerElementCoordinates(n);return r.plus(_.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(n){var r=this._scaleSpring.current.value;return n=n.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new e.Rect((n.x-this._xSpring.current.value)/r,(n.y-this._ySpring.current.value)/r,n.width/r,n.height/r,n.degrees)},viewportToImageZoom:function(n){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return r*n},imageToViewportZoom:function(n){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return n/r},setPosition:function(n,r){var s=this._xSpring.target.value===n.x&&this._ySpring.target.value===n.y;if(r){if(s&&this._xSpring.current.value===n.x&&this._ySpring.current.value===n.y)return;this._xSpring.resetTo(n.x),this._ySpring.resetTo(n.y),this._needsDraw=!0}else{if(s)return;this._xSpring.springTo(n.x),this._ySpring.springTo(n.y),this._needsDraw=!0}s||this._raiseBoundsChange()},setWidth:function(n,r){this._setScale(n,r)},setHeight:function(n,r){this._setScale(n/this.normHeight,r)},setCroppingPolygons:function(n){var r=function(l){return l instanceof e.Point||typeof l.x=="number"&&typeof l.y=="number"},s=function(l){return l.map(function(d){try{if(r(d))return{x:d.x,y:d.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!e.isArray(n))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=n.map(function(l){return s(l)})}catch(l){e.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),e.console.error(l),this._croppingPolygons=null}},resetCroppingPolygons:function(){this._croppingPolygons=null},fitBounds:function(n,r,s){r=r||e.Placement.CENTER;var l=e.Placement.properties[r],d=this.contentAspectX,f=0,v=0,y=1,T=1;if(this._clip&&(d=this._clip.getAspectRatio(),y=this._clip.width/this.source.dimensions.x,T=this._clip.height/this.source.dimensions.y,n.getAspectRatio()>d?(f=this._clip.x/this._clip.height*n.height,v=this._clip.y/this._clip.height*n.height):(f=this._clip.x/this._clip.width*n.width,v=this._clip.y/this._clip.width*n.width)),n.getAspectRatio()>d){var w=n.height/T,x=0;l.isHorizontallyCentered?x=(n.width-n.height*d)/2:l.isRight&&(x=n.width-n.height*d),this.setPosition(new e.Point(n.x-f+x,n.y-v),s),this.setHeight(w,s)}else{var C=n.width/y,D=0;l.isVerticallyCentered?D=(n.height-n.width/d)/2:l.isBottom&&(D=n.height-n.width/d),this.setPosition(new e.Point(n.x-f,n.y-v+D),s),this.setWidth(C,s)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(n){e.console.assert(!n||n instanceof e.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),n instanceof e.Rect?this._clip=n.clone():this._clip=null,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return!!this.flipped},setFlip:function(n){this.flipped=!!n,this._needsDraw=!0,this._raiseBoundsChange()},getOpacity:function(){return this.opacity},setOpacity:function(n){n!==this.opacity&&(this.opacity=n,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(n){this._preload=!!n,this._needsDraw=!0},getRotation:function(n){return n?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(n,r){this._degreesSpring.target.value===n&&this._degreesSpring.isAtTargetValue()||(r?this._degreesSpring.resetTo(n):this._degreesSpring.springTo(n),this._needsDraw=!0,this._raiseBoundsChange())},_getRotationPoint:function(n){return this.getBoundsNoRotate(n).getCenter()},getCompositeOperation:function(){return this.compositeOperation},setCompositeOperation:function(n){n!==this.compositeOperation&&(this.compositeOperation=n,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this.compositeOperation}))},setAjaxHeaders:function(n,r){if(n===null&&(n={}),!e.isPlainObject(n)){console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}this._ownAjaxHeaders=n,this._updateAjaxHeaders(r)},_updateAjaxHeaders:function(n){if(n===void 0&&(n=!0),e.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=e.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders,n){var r,s,l,d;for(var f in this.tilesMatrix){r=this.source.getNumTiles(f);for(var v in this.tilesMatrix[f]){s=(r.x+v%r.x)%r.x;for(var y in this.tilesMatrix[f][v])if(l=(r.y+y%r.y)%r.y,d=this.tilesMatrix[f][v][y],d.loadWithAjax=this.loadTilesWithAjax,d.loadWithAjax){var T=this.source.getTileAjaxHeaders(f,s,l);d.ajaxHeaders=e.extend({},this.ajaxHeaders,T)}else d.ajaxHeaders=null}}for(var w=0;w<this._imageLoader.jobQueue.length;w++){var x=this._imageLoader.jobQueue[w];x.loadWithAjax=x.tile.loadWithAjax,x.ajaxHeaders=x.tile.loadWithAjax?x.tile.ajaxHeaders:null}}},_setScale:function(n,r){var s=this._scaleSpring.target.value===n;if(r){if(s&&this._scaleSpring.current.value===n)return;this._scaleSpring.resetTo(n),this._updateForScale(),this._needsDraw=!0}else{if(s)return;this._scaleSpring.springTo(n),this._updateForScale(),this._needsDraw=!0}s||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 n=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),r=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,s=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(r/this.minPixelRatio)/Math.log(2))));return s=Math.max(s,this.source.minLevel||0),n=Math.min(n,s),{lowestLevel:n,highestLevel:s}},_updateViewport:function(){for(this._needsDraw=!1,this._tilesLoading=0,this.loadingCoverage={};this.lastDrawn.length>0;){var n=this.lastDrawn.pop();n.beingDrawn=!1}var r=this.viewport,s=this._viewportToTiledImageRectangle(r.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var l=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));if(s=s.intersection(l),s===null)return}for(var d=this._getLevelsInterval(),f=d.lowestLevel,v=d.highestLevel,y=null,T=!1,w=e.now(),x=v;x>=f;x--){var C=!1,D=r.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(x),!0).x*this._scaleSpring.current.value;if(x===f||!T&&D>=this.minPixelRatio)C=!0,T=!0;else if(!T)continue;var M=r.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(x),!1).x*this._scaleSpring.current.value,V=r.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,N=this.immediateRender?1:V,U=Math.min(1,(D-.5)/.5),k=N/Math.abs(N-M);if(y=this._updateLevel(T,C,x,U,k,s,w,y),this._providesCoverage(this.coverage,x))break}this._drawTiles(this.lastDrawn),y&&!y.context2D?(this._loadTile(y,w),this._needsDraw=!0,this._setFullyLoaded(!1)):this._setFullyLoaded(this._tilesLoading===0)},_getCornerTiles:function(n,r,s){var l,d;this.wrapHorizontal?(l=e.positiveModulo(r.x,1),d=e.positiveModulo(s.x,1)):(l=Math.max(0,r.x),d=Math.min(1,s.x));var f,v,y=1/this.source.aspectRatio;this.wrapVertical?(f=e.positiveModulo(r.y,y),v=e.positiveModulo(s.y,y)):(f=Math.max(0,r.y),v=Math.min(y,s.y));var T=this.source.getTileAtPoint(n,new e.Point(l,f)),w=this.source.getTileAtPoint(n,new e.Point(d,v)),x=this.source.getNumTiles(n);return this.wrapHorizontal&&(T.x+=x.x*Math.floor(r.x),w.x+=x.x*Math.floor(s.x)),this.wrapVertical&&(T.y+=x.y*Math.floor(r.y/y),w.y+=x.y*Math.floor(s.y/y)),{topLeft:T,bottomRight:w}},_updateLevel:function(n,r,s,l,d,f,v,y){var T=f.getBoundingBox().getTopLeft(),w=f.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:n,level:s,opacity:l,visibility:d,drawArea:f,topleft:T,bottomright:w,currenttime:v,best:y}),this._resetCoverage(this.coverage,s),this._resetCoverage(this.loadingCoverage,s);var x=this._getCornerTiles(s,T,w),C=x.topLeft,D=x.bottomRight,M=this.source.getNumTiles(s),V=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(D.x+=1,this.wrapHorizontal||(D.x=Math.min(D.x,M.x-1)));for(var N=C.x;N<=D.x;N++)for(var U=C.y;U<=D.y;U++){var k;if(this.getFlip()){var G=(M.x+N%M.x)%M.x;k=N+M.x-G-G-1}else k=N;f.intersection(this.getTileBounds(s,k,U))!==null&&(y=this._updateTile(r,n,k,U,s,l,d,V,M,v,y))}return y},_updateTile:function(n,r,s,l,d,f,v,y,T,w,x){var C=this._getTile(s,l,d,w,T,this._worldWidthCurrent,this._worldHeightCurrent),D=r;this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:C}),this._setCoverage(this.coverage,d,s,l,!1);var M=C.loaded||C.loading||this._isCovered(this.loadingCoverage,d,s,l);if(this._setCoverage(this.loadingCoverage,d,s,l,M),!C.exists||(n&&!D&&(this._isCovered(this.coverage,d,s,l)?this._setCoverage(this.coverage,d,s,l,!0):D=!0),!D))return x;if(this._positionTile(C,this.source.tileOverlap,this.viewport,y,v),!C.loaded)if(C.context2D)this._setTileLoaded(C);else{var V=this._tileCache.getImageRecord(C.cacheKey);V&&this._setTileLoaded(C,V.getData())}if(C.loaded){var N=this._blendTile(C,s,l,d,f,w);N&&(this._needsDraw=!0)}else C.loading?this._tilesLoading++:M||(x=this._compareTiles(x,C));return x},_getTile:function(n,r,s,l,d,f,v){var y,T,w,x,C,D,M,V,N,U,k=this.tilesMatrix,G=this.source;return k[s]||(k[s]={}),k[s][n]||(k[s][n]={}),(!k[s][n][r]||!k[s][n][r].flipped!=!this.flipped)&&(y=(d.x+n%d.x)%d.x,T=(d.y+r%d.y)%d.y,w=this.getTileBounds(s,n,r),x=G.getTileBounds(s,y,T,!0),C=G.tileExists(s,y,T),D=G.getTileUrl(s,y,T),M=G.getTilePostData(s,y,T),this.loadTilesWithAjax?(V=G.getTileAjaxHeaders(s,y,T),e.isPlainObject(this.ajaxHeaders)&&(V=e.extend({},this.ajaxHeaders,V))):V=null,N=G.getContext2D?G.getContext2D(s,y,T):void 0,U=new e.Tile(s,n,r,w,C,D,N,this.loadTilesWithAjax,V,x,M,G.getTileHashKey(s,y,T,D,V,M)),this.getFlip()?y===0&&(U.isRightMost=!0):y===d.x-1&&(U.isRightMost=!0),T===d.y-1&&(U.isBottomMost=!0),U.flipped=this.flipped,k[s][n][r]=U),U=k[s][n][r],U.lastTouchTime=l,U},_loadTile:function(n,r){var s=this;n.loading=!0,this._imageLoader.addJob({src:n.getUrl(),tile:n,source:this.source,postData:n.postData,loadWithAjax:n.loadWithAjax,ajaxHeaders:n.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(l,d,f){s._onTileLoad(n,r,l,d,f)},abort:function(){n.loading=!1}})},_onTileLoad:function(n,r,s,l,d){if(s)n.exists=!0;else{e.console.error("Tile %s failed to load: %s - error: %s",n,n.getUrl(),l),this.viewer.raiseEvent("tile-load-failed",{tile:n,tiledImage:this,time:r,message:l,tileRequest:d}),n.loading=!1,n.exists=!1;return}if(r<this.lastResetTime){e.console.warn("Ignoring tile %s loaded before reset: %s",n,n.getUrl()),n.loading=!1;return}var f=this,v=function(){var y=f.source,T=y.getClosestLevel();f._setTileLoaded(n,s,T,d)};this._midDraw?window.setTimeout(v,1):v()},_setTileLoaded:function(n,r,s,l){var d=0,f=!1,v=this;function y(){return f&&e.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),d++,T}function T(){d--,d===0&&(n.loading=!1,n.loaded=!0,n.hasTransparency=v.source.hasTransparency(n.context2D,n.getUrl(),n.ajaxHeaders,n.postData),n.context2D||v._tileCache.cacheTile({data:r,tile:n,cutoff:s,tiledImage:v}),v._needsDraw=!0)}var w=y();this.viewer.raiseEvent("tile-loaded",{tile:n,tiledImage:this,tileRequest:l,get image(){return e.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),r},data:r,getCompletionCallback:y}),f=!0,w()},_positionTile:function(n,r,s,l,d){var f=n.bounds.getTopLeft();f.x*=this._scaleSpring.current.value,f.y*=this._scaleSpring.current.value,f.x+=this._xSpring.current.value,f.y+=this._ySpring.current.value;var v=n.bounds.getSize();v.x*=this._scaleSpring.current.value,v.y*=this._scaleSpring.current.value;var y=s.pixelFromPointNoRotate(f,!0),T=s.pixelFromPointNoRotate(f,!1),w=s.deltaPixelsFromPointsNoRotate(v,!0),x=s.deltaPixelsFromPointsNoRotate(v,!1),C=T.plus(x.divide(2)),D=l.squaredDistanceTo(C);r||(w=w.plus(new e.Point(1,1))),n.isRightMost&&this.wrapHorizontal&&(w.x+=.75),n.isBottomMost&&this.wrapVertical&&(w.y+=.75),n.position=y,n.size=w,n.squaredDistance=D,n.visibility=d},_blendTile:function(n,r,s,l,d,f){var v=1e3*this.blendTime,y,T;if(n.blendStart||(n.blendStart=f),y=f-n.blendStart,T=v?Math.min(1,y/v):1,this.alwaysBlend&&(T*=d),n.opacity=T,this.lastDrawn.push(n),T===1)this._setCoverage(this.coverage,l,r,s,!0),this._hasOpaqueTile=!0;else if(y<v)return!0;return!1},_compareTiles:function(n,r){return!n||r.visibility>n.visibility||r.visibility===n.visibility&&r.squaredDistance<n.squaredDistance?r:n},_drawTiles:function(n){if(!(this.opacity===0||n.length===0&&!this.placeholderFillStyle)){var r=n[0],s;r&&(s=this.opacity<1||this.compositeOperation&&this.compositeOperation!=="source-over"||!this._isBottomItem()&&this.source.hasTransparency(r.context2D,r.getUrl(),r.ajaxHeaders,r.postData));var l,d,f=this.viewport.getZoom(!0),v=this.viewportToImageZoom(f);n.length>1&&v>this.smoothTileEdgesMinZoom&&!this.iOSDevice&&this.getRotation(!0)%360===0&&e.supportsCanvas&&this.viewer.useCanvas&&(s=!0,l=r.getScaleForEdgeSmoothing(),d=r.getTranslationForEdgeSmoothing(l,this._drawer.getCanvasSize(!1),this._drawer.getCanvasSize(!0)));var y;s&&(l||(y=this.viewport.viewportToViewerElementRectangle(this.getClippedBounds(!0)).getIntegerBoundingBox(),this._drawer.viewer.viewport.getFlip()&&(this.viewport.getRotation(!0)%360!==0||this.getRotation(!0)%360!==0)&&(y.x=this._drawer.viewer.container.clientWidth-(y.x+y.width)),y=y.times(e.pixelDensityRatio)),this._drawer._clear(!0,y)),l||(this.viewport.getRotation(!0)%360!==0&&this._drawer._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:s}),this.getRotation(!0)%360!==0&&this._drawer._offsetForRotation({degrees:this.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(this._getRotationPoint(!0),!0),useSketch:s}),this.viewport.getRotation(!0)%360===0&&this.getRotation(!0)%360===0&&this._drawer.viewer.viewport.getFlip()&&this._drawer._flip());var T=!1;if(this._clip){this._drawer.saveContext(s);var w=this.imageToViewportRectangle(this._clip,!0);w=w.rotate(-this.getRotation(!0),this._getRotationPoint(!0));var x=this._drawer.viewportToDrawerRectangle(w);l&&(x=x.times(l)),d&&(x=x.translate(d)),this._drawer.setClip(x,s),T=!0}if(this._croppingPolygons){var C=this;this._drawer.saveContext(s);try{var D=this._croppingPolygons.map(function(ee){return ee.map(function(Q){var J=C.imageToViewportCoordinates(Q.x,Q.y,!0).rotate(-C.getRotation(!0),C._getRotationPoint(!0)),se=C._drawer.viewportCoordToDrawerCoord(J);return l&&(se=se.times(l)),d&&(se=se.plus(d)),se})});this._drawer.clipWithPolygons(D,s)}catch(ee){e.console.error(ee)}T=!0}if(this.placeholderFillStyle&&this._hasOpaqueTile===!1){var M=this._drawer.viewportToDrawerRectangle(this.getBounds(!0));l&&(M=M.times(l)),d&&(M=M.translate(d));var V=null;typeof this.placeholderFillStyle=="function"?V=this.placeholderFillStyle(this,this._drawer.context):V=this.placeholderFillStyle,this._drawer.drawRectangle(M,V,s)}var N=h(this.subPixelRoundingForTransparency),U=!1;if(N===e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)U=!0;else if(N===e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var k=this.viewer&&this.viewer.isAnimating();U=!k}for(var G=n.length-1;G>=0;G--)r=n[G],this._drawer.drawTile(r,this._drawingHandler,s,l,d,U,this.source),r.beingDrawn=!0,this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:this,tile:r});T&&this._drawer.restoreContext(s),l||(this.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(s),this.viewport.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(s)),s&&(l&&(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:l,translate:d,compositeOperation:this.compositeOperation,bounds:y}),l&&(this.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(!1))),l||this.viewport.getRotation(!0)%360===0&&this.getRotation(!0)%360===0&&this._drawer.viewer.viewport.getFlip()&&this._drawer._flip(),this._drawDebugInfo(n)}},_drawDebugInfo:function(n){if(this.debugMode)for(var r=n.length-1;r>=0;r--){var s=n[r];try{this._drawer.drawDebugInfo(s,n.length,r,this)}catch(l){e.console.error(l)}}},_providesCoverage:function(n,r,s,l){var d,f,v,y;if(!n[r])return!1;if(s===void 0||l===void 0){d=n[r];for(v in d)if(Object.prototype.hasOwnProperty.call(d,v)){f=d[v];for(y in f)if(Object.prototype.hasOwnProperty.call(f,y)&&!f[y])return!1}return!0}return n[r][s]===void 0||n[r][s][l]===void 0||n[r][s][l]===!0},_isCovered:function(n,r,s,l){return s===void 0||l===void 0?this._providesCoverage(n,r+1):this._providesCoverage(n,r+1,2*s,2*l)&&this._providesCoverage(n,r+1,2*s,2*l+1)&&this._providesCoverage(n,r+1,2*s+1,2*l)&&this._providesCoverage(n,r+1,2*s+1,2*l+1)},_setCoverage:function(n,r,s,l,d){if(!n[r]){e.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",r);return}n[r][s]||(n[r][s]={}),n[r][s][l]=d},_resetCoverage:function(n,r){n[r]={}}});var t=e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function i(n){return n!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&n!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&n!==e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function o(n){return i(n)?t:n}function h(n){if(typeof n=="number")return o(n);if(!n||!e.Browser)return t;var r=n[e.Browser.vendor];return i(r)&&(r=n["*"]),o(r)}}(_),function(e){var t=function(o){e.console.assert(o,"[TileCache.cacheTile] options is required"),e.console.assert(o.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(o.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=o.tile,this.tiledImage=o.tiledImage},i=function(o){e.console.assert(o,"[ImageRecord] options is required"),e.console.assert(o.data,"[ImageRecord] options.data is required"),this._tiles=[],o.create.apply(null,[this,o.data,o.ownerTile]),this._destroyImplementation=o.destroy.bind(null,this),this.getImage=o.getImage.bind(null,this),this.getData=o.getData.bind(null,this),this.getRenderedContext=o.getRenderedContext.bind(null,this)};i.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(o){e.console.assert(o,"[ImageRecord.addTile] tile is required"),this._tiles.push(o)},removeTile:function(o){for(var h=0;h<this._tiles.length;h++)if(this._tiles[h]===o){this._tiles.splice(h,1);return}e.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",o)},getTileCount:function(){return this._tiles.length}},e.TileCache=function(o){o=o||{},this._maxImageCacheCount=o.maxImageCacheCount||e.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},e.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(o){e.console.assert(o,"[TileCache.cacheTile] options is required"),e.console.assert(o.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(o.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),e.console.assert(o.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var h=o.cutoff||0,n=this._tilesLoaded.length,r=this._imagesLoaded[o.tile.cacheKey];if(r||(o.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."),o.data=o.image),e.console.assert(o.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),r=this._imagesLoaded[o.tile.cacheKey]=new i({data:o.data,ownerTile:o.tile,create:o.tiledImage.source.createTileCache,destroy:o.tiledImage.source.destroyTileCache,getImage:o.tiledImage.source.getTileCacheDataAsImage,getData:o.tiledImage.source.getTileCacheData,getRenderedContext:o.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),r.addTile(o.tile),o.tile.cacheImageRecord=r,this._imagesLoadedCount>this._maxImageCacheCount){for(var s=null,l=-1,d=null,f,v,y,T,w,x,C=this._tilesLoaded.length-1;C>=0;C--)if(x=this._tilesLoaded[C],f=x.tile,!(f.level<=h||f.beingDrawn)){if(!s){s=f,l=C,d=x;continue}T=f.lastTouchTime,v=s.lastTouchTime,w=f.level,y=s.level,(T<v||T===v&&w>y)&&(s=f,l=C,d=x)}s&&l>=0&&(this._unloadTile(d),n=l)}this._tilesLoaded[n]=new t({tile:o.tile,tiledImage:o.tiledImage})},clearTilesFor:function(o){e.console.assert(o,"[TileCache.clearTilesFor] tiledImage is required");for(var h,n=0;n<this._tilesLoaded.length;++n)h=this._tilesLoaded[n],h.tiledImage===o&&(this._unloadTile(h),this._tilesLoaded.splice(n,1),n--)},getImageRecord:function(o){return e.console.assert(o,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[o]},_unloadTile:function(o){e.console.assert(o,"[TileCache._unloadTile] tileRecord is required");var h=o.tile,n=o.tiledImage;h.unload(),h.cacheImageRecord=null;var r=this._imagesLoaded[h.cacheKey];r.removeTile(h),r.getTileCount()||(r.destroy(),delete this._imagesLoaded[h.cacheKey],this._imagesLoadedCount--),n.viewer.raiseEvent("tile-unloaded",{tile:h,tiledImage:n})}}}(_),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(o){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"),i=i||{},i.index!==void 0){var o=Math.max(0,Math.min(this._items.length,i.index));this._items.splice(o,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(t!==void 0,"[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(i!==void 0,"[World.setItemIndex] index is required");var o=this.getIndexOfItem(t);if(i>=this._items.length)throw new Error("Index bigger than number of layers.");i===o||o===-1||(this._items.splice(o,1),this._items.splice(i,0,t),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:t,previousIndex:o,newIndex:i}))},removeItem:function(t){e.console.assert(t,"[World.removeItem] item is required");var i=e.indexOf(this._items,t);i!==-1&&(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(){this.viewer._cancelPendingImages();var t,i;for(i=0;i<this._items.length;i++)t=this._items[i],t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy();var o=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,i=0;i<o.length;i++)t=o[i],this._raiseRemoveItem(t)},resetItems:function(){for(var t=0;t<this._items.length;t++)this._items[t].reset()},update:function(){for(var t=!1,i=0;i<this._items.length;i++)t=this._items[i].update()||t;return t},draw:function(){for(var t=0;t<this._items.length;t++)this._items[t].draw();this._needsDraw=!1},needsDraw:function(){for(var t=0;t<this._items.length;t++)if(this._items[t].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(t){this._autoRefigureSizes=t,t&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(t){t=t||{};var i=t.immediately||!1,o=t.layout||e.DEFAULT_SETTINGS.collectionLayout,h=t.rows||e.DEFAULT_SETTINGS.collectionRows,n=t.columns||e.DEFAULT_SETTINGS.collectionColumns,r=t.tileSize||e.DEFAULT_SETTINGS.collectionTileSize,s=t.tileMargin||e.DEFAULT_SETTINGS.collectionTileMargin,l=r+s,d;!t.rows&&n?d=n:d=Math.ceil(this._items.length/h);var f=0,v=0,y,T,w,x,C;this.setAutoRefigureSizes(!1);for(var D=0;D<this._items.length;D++)D&&D%d===0&&(o==="horizontal"?(v+=l,f=0):(f+=l,v=0)),y=this._items[D],T=y.getBounds(),T.width>T.height?w=r:w=r*(T.width/T.height),x=w*(T.height/T.width),C=new e.Point(f+(r-w)/2,v+(r-x)/2),y.setPosition(C,i),y.setWidth(w,i),o==="horizontal"?f+=l:v+=l;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var t=this._homeBounds?this._homeBounds.clone():null,i=this._contentSize?this._contentSize.clone():null,o=this._contentFactor||0;if(!this._items.length)this._homeBounds=new e.Rect(0,0,1,1),this._contentSize=new e.Point(1,1),this._contentFactor=1;else{var h=this._items[0],n=h.getBounds();this._contentFactor=h.getContentSize().x/n.width;for(var r=h.getClippedBounds().getBoundingBox(),s=r.x,l=r.y,d=r.x+r.width,f=r.y+r.height,v=1;v<this._items.length;v++)h=this._items[v],n=h.getBounds(),this._contentFactor=Math.max(this._contentFactor,h.getContentSize().x/n.width),r=h.getClippedBounds().getBoundingBox(),s=Math.min(s,r.x),l=Math.min(l,r.y),d=Math.max(d,r.x+r.width),f=Math.max(f,r.y+r.height);this._homeBounds=new e.Rect(s,l,d-s,f-l),this._contentSize=new e.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==o||!this._homeBounds.equals(t)||!this._contentSize.equals(i))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(t){this.raiseEvent("remove-item",{item:t})}})}(_)})(rt);var Dt=rt.exports;const Ve=ct(Dt);var re={fullscreenEnabled:0,fullscreenElement:1,requestFullscreen:2,exitFullscreen:3,fullscreenchange:4,fullscreenerror:5,fullscreen:6},$e=["webkitFullscreenEnabled","webkitFullscreenElement","webkitRequestFullscreen","webkitExitFullscreen","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],et=["mozFullScreenEnabled","mozFullScreenElement","mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],tt=["msFullscreenEnabled","msFullscreenElement","msRequestFullscreen","msExitFullscreen","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"],ie=typeof window<"u"&&typeof window.document<"u"?window.document:{},oe="fullscreenEnabled"in ie&&Object.keys(re)||$e[0]in ie&&$e||et[0]in ie&&et||tt[0]in ie&&tt||[],we={requestFullscreen:function(E){return E[oe[re.requestFullscreen]]()},requestFullscreenFunction:function(E){return E[oe[re.requestFullscreen]]},get exitFullscreen(){return ie[oe[re.exitFullscreen]].bind(ie)},get fullscreenPseudoClass(){return":"+oe[re.fullscreen]},addEventListener:function(E,_,e){return ie.addEventListener(oe[re[E]],_,e)},removeEventListener:function(E,_,e){return ie.removeEventListener(oe[re[E]],_,e)},get fullscreenEnabled(){return!!ie[oe[re.fullscreenEnabled]]},set fullscreenEnabled(E){},get fullscreenElement(){return ie[oe[re.fullscreenElement]]},set fullscreenElement(E){},get onfullscreenchange(){return ie[("on"+oe[re.fullscreenchange]).toLowerCase()]},set onfullscreenchange(E){return ie[("on"+oe[re.fullscreenchange]).toLowerCase()]=E},get onfullscreenerror(){return ie[("on"+oe[re.fullscreenerror]).toLowerCase()]},set onfullscreenerror(E){return ie[("on"+oe[re.fullscreenerror]).toLowerCase()]=E}};const It={name:"ViewerButton",props:{buttonIcon:{type:String,required:!0,default:null},tooltipText:{type:String,required:!1,default:null},iconSize:{type:String,required:!1,default:"24"},disabled:{type:Boolean,required:!1,default:!1}}},zt={style:{padding:"0 0"}};function Ot(E,_,e,t,i,o){return K(),te("div",zt,[F(he,{icon:e.buttonIcon,size:"28",style:{"border-radius":"4px"},disabled:e.disabled},{default:q(()=>[F(le,{size:e.iconSize},null,8,["size"]),E.$vuetify.display.sm||E.$vuetify.display.xs?ae("",!0):(K(),Pe(dt,{key:0,disabled:e.disabled,location:"bottom","open-delay":"500",activator:"parent"},{default:q(()=>[ge("span",null,ve(e.tooltipText),1)]),_:1},8,["disabled"]))]),_:1},8,["icon","disabled"])])}const Ht=it(It,[["render",Ot]]),Bt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTMyIDc5LjE1OTI4NCwgMjAxNi8wNC8xOS0xMzoxMzo0MCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUuNSAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OTVEQzM5QTI4NTZFMTFFNkE0OUFBNDg2MDVDN0IxNjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OTVEQzM5QTM4NTZFMTFFNkE0OUFBNDg2MDVDN0IxNjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NURDMzlBMDg1NkUxMUU2QTQ5QUE0ODYwNUM3QjE2NiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5NURDMzlBMTg1NkUxMUU2QTQ5QUE0ODYwNUM3QjE2NiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkHtxoIAAAA8UExURdra2s7Ozr6+vsbGxtXV1e7u7sHBwba2tujo6Pn5+aqqqv39/fT09OHh4aampq6urrq6uvf396Wlpf///4ypwX8AAACnSURBVHja1NLbCsMgDABQjfGSeFmb/P+/LnYM9KXsbVQwRI+SIDq9He5x3IEXdoBVtaRAPnXVGkRk4SEC2i1620dF2fllyzKDs8lkGfuF5/F5MVew2G2GrTVkjjCgKYWRy+S4sMfTWqs9Neikk8daO4ndRCvZZtXJsrO1luVi4YvHLQPd8tb5Dxz/xMgfPgjGxQO3N68dYsJm2YlHORw99iN/x1uAAQCk8zs3N8QNGAAAAABJRU5ErkJggg==",Ft={name:"ImageViewer",components:{ImageViewerButton:Ht,LoadingSpinner:ft},props:{objectid:{type:Number,required:!1,default:0},imageData:{type:Array,required:!0},height:{type:String,required:!1,default:"400"},copyright:{type:String,required:!1,default:""},comparisonPage:{type:Boolean,required:!1,default:!1}},data(){return{viewer:null,viewport_overlays:{},overlays_shown:!1,zoom_in_disabled:!1,zoom_out_disabled:!1,reset_to_page_disabled:!1,reset_to_selection_disabled:!1,focus_margin_x:.02,focus_margin_y:.02,image_loaded:!1,selection_bounds:null,selection_zoom:null,max_zoom_level:18,min_zoom_level:.35,zoom_level:1,zoom_level_log:1,fullscreen_active:!1,startY:0,currentY:0,velocity:0,isScrolling:0,lastTouchTime:0}},computed:{identifier(){return this.comparisonPage?this.objectid:"1"},image_tiles(){var E=[];for(const _ of this.imageData)"iiif_url"in _?E.push(_.iiif_url):E.push({type:"image",buildPyramid:!0,url:_.image_url});return E},prev_disabled(){return this.viewer?this.viewer._sequenceIndex==0:!0},next_disabled(){return this.viewer?this.viewer._sequenceIndex==this.imageData.length-1:!0}},watch:{objectid:function(){if(this.image_loaded)if(this.viewer.clearOverlays(),this.add_overlays(),this.highlight_focused_overlay(),this.overlays_shown=!0,"areas"in this.imageData[this.viewer._sequenceIndex]&&this.imageData[this.viewer._sequenceIndex].areas.length&&this.imageData[this.viewer._sequenceIndex].areas.find(E=>E.objectId==parseInt(this.objectid)))this.zoom_to_overlay(2),this.selection_bounds=this.viewer.viewport.getBounds(),this.selection_zoom=this.viewer.viewport.getZoom(),this.reset_to_selection_disabled=!0;else{for(const E of this.viewer.currentOverlays)E.element.classList.remove("image-region-focused");this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.viewer.viewport.goHome()}}},mounted(){this.init_viewer()},methods:{fullscreen_change(){we.fullscreenElement?(this.fullscreen_active=!0,this.viewer.navigator.element.style.display="inline-block"):(this.fullscreen_active=!1,this.viewer.navigator.element.style.display="none","rotation"in this.imageData[this.viewer._sequenceIndex]?this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation):this.viewer.viewport.setRotation(0,!1),this.show_overlays(),we.removeEventListener("fullscreenchange",this.fullscreen_change,!1))},enter_fullscreen(){let E=document.getElementById(`viewer-image-${this.identifier}`);if(we.fullscreenEnabled){we.addEventListener("fullscreenchange",this.fullscreen_change,!1);let _=document.getElementById(`fullscreen-elements-${this.identifier}`);E.appendChild(_),we.requestFullscreen(E),this.hide_overlays()}},exit_fullscreen(){we.fullscreenElement&&we.exitFullscreen()},next_image(){this.image_loaded=!1,this.viewer.goToNextPage(),"rotation"in this.imageData[this.viewer._sequenceIndex]&&this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.$emit("image-index-change",this.viewer._sequenceIndex)},prev_image(){this.image_loaded=!1,this.viewer.goToPreviousPage(),"rotation"in this.imageData[this.viewer._sequenceIndex]&&this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.$emit("image-index-change",this.viewer._sequenceIndex)},handleTouchStart(E){E.touches.length==1&&(this.startY=E.touches[0].clientY,this.currentY=this.startY,this.velocity=0,this.isScrolling=!0,this.lastTouchTime=Date.now())},handleTouchMove(E){if(E.touches.length!=1||!this.isScrolling)return;const _=E.touches[0].clientY,e=_-this.currentY;this.currentY=_;const t=Date.now(),i=t-this.lastTouchTime;this.velocity=e/i,window.scrollBy(0,-e),this.lastTouchTime=t},handleTouchEnd(E){if(E.touches.length!=1)return;this.isScrolling=!1;const _=()=>{Math.abs(this.velocity)>.01&&(window.scrollBy(0,-this.velocity*16),this.velocity*=.95,requestAnimationFrame(_))};requestAnimationFrame(_)},init_viewer(){this.viewer=Ve({id:`viewer-image-${this.identifier}`,animationTime:1,showNavigator:!0,navigatorPosition:"BOTTOM_RIGHT",navigatorHeight:"180px",navigatorWidth:"150px",sequenceMode:!0,maxZoomLevel:this.max_zoom_level,minZoomLevel:this.min_zoom_level,zoomPerScroll:1.3,minPixelRatio:.7,gestureSettingsTouch:{dragToPan:!1,flickEnabled:!1,scrollToZoom:!1,clickToZoom:!1,pinchToZoom:!0},showNavigationControl:!1,showSequenceControl:!1,gestureSettingsMouse:{clickToZoom:!1},degrees:this.imageData[0].rotation,tileSources:this.image_tiles}),this.viewer.navigator.element.style.display="none",this.viewer.addHandler("open",()=>{this.zoom_level=this.viewer.viewport.getZoom(),this.zoom_level_log=Math.log(this.zoom_level),this.viewer.world.getItemAt(0).addOnceHandler("fully-loaded-change",()=>{"areas"in this.imageData[this.viewer._sequenceIndex]&&this.imageData[this.viewer._sequenceIndex].areas.length&&(this.add_overlays(),this.highlight_focused_overlay(),this.overlays_shown=!0,this.zoom_to_overlay(2),this.selection_bounds=this.viewer.viewport.getBounds(),this.selection_zoom=this.viewer.viewport.getZoom(),this.reset_to_selection_disabled=!0),this.image_loaded=!0})}),this.viewer.addHandler("pan",()=>{this.is_same_zoom_level(this.zoom_level,this.viewer.viewport.getHomeZoom())&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.viewer.viewport.getHomeBounds())?this.reset_to_page_disabled=!0:this.reset_to_page_disabled=!1,this.selection_bounds&&this.is_same_zoom_level(this.zoom_level,this.selection_zoom)&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.selection_bounds)?this.reset_to_selection_disabled=!0:this.reset_to_selection_disabled=!1}),this.viewer.addHandler("zoom",()=>{this.zoom_level=this.viewer.viewport.getZoom(),this.zoom_level_log=Math.log(this.zoom_level),this.zoom_level>=this.max_zoom_level-.05?this.zoom_in_disabled=!0:this.zoom_level<=this.min_zoom_level+.05?this.zoom_out_disabled=!0:this.is_same_zoom_level(this.zoom_level,this.viewer.viewport.getHomeZoom())&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.viewer.viewport.getHomeBounds())?this.reset_to_page_disabled=!0:(this.zoom_in_disabled=!1,this.zoom_out_disabled=!1,this.reset_to_page_disabled=!1),this.selection_bounds&&this.is_same_zoom_level(this.zoom_level,this.selection_zoom)&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.selection_bounds)?this.reset_to_selection_disabled=!0:this.reset_to_selection_disabled=!1}),this.viewer.addHandler("full-screen",E=>{E.fullScreen?(this.fullscreen_active=!0,this.hide_overlays(),this.viewer.navigator.element.style.display="inline-block"):(this.fullscreen_active=!1,this.viewer.navigator.element.style.display="none","rotation"in this.imageData[this.viewer._sequenceIndex]&&this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.show_overlays())})},is_same_zoom_level(E,_){return Math.abs(Math.log(E)-Math.log(_))<.05},check_if_same_bounds(E,_){return Math.abs(E.x-_.x)<.001&&Math.abs(E.width-_.width)<.001&&Math.abs(E.y-_.y)<.001&&Math.abs(E.height-_.height)<.001},add_overlays(){let E=this.imageData;this.comparisonPage&&(E[this.viewer._sequenceIndex].areas=E[this.viewer._sequenceIndex].areas.filter(_=>_.objectId==this.objectid)),this.viewport_overlays[this.viewer._sequenceIndex]={};for(const _ of E[this.viewer._sequenceIndex].areas){let e=new Ve.Rect(+_.h_offset,+_.v_offset,+_.width,+_.height),t=this.viewer.viewport.imageToViewportRectangle(e),i=document.createElement("div");i.id="region-"+_.objectId,i.className="image-region",i.style=`z-index:${_.z_index}`,this.viewer.addOverlay({element:i,location:t}),t.x-=t.width*this.focus_margin_x,t.width+=t.width*2*this.focus_margin_x,t.y-=t.height*this.focus_margin_y,t.height+=t.height*2*this.focus_margin_y,this.viewport_overlays[this.viewer._sequenceIndex][_.objectId]={viewport_coord:t,rotation:_.rotation},new Ve.MouseTracker({element:i,clickTimeThreshold:700,clickHandler:o=>{o.quick&&this.objectid!=_.objectId&&this.$router.push(`/object/${_.objectId}`)}})}},update_zoom_level(E){this.fullscreen_active&&this.viewer.viewport.zoomTo(Math.exp(E))},show_overlays(){"areas"in this.imageData[this.viewer._sequenceIndex]&&this.imageData[this.viewer._sequenceIndex].areas.length&&(this.overlays_shown=!0,this.add_overlays(),this.highlight_focused_overlay())},hide_overlays(){this.overlays_shown=!1,this.viewer.currentOverlays.length&&this.viewer.clearOverlays()},zoom_to_overlay(E){const _=this.viewer.viewport.zoomSpring.animationTime,e=this.viewer.viewport.degreesSpring.animationTime;this.viewer.viewport.zoomSpring.animationTime=E,this.viewer.viewport.degreesSpring.animationTime=E;let t=this.viewport_overlays[this.viewer._sequenceIndex][this.objectid];t&&(this.viewer.viewport.setRotation(+t.rotation),this.viewer.viewport.fitBounds(t.viewport_coord)),this.viewer.viewport.zoomSpring.animationTime=_,this.viewer.viewport.degreesSpring.animationTime=e},highlight_focused_overlay(){for(const E of this.viewer.currentOverlays)E.element.id.includes(this.objectid)?E.element.classList.add("image-region-focused"):E.element.classList.remove("image-region-focused")}}},Lt=["id"],Mt={class:"fullscreen-zoom-btns"},At={key:0},kt={key:0,class:"copyright"},Nt={class:"viewer-scan-buttons"},Ut={elevation:"0",class:"pa-3"},Vt={key:2},Wt={key:0,class:"d-flex flex-row-reverse align-center",style:{height:"100%"}},Gt={key:1},jt={key:0,class:"pa-0 ma-0 image-selection-number"};function qt(E,_,e,t,i,o){const h=Ye("LoadingSpinner"),n=Ye("ImageViewerButton");return K(),te("div",{id:"parent",ref:"parent",onTouchstart:_[13]||(_[13]=(...r)=>o.handleTouchStart&&o.handleTouchStart(...r)),onTouchmove:_[14]||(_[14]=(...r)=>o.handleTouchMove&&o.handleTouchMove(...r)),onTouchend:_[15]||(_[15]=(...r)=>o.handleTouchEnd&&o.handleTouchEnd(...r))},[He(ge("div",{id:`fullscreen-elements-${o.identifier}`},[ge("div",Mt,[F(Fe,{class:"pa-2 ma-2"},{default:q(()=>[F(fe,{justify:"center"},{default:q(()=>[F(he,{icon:"mdi-fit-to-page-outline",width:"34",height:"34",style:{"border-radius":"2px"},disabled:i.reset_to_page_disabled,onClick:_[0]||(_[0]=r=>i.viewer.viewport.goHome())},{default:q(()=>[F(le,{size:"34",color:"#757575"})]),_:1},8,["disabled"])]),_:1}),F(fe,{justify:"center"},{default:q(()=>[F(he,{icon:"mdi-plus",width:"34",height:"34",style:{"border-radius":"2px"},disabled:i.zoom_in_disabled,onClick:_[1]||(_[1]=r=>i.viewer.viewport.zoomBy(1.5))},{default:q(()=>[F(le,{size:"36",color:"#757575"})]),_:1},8,["disabled"])]),_:1}),i.viewer?(K(),Pe(fe,{key:0,justify:"center"},{default:q(()=>[F(gt,{modelValue:i.zoom_level_log,"onUpdate:modelValue":[_[2]||(_[2]=r=>i.zoom_level_log=r),o.update_zoom_level],class:"zoom-slider",direction:"vertical","hide-details":"",density:"compact","thumb-size":"20",step:"0.05",color:"#757575",ripple:!1,max:Math.log(i.max_zoom_level),min:Math.log(i.min_zoom_level)},null,8,["modelValue","max","min","onUpdate:modelValue"])]),_:1})):ae("",!0),F(fe,{justify:"center"},{default:q(()=>[F(he,{icon:"mdi-minus",width:"34",height:"34",style:{"border-radius":"2px"},disabled:i.zoom_out_disabled,onClick:_[3]||(_[3]=r=>i.viewer.viewport.zoomBy(.675))},{default:q(()=>[F(le,{size:"36",color:"#757575"})]),_:1},8,["disabled"])]),_:1}),F(fe,{justify:"center"},{default:q(()=>[F(he,{icon:"mdi-rotate-left",width:"34",height:"34",style:{"border-radius":"2px"},onClick:_[4]||(_[4]=r=>i.viewer.viewport.setRotation(i.viewer.viewport.getRotation()-90))},{default:q(()=>[F(le,{size:"34",color:"#757575"})]),_:1})]),_:1}),F(fe,{justify:"center"},{default:q(()=>[F(he,{icon:"mdi-rotate-right",width:"34",height:"34",style:{"border-radius":"2px"},onClick:_[5]||(_[5]=r=>i.viewer.viewport.setRotation(i.viewer.viewport.getRotation()+90))},{default:q(()=>[F(le,{size:"34",color:"#757575"})]),_:1})]),_:1})]),_:1})]),F(he,{class:"fullscreen-exit-btn",icon:"mdi-fullscreen-exit",height:"50",width:"50",style:{"border-radius":"2px"},onClick:_[6]||(_[6]=r=>i.viewer.setFullScreen(!1))},{default:q(()=>[F(le,{size:70,color:"#757575"})]),_:1}),i.viewer&&e.imageData.length>1?(K(),te("div",At,[F(he,{class:"fullscreen-next-btn",icon:"",width:"60",height:"60",disabled:o.next_disabled,onClick:o.next_image},{default:q(()=>[F(le,{size:"60",color:"#757575"},{default:q(()=>[Ke("mdi-chevron-right")]),_:1})]),_:1},8,["disabled","onClick"]),F(he,{class:"fullscreen-prev-btn",icon:"",width:"60",height:"60",disabled:o.prev_disabled,onClick:o.prev_image},{default:q(()=>[F(le,{size:"60",color:"#757575"},{default:q(()=>[Ke("mdi-chevron-left")]),_:1})]),_:1},8,["disabled","onClick"])])):ae("",!0)],8,Lt),[[Be,i.fullscreen_active]]),F(lt,{id:`viewer-image-${o.identifier}`,ref:"image",elevation:"0",class:"viewer-image","min-height":e.height},{default:q(()=>[F(at,{contained:"","model-value":!i.image_loaded,class:"align-center justify-center",scrim:!1,transition:"fade-transition"},{default:q(()=>[F(h,{style:{opacity:"0.3"}})]),_:1},8,["model-value"]),e.copyright?(K(),te("div",kt,[ge("span",null,"© "+ve(e.copyright),1)])):ae("",!0)]),_:1},8,["id","min-height"]),ge("div",Nt,[ge("div",Ut,[F(fe,{justify:"space-between",class:"py-2 px-1"},{default:q(()=>[F(Fe,{cols:"3"}),F(Fe,{cols:"6",class:"ma-0 pa-0","align-self":"center"},{default:q(()=>[F(fe,{class:"ma-0 pa-0",justify:"center"},{default:q(()=>[He(F(n,{"tooltip-text":E.$t("site_navigation.reset_to_section"),"button-icon":"mdi-home",disabled:i.reset_to_selection_disabled,onClick:_[7]||(_[7]=r=>o.zoom_to_overlay(1))},null,8,["tooltip-text","disabled"]),[[Be,i.viewer&&"areas"in e.imageData[i.viewer._sequenceIndex]&&e.imageData[i.viewer._sequenceIndex].areas.length&&e.imageData[i.viewer._sequenceIndex].areas.map(r=>r.objectId).includes(parseInt(e.objectid))]]),F(n,{"tooltip-text":E.$t("site_navigation.fit_to_page"),"button-icon":"mdi-fit-to-page-outline",disabled:i.reset_to_page_disabled,onClick:_[8]||(_[8]=r=>i.viewer.viewport.goHome())},null,8,["tooltip-text","disabled"]),F(n,{"tooltip-text":E.$t("site_navigation.zoom_in"),"button-icon":"mdi-plus","icon-size":"28",disabled:i.zoom_in_disabled,onClick:_[9]||(_[9]=r=>i.viewer.viewport.zoomBy(1.5))},null,8,["tooltip-text","disabled"]),F(n,{"tooltip-text":E.$t("site_navigation.zoom_out"),"button-icon":"mdi-minus","icon-size":"28",disabled:i.zoom_out_disabled,onClick:_[10]||(_[10]=r=>i.viewer.viewport.zoomBy(.675))},null,8,["tooltip-text","disabled"]),e.comparisonPage?(K(),Pe(n,{key:0,"tooltip-text":"Linksdrehung","button-icon":"mdi-rotate-left","icon-size":"28",onClick:_[11]||(_[11]=r=>i.viewer.viewport.setRotation(i.viewer.viewport.getRotation()-90))})):ae("",!0),e.comparisonPage?(K(),Pe(n,{key:1,"tooltip-text":"Rechtsdrehung","button-icon":"mdi-rotate-right","icon-size":"28",onClick:_[12]||(_[12]=r=>i.viewer.viewport.setRotation(i.viewer.viewport.getRotation()+90))})):ae("",!0),i.viewer&&"areas"in e.imageData[i.viewer._sequenceIndex]&&e.imageData[i.viewer._sequenceIndex].areas.length?(K(),te("div",Vt,[He(F(n,{"tooltip-text":E.$t("site_navigation.show_sections"),"button-icon":"mdi-selection",onClick:o.show_overlays},null,8,["tooltip-text","onClick"]),[[Be,!i.overlays_shown]]),He(F(n,{"tooltip-text":E.$t("site_navigation.hide_sections"),"button-icon":"mdi-selection-remove",onClick:o.hide_overlays},null,8,["tooltip-text","onClick"]),[[Be,i.overlays_shown]])])):ae("",!0),E.$vuetify.display.mobile?ae("",!0):(K(),Pe(n,{key:3,"tooltip-text":E.$t("site_navigation.fullscreen"),"button-icon":"mdi-overscan","icon-size":"26",disabled:i.fullscreen_active,onClick:o.enter_fullscreen},null,8,["tooltip-text","disabled","onClick"]))]),_:1})]),_:1}),F(Fe,{cols:"3",class:"ma-0 pa-0"},{default:q(()=>[i.viewer&&e.imageData[0].iiif_url?(K(),te("div",Wt,[ge("div",null,[F(ht,{src:Bt,alt:"iiif Logo",width:"26",height:"20",cover:""})])])):ae("",!0),i.viewer&&e.imageData.length>1?(K(),te("div",Gt,[F(fe,{justify:"end",align:"center",class:"ma-0 pa-0"},{default:q(()=>[F(he,{icon:"mdi-chevron-left",size:"28",disabled:o.prev_disabled,style:{"justify-content":"end",width:"24px"},onClick:o.prev_image},{default:q(()=>[F(le,{size:"24"})]),_:1},8,["disabled","onClick"]),ge("div",{class:We(["pa-0 ma-0 image-selection-number",e.imageData.length>9?"two-digit-width":"one-digit-width"])},ve(i.viewer._sequenceIndex+1),3),i.viewer?(K(),te("div",jt,"/")):ae("",!0),ge("div",{class:We(["pa-0 ma-0 image-selection-number",e.imageData.length>9?"two-digit-width":"one-digit-width"])},ve(e.imageData.length),3),F(he,{icon:"mdi-chevron-right",size:"28",disabled:o.next_disabled,style:{"justify-content":"start",width:"24px"},onClick:o.next_image},{default:q(()=>[F(le,{size:"24"})]),_:1},8,["disabled","onClick"])]),_:1})])):ae("",!0)]),_:1})]),_:1})])])],544)}const $t=it(Ft,[["render",qt],["__scopeId","data-v-e35b07c5"]]);export{$t as I,Jt as _,Et as u};