@triiiceratops/plugin-image-export 1.0.0-rc.1 → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iife.js +15 -15
- package/package.json +6 -6
package/dist/iife.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(){"use strict";function Nn(n,o){for(var e=0;e<o.length;e++){const t=o[e];if(typeof t!="string"&&!Array.isArray(t)){for(const r in t)if(r!=="default"&&!(r in n)){const i=Object.getOwnPropertyDescriptor(t,r);i&&Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const Pi=!1;var Ri=Array.isArray,Un=Array.prototype.indexOf,ri=Array.from,Wn=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Vn=Object.getOwnPropertyDescriptors,jn=Object.prototype,Gn=Array.prototype,ir=Object.getPrototypeOf,rr=Object.isExtensible;const nr=()=>{};function qn(n){for(var o=0;o<n.length;o++)n[o]()}function sr(){var n,o,e=new Promise((t,r)=>{n=t,o=r});return{promise:e,resolve:n,reject:o}}const Ee=2,Ci=4,Di=8,or=1<<24,Je=16,$e=32,ft=64,ni=128,Ne=512,Re=1024,Ie=2048,et=4096,Me=8192,tt=16384,Ai=32768,pt=65536,ar=1<<17,lr=1<<18,Ct=1<<19,Zn=1<<20,it=1<<25,gt=32768,Ii=1<<21,Oi=1<<22,ot=1<<23,mt=Symbol("$state"),Xn=Symbol("legacy props"),Yn=Symbol(""),Dt=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function Kn(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Qn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Jn(n){throw new Error("https://svelte.dev/e/effect_in_teardown")}function $n(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function es(n){throw new Error("https://svelte.dev/e/effect_orphan")}function ts(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function is(n){throw new Error("https://svelte.dev/e/props_invalid_value")}function rs(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function ns(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function ss(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function os(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const as=1,ls=2,ur=4,us=8,hs=16,cs=1,ds=4,fs=8,ps=16,gs=1,ms=2,be=Symbol(),vs="http://www.w3.org/1999/xhtml",ws="@attach";function ys(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function _s(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function hr(n){return n===this.v}function Ts(n,o){return n!=n?o==o:n!==o||n!==null&&typeof n=="object"||typeof n=="function"}function cr(n){return!Ts(n,this.v)}let xs=!1,De=null;function At(n){De=n}function Es(n){return bs().get(n)}function Fi(n,o=!1,e){De={p:De,i:!1,c:null,e:null,s:n,x:null,l:null}}function Li(n){var o=De,e=o.e;if(e!==null){o.e=null;for(var t of e)Or(t)}return o.i=!0,De=o.p,{}}function dr(){return!0}function bs(n){return De===null&&Kn(),De.c??=new Map(Ss(De)||void 0)}function Ss(n){let o=n.p;for(;o!==null;){const e=o.c;if(e!==null)return e;o=o.p}return null}let It=[];function Ps(){var n=It;It=[],qn(n)}function vt(n){if(It.length===0){var o=It;queueMicrotask(()=>{o===It&&Ps()})}It.push(n)}function fr(n){var o=ne;if(o===null)return ee.f|=ot,n;if((o.f&Ai)===0){if((o.f&ni)===0)throw n;o.b.error(n)}else Ot(n,o)}function Ot(n,o){for(;o!==null;){if((o.f&ni)!==0)try{o.b.error(n);return}catch(e){n=e}o=o.parent}throw n}const si=new Set;let ae=null,oi=null,ze=null,We=[],Mi=null,Bi=!1;class Ve{committed=!1;current=new Map;previous=new Map;#e=new Set;#t=new Set;#r=0;#i=0;#l=null;#s=[];#n=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#i>0}process(o){We=[],oi=null,this.apply();var e={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const t of o)this.#o(t,e);this.is_fork||this.#h(),this.is_deferred()?(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects)):(oi=this,ae=null,pr(e.render_effects),pr(e.effects),oi=null,this.#l?.resolve()),ze=null}#o(o,e){o.f^=Re;for(var t=o.first;t!==null;){var r=t.f,i=(r&($e|ft))!==0,s=i&&(r&Re)!==0,l=s||(r&Me)!==0||this.skipped_effects.has(t);if((t.f&ni)!==0&&t.b?.is_pending()&&(e={parent:e,effect:t,effects:[],render_effects:[],block_effects:[]}),!l&&t.fn!==null){i?t.f^=Re:(r&Ci)!==0?e.effects.push(t):Yt(t)&&((t.f&Je)!==0&&e.block_effects.push(t),Kt(t));var a=t.first;if(a!==null){t=a;continue}}var u=t.parent;for(t=t.next;t===null&&u!==null;)u===e.effect&&(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects),e=e.parent),t=u.next,u=u.parent}}#a(o){for(const e of o)((e.f&Ie)!==0?this.#s:this.#n).push(e),this.#u(e.deps),Ce(e,Re)}#u(o){if(o!==null)for(const e of o)(e.f&Ee)===0||(e.f>)===0||(e.f^=gt,this.#u(e.deps))}capture(o,e){this.previous.has(o)||this.previous.set(o,e),(o.f&ot)===0&&(this.current.set(o,o.v),ze?.set(o,o.v))}activate(){ae=this,this.apply()}deactivate(){ae===this&&(ae=null,ze=null)}flush(){if(this.activate(),We.length>0){if(Rs(),ae!==null&&ae!==this)return}else this.#r===0&&this.process([]);this.deactivate()}discard(){for(const o of this.#t)o(this);this.#t.clear()}#h(){if(this.#i===0){for(const o of this.#e)o();this.#e.clear()}this.#r===0&&this.#c()}#c(){if(si.size>1){this.previous.clear();var o=ze,e=!0,t={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const i of si){if(i===this){e=!1;continue}const s=[];for(const[a,u]of this.current){if(i.current.has(a))if(e&&u!==i.current.get(a))i.current.set(a,u);else continue;s.push(a)}if(s.length===0)continue;const l=[...i.current.keys()].filter(a=>!this.current.has(a));if(l.length>0){var r=We;We=[];const a=new Set,u=new Map;for(const h of s)gr(h,l,a,u);if(We.length>0){ae=i,i.apply();for(const h of We)i.#o(h,t);i.deactivate()}We=r}}ae=null,ze=o}this.committed=!0,si.delete(this)}increment(o){this.#r+=1,o&&(this.#i+=1)}decrement(o){this.#r-=1,o&&(this.#i-=1),this.revive()}revive(){for(const o of this.#s)Ce(o,Ie),wt(o);for(const o of this.#n)Ce(o,et),wt(o);this.#s=[],this.#n=[],this.flush()}oncommit(o){this.#e.add(o)}ondiscard(o){this.#t.add(o)}settled(){return(this.#l??=sr()).promise}static ensure(){if(ae===null){const o=ae=new Ve;si.add(ae),Ve.enqueue(()=>{ae===o&&o.flush()})}return ae}static enqueue(o){vt(o)}apply(){}}function Rs(){var n=Tt;Bi=!0;var o=null;try{var e=0;for(di(!0);We.length>0;){var t=Ve.ensure();if(e++>1e3){var r,i;Cs()}t.process(We),at.clear()}}finally{Bi=!1,di(n),Mi=null}}function Cs(){try{ts()}catch(n){Ot(n,Mi)}}let rt=null;function pr(n){var o=n.length;if(o!==0){for(var e=0;e<o;){var t=n[e++];if((t.f&(tt|Me))===0&&Yt(t)&&(rt=new Set,Kt(t),t.deps===null&&t.first===null&&t.nodes===null&&(t.teardown===null&&t.ac===null?Hr(t):t.fn=null),rt?.size>0)){at.clear();for(const r of rt){if((r.f&(tt|Me))!==0)continue;const i=[r];let s=r.parent;for(;s!==null;)rt.has(s)&&(rt.delete(s),i.push(s)),s=s.parent;for(let l=i.length-1;l>=0;l--){const a=i[l];(a.f&(tt|Me))===0&&Kt(a)}}rt.clear()}}rt=null}}function gr(n,o,e,t){if(!e.has(n)&&(e.add(n),n.reactions!==null))for(const r of n.reactions){const i=r.f;(i&Ee)!==0?gr(r,o,e,t):(i&(Oi|Je))!==0&&(i&Ie)===0&&mr(r,o,t)&&(Ce(r,Ie),wt(r))}}function mr(n,o,e){const t=e.get(n);if(t!==void 0)return t;if(n.deps!==null)for(const r of n.deps){if(o.includes(r))return!0;if((r.f&Ee)!==0&&mr(r,o,e))return e.set(r,!0),!0}return e.set(n,!1),!1}function wt(n){for(var o=Mi=n;o.parent!==null;){o=o.parent;var e=o.f;if(Bi&&o===ne&&(e&Je)!==0&&(e&lr)===0)return;if((e&(ft|$e))!==0){if((e&Re)===0)return;o.f^=Re}}We.push(o)}function Ds(n){let o=0,e=yt(0),t;return()=>{Gt()&&(b(e),Fr(()=>(o===0&&(t=pi(()=>n(()=>Wt(e)))),o+=1,()=>{vt(()=>{o-=1,o===0&&(t?.(),t=void 0,Wt(e))})})))}}var As=pt|Ct|ni;function Is(n,o,e){new Os(n,o,e)}class Os{parent;#e=!1;#t;#r=null;#i;#l;#s;#n=null;#o=null;#a=null;#u=null;#h=null;#c=0;#d=0;#p=!1;#f=null;#y=Ds(()=>(this.#f=yt(this.#c),()=>{this.#f=null}));constructor(o,e,t){this.#t=o,this.#i=e,this.#l=t,this.parent=ne.b,this.#e=!!this.#i.pending,this.#s=ci(()=>{ne.b=this;{var r=this.#v();try{this.#n=Oe(()=>t(r))}catch(i){this.error(i)}this.#d>0?this.#m():this.#e=!1}return()=>{this.#h?.remove()}},As)}#_(){try{this.#n=Oe(()=>this.#l(this.#t))}catch(o){this.error(o)}this.#e=!1}#T(){const o=this.#i.pending;o&&(this.#o=Oe(()=>o(this.#t)),Ve.enqueue(()=>{var e=this.#v();this.#n=this.#g(()=>(Ve.ensure(),Oe(()=>this.#l(e)))),this.#d>0?this.#m():(_t(this.#o,()=>{this.#o=null}),this.#e=!1)}))}#v(){var o=this.#t;return this.#e&&(this.#h=ut(),this.#t.before(this.#h),o=this.#h),o}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#i.pending}#g(o){var e=ne,t=ee,r=De;qe(this.#s),Fe(this.#s),At(this.#s.ctx);try{return o()}catch(i){return fr(i),null}finally{qe(e),Fe(t),At(r)}}#m(){const o=this.#i.pending;this.#n!==null&&(this.#u=document.createDocumentFragment(),this.#u.append(this.#h),Nr(this.#n,this.#u)),this.#o===null&&(this.#o=Oe(()=>o(this.#t)))}#w(o){if(!this.has_pending_snippet()){this.parent&&this.parent.#w(o);return}this.#d+=o,this.#d===0&&(this.#e=!1,this.#o&&_t(this.#o,()=>{this.#o=null}),this.#u&&(this.#t.before(this.#u),this.#u=null))}update_pending_count(o){this.#w(o),this.#c+=o,this.#f&&Ft(this.#f,this.#c)}get_effect_pending(){return this.#y(),b(this.#f)}error(o){var e=this.#i.onerror;let t=this.#i.failed;if(this.#p||!e&&!t)throw o;this.#n&&(Pe(this.#n),this.#n=null),this.#o&&(Pe(this.#o),this.#o=null),this.#a&&(Pe(this.#a),this.#a=null);var r=!1,i=!1;const s=()=>{if(r){_s();return}r=!0,i&&os(),Ve.ensure(),this.#c=0,this.#a!==null&&_t(this.#a,()=>{this.#a=null}),this.#e=this.has_pending_snippet(),this.#n=this.#g(()=>(this.#p=!1,Oe(()=>this.#l(this.#t)))),this.#d>0?this.#m():this.#e=!1};var l=ee;try{Fe(null),i=!0,e?.(o,s),i=!1}catch(a){Ot(a,this.#s&&this.#s.parent)}finally{Fe(l)}t&&vt(()=>{this.#a=this.#g(()=>{Ve.ensure(),this.#p=!0;try{return Oe(()=>{t(this.#t,()=>o,()=>s)})}catch(a){return Ot(a,this.#s.parent),null}finally{this.#p=!1}})})}}function vr(n,o,e,t){const r=li;if(e.length===0&&n.length===0){t(o.map(r));return}var i=ae,s=ne,l=Fs();function a(){Promise.all(e.map(u=>Ls(u))).then(u=>{l();try{t([...o.map(r),...u])}catch(h){(s.f&tt)===0&&Ot(h,s)}i?.deactivate(),ai()}).catch(u=>{Ot(u,s)})}n.length>0?Promise.all(n).then(()=>{l();try{return a()}finally{i?.deactivate(),ai()}}):a()}function Fs(){var n=ne,o=ee,e=De,t=ae;return function(i=!0){qe(n),Fe(o),At(e),i&&t?.activate()}}function ai(){qe(null),Fe(null),At(null)}function li(n){var o=Ee|Ie,e=ee!==null&&(ee.f&Ee)!==0?ee:null;return ne!==null&&(ne.f|=Ct),{ctx:De,deps:null,effects:null,equals:hr,f:o,fn:n,reactions:null,rv:0,v:be,wv:0,parent:e??ne,ac:null}}function Ls(n,o){let e=ne;e===null&&Qn();var t=e.b,r=void 0,i=yt(be),s=!ee,l=new Map;return Zs(()=>{var a=sr();r=a.promise;try{Promise.resolve(n()).then(a.resolve,a.reject).then(()=>{u===ae&&u.committed&&u.deactivate(),ai()})}catch(d){a.reject(d),ai()}var u=ae;if(s){var h=!t.is_pending();t.update_pending_count(1),u.increment(h),l.get(u)?.reject(Dt),l.delete(u),l.set(u,a)}const c=(d,m=void 0)=>{if(u.activate(),m)m!==Dt&&(i.f|=ot,Ft(i,m));else{(i.f&ot)!==0&&(i.f^=ot),Ft(i,d);for(const[v,y]of l){if(l.delete(v),v===u)break;y.reject(Dt)}}s&&(t.update_pending_count(-1),u.decrement(h))};a.promise.then(c,d=>c(null,d||"unknown"))}),Ir(()=>{for(const a of l.values())a.reject(Dt)}),new Promise(a=>{function u(h){function c(){h===r?a(i):u(r)}h.then(c,c)}u(r)})}function le(n){const o=li(n);return Wr(o),o}function wr(n){const o=li(n);return o.equals=cr,o}function yr(n){var o=n.effects;if(o!==null){n.effects=null;for(var e=0;e<o.length;e+=1)Pe(o[e])}}function Ms(n){for(var o=n.parent;o!==null;){if((o.f&Ee)===0)return(o.f&tt)===0?o:null;o=o.parent}return null}function Hi(n){var o,e=ne;qe(Ms(n));try{n.f&=~gt,yr(n),o=Zr(n)}finally{qe(e)}return o}function _r(n){var o=Hi(n);if(n.equals(o)||(ae?.is_fork||(n.v=o),n.wv=Gr()),!xt)if(ze!==null)(Gt()||ae?.is_fork)&&ze.set(n,o);else{var e=(n.f&Ne)===0?et:Re;Ce(n,e)}}let zi=new Set;const at=new Map;let Tr=!1;function yt(n,o){var e={f:0,v:n,reactions:null,equals:hr,rv:0,wv:0};return e}function ue(n,o){const e=yt(n);return Wr(e),e}function Bs(n,o=!1,e=!0){const t=yt(n);return o||(t.equals=cr),t}function G(n,o,e=!1){ee!==null&&(!Ge||(ee.f&ar)!==0)&&dr()&&(ee.f&(Ee|Je|Oi|ar))!==0&&!nt?.includes(n)&&ss();let t=e?lt(o):o;return Ft(n,t)}function Ft(n,o){if(!n.equals(o)){var e=n.v;xt?at.set(n,o):at.set(n,e),n.v=o;var t=Ve.ensure();t.capture(n,e),(n.f&Ee)!==0&&((n.f&Ie)!==0&&Hi(n),Ce(n,(n.f&Ne)!==0?Re:et)),n.wv=Gr(),Er(n,Ie),ne!==null&&(ne.f&Re)!==0&&(ne.f&($e|ft))===0&&(ke===null?Ks([n]):ke.push(n)),!t.is_fork&&zi.size>0&&!Tr&&Hs()}return o}function Hs(){Tr=!1;var n=Tt;di(!0);const o=Array.from(zi);try{for(const e of o)(e.f&Re)!==0&&Ce(e,et),Yt(e)&&Kt(e)}finally{di(n)}zi.clear()}function xr(n,o=1){var e=b(n),t=o===1?e++:e--;return G(n,e),t}function Wt(n){G(n,n.v+1)}function Er(n,o){var e=n.reactions;if(e!==null)for(var t=e.length,r=0;r<t;r++){var i=e[r],s=i.f,l=(s&Ie)===0;if(l&&Ce(i,o),(s&Ee)!==0){var a=i;ze?.delete(a),(s>)===0&&(s&Ne&&(i.f|=gt),Er(a,et))}else l&&((s&Je)!==0&&rt!==null&&rt.add(i),wt(i))}}function lt(n){if(typeof n!="object"||n===null||mt in n)return n;const o=ir(n);if(o!==jn&&o!==Gn)return n;var e=new Map,t=Ri(n),r=ue(0),i=Et,s=l=>{if(Et===i)return l();var a=ee,u=Et;Fe(null),jr(i);var h=l();return Fe(a),jr(u),h};return t&&e.set("length",ue(n.length)),new Proxy(n,{defineProperty(l,a,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&rs();var h=e.get(a);return h===void 0?h=s(()=>{var c=ue(u.value);return e.set(a,c),c}):G(h,u.value,!0),!0},deleteProperty(l,a){var u=e.get(a);if(u===void 0){if(a in l){const h=s(()=>ue(be));e.set(a,h),Wt(r)}}else G(u,be),Wt(r);return!0},get(l,a,u){if(a===mt)return n;var h=e.get(a),c=a in l;if(h===void 0&&(!c||Rt(l,a)?.writable)&&(h=s(()=>{var m=lt(c?l[a]:be),v=ue(m);return v}),e.set(a,h)),h!==void 0){var d=b(h);return d===be?void 0:d}return Reflect.get(l,a,u)},getOwnPropertyDescriptor(l,a){var u=Reflect.getOwnPropertyDescriptor(l,a);if(u&&"value"in u){var h=e.get(a);h&&(u.value=b(h))}else if(u===void 0){var c=e.get(a),d=c?.v;if(c!==void 0&&d!==be)return{enumerable:!0,configurable:!0,value:d,writable:!0}}return u},has(l,a){if(a===mt)return!0;var u=e.get(a),h=u!==void 0&&u.v!==be||Reflect.has(l,a);if(u!==void 0||ne!==null&&(!h||Rt(l,a)?.writable)){u===void 0&&(u=s(()=>{var d=h?lt(l[a]):be,m=ue(d);return m}),e.set(a,u));var c=b(u);if(c===be)return!1}return h},set(l,a,u,h){var c=e.get(a),d=a in l;if(t&&a==="length")for(var m=u;m<c.v;m+=1){var v=e.get(m+"");v!==void 0?G(v,be):m in l&&(v=s(()=>ue(be)),e.set(m+"",v))}if(c===void 0)(!d||Rt(l,a)?.writable)&&(c=s(()=>ue(void 0)),G(c,lt(u)),e.set(a,c));else{d=c.v!==be;var y=s(()=>lt(u));G(c,y)}var _=Reflect.getOwnPropertyDescriptor(l,a);if(_?.set&&_.set.call(h,u),!d){if(t&&typeof a=="string"){var E=e.get("length"),S=Number(a);Number.isInteger(S)&&S>=E.v&&G(E,S+1)}Wt(r)}return!0},ownKeys(l){b(r);var a=Reflect.ownKeys(l).filter(c=>{var d=e.get(c);return d===void 0||d.v!==be});for(var[u,h]of e)h.v!==be&&!(u in l)&&a.push(u);return a},setPrototypeOf(){ns()}})}function br(n){try{if(n!==null&&typeof n=="object"&&mt in n)return n[mt]}catch{}return n}function zs(n,o){return Object.is(br(n),br(o))}var Sr,Pr,Rr,Cr;function ks(){if(Sr===void 0){Sr=window,Pr=/Firefox/.test(navigator.userAgent);var n=Element.prototype,o=Node.prototype,e=Text.prototype;Rr=Rt(o,"firstChild").get,Cr=Rt(o,"nextSibling").get,rr(n)&&(n.__click=void 0,n.__className=void 0,n.__attributes=null,n.__style=void 0,n.__e=void 0),rr(e)&&(e.__t=void 0)}}function ut(n=""){return document.createTextNode(n)}function ui(n){return Rr.call(n)}function Vt(n){return Cr.call(n)}function $(n,o){return ui(n)}function jt(n,o=!1){{var e=ui(n);return e instanceof Comment&&e.data===""?Vt(e):e}}function _e(n,o=1,e=!1){let t=n;for(;o--;)t=Vt(t);return t}function Ns(n){n.textContent=""}function Dr(){return!1}function Us(n,o){if(o){const e=document.body;n.autofocus=!0,vt(()=>{document.activeElement===e&&n.focus()})}}let Ar=!1;function Ws(){Ar||(Ar=!0,document.addEventListener("reset",n=>{Promise.resolve().then(()=>{if(!n.defaultPrevented)for(const o of n.target.elements)o.__on_r?.()})},{capture:!0}))}function hi(n){var o=ee,e=ne;Fe(null),qe(null);try{return n()}finally{Fe(o),qe(e)}}function Vs(n,o,e,t=e){n.addEventListener(o,()=>hi(e));const r=n.__on_r;r?n.__on_r=()=>{r(),t(!0)}:n.__on_r=()=>t(!0),Ws()}function js(n){ne===null&&(ee===null&&es(),$n()),xt&&Jn()}function Gs(n,o){var e=o.last;e===null?o.last=o.first=n:(e.next=n,n.prev=e,o.last=n)}function je(n,o,e){var t=ne;t!==null&&(t.f&Me)!==0&&(n|=Me);var r={ctx:De,deps:null,nodes:null,f:n|Ie|Ne,first:null,fn:o,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};if(e)try{Kt(r),r.f|=Ai}catch(l){throw Pe(r),l}else o!==null&&wt(r);var i=r;if(e&&i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Ct)===0&&(i=i.first,(n&Je)!==0&&(n&pt)!==0&&i!==null&&(i.f|=pt)),i!==null&&(i.parent=t,t!==null&&Gs(i,t),ee!==null&&(ee.f&Ee)!==0&&(n&ft)===0)){var s=ee;(s.effects??=[]).push(i)}return r}function Gt(){return ee!==null&&!Ge}function Ir(n){const o=je(Di,null,!1);return Ce(o,Re),o.teardown=n,o}function qt(n){js();var o=ne.f,e=!ee&&(o&$e)!==0&&(o&Ai)===0;if(e){var t=De;(t.e??=[]).push(n)}else return Or(n)}function Or(n){return je(Ci|Zn,n,!1)}function qs(n){Ve.ensure();const o=je(ft|Ct,n,!0);return(e={})=>new Promise(t=>{e.outro?_t(o,()=>{Pe(o),t(void 0)}):(Pe(o),t(void 0))})}function Zt(n){return je(Ci,n,!1)}function Zs(n){return je(Oi|Ct,n,!0)}function Fr(n,o=0){return je(Di|o,n,!0)}function Se(n,o=[],e=[],t=[]){vr(t,o,e,r=>{je(Di,()=>n(...r.map(b)),!0)})}function ci(n,o=0){var e=je(Je|o,n,!0);return e}function Lr(n,o=0){var e=je(or|o,n,!0);return e}function Oe(n){return je($e|Ct,n,!0)}function Mr(n){var o=n.teardown;if(o!==null){const e=xt,t=ee;Ur(!0),Fe(null);try{o.call(null)}finally{Ur(e),Fe(t)}}}function Br(n,o=!1){var e=n.first;for(n.first=n.last=null;e!==null;){const r=e.ac;r!==null&&hi(()=>{r.abort(Dt)});var t=e.next;(e.f&ft)!==0?e.parent=null:Pe(e,o),e=t}}function Xs(n){for(var o=n.first;o!==null;){var e=o.next;(o.f&$e)===0&&Pe(o),o=e}}function Pe(n,o=!0){var e=!1;(o||(n.f&lr)!==0)&&n.nodes!==null&&n.nodes.end!==null&&(Ys(n.nodes.start,n.nodes.end),e=!0),Br(n,o&&!e),fi(n,0),Ce(n,tt);var t=n.nodes&&n.nodes.t;if(t!==null)for(const i of t)i.stop();Mr(n);var r=n.parent;r!==null&&r.first!==null&&Hr(n),n.next=n.prev=n.teardown=n.ctx=n.deps=n.fn=n.nodes=n.ac=null}function Ys(n,o){for(;n!==null;){var e=n===o?null:Vt(n);n.remove(),n=e}}function Hr(n){var o=n.parent,e=n.prev,t=n.next;e!==null&&(e.next=t),t!==null&&(t.prev=e),o!==null&&(o.first===n&&(o.first=t),o.last===n&&(o.last=e))}function _t(n,o,e=!0){var t=[];zr(n,t,!0);var r=()=>{e&&Pe(n),o&&o()},i=t.length;if(i>0){var s=()=>--i||r();for(var l of t)l.out(s)}else r()}function zr(n,o,e){if((n.f&Me)===0){n.f^=Me;var t=n.nodes&&n.nodes.t;if(t!==null)for(const l of t)(l.is_global||e)&&o.push(l);for(var r=n.first;r!==null;){var i=r.next,s=(r.f&pt)!==0||(r.f&$e)!==0&&(n.f&Je)!==0;zr(r,o,s?e:!1),r=i}}}function ki(n){kr(n,!0)}function kr(n,o){if((n.f&Me)!==0){n.f^=Me,(n.f&Re)===0&&(Ce(n,Ie),wt(n));for(var e=n.first;e!==null;){var t=e.next,r=(e.f&pt)!==0||(e.f&$e)!==0;kr(e,r?o:!1),e=t}var i=n.nodes&&n.nodes.t;if(i!==null)for(const s of i)(s.is_global||o)&&s.in()}}function Nr(n,o){if(n.nodes)for(var e=n.nodes.start,t=n.nodes.end;e!==null;){var r=e===t?null:Vt(e);o.append(e),e=r}}let Tt=!1;function di(n){Tt=n}let xt=!1;function Ur(n){xt=n}let ee=null,Ge=!1;function Fe(n){ee=n}let ne=null;function qe(n){ne=n}let nt=null;function Wr(n){ee!==null&&(nt===null?nt=[n]:nt.push(n))}let Ae=null,Be=0,ke=null;function Ks(n){ke=n}let Vr=1,Xt=0,Et=Xt;function jr(n){Et=n}function Gr(){return++Vr}function Yt(n){var o=n.f;if((o&Ie)!==0)return!0;if(o&Ee&&(n.f&=~gt),(o&et)!==0){var e=n.deps;if(e!==null)for(var t=e.length,r=0;r<t;r++){var i=e[r];if(Yt(i)&&_r(i),i.wv>n.wv)return!0}(o&Ne)!==0&&ze===null&&Ce(n,Re)}return!1}function qr(n,o,e=!0){var t=n.reactions;if(t!==null&&!nt?.includes(n))for(var r=0;r<t.length;r++){var i=t[r];(i.f&Ee)!==0?qr(i,o,!1):o===i&&(e?Ce(i,Ie):(i.f&Re)!==0&&Ce(i,et),wt(i))}}function Zr(n){var o=Ae,e=Be,t=ke,r=ee,i=nt,s=De,l=Ge,a=Et,u=n.f;Ae=null,Be=0,ke=null,ee=(u&($e|ft))===0?n:null,nt=null,At(n.ctx),Ge=!1,Et=++Xt,n.ac!==null&&(hi(()=>{n.ac.abort(Dt)}),n.ac=null);try{n.f|=Ii;var h=n.fn,c=h(),d=n.deps;if(Ae!==null){var m;if(fi(n,Be),d!==null&&Be>0)for(d.length=Be+Ae.length,m=0;m<Ae.length;m++)d[Be+m]=Ae[m];else n.deps=d=Ae;if(Gt()&&(n.f&Ne)!==0)for(m=Be;m<d.length;m++)(d[m].reactions??=[]).push(n)}else d!==null&&Be<d.length&&(fi(n,Be),d.length=Be);if(dr()&&ke!==null&&!Ge&&d!==null&&(n.f&(Ee|et|Ie))===0)for(m=0;m<ke.length;m++)qr(ke[m],n);return r!==null&&r!==n&&(Xt++,ke!==null&&(t===null?t=ke:t.push(...ke))),(n.f&ot)!==0&&(n.f^=ot),c}catch(v){return fr(v)}finally{n.f^=Ii,Ae=o,Be=e,ke=t,ee=r,nt=i,At(s),Ge=l,Et=a}}function Qs(n,o){let e=o.reactions;if(e!==null){var t=Un.call(e,n);if(t!==-1){var r=e.length-1;r===0?e=o.reactions=null:(e[t]=e[r],e.pop())}}e===null&&(o.f&Ee)!==0&&(Ae===null||!Ae.includes(o))&&(Ce(o,et),(o.f&Ne)!==0&&(o.f^=Ne,o.f&=~gt),yr(o),fi(o,0))}function fi(n,o){var e=n.deps;if(e!==null)for(var t=o;t<e.length;t++)Qs(n,e[t])}function Kt(n){var o=n.f;if((o&tt)===0){Ce(n,Re);var e=ne,t=Tt;ne=n,Tt=!0;try{(o&(Je|or))!==0?Xs(n):Br(n),Mr(n);var r=Zr(n);n.teardown=typeof r=="function"?r:null,n.wv=Vr;var i;Pi&&xs&&(n.f&Ie)!==0&&n.deps}finally{Tt=t,ne=e}}}function b(n){var o=n.f,e=(o&Ee)!==0;if(ee!==null&&!Ge){var t=ne!==null&&(ne.f&tt)!==0;if(!t&&!nt?.includes(n)){var r=ee.deps;if((ee.f&Ii)!==0)n.rv<Xt&&(n.rv=Xt,Ae===null&&r!==null&&r[Be]===n?Be++:Ae===null?Ae=[n]:Ae.includes(n)||Ae.push(n));else{(ee.deps??=[]).push(n);var i=n.reactions;i===null?n.reactions=[ee]:i.includes(ee)||i.push(ee)}}}if(xt){if(at.has(n))return at.get(n);if(e){var s=n,l=s.v;return((s.f&Re)===0&&s.reactions!==null||Yr(s))&&(l=Hi(s)),at.set(s,l),l}}else e&&(!ze?.has(n)||ae?.is_fork&&!Gt())&&(s=n,Yt(s)&&_r(s),Tt&&Gt()&&(s.f&Ne)===0&&Xr(s));if(ze?.has(n))return ze.get(n);if((n.f&ot)!==0)throw n.v;return n.v}function Xr(n){if(n.deps!==null){n.f^=Ne;for(const o of n.deps)(o.reactions??=[]).push(n),(o.f&Ee)!==0&&(o.f&Ne)===0&&Xr(o)}}function Yr(n){if(n.v===be)return!0;if(n.deps===null)return!1;for(const o of n.deps)if(at.has(o)||(o.f&Ee)!==0&&Yr(o))return!0;return!1}function pi(n){var o=Ge;try{return Ge=!0,n()}finally{Ge=o}}const Js=-7169;function Ce(n,o){n.f=n.f&Js|o}function $s(n){return n.endsWith("capture")&&n!=="gotpointercapture"&&n!=="lostpointercapture"}const eo=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function to(n){return eo.includes(n)}const io={formnovalidate:"formNoValidate",ismap:"isMap",nomodule:"noModule",playsinline:"playsInline",readonly:"readOnly",defaultvalue:"defaultValue",defaultchecked:"defaultChecked",srcobject:"srcObject",novalidate:"noValidate",allowfullscreen:"allowFullscreen",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback"};function ro(n){return n=n.toLowerCase(),io[n]??n}const no=["touchstart","touchmove"];function so(n){return no.includes(n)}const Kr=new Set,Ni=new Set;function oo(n,o,e,t={}){function r(i){if(t.capture||Qt.call(o,i),!i.cancelBubble)return hi(()=>e?.call(this,i))}return n.startsWith("pointer")||n.startsWith("touch")||n==="wheel"?vt(()=>{o.addEventListener(n,r,t)}):o.addEventListener(n,r,t),r}function Qr(n){for(var o=0;o<n.length;o++)Kr.add(n[o]);for(var e of Ni)e(n)}let Jr=null;function Qt(n){var o=this,e=o.ownerDocument,t=n.type,r=n.composedPath?.()||[],i=r[0]||n.target;Jr=n;var s=0,l=Jr===n&&n.__root;if(l){var a=r.indexOf(l);if(a!==-1&&(o===document||o===window)){n.__root=o;return}var u=r.indexOf(o);if(u===-1)return;a<=u&&(s=a)}if(i=r[s]||n.target,i!==o){Wn(n,"currentTarget",{configurable:!0,get(){return i||e}});var h=ee,c=ne;Fe(null),qe(null);try{for(var d,m=[];i!==null;){var v=i.assignedSlot||i.parentNode||i.host||null;try{var y=i["__"+t];y!=null&&(!i.disabled||n.target===i)&&y.call(i,n)}catch(_){d?m.push(_):d=_}if(n.cancelBubble||v===o||v===null)break;i=v}if(d){for(let _ of m)queueMicrotask(()=>{throw _});throw d}}finally{n.__root=o,delete n.currentTarget,Fe(h),qe(c)}}}function ao(n){var o=document.createElement("template");return o.innerHTML=n.replaceAll("<!>","<!---->"),o.content}function Ui(n,o){var e=ne;e.nodes===null&&(e.nodes={start:n,end:o,a:null,t:null})}function me(n,o){var e=(o&gs)!==0,t=(o&ms)!==0,r,i=!n.startsWith("<!>");return()=>{r===void 0&&(r=ao(i?n:"<!>"+n),e||(r=ui(r)));var s=t||Pr?document.importNode(r,!0):r.cloneNode(!0);if(e){var l=ui(s),a=s.lastChild;Ui(l,a)}else Ui(s,s);return s}}function $r(){var n=document.createDocumentFragment(),o=document.createComment(""),e=ut();return n.append(o,e),Ui(o,e),n}function ge(n,o){n!==null&&n.before(o)}function Te(n,o){var e=o==null?"":typeof o=="object"?o+"":o;e!==(n.__t??=n.nodeValue)&&(n.__t=e,n.nodeValue=e+"")}function lo(n,o){return uo(n,o)}const Lt=new Map;function uo(n,{target:o,anchor:e,props:t={},events:r,context:i,intro:s=!0}){ks();var l=new Set,a=c=>{for(var d=0;d<c.length;d++){var m=c[d];if(!l.has(m)){l.add(m);var v=so(m);o.addEventListener(m,Qt,{passive:v});var y=Lt.get(m);y===void 0?(document.addEventListener(m,Qt,{passive:v}),Lt.set(m,1)):Lt.set(m,y+1)}}};a(ri(Kr)),Ni.add(a);var u=void 0,h=qs(()=>{var c=e??o.appendChild(ut());return Is(c,{pending:()=>{}},d=>{if(i){Fi({});var m=De;m.c=i}r&&(t.$$events=r),u=n(d,t)||{},i&&Li()}),()=>{for(var d of l){o.removeEventListener(d,Qt);var m=Lt.get(d);--m===0?(document.removeEventListener(d,Qt),Lt.delete(d)):Lt.set(d,m)}Ni.delete(a),c!==e&&c.parentNode?.removeChild(c)}});return Wi.set(u,h),u}let Wi=new WeakMap;function ho(n,o){const e=Wi.get(n);return e?(Wi.delete(n),e(o)):Promise.resolve()}class en{anchor;#e=new Map;#t=new Map;#r=new Map;#i=new Set;#l=!0;constructor(o,e=!0){this.anchor=o,this.#l=e}#s=()=>{var o=ae;if(this.#e.has(o)){var e=this.#e.get(o),t=this.#t.get(e);if(t)ki(t),this.#i.delete(e);else{var r=this.#r.get(e);r&&(this.#t.set(e,r.effect),this.#r.delete(e),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),t=r.effect)}for(const[i,s]of this.#e){if(this.#e.delete(i),i===o)break;const l=this.#r.get(s);l&&(Pe(l.effect),this.#r.delete(s))}for(const[i,s]of this.#t){if(i===e||this.#i.has(i))continue;const l=()=>{if(Array.from(this.#e.values()).includes(i)){var u=document.createDocumentFragment();Nr(s,u),u.append(ut()),this.#r.set(i,{effect:s,fragment:u})}else Pe(s);this.#i.delete(i),this.#t.delete(i)};this.#l||!t?(this.#i.add(i),_t(s,l,!1)):l()}}};#n=o=>{this.#e.delete(o);const e=Array.from(this.#e.values());for(const[t,r]of this.#r)e.includes(t)||(Pe(r.effect),this.#r.delete(t))};ensure(o,e){var t=ae,r=Dr();if(e&&!this.#t.has(o)&&!this.#r.has(o))if(r){var i=document.createDocumentFragment(),s=ut();i.append(s),this.#r.set(o,{effect:Oe(()=>e(s)),fragment:i})}else this.#t.set(o,Oe(()=>e(this.anchor)));if(this.#e.set(t,o),r){for(const[l,a]of this.#t)l===o?t.skipped_effects.delete(a):t.skipped_effects.add(a);for(const[l,a]of this.#r)l===o?t.skipped_effects.delete(a.effect):t.skipped_effects.add(a.effect);t.oncommit(this.#s),t.ondiscard(this.#n)}else this.#s()}}function st(n,o,e=!1){var t=new en(n),r=e?pt:0;function i(s,l){t.ensure(s,l)}ci(()=>{var s=!1;o((l,a=!0)=>{s=!0,i(a,l)}),s||i(!1,null)},r)}function Vi(n,o){return o}function co(n,o,e){for(var t=[],r=o.length,i,s=o.length,l=0;l<r;l++){let c=o[l];_t(c,()=>{if(i){if(i.pending.delete(c),i.done.add(c),i.pending.size===0){var d=n.outrogroups;ji(ri(i.done)),d.delete(i),d.size===0&&(n.outrogroups=null)}}else s-=1},!1)}if(s===0){var a=t.length===0&&e!==null;if(a){var u=e,h=u.parentNode;Ns(h),h.append(u),n.items.clear()}ji(o,!a)}else i={pending:new Set(o),done:new Set},(n.outrogroups??=new Set).add(i)}function ji(n,o=!0){for(var e=0;e<n.length;e++)Pe(n[e],o)}var tn;function gi(n,o,e,t,r,i=null){var s=n,l=new Map,a=(o&ur)!==0;if(a){var u=n;s=u.appendChild(ut())}var h=null,c=wr(()=>{var E=e();return Ri(E)?E:E==null?[]:ri(E)}),d,m=!0;function v(){_.fallback=h,fo(_,d,s,o,t),h!==null&&(d.length===0?(h.f&it)===0?ki(h):(h.f^=it,Jt(h,null,s)):_t(h,()=>{h=null}))}var y=ci(()=>{d=b(c);for(var E=d.length,S=new Set,P=ae,L=Dr(),F=0;F<E;F+=1){var H=d[F],B=t(H,F),V=m?null:l.get(B);V?(V.v&&Ft(V.v,H),V.i&&Ft(V.i,F),L&&P.skipped_effects.delete(V.e)):(V=po(l,m?s:tn??=ut(),H,B,F,r,o,e),m||(V.e.f|=it),l.set(B,V)),S.add(B)}if(E===0&&i&&!h&&(m?h=Oe(()=>i(s)):(h=Oe(()=>i(tn??=ut())),h.f|=it)),!m)if(L){for(const[Y,J]of l)S.has(Y)||P.skipped_effects.add(J.e);P.oncommit(v),P.ondiscard(()=>{})}else v();b(c)}),_={effect:y,items:l,outrogroups:null,fallback:h};m=!1}function fo(n,o,e,t,r){var i=(t&us)!==0,s=o.length,l=n.items,a=n.effect.first,u,h=null,c,d=[],m=[],v,y,_,E;if(i)for(E=0;E<s;E+=1)v=o[E],y=r(v,E),_=l.get(y).e,(_.f&it)===0&&(_.nodes?.a?.measure(),(c??=new Set).add(_));for(E=0;E<s;E+=1){if(v=o[E],y=r(v,E),_=l.get(y).e,n.outrogroups!==null)for(const J of n.outrogroups)J.pending.delete(_),J.done.delete(_);if((_.f&it)!==0)if(_.f^=it,_===a)Jt(_,null,e);else{var S=h?h.next:a;_===n.effect.last&&(n.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),ht(n,h,_),ht(n,_,S),Jt(_,S,e),h=_,d=[],m=[],a=h.next;continue}if((_.f&Me)!==0&&(ki(_),i&&(_.nodes?.a?.unfix(),(c??=new Set).delete(_))),_!==a){if(u!==void 0&&u.has(_)){if(d.length<m.length){var P=m[0],L;h=P.prev;var F=d[0],H=d[d.length-1];for(L=0;L<d.length;L+=1)Jt(d[L],P,e);for(L=0;L<m.length;L+=1)u.delete(m[L]);ht(n,F.prev,H.next),ht(n,h,F),ht(n,H,P),a=P,h=H,E-=1,d=[],m=[]}else u.delete(_),Jt(_,a,e),ht(n,_.prev,_.next),ht(n,_,h===null?n.effect.first:h.next),ht(n,h,_),h=_;continue}for(d=[],m=[];a!==null&&a!==_;)(u??=new Set).add(a),m.push(a),a=a.next;if(a===null)continue}(_.f&it)===0&&d.push(_),h=_,a=_.next}if(n.outrogroups!==null){for(const J of n.outrogroups)J.pending.size===0&&(ji(ri(J.done)),n.outrogroups?.delete(J));n.outrogroups.size===0&&(n.outrogroups=null)}if(a!==null||u!==void 0){var B=[];if(u!==void 0)for(_ of u)(_.f&Me)===0&&B.push(_);for(;a!==null;)(a.f&Me)===0&&a!==n.fallback&&B.push(a),a=a.next;var V=B.length;if(V>0){var Y=(t&ur)!==0&&s===0?e:null;if(i){for(E=0;E<V;E+=1)B[E].nodes?.a?.measure();for(E=0;E<V;E+=1)B[E].nodes?.a?.fix()}co(n,B,Y)}}i&&vt(()=>{if(c!==void 0)for(_ of c)_.nodes?.a?.apply()})}function po(n,o,e,t,r,i,s,l){var a=(s&as)!==0?(s&hs)===0?Bs(e,!1,!1):yt(e):null,u=(s&ls)!==0?yt(r):null;return{v:a,i:u,e:Oe(()=>(i(o,a??e,u??r,l),()=>{n.delete(t)}))}}function Jt(n,o,e){if(n.nodes)for(var t=n.nodes.start,r=n.nodes.end,i=o&&(o.f&it)===0?o.nodes.start:e;t!==null;){var s=Vt(t);if(i.before(t),t===r)return;t=s}}function ht(n,o,e){o===null?n.effect.first=e:o.next=e,e===null?n.effect.last=o:e.prev=o}function rn(n,o,...e){var t=new en(n);ci(()=>{const r=o()??null;t.ensure(r,r&&(i=>r(i,...e)))},pt)}function go(n,o,e){Zt(()=>{var t=pi(()=>o(n,e?.())||{});if(t?.destroy)return()=>t.destroy()})}function mo(n,o){var e=void 0,t;Lr(()=>{e!==(e=o())&&(t&&(Pe(t),t=null),e&&(t=Oe(()=>{Zt(()=>e(n))})))})}function nn(n){var o,e,t="";if(typeof n=="string"||typeof n=="number")t+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(o=0;o<r;o++)n[o]&&(e=nn(n[o]))&&(t&&(t+=" "),t+=e)}else for(e in n)n[e]&&(t&&(t+=" "),t+=e);return t}function vo(){for(var n,o,e=0,t="",r=arguments.length;e<r;e++)(n=arguments[e])&&(o=nn(n))&&(t&&(t+=" "),t+=o);return t}function wo(n){return typeof n=="object"?vo(n):n??""}const sn=[...`
|
|
2
|
-
\r\f \v\uFEFF`];function
|
|
3
|
-
`);return`Plugin "${
|
|
1
|
+
(function(){"use strict";var Pi=Array.isArray,Hr=Array.prototype.indexOf,ri=Array.from,Nr=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Ur=Object.getOwnPropertyDescriptors,Wr=Object.prototype,jr=Array.prototype,tn=Object.getPrototypeOf,nn=Object.isExtensible;const rn=()=>{};function Vr(r){for(var s=0;s<r.length;s++)r[s]()}function on(){var r,s,e=new Promise((t,i)=>{r=t,s=i});return{promise:e,resolve:r,reject:s}}const Te=2,Ci=4,Ri=8,sn=1<<24,Qe=16,Je=32,pt=64,oi=128,Ne=512,Ce=1024,Be=2048,et=4096,Fe=8192,tt=16384,Di=32768,ft=65536,an=1<<17,ln=1<<18,Rt=1<<19,Gr=1<<20,it=1<<25,gt=32768,Ii=1<<21,Ai=1<<22,st=1<<23,vt=Symbol("$state"),qr=Symbol("legacy props"),Zr=Symbol(""),Dt=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function Xr(r){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function $r(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Yr(r){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Kr(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Qr(r){throw new Error("https://svelte.dev/e/effect_orphan")}function Jr(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function eo(r){throw new Error("https://svelte.dev/e/props_invalid_value")}function to(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function io(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function no(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function ro(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const oo=1,so=2,un=4,ao=8,lo=16,uo=1,ho=4,co=8,po=16,fo=1,go=2,Ee=Symbol(),vo="http://www.w3.org/1999/xhtml",mo="@attach";function wo(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function yo(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function hn(r){return r===this.v}function _o(r,s){return r!=r?s==s:r!==s||r!==null&&typeof r=="object"||typeof r=="function"}function cn(r){return!_o(r,this.v)}let Al=!1,De=null;function It(r){De=r}function xo(r){return To().get(r)}function ki(r,s=!1,e){De={p:De,i:!1,c:null,e:null,s:r,x:null,l:null}}function Oi(r){var s=De,e=s.e;if(e!==null){s.e=null;for(var t of e)kn(t)}return s.i=!0,De=s.p,{}}function dn(){return!0}function To(r){return De===null&&Xr(),De.c??=new Map(Eo(De)||void 0)}function Eo(r){let s=r.p;for(;s!==null;){const e=s.c;if(e!==null)return e;s=s.p}return null}let At=[];function bo(){var r=At;At=[],Vr(r)}function mt(r){if(At.length===0){var s=At;queueMicrotask(()=>{s===At&&bo()})}At.push(r)}function pn(r){var s=ne;if(s===null)return te.f|=st,r;if((s.f&Di)===0){if((s.f&oi)===0)throw r;s.b.error(r)}else kt(r,s)}function kt(r,s){for(;s!==null;){if((s.f&oi)!==0)try{s.b.error(r);return}catch(e){r=e}s=s.parent}throw r}const si=new Set;let se=null,ai=null,ze=null,We=[],Bi=null,Fi=!1;class je{committed=!1;current=new Map;previous=new Map;#e=new Set;#t=new Set;#n=0;#i=0;#l=null;#o=[];#r=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#i>0}process(s){We=[],ai=null,this.apply();var e={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const t of s)this.#s(t,e);this.is_fork||this.#h(),this.is_deferred()?(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects)):(ai=this,se=null,fn(e.render_effects),fn(e.effects),ai=null,this.#l?.resolve()),ze=null}#s(s,e){s.f^=Ce;for(var t=s.first;t!==null;){var i=t.f,n=(i&(Je|pt))!==0,o=n&&(i&Ce)!==0,u=o||(i&Fe)!==0||this.skipped_effects.has(t);if((t.f&oi)!==0&&t.b?.is_pending()&&(e={parent:e,effect:t,effects:[],render_effects:[],block_effects:[]}),!u&&t.fn!==null){n?t.f^=Ce:(i&Ci)!==0?e.effects.push(t):Yt(t)&&((t.f&Qe)!==0&&e.block_effects.push(t),Kt(t));var l=t.first;if(l!==null){t=l;continue}}var a=t.parent;for(t=t.next;t===null&&a!==null;)a===e.effect&&(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects),e=e.parent),t=a.next,a=a.parent}}#a(s){for(const e of s)((e.f&Be)!==0?this.#o:this.#r).push(e),this.#u(e.deps),Re(e,Ce)}#u(s){if(s!==null)for(const e of s)(e.f&Te)===0||(e.f>)===0||(e.f^=gt,this.#u(e.deps))}capture(s,e){this.previous.has(s)||this.previous.set(s,e),(s.f&st)===0&&(this.current.set(s,s.v),ze?.set(s,s.v))}activate(){se=this,this.apply()}deactivate(){se===this&&(se=null,ze=null)}flush(){if(this.activate(),We.length>0){if(So(),se!==null&&se!==this)return}else this.#n===0&&this.process([]);this.deactivate()}discard(){for(const s of this.#t)s(this);this.#t.clear()}#h(){if(this.#i===0){for(const s of this.#e)s();this.#e.clear()}this.#n===0&&this.#c()}#c(){if(si.size>1){this.previous.clear();var s=ze,e=!0,t={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const n of si){if(n===this){e=!1;continue}const o=[];for(const[l,a]of this.current){if(n.current.has(l))if(e&&a!==n.current.get(l))n.current.set(l,a);else continue;o.push(l)}if(o.length===0)continue;const u=[...n.current.keys()].filter(l=>!this.current.has(l));if(u.length>0){var i=We;We=[];const l=new Set,a=new Map;for(const h of o)gn(h,u,l,a);if(We.length>0){se=n,n.apply();for(const h of We)n.#s(h,t);n.deactivate()}We=i}}se=null,ze=s}this.committed=!0,si.delete(this)}increment(s){this.#n+=1,s&&(this.#i+=1)}decrement(s){this.#n-=1,s&&(this.#i-=1),this.revive()}revive(){for(const s of this.#o)Re(s,Be),wt(s);for(const s of this.#r)Re(s,et),wt(s);this.#o=[],this.#r=[],this.flush()}oncommit(s){this.#e.add(s)}ondiscard(s){this.#t.add(s)}settled(){return(this.#l??=on()).promise}static ensure(){if(se===null){const s=se=new je;si.add(se),je.enqueue(()=>{se===s&&s.flush()})}return se}static enqueue(s){mt(s)}apply(){}}function So(){var r=xt;Fi=!0;var s=null;try{var e=0;for(pi(!0);We.length>0;){var t=je.ensure();if(e++>1e3){var i,n;Po()}t.process(We),at.clear()}}finally{Fi=!1,pi(r),Bi=null}}function Po(){try{Jr()}catch(r){kt(r,Bi)}}let nt=null;function fn(r){var s=r.length;if(s!==0){for(var e=0;e<s;){var t=r[e++];if((t.f&(tt|Fe))===0&&Yt(t)&&(nt=new Set,Kt(t),t.deps===null&&t.first===null&&t.nodes===null&&(t.teardown===null&&t.ac===null?Ln(t):t.fn=null),nt?.size>0)){at.clear();for(const i of nt){if((i.f&(tt|Fe))!==0)continue;const n=[i];let o=i.parent;for(;o!==null;)nt.has(o)&&(nt.delete(o),n.push(o)),o=o.parent;for(let u=n.length-1;u>=0;u--){const l=n[u];(l.f&(tt|Fe))===0&&Kt(l)}}nt.clear()}}nt=null}}function gn(r,s,e,t){if(!e.has(r)&&(e.add(r),r.reactions!==null))for(const i of r.reactions){const n=i.f;(n&Te)!==0?gn(i,s,e,t):(n&(Ai|Qe))!==0&&(n&Be)===0&&vn(i,s,t)&&(Re(i,Be),wt(i))}}function vn(r,s,e){const t=e.get(r);if(t!==void 0)return t;if(r.deps!==null)for(const i of r.deps){if(s.includes(i))return!0;if((i.f&Te)!==0&&vn(i,s,e))return e.set(i,!0),!0}return e.set(r,!1),!1}function wt(r){for(var s=Bi=r;s.parent!==null;){s=s.parent;var e=s.f;if(Fi&&s===ne&&(e&Qe)!==0&&(e&ln)===0)return;if((e&(pt|Je))!==0){if((e&Ce)===0)return;s.f^=Ce}}We.push(s)}function Co(r){let s=0,e=yt(0),t;return()=>{qt()&&(b(e),On(()=>(s===0&&(t=gi(()=>r(()=>jt(e)))),s+=1,()=>{mt(()=>{s-=1,s===0&&(t?.(),t=void 0,jt(e))})})))}}var Ro=ft|Rt|oi;function Do(r,s,e){new Io(r,s,e)}class Io{parent;#e=!1;#t;#n=null;#i;#l;#o;#r=null;#s=null;#a=null;#u=null;#h=null;#c=0;#d=0;#f=!1;#p=null;#y=Co(()=>(this.#p=yt(this.#c),()=>{this.#p=null}));constructor(s,e,t){this.#t=s,this.#i=e,this.#l=t,this.parent=ne.b,this.#e=!!this.#i.pending,this.#o=di(()=>{ne.b=this;{var i=this.#m();try{this.#r=Ae(()=>t(i))}catch(n){this.error(n)}this.#d>0?this.#v():this.#e=!1}return()=>{this.#h?.remove()}},Ro)}#_(){try{this.#r=Ae(()=>this.#l(this.#t))}catch(s){this.error(s)}this.#e=!1}#x(){const s=this.#i.pending;s&&(this.#s=Ae(()=>s(this.#t)),je.enqueue(()=>{var e=this.#m();this.#r=this.#g(()=>(je.ensure(),Ae(()=>this.#l(e)))),this.#d>0?this.#v():(_t(this.#s,()=>{this.#s=null}),this.#e=!1)}))}#m(){var s=this.#t;return this.#e&&(this.#h=ut(),this.#t.before(this.#h),s=this.#h),s}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#i.pending}#g(s){var e=ne,t=te,i=De;qe(this.#o),ke(this.#o),It(this.#o.ctx);try{return s()}catch(n){return pn(n),null}finally{qe(e),ke(t),It(i)}}#v(){const s=this.#i.pending;this.#r!==null&&(this.#u=document.createDocumentFragment(),this.#u.append(this.#h),Nn(this.#r,this.#u)),this.#s===null&&(this.#s=Ae(()=>s(this.#t)))}#w(s){if(!this.has_pending_snippet()){this.parent&&this.parent.#w(s);return}this.#d+=s,this.#d===0&&(this.#e=!1,this.#s&&_t(this.#s,()=>{this.#s=null}),this.#u&&(this.#t.before(this.#u),this.#u=null))}update_pending_count(s){this.#w(s),this.#c+=s,this.#p&&Ot(this.#p,this.#c)}get_effect_pending(){return this.#y(),b(this.#p)}error(s){var e=this.#i.onerror;let t=this.#i.failed;if(this.#f||!e&&!t)throw s;this.#r&&(Se(this.#r),this.#r=null),this.#s&&(Se(this.#s),this.#s=null),this.#a&&(Se(this.#a),this.#a=null);var i=!1,n=!1;const o=()=>{if(i){yo();return}i=!0,n&&ro(),je.ensure(),this.#c=0,this.#a!==null&&_t(this.#a,()=>{this.#a=null}),this.#e=this.has_pending_snippet(),this.#r=this.#g(()=>(this.#f=!1,Ae(()=>this.#l(this.#t)))),this.#d>0?this.#v():this.#e=!1};var u=te;try{ke(null),n=!0,e?.(s,o),n=!1}catch(l){kt(l,this.#o&&this.#o.parent)}finally{ke(u)}t&&mt(()=>{this.#a=this.#g(()=>{je.ensure(),this.#f=!0;try{return Ae(()=>{t(this.#t,()=>s,()=>o)})}catch(l){return kt(l,this.#o.parent),null}finally{this.#f=!1}})})}}function mn(r,s,e,t){const i=ui;if(e.length===0&&r.length===0){t(s.map(i));return}var n=se,o=ne,u=Ao();function l(){Promise.all(e.map(a=>ko(a))).then(a=>{u();try{t([...s.map(i),...a])}catch(h){(o.f&tt)===0&&kt(h,o)}n?.deactivate(),li()}).catch(a=>{kt(a,o)})}r.length>0?Promise.all(r).then(()=>{u();try{return l()}finally{n?.deactivate(),li()}}):l()}function Ao(){var r=ne,s=te,e=De,t=se;return function(n=!0){qe(r),ke(s),It(e),n&&t?.activate()}}function li(){qe(null),ke(null),It(null)}function ui(r){var s=Te|Be,e=te!==null&&(te.f&Te)!==0?te:null;return ne!==null&&(ne.f|=Rt),{ctx:De,deps:null,effects:null,equals:hn,f:s,fn:r,reactions:null,rv:0,v:Ee,wv:0,parent:e??ne,ac:null}}function ko(r,s){let e=ne;e===null&&$r();var t=e.b,i=void 0,n=yt(Ee),o=!te,u=new Map;return Go(()=>{var l=on();i=l.promise;try{Promise.resolve(r()).then(l.resolve,l.reject).then(()=>{a===se&&a.committed&&a.deactivate(),li()})}catch(d){l.reject(d),li()}var a=se;if(o){var h=!t.is_pending();t.update_pending_count(1),a.increment(h),u.get(a)?.reject(Dt),u.delete(a),u.set(a,l)}const c=(d,v=void 0)=>{if(a.activate(),v)v!==Dt&&(n.f|=st,Ot(n,v));else{(n.f&st)!==0&&(n.f^=st),Ot(n,d);for(const[m,_]of u){if(u.delete(m),m===a)break;_.reject(Dt)}}o&&(t.update_pending_count(-1),a.decrement(h))};l.promise.then(c,d=>c(null,d||"unknown"))}),An(()=>{for(const l of u.values())l.reject(Dt)}),new Promise(l=>{function a(h){function c(){h===i?l(n):a(i)}h.then(c,c)}a(i)})}function ae(r){const s=ui(r);return Wn(s),s}function wn(r){const s=ui(r);return s.equals=cn,s}function yn(r){var s=r.effects;if(s!==null){r.effects=null;for(var e=0;e<s.length;e+=1)Se(s[e])}}function Oo(r){for(var s=r.parent;s!==null;){if((s.f&Te)===0)return(s.f&tt)===0?s:null;s=s.parent}return null}function Mi(r){var s,e=ne;qe(Oo(r));try{r.f&=~gt,yn(r),s=Zn(r)}finally{qe(e)}return s}function _n(r){var s=Mi(r);if(r.equals(s)||(se?.is_fork||(r.v=s),r.wv=Gn()),!Tt)if(ze!==null)(qt()||se?.is_fork)&&ze.set(r,s);else{var e=(r.f&Ne)===0?et:Ce;Re(r,e)}}let Li=new Set;const at=new Map;let xn=!1;function yt(r,s){var e={f:0,v:r,reactions:null,equals:hn,rv:0,wv:0};return e}function le(r,s){const e=yt(r);return Wn(e),e}function Bo(r,s=!1,e=!0){const t=yt(r);return s||(t.equals=cn),t}function G(r,s,e=!1){te!==null&&(!Ge||(te.f&an)!==0)&&dn()&&(te.f&(Te|Qe|Ai|an))!==0&&!rt?.includes(r)&&no();let t=e?lt(s):s;return Ot(r,t)}function Ot(r,s){if(!r.equals(s)){var e=r.v;Tt?at.set(r,s):at.set(r,e),r.v=s;var t=je.ensure();t.capture(r,e),(r.f&Te)!==0&&((r.f&Be)!==0&&Mi(r),Re(r,(r.f&Ne)!==0?Ce:et)),r.wv=Gn(),En(r,Be),ne!==null&&(ne.f&Ce)!==0&&(ne.f&(Je|pt))===0&&(He===null?Xo([r]):He.push(r)),!t.is_fork&&Li.size>0&&!xn&&Fo()}return s}function Fo(){xn=!1;var r=xt;pi(!0);const s=Array.from(Li);try{for(const e of s)(e.f&Ce)!==0&&Re(e,et),Yt(e)&&Kt(e)}finally{pi(r)}Li.clear()}function Tn(r,s=1){var e=b(r),t=s===1?e++:e--;return G(r,e),t}function jt(r){G(r,r.v+1)}function En(r,s){var e=r.reactions;if(e!==null)for(var t=e.length,i=0;i<t;i++){var n=e[i],o=n.f,u=(o&Be)===0;if(u&&Re(n,s),(o&Te)!==0){var l=n;ze?.delete(l),(o>)===0&&(o&Ne&&(n.f|=gt),En(l,et))}else u&&((o&Qe)!==0&&nt!==null&&nt.add(n),wt(n))}}function lt(r){if(typeof r!="object"||r===null||vt in r)return r;const s=tn(r);if(s!==Wr&&s!==jr)return r;var e=new Map,t=Pi(r),i=le(0),n=Et,o=u=>{if(Et===n)return u();var l=te,a=Et;ke(null),Vn(n);var h=u();return ke(l),Vn(a),h};return t&&e.set("length",le(r.length)),new Proxy(r,{defineProperty(u,l,a){(!("value"in a)||a.configurable===!1||a.enumerable===!1||a.writable===!1)&&to();var h=e.get(l);return h===void 0?h=o(()=>{var c=le(a.value);return e.set(l,c),c}):G(h,a.value,!0),!0},deleteProperty(u,l){var a=e.get(l);if(a===void 0){if(l in u){const h=o(()=>le(Ee));e.set(l,h),jt(i)}}else G(a,Ee),jt(i);return!0},get(u,l,a){if(l===vt)return r;var h=e.get(l),c=l in u;if(h===void 0&&(!c||Ct(u,l)?.writable)&&(h=o(()=>{var v=lt(c?u[l]:Ee),m=le(v);return m}),e.set(l,h)),h!==void 0){var d=b(h);return d===Ee?void 0:d}return Reflect.get(u,l,a)},getOwnPropertyDescriptor(u,l){var a=Reflect.getOwnPropertyDescriptor(u,l);if(a&&"value"in a){var h=e.get(l);h&&(a.value=b(h))}else if(a===void 0){var c=e.get(l),d=c?.v;if(c!==void 0&&d!==Ee)return{enumerable:!0,configurable:!0,value:d,writable:!0}}return a},has(u,l){if(l===vt)return!0;var a=e.get(l),h=a!==void 0&&a.v!==Ee||Reflect.has(u,l);if(a!==void 0||ne!==null&&(!h||Ct(u,l)?.writable)){a===void 0&&(a=o(()=>{var d=h?lt(u[l]):Ee,v=le(d);return v}),e.set(l,a));var c=b(a);if(c===Ee)return!1}return h},set(u,l,a,h){var c=e.get(l),d=l in u;if(t&&l==="length")for(var v=a;v<c.v;v+=1){var m=e.get(v+"");m!==void 0?G(m,Ee):v in u&&(m=o(()=>le(Ee)),e.set(v+"",m))}if(c===void 0)(!d||Ct(u,l)?.writable)&&(c=o(()=>le(void 0)),G(c,lt(a)),e.set(l,c));else{d=c.v!==Ee;var _=o(()=>lt(a));G(c,_)}var y=Reflect.getOwnPropertyDescriptor(u,l);if(y?.set&&y.set.call(h,a),!d){if(t&&typeof l=="string"){var E=e.get("length"),S=Number(l);Number.isInteger(S)&&S>=E.v&&G(E,S+1)}jt(i)}return!0},ownKeys(u){b(i);var l=Reflect.ownKeys(u).filter(c=>{var d=e.get(c);return d===void 0||d.v!==Ee});for(var[a,h]of e)h.v!==Ee&&!(a in u)&&l.push(a);return l},setPrototypeOf(){io()}})}function bn(r){try{if(r!==null&&typeof r=="object"&&vt in r)return r[vt]}catch{}return r}function Mo(r,s){return Object.is(bn(r),bn(s))}var Sn,Pn,Cn,Rn;function Lo(){if(Sn===void 0){Sn=window,Pn=/Firefox/.test(navigator.userAgent);var r=Element.prototype,s=Node.prototype,e=Text.prototype;Cn=Ct(s,"firstChild").get,Rn=Ct(s,"nextSibling").get,nn(r)&&(r.__click=void 0,r.__className=void 0,r.__attributes=null,r.__style=void 0,r.__e=void 0),nn(e)&&(e.__t=void 0)}}function ut(r=""){return document.createTextNode(r)}function hi(r){return Cn.call(r)}function Vt(r){return Rn.call(r)}function J(r,s){return hi(r)}function Gt(r,s=!1){{var e=hi(r);return e instanceof Comment&&e.data===""?Vt(e):e}}function ye(r,s=1,e=!1){let t=r;for(;s--;)t=Vt(t);return t}function zo(r){r.textContent=""}function Dn(){return!1}function Ho(r,s){if(s){const e=document.body;r.autofocus=!0,mt(()=>{document.activeElement===e&&r.focus()})}}let In=!1;function No(){In||(In=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(const s of r.target.elements)s.__on_r?.()})},{capture:!0}))}function ci(r){var s=te,e=ne;ke(null),qe(null);try{return r()}finally{ke(s),qe(e)}}function Uo(r,s,e,t=e){r.addEventListener(s,()=>ci(e));const i=r.__on_r;i?r.__on_r=()=>{i(),t(!0)}:r.__on_r=()=>t(!0),No()}function Wo(r){ne===null&&(te===null&&Qr(),Kr()),Tt&&Yr()}function jo(r,s){var e=s.last;e===null?s.last=s.first=r:(e.next=r,r.prev=e,s.last=r)}function Ve(r,s,e){var t=ne;t!==null&&(t.f&Fe)!==0&&(r|=Fe);var i={ctx:De,deps:null,nodes:null,f:r|Be|Ne,first:null,fn:s,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};if(e)try{Kt(i),i.f|=Di}catch(u){throw Se(i),u}else s!==null&&wt(i);var n=i;if(e&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&Rt)===0&&(n=n.first,(r&Qe)!==0&&(r&ft)!==0&&n!==null&&(n.f|=ft)),n!==null&&(n.parent=t,t!==null&&jo(n,t),te!==null&&(te.f&Te)!==0&&(r&pt)===0)){var o=te;(o.effects??=[]).push(n)}return i}function qt(){return te!==null&&!Ge}function An(r){const s=Ve(Ri,null,!1);return Re(s,Ce),s.teardown=r,s}function Zt(r){Wo();var s=ne.f,e=!te&&(s&Je)!==0&&(s&Di)===0;if(e){var t=De;(t.e??=[]).push(r)}else return kn(r)}function kn(r){return Ve(Ci|Gr,r,!1)}function Vo(r){je.ensure();const s=Ve(pt|Rt,r,!0);return(e={})=>new Promise(t=>{e.outro?_t(s,()=>{Se(s),t(void 0)}):(Se(s),t(void 0))})}function Xt(r){return Ve(Ci,r,!1)}function Go(r){return Ve(Ai|Rt,r,!0)}function On(r,s=0){return Ve(Ri|s,r,!0)}function be(r,s=[],e=[],t=[]){mn(t,s,e,i=>{Ve(Ri,()=>r(...i.map(b)),!0)})}function di(r,s=0){var e=Ve(Qe|s,r,!0);return e}function Bn(r,s=0){var e=Ve(sn|s,r,!0);return e}function Ae(r){return Ve(Je|Rt,r,!0)}function Fn(r){var s=r.teardown;if(s!==null){const e=Tt,t=te;Un(!0),ke(null);try{s.call(null)}finally{Un(e),ke(t)}}}function Mn(r,s=!1){var e=r.first;for(r.first=r.last=null;e!==null;){const i=e.ac;i!==null&&ci(()=>{i.abort(Dt)});var t=e.next;(e.f&pt)!==0?e.parent=null:Se(e,s),e=t}}function qo(r){for(var s=r.first;s!==null;){var e=s.next;(s.f&Je)===0&&Se(s),s=e}}function Se(r,s=!0){var e=!1;(s||(r.f&ln)!==0)&&r.nodes!==null&&r.nodes.end!==null&&(Zo(r.nodes.start,r.nodes.end),e=!0),Mn(r,s&&!e),fi(r,0),Re(r,tt);var t=r.nodes&&r.nodes.t;if(t!==null)for(const n of t)n.stop();Fn(r);var i=r.parent;i!==null&&i.first!==null&&Ln(r),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes=r.ac=null}function Zo(r,s){for(;r!==null;){var e=r===s?null:Vt(r);r.remove(),r=e}}function Ln(r){var s=r.parent,e=r.prev,t=r.next;e!==null&&(e.next=t),t!==null&&(t.prev=e),s!==null&&(s.first===r&&(s.first=t),s.last===r&&(s.last=e))}function _t(r,s,e=!0){var t=[];zn(r,t,!0);var i=()=>{e&&Se(r),s&&s()},n=t.length;if(n>0){var o=()=>--n||i();for(var u of t)u.out(o)}else i()}function zn(r,s,e){if((r.f&Fe)===0){r.f^=Fe;var t=r.nodes&&r.nodes.t;if(t!==null)for(const u of t)(u.is_global||e)&&s.push(u);for(var i=r.first;i!==null;){var n=i.next,o=(i.f&ft)!==0||(i.f&Je)!==0&&(r.f&Qe)!==0;zn(i,s,o?e:!1),i=n}}}function zi(r){Hn(r,!0)}function Hn(r,s){if((r.f&Fe)!==0){r.f^=Fe,(r.f&Ce)===0&&(Re(r,Be),wt(r));for(var e=r.first;e!==null;){var t=e.next,i=(e.f&ft)!==0||(e.f&Je)!==0;Hn(e,i?s:!1),e=t}var n=r.nodes&&r.nodes.t;if(n!==null)for(const o of n)(o.is_global||s)&&o.in()}}function Nn(r,s){if(r.nodes)for(var e=r.nodes.start,t=r.nodes.end;e!==null;){var i=e===t?null:Vt(e);s.append(e),e=i}}let xt=!1;function pi(r){xt=r}let Tt=!1;function Un(r){Tt=r}let te=null,Ge=!1;function ke(r){te=r}let ne=null;function qe(r){ne=r}let rt=null;function Wn(r){te!==null&&(rt===null?rt=[r]:rt.push(r))}let Ie=null,Me=0,He=null;function Xo(r){He=r}let jn=1,$t=0,Et=$t;function Vn(r){Et=r}function Gn(){return++jn}function Yt(r){var s=r.f;if((s&Be)!==0)return!0;if(s&Te&&(r.f&=~gt),(s&et)!==0){var e=r.deps;if(e!==null)for(var t=e.length,i=0;i<t;i++){var n=e[i];if(Yt(n)&&_n(n),n.wv>r.wv)return!0}(s&Ne)!==0&&ze===null&&Re(r,Ce)}return!1}function qn(r,s,e=!0){var t=r.reactions;if(t!==null&&!rt?.includes(r))for(var i=0;i<t.length;i++){var n=t[i];(n.f&Te)!==0?qn(n,s,!1):s===n&&(e?Re(n,Be):(n.f&Ce)!==0&&Re(n,et),wt(n))}}function Zn(r){var s=Ie,e=Me,t=He,i=te,n=rt,o=De,u=Ge,l=Et,a=r.f;Ie=null,Me=0,He=null,te=(a&(Je|pt))===0?r:null,rt=null,It(r.ctx),Ge=!1,Et=++$t,r.ac!==null&&(ci(()=>{r.ac.abort(Dt)}),r.ac=null);try{r.f|=Ii;var h=r.fn,c=h(),d=r.deps;if(Ie!==null){var v;if(fi(r,Me),d!==null&&Me>0)for(d.length=Me+Ie.length,v=0;v<Ie.length;v++)d[Me+v]=Ie[v];else r.deps=d=Ie;if(qt()&&(r.f&Ne)!==0)for(v=Me;v<d.length;v++)(d[v].reactions??=[]).push(r)}else d!==null&&Me<d.length&&(fi(r,Me),d.length=Me);if(dn()&&He!==null&&!Ge&&d!==null&&(r.f&(Te|et|Be))===0)for(v=0;v<He.length;v++)qn(He[v],r);return i!==null&&i!==r&&($t++,He!==null&&(t===null?t=He:t.push(...He))),(r.f&st)!==0&&(r.f^=st),c}catch(m){return pn(m)}finally{r.f^=Ii,Ie=s,Me=e,He=t,te=i,rt=n,It(o),Ge=u,Et=l}}function $o(r,s){let e=s.reactions;if(e!==null){var t=Hr.call(e,r);if(t!==-1){var i=e.length-1;i===0?e=s.reactions=null:(e[t]=e[i],e.pop())}}e===null&&(s.f&Te)!==0&&(Ie===null||!Ie.includes(s))&&(Re(s,et),(s.f&Ne)!==0&&(s.f^=Ne,s.f&=~gt),yn(s),fi(s,0))}function fi(r,s){var e=r.deps;if(e!==null)for(var t=s;t<e.length;t++)$o(r,e[t])}function Kt(r){var s=r.f;if((s&tt)===0){Re(r,Ce);var e=ne,t=xt;ne=r,xt=!0;try{(s&(Qe|sn))!==0?qo(r):Mn(r),Fn(r);var i=Zn(r);r.teardown=typeof i=="function"?i:null,r.wv=jn;var n}finally{xt=t,ne=e}}}function b(r){var s=r.f,e=(s&Te)!==0;if(te!==null&&!Ge){var t=ne!==null&&(ne.f&tt)!==0;if(!t&&!rt?.includes(r)){var i=te.deps;if((te.f&Ii)!==0)r.rv<$t&&(r.rv=$t,Ie===null&&i!==null&&i[Me]===r?Me++:Ie===null?Ie=[r]:Ie.includes(r)||Ie.push(r));else{(te.deps??=[]).push(r);var n=r.reactions;n===null?r.reactions=[te]:n.includes(te)||n.push(te)}}}if(Tt){if(at.has(r))return at.get(r);if(e){var o=r,u=o.v;return((o.f&Ce)===0&&o.reactions!==null||$n(o))&&(u=Mi(o)),at.set(o,u),u}}else e&&(!ze?.has(r)||se?.is_fork&&!qt())&&(o=r,Yt(o)&&_n(o),xt&&qt()&&(o.f&Ne)===0&&Xn(o));if(ze?.has(r))return ze.get(r);if((r.f&st)!==0)throw r.v;return r.v}function Xn(r){if(r.deps!==null){r.f^=Ne;for(const s of r.deps)(s.reactions??=[]).push(r),(s.f&Te)!==0&&(s.f&Ne)===0&&Xn(s)}}function $n(r){if(r.v===Ee)return!0;if(r.deps===null)return!1;for(const s of r.deps)if(at.has(s)||(s.f&Te)!==0&&$n(s))return!0;return!1}function gi(r){var s=Ge;try{return Ge=!0,r()}finally{Ge=s}}const Yo=-7169;function Re(r,s){r.f=r.f&Yo|s}function Ko(r){return r.endsWith("capture")&&r!=="gotpointercapture"&&r!=="lostpointercapture"}const Qo=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function Jo(r){return Qo.includes(r)}const es={formnovalidate:"formNoValidate",ismap:"isMap",nomodule:"noModule",playsinline:"playsInline",readonly:"readOnly",defaultvalue:"defaultValue",defaultchecked:"defaultChecked",srcobject:"srcObject",novalidate:"noValidate",allowfullscreen:"allowFullscreen",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback"};function ts(r){return r=r.toLowerCase(),es[r]??r}const is=["touchstart","touchmove"];function ns(r){return is.includes(r)}const Yn=new Set,Hi=new Set;function rs(r,s,e,t={}){function i(n){if(t.capture||Qt.call(s,n),!n.cancelBubble)return ci(()=>e?.call(this,n))}return r.startsWith("pointer")||r.startsWith("touch")||r==="wheel"?mt(()=>{s.addEventListener(r,i,t)}):s.addEventListener(r,i,t),i}function Kn(r){for(var s=0;s<r.length;s++)Yn.add(r[s]);for(var e of Hi)e(r)}let Qn=null;function Qt(r){var s=this,e=s.ownerDocument,t=r.type,i=r.composedPath?.()||[],n=i[0]||r.target;Qn=r;var o=0,u=Qn===r&&r.__root;if(u){var l=i.indexOf(u);if(l!==-1&&(s===document||s===window)){r.__root=s;return}var a=i.indexOf(s);if(a===-1)return;l<=a&&(o=l)}if(n=i[o]||r.target,n!==s){Nr(r,"currentTarget",{configurable:!0,get(){return n||e}});var h=te,c=ne;ke(null),qe(null);try{for(var d,v=[];n!==null;){var m=n.assignedSlot||n.parentNode||n.host||null;try{var _=n["__"+t];_!=null&&(!n.disabled||r.target===n)&&_.call(n,r)}catch(y){d?v.push(y):d=y}if(r.cancelBubble||m===s||m===null)break;n=m}if(d){for(let y of v)queueMicrotask(()=>{throw y});throw d}}finally{r.__root=s,delete r.currentTarget,ke(h),qe(c)}}}function os(r){var s=document.createElement("template");return s.innerHTML=r.replaceAll("<!>","<!---->"),s.content}function Ni(r,s){var e=ne;e.nodes===null&&(e.nodes={start:r,end:s,a:null,t:null})}function ve(r,s){var e=(s&fo)!==0,t=(s&go)!==0,i,n=!r.startsWith("<!>");return()=>{i===void 0&&(i=os(n?r:"<!>"+r),e||(i=hi(i)));var o=t||Pn?document.importNode(i,!0):i.cloneNode(!0);if(e){var u=hi(o),l=o.lastChild;Ni(u,l)}else Ni(o,o);return o}}function Jn(){var r=document.createDocumentFragment(),s=document.createComment(""),e=ut();return r.append(s,e),Ni(s,e),r}function fe(r,s){r!==null&&r.before(s)}function _e(r,s){var e=s==null?"":typeof s=="object"?s+"":s;e!==(r.__t??=r.nodeValue)&&(r.__t=e,r.nodeValue=e+"")}function ss(r,s){return as(r,s)}const Bt=new Map;function as(r,{target:s,anchor:e,props:t={},events:i,context:n,intro:o=!0}){Lo();var u=new Set,l=c=>{for(var d=0;d<c.length;d++){var v=c[d];if(!u.has(v)){u.add(v);var m=ns(v);s.addEventListener(v,Qt,{passive:m});var _=Bt.get(v);_===void 0?(document.addEventListener(v,Qt,{passive:m}),Bt.set(v,1)):Bt.set(v,_+1)}}};l(ri(Yn)),Hi.add(l);var a=void 0,h=Vo(()=>{var c=e??s.appendChild(ut());return Do(c,{pending:()=>{}},d=>{if(n){ki({});var v=De;v.c=n}i&&(t.$$events=i),a=r(d,t)||{},n&&Oi()}),()=>{for(var d of u){s.removeEventListener(d,Qt);var v=Bt.get(d);--v===0?(document.removeEventListener(d,Qt),Bt.delete(d)):Bt.set(d,v)}Hi.delete(l),c!==e&&c.parentNode?.removeChild(c)}});return Ui.set(a,h),a}let Ui=new WeakMap;function ls(r,s){const e=Ui.get(r);return e?(Ui.delete(r),e(s)):Promise.resolve()}class er{anchor;#e=new Map;#t=new Map;#n=new Map;#i=new Set;#l=!0;constructor(s,e=!0){this.anchor=s,this.#l=e}#o=()=>{var s=se;if(this.#e.has(s)){var e=this.#e.get(s),t=this.#t.get(e);if(t)zi(t),this.#i.delete(e);else{var i=this.#n.get(e);i&&(this.#t.set(e,i.effect),this.#n.delete(e),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),t=i.effect)}for(const[n,o]of this.#e){if(this.#e.delete(n),n===s)break;const u=this.#n.get(o);u&&(Se(u.effect),this.#n.delete(o))}for(const[n,o]of this.#t){if(n===e||this.#i.has(n))continue;const u=()=>{if(Array.from(this.#e.values()).includes(n)){var a=document.createDocumentFragment();Nn(o,a),a.append(ut()),this.#n.set(n,{effect:o,fragment:a})}else Se(o);this.#i.delete(n),this.#t.delete(n)};this.#l||!t?(this.#i.add(n),_t(o,u,!1)):u()}}};#r=s=>{this.#e.delete(s);const e=Array.from(this.#e.values());for(const[t,i]of this.#n)e.includes(t)||(Se(i.effect),this.#n.delete(t))};ensure(s,e){var t=se,i=Dn();if(e&&!this.#t.has(s)&&!this.#n.has(s))if(i){var n=document.createDocumentFragment(),o=ut();n.append(o),this.#n.set(s,{effect:Ae(()=>e(o)),fragment:n})}else this.#t.set(s,Ae(()=>e(this.anchor)));if(this.#e.set(t,s),i){for(const[u,l]of this.#t)u===s?t.skipped_effects.delete(l):t.skipped_effects.add(l);for(const[u,l]of this.#n)u===s?t.skipped_effects.delete(l.effect):t.skipped_effects.add(l.effect);t.oncommit(this.#o),t.ondiscard(this.#r)}else this.#o()}}function ot(r,s,e=!1){var t=new er(r),i=e?ft:0;function n(o,u){t.ensure(o,u)}di(()=>{var o=!1;s((u,l=!0)=>{o=!0,n(l,u)}),o||n(!1,null)},i)}function Wi(r,s){return s}function us(r,s,e){for(var t=[],i=s.length,n,o=s.length,u=0;u<i;u++){let c=s[u];_t(c,()=>{if(n){if(n.pending.delete(c),n.done.add(c),n.pending.size===0){var d=r.outrogroups;ji(ri(n.done)),d.delete(n),d.size===0&&(r.outrogroups=null)}}else o-=1},!1)}if(o===0){var l=t.length===0&&e!==null;if(l){var a=e,h=a.parentNode;zo(h),h.append(a),r.items.clear()}ji(s,!l)}else n={pending:new Set(s),done:new Set},(r.outrogroups??=new Set).add(n)}function ji(r,s=!0){for(var e=0;e<r.length;e++)Se(r[e],s)}var tr;function vi(r,s,e,t,i,n=null){var o=r,u=new Map,l=(s&un)!==0;if(l){var a=r;o=a.appendChild(ut())}var h=null,c=wn(()=>{var E=e();return Pi(E)?E:E==null?[]:ri(E)}),d,v=!0;function m(){y.fallback=h,hs(y,d,o,s,t),h!==null&&(d.length===0?(h.f&it)===0?zi(h):(h.f^=it,Jt(h,null,o)):_t(h,()=>{h=null}))}var _=di(()=>{d=b(c);for(var E=d.length,S=new Set,P=se,B=Dn(),O=0;O<E;O+=1){var M=d[O],L=t(M,O),W=v?null:u.get(L);W?(W.v&&Ot(W.v,M),W.i&&Ot(W.i,O),B&&P.skipped_effects.delete(W.e)):(W=cs(u,v?o:tr??=ut(),M,L,O,i,s,e),v||(W.e.f|=it),u.set(L,W)),S.add(L)}if(E===0&&n&&!h&&(v?h=Ae(()=>n(o)):(h=Ae(()=>n(tr??=ut())),h.f|=it)),!v)if(B){for(const[Y,Q]of u)S.has(Y)||P.skipped_effects.add(Q.e);P.oncommit(m),P.ondiscard(()=>{})}else m();b(c)}),y={effect:_,items:u,outrogroups:null,fallback:h};v=!1}function hs(r,s,e,t,i){var n=(t&ao)!==0,o=s.length,u=r.items,l=r.effect.first,a,h=null,c,d=[],v=[],m,_,y,E;if(n)for(E=0;E<o;E+=1)m=s[E],_=i(m,E),y=u.get(_).e,(y.f&it)===0&&(y.nodes?.a?.measure(),(c??=new Set).add(y));for(E=0;E<o;E+=1){if(m=s[E],_=i(m,E),y=u.get(_).e,r.outrogroups!==null)for(const Q of r.outrogroups)Q.pending.delete(y),Q.done.delete(y);if((y.f&it)!==0)if(y.f^=it,y===l)Jt(y,null,e);else{var S=h?h.next:l;y===r.effect.last&&(r.effect.last=y.prev),y.prev&&(y.prev.next=y.next),y.next&&(y.next.prev=y.prev),ht(r,h,y),ht(r,y,S),Jt(y,S,e),h=y,d=[],v=[],l=h.next;continue}if((y.f&Fe)!==0&&(zi(y),n&&(y.nodes?.a?.unfix(),(c??=new Set).delete(y))),y!==l){if(a!==void 0&&a.has(y)){if(d.length<v.length){var P=v[0],B;h=P.prev;var O=d[0],M=d[d.length-1];for(B=0;B<d.length;B+=1)Jt(d[B],P,e);for(B=0;B<v.length;B+=1)a.delete(v[B]);ht(r,O.prev,M.next),ht(r,h,O),ht(r,M,P),l=P,h=M,E-=1,d=[],v=[]}else a.delete(y),Jt(y,l,e),ht(r,y.prev,y.next),ht(r,y,h===null?r.effect.first:h.next),ht(r,h,y),h=y;continue}for(d=[],v=[];l!==null&&l!==y;)(a??=new Set).add(l),v.push(l),l=l.next;if(l===null)continue}(y.f&it)===0&&d.push(y),h=y,l=y.next}if(r.outrogroups!==null){for(const Q of r.outrogroups)Q.pending.size===0&&(ji(ri(Q.done)),r.outrogroups?.delete(Q));r.outrogroups.size===0&&(r.outrogroups=null)}if(l!==null||a!==void 0){var L=[];if(a!==void 0)for(y of a)(y.f&Fe)===0&&L.push(y);for(;l!==null;)(l.f&Fe)===0&&l!==r.fallback&&L.push(l),l=l.next;var W=L.length;if(W>0){var Y=(t&un)!==0&&o===0?e:null;if(n){for(E=0;E<W;E+=1)L[E].nodes?.a?.measure();for(E=0;E<W;E+=1)L[E].nodes?.a?.fix()}us(r,L,Y)}}n&&mt(()=>{if(c!==void 0)for(y of c)y.nodes?.a?.apply()})}function cs(r,s,e,t,i,n,o,u){var l=(o&oo)!==0?(o&lo)===0?Bo(e,!1,!1):yt(e):null,a=(o&so)!==0?yt(i):null;return{v:l,i:a,e:Ae(()=>(n(s,l??e,a??i,u),()=>{r.delete(t)}))}}function Jt(r,s,e){if(r.nodes)for(var t=r.nodes.start,i=r.nodes.end,n=s&&(s.f&it)===0?s.nodes.start:e;t!==null;){var o=Vt(t);if(n.before(t),t===i)return;t=o}}function ht(r,s,e){s===null?r.effect.first=e:s.next=e,e===null?r.effect.last=s:e.prev=s}function ir(r,s,...e){var t=new er(r);di(()=>{const i=s()??null;t.ensure(i,i&&(n=>i(n,...e)))},ft)}function ds(r,s,e){Xt(()=>{var t=gi(()=>s(r,e?.())||{});if(t?.destroy)return()=>t.destroy()})}function ps(r,s){var e=void 0,t;Bn(()=>{e!==(e=s())&&(t&&(Se(t),t=null),e&&(t=Ae(()=>{Xt(()=>e(r))})))})}function nr(r){var s,e,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var i=r.length;for(s=0;s<i;s++)r[s]&&(e=nr(r[s]))&&(t&&(t+=" "),t+=e)}else for(e in r)r[e]&&(t&&(t+=" "),t+=e);return t}function fs(){for(var r,s,e=0,t="",i=arguments.length;e<i;e++)(r=arguments[e])&&(s=nr(r))&&(t&&(t+=" "),t+=s);return t}function gs(r){return typeof r=="object"?fs(r):r??""}const rr=[...`
|
|
2
|
+
\r\f \v\uFEFF`];function vs(r,s,e){var t=r==null?"":""+r;if(s&&(t=t?t+" "+s:s),e){for(var i in e)if(e[i])t=t?t+" "+i:i;else if(t.length)for(var n=i.length,o=0;(o=t.indexOf(i,o))>=0;){var u=o+n;(o===0||rr.includes(t[o-1]))&&(u===t.length||rr.includes(t[u]))?t=(o===0?"":t.substring(0,o))+t.substring(u+1):o=u}}return t===""?null:t}function or(r,s=!1){var e=s?" !important;":";",t="";for(var i in r){var n=r[i];n!=null&&n!==""&&(t+=" "+i+": "+n+e)}return t}function Vi(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function ms(r,s){if(s){var e="",t,i;if(Array.isArray(s)?(t=s[0],i=s[1]):t=s,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,u=!1,l=[];t&&l.push(...Object.keys(t).map(Vi)),i&&l.push(...Object.keys(i).map(Vi));var a=0,h=-1;const _=r.length;for(var c=0;c<_;c++){var d=r[c];if(u?d==="/"&&r[c-1]==="*"&&(u=!1):n?n===d&&(n=!1):d==="/"&&r[c+1]==="*"?u=!0:d==='"'||d==="'"?n=d:d==="("?o++:d===")"&&o--,!u&&n===!1&&o===0){if(d===":"&&h===-1)h=c;else if(d===";"||c===_-1){if(h!==-1){var v=Vi(r.substring(a,h).trim());if(!l.includes(v)){d!==";"&&c++;var m=r.substring(a,c).trim();e+=" "+m+";"}}a=c+1,h=-1}}}}return t&&(e+=or(t)),i&&(e+=or(i,!0)),e=e.trim(),e===""?null:e}return r==null?null:String(r)}function ei(r,s,e,t,i,n){var o=r.__className;if(o!==e||o===void 0){var u=vs(e,t,n);u==null?r.removeAttribute("class"):s?r.className=u:r.setAttribute("class",u),r.__className=e}else if(n&&i!==n)for(var l in n){var a=!!n[l];(i==null||a!==!!i[l])&&r.classList.toggle(l,a)}return n}function Gi(r,s={},e,t){for(var i in e){var n=e[i];s[i]!==n&&(e[i]==null?r.style.removeProperty(i):r.style.setProperty(i,n,t))}}function qi(r,s,e,t){var i=r.__style;if(i!==s){var n=ms(s,t);n==null?r.removeAttribute("style"):r.style.cssText=n,r.__style=s}else t&&(Array.isArray(t)?(Gi(r,e?.[0],t[0]),Gi(r,e?.[1],t[1],"important")):Gi(r,e,t));return t}function mi(r,s,e=!1){if(r.multiple){if(s==null)return;if(!Pi(s))return wo();for(var t of r.options)t.selected=s.includes(ti(t));return}for(t of r.options){var i=ti(t);if(Mo(i,s)){t.selected=!0;return}}(!e||s!==void 0)&&(r.selectedIndex=-1)}function sr(r){var s=new MutationObserver(()=>{mi(r,r.__value)});s.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),An(()=>{s.disconnect()})}function ws(r,s,e=s){var t=new WeakSet,i=!0;Uo(r,"change",n=>{var o=n?"[selected]":":checked",u;if(r.multiple)u=[].map.call(r.querySelectorAll(o),ti);else{var l=r.querySelector(o)??r.querySelector("option:not([disabled])");u=l&&ti(l)}e(u),se!==null&&t.add(se)}),Xt(()=>{var n=s();if(r===document.activeElement){var o=ai??se;if(t.has(o))return}if(mi(r,n,i),i&&n===void 0){var u=r.querySelector(":checked");u!==null&&(n=ti(u),e(n))}r.__value=n,i=!1}),sr(r)}function ti(r){return"__value"in r?r.__value:r.value}const Ft=Symbol("class"),ii=Symbol("style"),ar=Symbol("is custom element"),lr=Symbol("is html");function ys(r,s){s?r.hasAttribute("selected")||r.setAttribute("selected",""):r.removeAttribute("selected")}function Ze(r,s,e,t){var i=hr(r);i[s]!==(i[s]=e)&&(s==="loading"&&(r[Zr]=e),e==null?r.removeAttribute(s):typeof e!="string"&&dr(r).includes(s)?r[s]=e:r.setAttribute(s,e))}function _s(r,s,e,t,i=!1,n=!1){var o=hr(r),u=o[ar],l=!o[lr],a=s||{},h=r.tagName==="OPTION";for(var c in s)c in e||(e[c]=null);e.class?e.class=gs(e.class):(t||e[Ft])&&(e.class=null),e[ii]&&(e.style??=null);var d=dr(r);for(const P in e){let B=e[P];if(h&&P==="value"&&B==null){r.value=r.__value="",a[P]=B;continue}if(P==="class"){var v=r.namespaceURI==="http://www.w3.org/1999/xhtml";ei(r,v,B,t,s?.[Ft],e[Ft]),a[P]=B,a[Ft]=e[Ft];continue}if(P==="style"){qi(r,B,s?.[ii],e[ii]),a[P]=B,a[ii]=e[ii];continue}var m=a[P];if(!(B===m&&!(B===void 0&&r.hasAttribute(P)))){a[P]=B;var _=P[0]+P[1];if(_!=="$$")if(_==="on"){const O={},M="$$"+P;let L=P.slice(2);var y=Jo(L);if(Ko(L)&&(L=L.slice(0,-7),O.capture=!0),!y&&m){if(B!=null)continue;r.removeEventListener(L,a[M],O),a[M]=null}if(B!=null)if(y)r[`__${L}`]=B,Kn([L]);else{let W=function(Y){a[P].call(this,Y)};a[M]=rs(L,r,W,O)}else y&&(r[`__${L}`]=void 0)}else if(P==="style")Ze(r,P,B);else if(P==="autofocus")Ho(r,!!B);else if(!u&&(P==="__value"||P==="value"&&B!=null))r.value=r.__value=B;else if(P==="selected"&&h)ys(r,B);else{var E=P;l||(E=ts(E));var S=E==="defaultValue"||E==="defaultChecked";if(B==null&&!u&&!S)if(o[P]=null,E==="value"||E==="checked"){let O=r;const M=s===void 0;if(E==="value"){let L=O.defaultValue;O.removeAttribute(E),O.defaultValue=L,O.value=O.__value=M?L:null}else{let L=O.defaultChecked;O.removeAttribute(E),O.defaultChecked=L,O.checked=M?L:!1}}else r.removeAttribute(P);else S||d.includes(E)&&(u||typeof B!="string")?(r[E]=B,E in o&&(o[E]=Ee)):typeof B!="function"&&Ze(r,E,B)}}}return a}function ur(r,s,e=[],t=[],i=[],n,o=!1,u=!1){mn(i,e,t,l=>{var a=void 0,h={},c=r.nodeName==="SELECT",d=!1;if(Bn(()=>{var m=s(...l.map(b)),_=_s(r,a,m,n,o,u);d&&c&&"value"in m&&mi(r,m.value);for(let E of Object.getOwnPropertySymbols(h))m[E]||Se(h[E]);for(let E of Object.getOwnPropertySymbols(m)){var y=m[E];E.description===mo&&(!a||y!==a[E])&&(h[E]&&Se(h[E]),h[E]=Ae(()=>ps(r,()=>y))),_[E]=y}a=_}),c){var v=r;Xt(()=>{mi(v,a.value,!0),sr(v)})}d=!0})}function hr(r){return r.__attributes??={[ar]:r.nodeName.includes("-"),[lr]:r.namespaceURI===vo}}var cr=new Map;function dr(r){var s=r.getAttribute("is")||r.nodeName,e=cr.get(s);if(e)return e;cr.set(s,e=[]);for(var t,i=r,n=Element.prototype;n!==i;){t=Ur(i);for(var o in t)t[o].set&&e.push(o);i=tn(i)}return e}function pr(r,s){return r===s||r?.[vt]===s}function wi(r={},s,e,t){return Xt(()=>{var i,n;return On(()=>{i=n,n=[],gi(()=>{r!==e(...n)&&(s(r,...n),i&&pr(e(...i),r)&&s(null,...i))})}),()=>{mt(()=>{n&&pr(e(...n),r)&&s(null,...n)})}}),r}let yi=!1;function xs(r){var s=yi;try{return yi=!1,[r(),yi]}finally{yi=s}}const Ts={get(r,s){if(!r.exclude.includes(s))return r.props[s]},set(r,s){return!1},getOwnPropertyDescriptor(r,s){if(!r.exclude.includes(s)&&s in r.props)return{enumerable:!0,configurable:!0,value:r.props[s]}},has(r,s){return r.exclude.includes(s)?!1:s in r.props},ownKeys(r){return Reflect.ownKeys(r.props).filter(s=>!r.exclude.includes(s))}};function fr(r,s,e){return new Proxy({props:r,exclude:s},Ts)}function Oe(r,s,e,t){var i=(e&co)!==0,n=(e&po)!==0,o=t,u=!0,l=()=>(u&&(u=!1,o=n?gi(t):t),o),a;if(i){var h=vt in r||qr in r;a=Ct(r,s)?.set??(h&&s in r?S=>r[s]=S:void 0)}var c,d=!1;i?[c,d]=xs(()=>r[s]):c=r[s],c===void 0&&t!==void 0&&(c=l(),a&&(eo(),a(c)));var v;if(v=()=>{var S=r[s];return S===void 0?l():(u=!0,S)},(e&ho)===0)return v;if(a){var m=r.$$legacy;return(function(S,P){return arguments.length>0?((!P||m||d)&&a(P?v():S),S):v()})}var _=!1,y=((e&uo)!==0?ui:wn)(()=>(_=!1,v()));i&&b(y);var E=ne;return(function(S,P){if(arguments.length>0){const B=P?b(y):i?lt(S):S;return G(y,B),_=!0,o!==void 0&&(o=B),S}return Tt&&_||(E.f&tt)!==0?y.v:b(y)})}const Es=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-.]+))?(?:\+[0-9A-Za-z-.]+)?$/;function _i(r){const s=Es.exec(r.trim());if(!s)return null;const[,e,t,i,n]=s,o=n?n.split(".").map(u=>/^\d+$/.test(u)?Number(u):u):[];return{major:Number(e),minor:Number(t),patch:Number(i),prerelease:o}}function bs(r,s){return r.major-s.major||r.minor-s.minor||r.patch-s.patch}function Ss(r,s){if(r.prerelease.length===0&&s.prerelease.length===0)return 0;if(r.prerelease.length===0)return 1;if(s.prerelease.length===0)return-1;const e=Math.max(r.prerelease.length,s.prerelease.length);for(let t=0;t<e;t++){const i=r.prerelease[t],n=s.prerelease[t];if(i===void 0)return-1;if(n===void 0)return 1;if(i===n)continue;const o=typeof i=="number",u=typeof n=="number";return o&&u?i<n?-1:1:o?-1:u?1:String(i)<String(n)?-1:1}return 0}function Ps(r,s){return bs(r,s)||Ss(r,s)}function Cs(r){return r.major>0?{major:r.major+1,minor:0,patch:0,prerelease:[]}:r.minor>0?{major:0,minor:r.minor+1,patch:0,prerelease:[]}:{major:0,minor:0,patch:r.patch+1,prerelease:[]}}function Rs(r){if(r===""||r==="*"||r==="x"||r==="X")return[];let s;if(s=/^\^\s*(.+)$/.exec(r)){const e=_i(s[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:Cs(e)}]:null}if(s=/^~\s*(.+)$/.exec(r)){const e=_i(s[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:{major:e.major,minor:e.minor+1,patch:0,prerelease:[]}}]:null}if(s=/^(>=|<=|>|<|=)?\s*(.+)$/.exec(r)){const e=_i(s[2]??"");return e?[{op:s[1]??"=",ver:e}]:null}return null}function Ds(r,s){const e=Ps(r,s.ver);switch(s.op){case"<":return e<0;case"<=":return e<=0;case">":return e>0;case">=":return e>=0;case"=":return e===0}}function Is(r,s){const e=s.trim();if(e===""||e==="*"||e==="x")return!0;const t=e.split(/\s+/).filter(Boolean);for(const i of t){const n=Rs(i);if(n===null||!n.every(o=>Ds(r,o)))return!1}return!0}function gr(r,s){const e=_i(r);if(!e)return!1;const t=s.split("||").map(i=>i.trim()).filter(i=>i.length>0);return t.length===0?!0:t.some(i=>Is(e,i))}class Zi extends Error{code="PLUGIN_INCOMPATIBLE";pluginName;pluginVersion;reasons;constructor(s,e,t){super(As(s,e,t)),this.name="PluginCompatibilityError",this.pluginName=s,this.pluginVersion=e,this.reasons=t,Object.setPrototypeOf(this,Zi.prototype)}}function As(r,s,e){const t=e.map(i=>` - ${i.message}`).join(`
|
|
3
|
+
`);return`Plugin "${r}"@${s} cannot activate — incompatible with this viewer:
|
|
4
4
|
${t}
|
|
5
|
-
Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function Mo(n,o){const e=[];mn(o.coreVersion,n.coreRange)||e.push({kind:"core",required:n.coreRange,actual:o.coreVersion,message:`requires core ${n.coreRange} but this viewer is core ${o.coreVersion}`}),mn(o.pluginApiVersion,n.pluginApiRange)||e.push({kind:"pluginApi",required:n.pluginApiRange,actual:o.pluginApiVersion,message:`requires plugin API ${n.pluginApiRange} but this viewer provides plugin API ${o.pluginApiVersion}`});const t=new Set(o.capabilities);for(const r of n.requiredCapabilities)t.has(r)||e.push({kind:"capability",required:r,actual:o.capabilities.join(", ")||"(none)",message:`requires capability "${r}" which this viewer does not provide (has: ${o.capabilities.join(", ")||"none"})`});return e}function Bo(n,o){const e=Mo(n,o);if(e.length>0)throw new Xi(n.name,n.version,e)}function Ho(n,o={}){let e=0,t=!1;const r=new Set,i=n.subscribe(()=>{e++;for(const l of[...r])l()},o.onListenerError);return{selectors:{select(l,a=Object.is){let u=-1,h;const c=()=>(u!==e&&(h=l(n),u=e),h);return{get:c,subscribe(d){if(t)return()=>{};let m=c();const v=()=>{let y;try{y=c()}catch(_){o.onProjectionError?.(_);return}a(m,y)||(m=y,d(y))};return r.add(v),()=>{r.delete(v)}}}}},dispose(){t||(t=!0,r.clear(),i())}}}const Yi=()=>{};function zo(){return{install(n,o){return Yi}}}function ko(){return{current:"en",t(n,o){return n},subscribe(n){return Yi}}}function No(){return{renderIcon(n,o){return Yi}}}function Uo(n){const o=new Set;return{service:{install(e,t){const r=n.install(e,t);let i=!1;const s=()=>{i||(i=!0,o.delete(s),r())};return o.add(s),s}},releaseAll(){for(const e of[...o])e();o.clear()}}}function Wo(n){const o=new Set;return{service:{get current(){return n.current},t(e,t){return n.t(e,t)},subscribe(e){const t=n.subscribe(e);let r=!1;const i=()=>{r||(r=!0,o.delete(i),t())};return o.add(i),i}},releaseAll(){for(const e of[...o])e();o.clear()}}}const Vo={deactivate(){}};function jo(n,o){const e=o.reportError;let t,r,i,s;try{Bo(n,o),t=Ho(o.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),r=Uo(o.styles??zo()),i=Wo(o.locale??ko()),s={viewerState:o.viewerState,selectors:t.selectors,styles:r.service,locale:i.service,ui:o.ui??No()}}catch(d){if(t?.dispose(),r?.releaseAll(),i?.releaseAll(),e)return e({phase:"setup",error:d}),Vo;throw d}const l=[],a=r,u=i,h=t;try{const d=n.view.mount(o.container,s);typeof d=="function"&&l.push(d)}catch(d){if(!e)throw a.releaseAll(),u.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}l.push(()=>a.releaseAll()),l.push(()=>u.releaseAll()),l.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=l.length-1;d>=0;d--)try{l[d]?.()}catch(m){e?e({phase:"cleanup",error:m}):console.error(`[triiiceratops] Plugin "${n.name}" cleanup threw during deactivation; teardown continues.`,m)}l.length=0}}}}const Go="triiiceratops-plugin";function qo(n){const o={name:n.name,uiId:n.uiId,version:n.version,coreRange:n.coreRange,pluginApiRange:n.pluginApiRange,requiredCapabilities:n.requiredCapabilities??[],icon:n.icon,target:n.target??"panel",dismiss:n.dismiss,catalog:n.catalog,view:n.view};return{kind:Go,...o,activate(e){return jo(o,e)}}}class Zo extends Error{name="SvgIconError";constructor(o){super(`svgIcon: ${o}`)}}const Xo="0 0 24 24";function bt(n,o){if(!n)throw new Zo(o)}const Yo=/<svg\b[^>]*>/i;function Ko(n){bt(typeof n=="string","expected an SVG string.");const o=n.trim();bt(o.length>0,"received an empty string.");const e=Yo.exec(o);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(o),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(o),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(o),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const l of o.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const a=(l[1]??l[2]??l[3]??"").trim();bt(a.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${a}"); only internal "#id" references are.`)}const t=e[0],r=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let i=(r?.[1]??r?.[2])?.trim();if(!i){const l=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),u=parseFloat(l?.[1]??l?.[2]??""),h=parseFloat(a?.[1]??a?.[2]??"");i=Number.isFinite(u)&&Number.isFinite(h)?`0 0 ${u} ${h}`:Xo}let s="";if(!/\/\s*>$/.test(t)){const l=e.index+t.length,a=o.lastIndexOf("</svg>");s=(a>=l?o.slice(l,a):o.slice(l)).trim()}return{kind:"svg",inner:s,viewBox:i}}function Qo(n,o){return{STYLES:n,STYLE_ID:o}}function Jo(n,o,e,t,r){const i={pluginName:o,pluginVersion:e,phase:"command",error:t,retry:r};n.dispatchEvent(new CustomEvent("pluginerror",{detail:i,bubbles:!0,composed:!0}))}const $o=".btn.svelte-sgoebi{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1hwvamm{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",ea={en:{image_download_title:"Download Image",image_download_close:"Close Download Image",image_download_description:"Download the current canvas as an image.",image_download_mode:"What to download",image_download_mode_composite:"Composite canvas",image_download_mode_composite_hint:"Every image on the current canvas, composited together.",image_download_mode_single:"Single image",image_download_mode_single_hint:"One image from the current canvas.",image_download_mode_world:"Current view",image_download_mode_world_hint:"Everything currently laid out together in the viewer.",image_download_canvas:"Canvas",image_download_image:"Image",image_download_resolution:"Resolution",image_download_resolution_placeholder:"Select a resolution",image_download_downloading:"Downloading...",image_download_download:"Download",image_download_disabled_no_canvas:"Load a manifest to download an image.",image_download_disabled_no_resolution:"Select a resolution to download.",image_download_result_downloaded:"Downloaded {filename}.",image_download_error_failed:"Unable to download image. Check the browser console for details."},de:{image_download_title:"Bild herunterladen",image_download_close:"Bild-Download schließen",image_download_description:"Die aktuelle Leinwand als Bild herunterladen.",image_download_mode:"Was heruntergeladen werden soll",image_download_mode_composite:"Zusammengesetzte Leinwand",image_download_mode_composite_hint:"Alle Bilder der aktuellen Leinwand, zusammengesetzt.",image_download_mode_single:"Einzelbild",image_download_mode_single_hint:"Ein Bild von der aktuellen Leinwand.",image_download_mode_world:"Aktuelle Ansicht",image_download_mode_world_hint:"Alles, was aktuell zusammen im Viewer angezeigt wird.",image_download_canvas:"Leinwand",image_download_image:"Bild",image_download_resolution:"Auflösung",image_download_resolution_placeholder:"Auflösung auswählen",image_download_downloading:"Wird heruntergeladen...",image_download_download:"Herunterladen",image_download_disabled_no_canvas:"Laden Sie ein Manifest, um ein Bild herunterzuladen.",image_download_disabled_no_resolution:"Wählen Sie eine Auflösung zum Herunterladen aus.",image_download_result_downloaded:"{filename} heruntergeladen.",image_download_error_failed:"Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."}},vn=Symbol("triiiceratops:plugin-image-download"),wn=Ko('<svg viewBox="0 0 256 256"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg>'),ta="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(ta);var ia=me("<button><!></button>");function ra(n,o){let e=Le(o,"variant",3,"default"),t=Le(o,"size",3,"md"),r=Le(o,"circle",3,!1),i=Le(o,"square",3,!1),s=Le(o,"ghost",3,!1),l=Le(o,"outline",3,!1),a=Le(o,"active",3,!1),u=Le(o,"class",3,""),h=Le(o,"style",3,""),c=gn(o,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},m={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let v=le(()=>`${m[t()]}${d[e()]}${h()}`);var y=ia();hn(y,()=>({class:`btn ${u()??""}`,style:b(v),...c,[Mt]:{circle:r(),square:i(),ghost:s(),outline:l(),active:a()}}),void 0,void 0,void 0,"svelte-sgoebi");var _=$(y);rn(_,()=>o.children??nr),ge(n,y)}let na=0;var sa=me('<div role="option"> </div>'),oa=me('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function _i(n,o){Fi(o,!0);let e=Le(o,"value",15),t=Le(o,"size",3,"md"),r=Le(o,"ghost",3,!1),i=Le(o,"class",3,""),s=Le(o,"style",3,""),l=gn(o,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const a={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let u=le(()=>`--size:${a[t()]};${s()}`);const h=`tri-listbox-${na++}`;let c=ue(null),d=ue(null),m=ue(null),v=ue(lt([])),y=ue(!1),_=ue(-1),E=le(()=>!!o.disabled),S=le(()=>e()==null?"":String(e())),P=le(()=>b(v).find(k=>k.value===b(S))??b(v)[0]);function L(){b(c)&&G(v,Array.from(b(c).querySelectorAll("option")).map(k=>({value:k.value,label:(k.textContent??"").trim(),disabled:k.disabled})),!0)}qt(()=>{if(!b(c))return;L();const k=new MutationObserver(()=>L());return k.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>k.disconnect()});function F(k){const te=b(v)[k];!b(c)||!te||te.disabled||(b(c).value=te.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),J())}function H(){if(!b(d)||!b(m))return;const k=b(d).getBoundingClientRect();b(m).style.minWidth=`${k.width}px`,b(m).style.left=`${k.left}px`;const te=b(m).offsetHeight,de=window.innerHeight-k.bottom;de<te&&k.top>de?b(m).style.top=`${Math.max(4,k.top-te-4)}px`:b(m).style.top=`${k.bottom+4}px`}function B(){b(m)?.children[b(_)]?.scrollIntoView({block:"nearest"})}function V(k){const te=k.composedPath();b(d)&&te.includes(b(d))||b(m)&&te.includes(b(m))||J()}function Y(){b(E)||b(y)||!b(m)||(G(y,!0),b(m).showPopover(),H(),G(_,b(v).findIndex(k=>k.value===b(S)),!0),b(_)<0&&G(_,b(v).findIndex(k=>!k.disabled),!0),B(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),document.addEventListener("pointerdown",V,!0))}function J(){b(y)&&(G(y,!1),b(m)?.hidePopover(),window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),document.removeEventListener("pointerdown",V,!0),b(d)?.focus())}function re(){b(y)?J():Y()}function Z(k){if(!b(v).length)return;let te=b(_);for(let de=0;de<b(v).length;de++)if(te=(te+k+b(v).length)%b(v).length,!b(v)[te]?.disabled){G(_,te,!0),B();return}}function ie(k){const te=k==="start"?b(v).map((de,ye)=>ye):b(v).map((de,ye)=>b(v).length-1-ye);for(const de of te)if(!b(v)[de]?.disabled){G(_,de,!0),B();return}}let he="",pe;function ce(k){he+=k.toLowerCase(),clearTimeout(pe),pe=setTimeout(()=>he="",600);const te=b(v).findIndex(de=>!de.disabled&&de.label.toLowerCase().startsWith(he));te>=0&&(G(_,te,!0),B())}function ve(k){if(!b(E)){if(!b(y)){["ArrowDown","ArrowUp","Enter"," "].includes(k.key)&&(k.preventDefault(),Y());return}switch(k.key){case"ArrowDown":k.preventDefault(),Z(1);break;case"ArrowUp":k.preventDefault(),Z(-1);break;case"Home":k.preventDefault(),ie("start");break;case"End":k.preventDefault(),ie("end");break;case"Enter":case" ":k.preventDefault(),b(_)>=0&&F(b(_));break;case"Escape":k.preventDefault(),J();break;case"Tab":J();break;default:k.key.length===1&&!k.metaKey&&!k.ctrlKey&&ce(k.key)}}}var fe=oa(),we=$(fe);hn(we,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...l}),void 0,void 0,void 0,"svelte-1hwvamm");var He=$(we);rn(He,()=>o.children??nr),vi(we,k=>G(c,k),()=>b(c));var xe=_e(we,2);let Xe;xe.__click=re,xe.__keydown=ve;var X=$(xe);let Ye;var ct=$(X);vi(xe,k=>G(d,k),()=>b(d));var Ue=_e(xe,2);gi(Ue,23,()=>b(v),(k,te)=>k.value+"\0"+te,(k,te,de)=>{var ye=sa();let Ke;ye.__click=()=>F(b(de)),ye.__pointermove=()=>G(_,b(de),!0);var St=$(ye);Se(()=>{Ze(ye,"id",`${h}-opt-${b(de)??""}`),Ke=$t(ye,1,"option svelte-1hwvamm",null,Ke,{active:b(de)===b(_),selected:b(te).value===b(S)}),Ze(ye,"aria-selected",b(te).value===b(S)),Ze(ye,"aria-disabled",b(te).disabled),Te(St,b(te).label)}),ge(k,ye)}),vi(Ue,k=>G(m,k),()=>b(m)),Se(()=>{$t(fe,1,`select-wrapper ${i()??""}`,"svelte-1hwvamm"),Zi(fe,s()),Xe=$t(xe,1,"select svelte-1hwvamm",null,Xe,{ghost:r(),open:b(y)}),Zi(xe,b(u)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(y)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(y)&&b(_)>=0?`${h}-opt-${b(_)}`:void 0),Ze(xe,"aria-label",l["aria-label"]),Ye=$t(X,1,"select-label svelte-1hwvamm",null,Ye,{placeholder:b(P)?.disabled}),Te(ct,b(P)?.label??""),Ze(Ue,"id",h)}),To(we,e),ge(n,fe),Li()}Qr(["click","keydown","pointermove"]);function Bt(n){return n?.id||n?.["@id"]||n?.__jsonld?.id||n?.__jsonld?.["@id"]||(typeof n?.getId=="function"?n.getId():null)||null}function Ht(n){return Bt(n)||(typeof n?.getCanvasId=="function"?n.getCanvasId():null)||(typeof n?.getId=="function"?n.getId():null)||""}function aa(n){const o=n?.behavior||n?.__jsonld?.behavior||(typeof n?.getBehavior=="function"?n.getBehavior():[]);return o?(Array.isArray(o)?o:[o]).map(t=>{const r=String(t).trim().toLowerCase(),i=r.split(/[#/:]/);return i[i.length-1]||r}):[]}function yn(n){const o=aa(n);return o.includes("non-paged")||o.includes("facing-pages")}function la(n,o){const e=[];for(let t=0;t<Math.min(o,n.length);t++){const r=n[t],i=Ht(r);e.push({startIndex:t,endIndex:t,entries:i?[{canvasId:i,canvas:r}]:[]})}for(let t=o;t<n.length;){const r=n[t],i=Ht(r),s=n[t+1],l=Ht(s),a=!!s&&!!i&&!!l&&!yn(r)&&!yn(s);e.push({startIndex:t,endIndex:a?t+1:t,entries:[...i?[{canvasId:i,canvas:r}]:[],...a?[{canvasId:l,canvas:s}]:[]]}),t+=a?2:1}return e}function ua({canvases:n,currentCanvasId:o,currentCanvasIndex:e,viewingMode:t,pagedOffset:r}){if(!o)return[];if(e<0||e>=n.length)return[];const i=[],s=n[e];return s?t!=="paged"?(i.push({canvasId:o,canvas:s}),i):la(n,r).find(({startIndex:a,endIndex:u})=>e>=a&&e<=u)?.entries??i:i}function Ti(n,o){if(!n)return"";if(typeof n=="string")return n;if(typeof n=="object"&&!Array.isArray(n)){const e=n;if("@value"in e){const i=e["@value"];return Array.isArray(i)&&i.length>0?String(i[0]):i===void 0?"":String(i)}const t=Object.keys(e),r=i=>{const s=e[i];if(s!==void 0)return Array.isArray(s)&&s.length>0?String(s[0]):String(s)};for(const i of["en","none"]){const s=r(i);if(s!==void 0)return s}return t.length>0?r(t[0])??"":""}if(Array.isArray(n)&&n.length>0){if(typeof n[0]=="string")return n[0];const e=n,t=l=>l?.value??l?._value,i=(l=>e.find(a=>a.locale===l||a._locale===l||a.language===l))("en");{const l=t(i);if(l)return l}const s=e.find(l=>!l.locale&&!l._locale&&!l.language);{const l=t(s);if(l)return l}return t(e[0])??""}return String(n)}function _n(n,o){const e=o===void 0?"Untitled canvas":`Canvas ${o+1}`;try{const r=n.getLabel?.();if(Array.isArray(r)&&r.length>0)return Ti(r)||e}catch{}const t=n.label||n.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}return e}function Ki(n){if(!n)return null;const o=n.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return o?[Number(o[1]),Number(o[2]),Number(o[3]),Number(o[4])]:null}function ha(n){const[o]=n.split("#");return o||null}function Qi(n){if(!n)return null;if(typeof n=="string")return n;if(Array.isArray(n)){for(const e of n){const t=Qi(e);if(t)return t}return null}if(typeof n!="object")return null;const o=n;return typeof o.id=="string"?o.id:typeof o["@id"]=="string"?o["@id"]:o.source?Qi(o.source):null}function Ji(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(e=>Ji(e));if(typeof n!="object")return[];const o=n;return o.item?Ji(o.item):[o]}function ca(n){const o=n.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(o)return Ki(o.value);const e=n.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Ki(e.value):null}function Tn(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(r=>Tn(r));const o=Qi(n),e=typeof n=="object"&&n&&"selector"in n?Ji(n.selector):[],t=ca(e)||(o?Ki(o):null);return[{raw:n,targetId:o,canvasId:o?ha(o):null,selectors:e,xywh:t}]}function xn(n){return n.endsWith("/info.json")?n.slice(0,-10):n}function zt(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function da(n){const o=n?.__jsonld||n;return{width:zt(n?.width)||zt(o?.width)||(typeof n?.getWidth=="function"?zt(n.getWidth()):null),height:zt(n?.height)||zt(o?.height)||(typeof n?.getHeight=="function"?zt(n.getHeight()):null)}}function En(n){const o=n?.__jsonld||n;return o?.type==="SpecificResource"&&o?.source?o.source:null}function fa(n,o){return o?.type==="Choice"||o?.type==="oa:Choice"||!!n&&!Array.isArray(n)&&(n.type==="Choice"||n.type==="oa:Choice")}function bn(n,o){return o&&(o.items||o.item)?o.items||o.item:Array.isArray(n)?n:n&&(n.items||n.item)?n.items||n.item:[]}function pa({body:n,rawBody:o,canvasId:e,getSelectedChoice:t}){const r=Array.isArray(n)?n:bn(n,null),i=bn(null,o),s=t?.(e);if(s){const l=r.find(u=>Bt(u)===s);if(l)return l;const a=i.findIndex(u=>Bt(u)===s);if(a>=0)return r[a]||i[a]}return r[0]||i[0]||null}function ga(n){let o=n.getImages?.()||[];return(!o||!o.length)&&n.getContent&&(o=n.getContent()),o||[]}function ma(n){const o=n?.width||n?.__jsonld?.width||(typeof n?.getWidth=="function"?n.getWidth():null),e=n?.height||n?.__jsonld?.height||(typeof n?.getHeight=="function"?n.getHeight():null);return typeof o!="number"||typeof e!="number"?null:{width:o,height:e}}function va(n){const o=Tn(n?.target||n?.__jsonld?.target).find(e=>e.xywh)?.xywh;return o?{x:o[0],y:o[1],width:o[2],height:o[3]}:null}function wa(n,o){if(typeof n!="string"||!n.trim())return null;const e=n.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(s=>Number(s.trim()));return i.length!==4||i.some(s=>!Number.isFinite(s)||s<0)?null:t?typeof o.width!="number"||typeof o.height!="number"?null:{x:i[0]/100*o.width,y:i[1]/100*o.height,width:i[2]/100*o.width,height:i[3]/100*o.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function ya(n,o){const e=n?.__jsonld||n;return wa(e?.selector?.type==="ImageApiSelector"?e.selector.region:null,o)}function _a(n){return[n.x,n.y,n.width,n.height].map(o=>Math.round(o)).join(",")}function Ta(n){const o=n?.__jsonld||n,e=En(n);return!!(n&&(n.id||n["@id"]||o?.service||e||o?.id||o?.["@id"]))}function xa(n,o,e){let t=n.getResource?n.getResource():null;if(!t&&n.getBody){const r=n.getBody(),i=n.__jsonld?.body||n.body;fa(r,i)?t=pa({body:r,rawBody:i,canvasId:o,getSelectedChoice:e}):Array.isArray(r)&&r.length>0?t=r[0]:r&&(t=r)}if(t&&!Ta(t)&&(t=null),!t){const r=n.__jsonld||n;if(r.body){let i=r.body;if(i.type==="Choice"||i.type==="oa:Choice"){const s=i.items||i.item||[],l=e?.(o);i=(l?s.find(u=>Bt(u)===l):null)||s[0]||null}t=Array.isArray(i)?i[0]:i}}return t}function Sn(n){return typeof n=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(n)||n==="level0"||n==="level1"||n==="level2":Array.isArray(n)?n.some(o=>Sn(o)):!1}function Ea(n){return typeof n=="string"?n||null:Array.isArray(n)&&n.find(e=>typeof e=="string")||null}function ba(n){let o=[];const e=n?.__jsonld||n;return e?.service&&(o=Array.isArray(e.service)?e.service:[e.service]),!o.length&&n?.getServices&&(o=n.getServices()),o.length&&o.find(t=>{const r=t.getType?t.getType():t.type||t["@type"]||"",i=t.getProfile?t.getProfile():t.profile||"";return r==="ImageService1"||r==="ImageService2"||r==="ImageService3"||Sn(i)})||null}function Sa(n,o){for(const e of[n,o]){if(!e)continue;try{const r=e.getLabel?.();if(Array.isArray(r)&&r.length>0){const i=Ti(r);if(i)return i}}catch{}const t=e.label||e.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}}return null}function Pa(n){const o=ba(n),e=Bt(o),t=o?o.getProfile?o.getProfile():o.profile||"":null;return{serviceId:e?xn(e):null,serviceProfile:Ea(t)}}function Ra(n){if(!n||!n.includes("/iiif/"))return null;const o=n.split("/"),e=o.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?o.slice(0,e).join("/"):null}function xi(n,o={}){const e=Ht(n);if(!e)return[];const t=ma(n);if(!t)return[];const r=ga(n);return r.length?r.map(i=>{const s=xa(i,e,o.getSelectedChoice),l=En(s)||s;if(!l)return null;const a=Bt(l),u=da(l),h=Pa(l),c=h.serviceId||Ra(a),d=va(i),m=ya(s,u);return{canvasId:e,annotation:i,resource:l,resourceId:a,label:Sa(l,i),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:m?.width||u.width,resourceHeight:m?.height||u.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:m,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(i=>i!==null):[]}function Ca(n,o={width:1600}){const e=xn(n),t=o.region||"full",r=o.quality||"default",i=o.format||"jpg",s=typeof o.width=="number"?Math.max(1,Math.round(o.width)):null,l=typeof o.height=="number"?Math.max(1,Math.round(o.height)):null,a=o.size||(s?`${s},`:`,${l||1600}`);return`${e}/${t}/${a}/0/${r}.${i}`}function Da(n){return typeof n=="string"?n:Array.isArray(n)&&typeof n[0]=="string"?n[0]:null}function Ei(n){const o=Da(n);return o?o==="level0"||o.endsWith("/level0.json")||o.endsWith("#level0"):!1}function Aa(n,o,e,t){if(!n?.IIIFTileSource?.prototype)return o;try{const r=n.IIIFTileSource.prototype.configure.call({},o,e,null),i=new n.IIIFTileSource(r);return Ia(i,t),i}catch{return o}}function Ia(n,o){if(!Ei(n?.profile)||typeof n?.getTileUrl!="function"||n.__triiiceratopsLevel0LowZoomPrepared)return;const e=n.getTileUrl.bind(n),t=typeof n.getNumTiles=="function"?n.getNumTiles.bind(n):null,r=La(),i=Fa(n),s=Oa(n,i,t);t&&(n.getNumTiles=function(l){return Rn(l,s,i,this)?{x:0,y:0}:Pn(this,l,r,i,t,s)?{x:1,y:1}:t(l)}),typeof n?.minLevel=="number"&&s>=0&&(n.minLevel=Math.max(n.minLevel,s)),n.getTileUrl=function(l,a,u){if(Rn(l,s,i,this)){const h=s>=0?s:l;return e(h,a,u)}return Pn(this,l,r,i,t,s)?Cn(this,l):e(l,a,u)},n.__triiiceratopsLevel0LowZoomPrepared=!0}function Pn(n,o,e,t,r,i){if(i>=0)return!1;if(e>=0&&o<=e||!$i(n,o,t))return!0;if(!r)return!1;const s=r(o);return s?.x===1&&s?.y===1}function Oa(n,o,e){if(!e||typeof n?.minLevel!="number"||typeof n?.maxLevel!="number"||o.size===0)return-1;for(let t=n.minLevel;t<=n.maxLevel;t++){if(!$i(n,t,o))continue;const r=e(t);if(r?.x>1||r?.y>1)return t}return-1}function Rn(n,o,e,t){return o<0?!1:n<o?!0:!$i(t,n,e)}function Fa(n){const o=new Set,e=n?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&o.add(t);return o}function $i(n,o,e){if(e.size===0||typeof n?.maxLevel!="number"||typeof o!="number")return!0;const t=Math.pow(2,n.maxLevel-o);return e.has(t)}function La(n,o){return-1}function Cn(n,o){const e=n.getLevelScale(o),t=Math.ceil(n.width*e),r=Math.ceil(n.height*e),i=n.version===3,s=Ei(n?.profile),l=i?t===n.width&&r===n.height?"max":s?`${t},`:`${t},${r}`:t===n.width?"full":`${t},`,a=i?"default":"native";return`${n._id}/full/${l}/0/${a}.${n.tileFormat}`}const bi=8e3,Dn=4e7;function Ma(n,o,e,t){const r=Math.max(1,Math.round(n.width*o*t)),i=n.resourceWidth&&n.resourceHeight?n.resourceHeight/n.resourceWidth:e/o;return{x:Math.round(n.x*o*t),y:Math.round(n.y*e*t),width:r,height:Math.max(1,Math.round(r*i))}}function Ba(n,o){const e=URL.createObjectURL(n),t=document.createElement("a");t.href=e,t.download=o,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function er(n,o){const e=await fetch(n,o);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function Ha(n){const o=URL.createObjectURL(n);try{return await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>t(new Error("Unable to decode image for export.")),r.src=o})}finally{URL.revokeObjectURL(o)}}async function An(n,o,e,t="image/png"){const r=document.createElement("canvas");r.width=Math.max(1,Math.round(o)),r.height=Math.max(1,Math.round(e));const i=r.getContext("2d");if(!i)throw new Error("Unable to create a canvas for image export.");for(const s of n){const l=await Ha(s.blob);i.drawImage(l,s.x,s.y,s.width,s.height)}return new Promise((s,l)=>{r.toBlob(a=>{if(a){s(a);return}l(new Error("Unable to export composed image."))},t)})}function In(n,o){let e=1;n>bi&&(e=Math.min(e,bi/n)),o>bi&&(e=Math.min(e,bi/o));const t=n*o;return t*e*e>Dn&&(e=Math.min(e,Math.sqrt(Dn/t))),e>=1?{width:Math.round(n),height:Math.round(o),clamped:!1}:{width:Math.max(1,Math.round(n*e)),height:Math.max(1,Math.round(o*e)),clamped:!0}}function ii(n,o={}){if(Ei(n.serviceProfile))return n.resourceId??null;if(n.serviceId){const e=n.imageApiRegion?_a(n.imageApiRegion):void 0,t=!!(o.width||o.height);return Ca(n.serviceId,{region:e,size:t?void 0:"max",width:o.width,height:o.height})}return n.resourceId??null}async function za(n){if(!n.serviceId)return[];const o=n.serviceId.endsWith("/info.json")?n.serviceId:`${n.serviceId}/info.json`;try{const e=await fetch(o);if(!e.ok)return[];const t=await e.json(),r=await Promise.resolve().then(()=>Al),i=r.default||r,s=Aa(i,t,o);if(!s||typeof s.minLevel!="number"||typeof s.maxLevel!="number"||typeof s.getLevelScale!="function")return[];const l=new Set,a=[];for(let u=s.minLevel;u<=s.maxLevel;u+=1){const h=s.getLevelScale(u),c=Math.ceil(s.width*h),d=Math.ceil(s.height*h),m=`${c}x${d}`;l.has(m)||(l.add(m),a.push({width:c,height:d,label:`${c} × ${d}px`,url:Cn(s,u)}))}return a.sort((u,h)=>h.width-u.width)}catch{return[]}}const ka=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function tr(n,o,e){return ka.map(({fraction:t,label:r})=>{const i=Math.max(1,Math.round(n*t)),s=Math.max(1,Math.round(o*t)),l=e?.({width:i,height:s,isOriginal:t===1});return{width:i,height:s,label:`${r} (${i} × ${s}px)`,url:l??void 0}}).filter(t=>!e||!!t.url)}function Na(n){const o=n.resourceWidth,e=n.resourceHeight;if(!n.serviceId||!o||!e){const t=ii(n);return t?[{width:o??0,height:e??0,label:"Original",url:t}]:[]}return tr(o,e,({width:t,height:r,isOriginal:i})=>ii(n,i?{}:{width:t,height:r}))}async function Ua(n){if(Ei(n.serviceProfile)){const o=await za(n);return o.length?o:n.resourceId?[{width:n.resourceWidth??0,height:n.resourceHeight??0,label:"Original",url:n.resourceId}]:[]}return Na(n)}const Wa=.0125;function Va(n){return!!n&&typeof n=="object"&&"tileSource"in n}function On(n,o){if(!n||typeof n!="object")return null;const e=n[o];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function ja(n,o,e){return Math.min(e,Math.max(o,n))}function Ga(n){const o=[...n].sort((t,r)=>t-r),e=Math.floor(o.length/2);return o.length%2===0?(o[e-1]+o[e])/2:o[e]}function qa(n){const o=new Map;return n.forEach((e,t)=>{const r=Va(e),i=r?e.tileSource:e,s=r?e.canvasId??`canvas-${t}`:`canvas-${t}`,l=r?e.x??0:0,a=r?e.y??0:0,u=r?e.width??1:1,h=On(i,"width"),c=On(i,"height"),d=h&&c?u*c/h:null;let m=o.get(s);m||(m={canvasId:s,sources:[],width:0,height:null},o.set(s,m)),m.sources.push({source:e,tileSource:i,localX:l,localY:a,localWidth:u,localHeight:d}),m.width=Math.max(m.width,l+u),m.height=d===null?null:Math.max(m.height??0,a+d)}),[...o.values()]}function Za(n){return{layouts:n.map(o=>({canvasId:o.canvasId,x:0,y:0,width:o.width,height:o.height??1})),sources:n.flatMap(o=>o.sources.map(({tileSource:e,localX:t,localY:r,localWidth:i})=>({tileSource:e,x:t,y:r,width:i,canvasId:o.canvasId})))}}function Xa(n,o){const e=qa(n);if(o.mode==="individuals"||e.length<=1)return Za(e);const t=!o.preserveCanvasScale&&e.every(s=>s.height!==null),r=t?Ga(e.map(s=>s.height)):1,i=e.map(s=>{const l=t?ja(r/s.height,.25,4):1;return{group:s,scale:l,width:s.width*l,height:(s.height??1)*l,x:0,y:0}});if(o.mode==="continuous"){let s=0;const l=o.direction==="top-to-bottom"||o.direction==="bottom-to-top",a=o.direction==="right-to-left"||o.direction==="bottom-to-top";for(const u of i)l?(u.y=a?-s:s,s+=(t?u.height:1)+o.gap):(u.x=a?-s:s,s+=(t?u.width:1)+o.gap)}else if(o.mode==="paged"){const s=Math.max(...i.map(a=>a.height)),l=o.direction==="right-to-left";i.forEach((a,u)=>{const h=l?i.slice(u+1):i.slice(0,u);a.x=h.reduce((c,d)=>c+(t?d.width:1)+o.gap,0),a.y=(s-a.height)/2})}return{layouts:i.map(s=>({canvasId:s.group.canvasId,x:s.x,y:s.y,width:s.width,height:s.height})),sources:i.flatMap(s=>s.group.sources.map(({tileSource:l,localX:a,localY:u,localWidth:h})=>({tileSource:l,x:s.x+a*s.scale,y:s.y+u*s.scale,width:h*s.scale,canvasId:s.group.canvasId})))}}function Ya(n,o,e){Jo(n,"@triiiceratops/plugin-image-export","1.0.0-rc.0",o,e)}function Ka(n){return n.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Qa(n,o,e){const r=Ka(n)||"image",i=o==="single"?"":`-${o}`;return`${r}${i}.png`}function Fn(n,o){return xi(n,{getSelectedChoice:o})}function Ja(n){return Ua(n)}function $a(n,o){const t=xi(n,{getSelectedChoice:o})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:tr(t.canvasWidth,t.canvasHeight)}async function el(n,o){const e=o.url??ii(n,{width:o.width,height:o.height});if(!e)throw new Error("No exportable image found for this canvas.");return er(e)}async function tl(n,o,e={}){const t=xi(n,{getSelectedChoice:e.getSelectedChoice}),r=t[0];if(!r)throw new Error("No exportable image found for this canvas.");const{canvasWidth:i,canvasHeight:s}=r;if(!i||!s)throw new Error("Unable to determine canvas dimensions for export.");const{width:l,height:a}=In(o.width,o.height),u=l/i,h=await Promise.all(t.map(async c=>il(c,i,s,u)));return An(h,l,a,e.format??"image/png")}async function il(n,o,e,t){const r=Ma(n,o,e,t),i=ii(n,{width:r.width});if(!i)throw new Error("No exportable image found for this canvas.");return{blob:await er(i),...r}}function Ln(n){return ua({canvases:n.canvases,currentCanvasId:n.canvasId,currentCanvasIndex:n.currentCanvasIndex,viewingMode:n.viewingMode,pagedOffset:n.pagedOffset}).map(o=>o.canvas)}function Mn(n,o){const e=Ln(n);if(!e.length)return null;const t=e.flatMap((c,d)=>{const m=Ht(c)??`canvas-${d}`;return xi(c,{getSelectedChoice:o}).map(v=>({canvasId:m,x:v.x,y:v.y,width:v.width,tileSource:{width:v.resourceWidth||v.canvasWidth,height:v.resourceHeight||v.canvasHeight,resolved:v}}))});if(!t.length)return null;const{layouts:r,sources:i}=Xa(t,{mode:n.viewingMode,direction:n.viewingDirection,preserveCanvasScale:n.preserveCanvasScale,gap:Wa});if(!r.length)return null;const s=Math.min(...r.map(c=>c.x)),l=Math.min(...r.map(c=>c.y)),a=Math.max(...r.map(c=>c.x+c.width)),u=Math.max(...r.map(c=>c.y+c.height));return{entries:i.map(c=>({resolved:c.tileSource.resolved,x:c.x-s,y:c.y-l,width:c.width})),worldWidth:a-s,worldHeight:u-l}}function rl(n,o){const e=Mn(n,o);if(!e)return[];const t=e.entries[0],r=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,i=Math.round(e.worldWidth*r),s=Math.round(e.worldHeight*r);return!i||!s?[]:tr(i,s)}async function nl(n,o,e={}){const t=Mn(n,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:r,height:i}=In(o.width,o.height),s=r/t.worldWidth,l=await Promise.all(t.entries.map(async({resolved:a,x:u,y:h,width:c})=>{const d=Math.max(1,Math.round(c*s)),m=a.resourceWidth&&a.resourceHeight?a.resourceHeight/a.resourceWidth:1,v=Math.max(1,Math.round(d*m)),y=ii(a,{width:d});if(!y)throw new Error("No exportable image found for the current view.");return{blob:await er(y),x:Math.round(u*s),y:Math.round(h*s),width:d,height:v}}));return An(l,r,i,e.format??"image/png")}var sl=me("<option> </option>"),ol=me("<option> </option>"),al=me("<!> <option> </option> <!>",1),ll=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),ul=me("<option> </option>"),hl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),cl=me("<option> </option>"),dl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),fl=me("<option> </option>"),pl=me("<option disabled> </option> <!>",1),gl=me('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),ml=me('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),vl=me('<div class="tri-id-alert"><span> </span></div>'),wl=me('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),yl=me('<span aria-hidden="true"></span> ',1),_l=me('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');function Tl(n,o){Fi(o,!0);const{context:e}=Es(vn),{viewerState:t,selectors:r,locale:i,ui:s}=e;let l=ue(0),a=ue(0);r.select(I=>[I.canvasId,I.currentCanvasIndex,I.canvases,I.viewingMode,I.viewingDirection,I.pagedOffset,I.preserveCanvasScale]).subscribe(()=>{xr(l)}),i.subscribe(()=>{xr(a)});const u=(I,D)=>(b(a),i.t(I,D));let h=ue("single"),c=ue(0),d=ue(0),m=ue(lt([])),v=ue(null),y=ue(!1),_=ue(!1),E=ue(""),S=ue(""),P=ue(null);const L=I=>t.getSelectedChoice(I),F=le(()=>(b(l),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),H=le(()=>(b(l),b(F)?Fn(b(F),L):[])),B=le(()=>b(H).length>1),V=le(()=>b(B)),Y=le(()=>(b(l),Ln(t))),J=le(()=>b(Y).length>1),re=le(()=>b(J)),Z=le(()=>b(V)||b(re)),ie=le(()=>(b(l),b(h)==="single"&&b(J)?b(Y)[b(c)]??b(F):b(F))),he=le(()=>(b(l),b(ie)?Fn(b(ie),L):[])),pe=le(()=>b(he).length>1),ce=le(()=>b(v)!==null?b(m)[b(v)]??null:null),ve=le(()=>!b(_)&&!b(y)&&!!b(F)&&!!b(ce)),fe=le(()=>(b(a),b(F)?!b(y)&&!b(m).length?u("image_download_disabled_no_resolution"):null:u("image_download_disabled_no_canvas")));qt(()=>{(b(h)==="composite"&&!b(V)||b(h)==="world"&&!b(re))&&G(h,"single")}),qt(()=>{b(l);const I=t.canvasId,D=b(Y).findIndex(z=>Ht(z)===I);G(c,D>=0?D:0,!0)}),qt(()=>{b(ie),G(d,0)}),qt(()=>{const I=b(F),D=b(h),z=b(d);let j=!1;if(G(m,[],!0),G(v,null),!!I){if(D==="single"){const q=b(he)[z];if(!q)return;G(y,!0),Ja(q).then(U=>{j||(G(m,U,!0),G(v,U.length?0:null,!0))}).finally(()=>{j||G(y,!1)})}else if(D==="composite"){const q=$a(I,L);G(m,q,!0),G(v,q.length?0:null,!0)}else{const q=rl(t,L);G(m,q,!0),G(v,q.length?0:null,!0)}return()=>{j=!0}}});function we(I){const D=Number(I);return Number.isInteger(D)?D:0}async function He(){if(!(!b(F)||!b(ce)||!b(ve))){G(_,!0),G(E,""),G(S,"");try{let I,D=b(F);if(b(h)==="single"){D=b(ie);const j=b(he)[b(d)];if(!j)return;I=await el(j,b(ce))}else b(h)==="composite"?I=await tl(b(F),b(ce),{getSelectedChoice:L}):I=await nl(t,b(ce),{getSelectedChoice:L});const z=Qa(_n(D,t.currentCanvasIndex),b(h),"image/png");Ba(I,z),G(S,u("image_download_result_downloaded",{filename:z}),!0)}catch(I){G(E,u("image_download_error_failed"),!0),b(P)&&Ya(b(P),I,()=>void He())}finally{G(_,!1)}}}function xe(I){return{destroy:s.renderIcon(wn,I)}}var Xe=_l(),X=$(Xe),Ye=$(X),ct=$(Ye),Ue=_e(Ye,2),k=$(Ue);{var te=I=>{var D=ll(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_mode"));_i(U,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(h)},onchange:g=>{G(h,g.currentTarget.value,!0)},children:(g,p)=>{var w=al(),x=jt(w);{var C=oe=>{var se=sl(),Qe=$(se);se.value=se.__value="composite",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_composite")]),ge(oe,se)};st(x,oe=>{b(V)&&oe(C)})}var A=_e(x,2),N=$(A);A.value=A.__value="single";var Q=_e(A,2);{var W=oe=>{var se=ol(),Qe=$(se);se.value=se.__value="world",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_world")]),ge(oe,se)};st(Q,oe=>{b(re)&&oe(W)})}Se(oe=>Te(N,oe),[()=>u("image_download_mode_single")]),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_mode")]),ge(I,D)};st(k,I=>{b(Z)&&I(te)})}var de=_e(k,2);{var ye=I=>{var D=hl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_canvas"));_i(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(c)},onchange:g=>{G(c,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(Y),Vi,(C,A,N)=>{var Q=ul(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>_n(b(A),N)]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_canvas")]),ge(I,D)};st(de,I=>{b(h)==="single"&&b(J)&&I(ye)})}var Ke=_e(de,2);{var St=I=>{var D=dl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_image"));_i(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(d)},onchange:g=>{G(d,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(he),Vi,(C,A,N)=>{var Q=cl(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>b(A).label??`${u("image_download_image")} ${N+1}`]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_image")]),ge(I,D)};st(Ke,I=>{b(h)==="single"&&b(pe)&&I(St)})}var kt=_e(Ke,2),Nt=$(kt),Pt=$(Nt),dt=$(Pt),f=_e(Nt,2);{let I=le(()=>u("image_download_resolution")),D=le(()=>b(_)||b(y)||!b(m).length),z=le(()=>b(v)??"");_i(f,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(I)},get disabled(){return b(D)},get value(){return b(z)},onchange:j=>{G(v,we(j.currentTarget.value),!0)},children:(j,q)=>{var U=pl(),K=jt(U),g=$(K);K.value=K.__value="";var p=_e(K,2);gi(p,17,()=>b(m),Vi,(w,x,C)=>{var A=fl(),N=$(A);A.value=A.__value=C,Se(()=>Te(N,b(x).label)),ge(w,A)}),Se(w=>Te(g,w),[()=>u("image_download_resolution_placeholder")]),ge(j,U)},$$slots:{default:!0}})}var T=_e(Ue,2);{var R=I=>{var D=wl(),z=$(D),j=$(z);{var q=w=>{var x=gl(),C=$(x),A=$(C);Se(()=>Te(A,b(S))),ge(w,x)};st(j,w=>{b(S)&&w(q)})}var U=_e(j,2);{var K=w=>{var x=ml(),C=$(x),A=$(C);Se(()=>Te(A,b(E))),ge(w,x)};st(U,w=>{b(E)&&w(K)})}var g=_e(U,2);{var p=w=>{var x=vl(),C=$(x),A=$(C);Se(()=>Te(A,b(fe))),ge(w,x)};st(g,w=>{b(fe)&&w(p)})}ge(I,D)};st(T,I=>{(b(S)||b(E)||b(fe))&&I(R)})}var O=_e(X,2),M=$(O);{let I=le(()=>!b(ve));ra(M,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(I)},onclick:He,children:(D,z)=>{var j=yl(),q=jt(j);go(q,K=>xe?.(K));var U=_e(q);Se(K=>Te(U,` ${K??""}`),[()=>b(_)?u("image_download_downloading"):u("image_download_download")]),ge(D,j)},$$slots:{default:!0}})}vi(Xe,I=>G(P,I),()=>b(P)),Se((I,D)=>{Te(ct,I),Te(dt,D)},[()=>u("image_download_description"),()=>u("image_download_resolution")]),ge(n,Xe),Li()}const{STYLES:xl,STYLE_ID:El}=Qo(`
|
|
5
|
+
Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function ks(r,s){const e=[];gr(s.coreVersion,r.coreRange)||e.push({kind:"core",required:r.coreRange,actual:s.coreVersion,message:`requires core ${r.coreRange} but this viewer is core ${s.coreVersion}`}),gr(s.pluginApiVersion,r.pluginApiRange)||e.push({kind:"pluginApi",required:r.pluginApiRange,actual:s.pluginApiVersion,message:`requires plugin API ${r.pluginApiRange} but this viewer provides plugin API ${s.pluginApiVersion}`});const t=new Set(s.capabilities);for(const i of r.requiredCapabilities)t.has(i)||e.push({kind:"capability",required:i,actual:s.capabilities.join(", ")||"(none)",message:`requires capability "${i}" which this viewer does not provide (has: ${s.capabilities.join(", ")||"none"})`});return e}function Os(r,s){const e=ks(r,s);if(e.length>0)throw new Zi(r.name,r.version,e)}function Bs(r,s={}){let e=0,t=!1;const i=new Set,n=r.subscribe(()=>{e++;for(const u of[...i])u()},s.onListenerError);return{selectors:{select(u,l=Object.is){let a=-1,h;const c=()=>(a!==e&&(h=u(r),a=e),h);return{get:c,subscribe(d){if(t)return()=>{};let v=c();const m=()=>{let _;try{_=c()}catch(y){s.onProjectionError?.(y);return}l(v,_)||(v=_,d(_))};return i.add(m),()=>{i.delete(m)}}}}},dispose(){t||(t=!0,i.clear(),n())}}}const Mt=()=>{};function Fs(){return{install(r,s){return Mt}}}function Ms(){return{current:"en",t(r,s){return r},subscribe(r){return Mt}}}function Ls(){return{renderIcon(r,s){return Mt}}}function zs(r){return{id:r??"",isOpen:!0,target:"panel",open:Mt,close:Mt,toggle:Mt}}function Hs(r){const s=new Set;return{service:{install(e,t){const i=r.install(e,t);let n=!1;const o=()=>{n||(n=!0,s.delete(o),i())};return s.add(o),o}},releaseAll(){for(const e of[...s])e();s.clear()}}}function Ns(r){const s=new Set;return{service:{get current(){return r.current},t(e,t){return r.t(e,t)},subscribe(e){const t=r.subscribe(e);let i=!1;const n=()=>{i||(i=!0,s.delete(n),t())};return s.add(n),n}},releaseAll(){for(const e of[...s])e();s.clear()}}}const Us={deactivate(){}};function Ws(r,s){const e=s.reportError;let t,i,n,o;try{Os(r,s),t=Bs(s.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),i=Hs(s.styles??Fs()),n=Ns(s.locale??Ms()),o={viewerState:s.viewerState,selectors:t.selectors,surface:s.surface??zs(r.uiId??r.name),styles:i.service,locale:n.service,ui:s.ui??Ls()}}catch(d){if(t?.dispose(),i?.releaseAll(),n?.releaseAll(),e)return e({phase:"setup",error:d}),Us;throw d}const u=[],l=i,a=n,h=t;try{const d=r.view.mount(s.container,o);typeof d=="function"&&u.push(d)}catch(d){if(!e)throw l.releaseAll(),a.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}u.push(()=>l.releaseAll()),u.push(()=>a.releaseAll()),u.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=u.length-1;d>=0;d--)try{u[d]?.()}catch(v){e?e({phase:"cleanup",error:v}):console.error(`[triiiceratops] Plugin "${r.name}" cleanup threw during deactivation; teardown continues.`,v)}u.length=0}}}}const js="triiiceratops-plugin";function Vs(r){const s={name:r.name,uiId:r.uiId,version:r.version,coreRange:r.coreRange,pluginApiRange:r.pluginApiRange,requiredCapabilities:r.requiredCapabilities??[],icon:r.icon,target:r.target??"panel",dismiss:r.dismiss,catalog:r.catalog,view:r.view};return{kind:js,...s,activate(e){return Ws(s,e)}}}class Gs extends Error{name="SvgIconError";constructor(s){super(`svgIcon: ${s}`)}}const qs="0 0 24 24";function bt(r,s){if(!r)throw new Gs(s)}const Zs=/<svg\b[^>]*>/i;function Xs(r){bt(typeof r=="string","expected an SVG string.");const s=r.trim();bt(s.length>0,"received an empty string.");const e=Zs.exec(s);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(s),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(s),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(s),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const u of s.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const l=(u[1]??u[2]??u[3]??"").trim();bt(l.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${l}"); only internal "#id" references are.`)}const t=e[0],i=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let n=(i?.[1]??i?.[2])?.trim();if(!n){const u=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),l=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=parseFloat(u?.[1]??u?.[2]??""),h=parseFloat(l?.[1]??l?.[2]??"");n=Number.isFinite(a)&&Number.isFinite(h)?`0 0 ${a} ${h}`:qs}let o="";if(!/\/\s*>$/.test(t)){const u=e.index+t.length,l=s.lastIndexOf("</svg>");o=(l>=u?s.slice(u,l):s.slice(u)).trim()}return{kind:"svg",inner:o,viewBox:n}}function $s(r,s){return{STYLES:r,STYLE_ID:s}}function Ys(r,s,e,t,i){const n={pluginName:s,pluginVersion:e,phase:"command",error:t,retry:i};r.dispatchEvent(new CustomEvent("pluginerror",{detail:n,bubbles:!0,composed:!0}))}const Ks=".btn.svelte-sgoebi{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1hwvamm{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",Qs={en:{image_download_title:"Download Image",image_download_close:"Close Download Image",image_download_description:"Download the current canvas as an image.",image_download_mode:"What to download",image_download_mode_composite:"Composite canvas",image_download_mode_composite_hint:"Every image on the current canvas, composited together.",image_download_mode_single:"Single image",image_download_mode_single_hint:"One image from the current canvas.",image_download_mode_world:"Current view",image_download_mode_world_hint:"Everything currently laid out together in the viewer.",image_download_canvas:"Canvas",image_download_image:"Image",image_download_resolution:"Resolution",image_download_resolution_placeholder:"Select a resolution",image_download_downloading:"Downloading...",image_download_download:"Download",image_download_disabled_no_canvas:"Load a manifest to download an image.",image_download_disabled_no_resolution:"Select a resolution to download.",image_download_result_downloaded:"Downloaded {filename}.",image_download_error_failed:"Unable to download image. Check the browser console for details."},de:{image_download_title:"Bild herunterladen",image_download_close:"Bild-Download schließen",image_download_description:"Die aktuelle Leinwand als Bild herunterladen.",image_download_mode:"Was heruntergeladen werden soll",image_download_mode_composite:"Zusammengesetzte Leinwand",image_download_mode_composite_hint:"Alle Bilder der aktuellen Leinwand, zusammengesetzt.",image_download_mode_single:"Einzelbild",image_download_mode_single_hint:"Ein Bild von der aktuellen Leinwand.",image_download_mode_world:"Aktuelle Ansicht",image_download_mode_world_hint:"Alles, was aktuell zusammen im Viewer angezeigt wird.",image_download_canvas:"Leinwand",image_download_image:"Bild",image_download_resolution:"Auflösung",image_download_resolution_placeholder:"Auflösung auswählen",image_download_downloading:"Wird heruntergeladen...",image_download_download:"Herunterladen",image_download_disabled_no_canvas:"Laden Sie ein Manifest, um ein Bild herunterzuladen.",image_download_disabled_no_resolution:"Wählen Sie eine Auflösung zum Herunterladen aus.",image_download_result_downloaded:"{filename} heruntergeladen.",image_download_error_failed:"Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."}},vr=Symbol("triiiceratops:plugin-image-download"),mr=Xs('<svg viewBox="0 0 256 256"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg>'),Js="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(Js);var ea=ve("<button><!></button>");function ta(r,s){let e=Oe(s,"variant",3,"default"),t=Oe(s,"size",3,"md"),i=Oe(s,"circle",3,!1),n=Oe(s,"square",3,!1),o=Oe(s,"ghost",3,!1),u=Oe(s,"outline",3,!1),l=Oe(s,"active",3,!1),a=Oe(s,"class",3,""),h=Oe(s,"style",3,""),c=fr(s,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},v={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let m=ae(()=>`${v[t()]}${d[e()]}${h()}`);var _=ea();ur(_,()=>({class:`btn ${a()??""}`,style:b(m),...c,[Ft]:{circle:i(),square:n(),ghost:o(),outline:u(),active:l()}}),void 0,void 0,void 0,"svelte-sgoebi");var y=J(_);ir(y,()=>s.children??rn),fe(r,_)}let ia=0;var na=ve('<div role="option"> </div>'),ra=ve('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function xi(r,s){ki(s,!0);let e=Oe(s,"value",15),t=Oe(s,"size",3,"md"),i=Oe(s,"ghost",3,!1),n=Oe(s,"class",3,""),o=Oe(s,"style",3,""),u=fr(s,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const l={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let a=ae(()=>`--size:${l[t()]};${o()}`);const h=`tri-listbox-${ia++}`;let c=le(null),d=le(null),v=le(null),m=le(lt([])),_=le(!1),y=le(-1),E=ae(()=>!!s.disabled),S=ae(()=>e()==null?"":String(e())),P=ae(()=>b(m).find(z=>z.value===b(S))??b(m)[0]);function B(){b(c)&&G(m,Array.from(b(c).querySelectorAll("option")).map(z=>({value:z.value,label:(z.textContent??"").trim(),disabled:z.disabled})),!0)}Zt(()=>{if(!b(c))return;B();const z=new MutationObserver(()=>B());return z.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>z.disconnect()});function O(z){const ie=b(m)[z];!b(c)||!ie||ie.disabled||(b(c).value=ie.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),Q())}function M(){if(!b(d)||!b(v))return;const z=b(d).getBoundingClientRect();b(v).style.minWidth=`${z.width}px`,b(v).style.left=`${z.left}px`;const ie=b(v).offsetHeight,ce=window.innerHeight-z.bottom;ce<ie&&z.top>ce?b(v).style.top=`${Math.max(4,z.top-ie-4)}px`:b(v).style.top=`${z.bottom+4}px`}function L(){b(v)?.children[b(y)]?.scrollIntoView({block:"nearest"})}function W(z){const ie=z.composedPath();b(d)&&ie.includes(b(d))||b(v)&&ie.includes(b(v))||Q()}function Y(){b(E)||b(_)||!b(v)||(G(_,!0),b(v).showPopover(),M(),G(y,b(m).findIndex(z=>z.value===b(S)),!0),b(y)<0&&G(y,b(m).findIndex(z=>!z.disabled),!0),L(),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),document.addEventListener("pointerdown",W,!0))}function Q(){b(_)&&(G(_,!1),b(v)?.hidePopover(),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",W,!0),b(d)?.focus())}function ee(){b(_)?Q():Y()}function X(z){if(!b(m).length)return;let ie=b(y);for(let ce=0;ce<b(m).length;ce++)if(ie=(ie+z+b(m).length)%b(m).length,!b(m)[ie]?.disabled){G(y,ie,!0),L();return}}function ue(z){const ie=z==="start"?b(m).map((ce,we)=>we):b(m).map((ce,we)=>b(m).length-1-we);for(const ce of ie)if(!b(m)[ce]?.disabled){G(y,ce,!0),L();return}}let he="",de;function pe(z){he+=z.toLowerCase(),clearTimeout(de),de=setTimeout(()=>he="",600);const ie=b(m).findIndex(ce=>!ce.disabled&&ce.label.toLowerCase().startsWith(he));ie>=0&&(G(y,ie,!0),L())}function ge(z){if(!b(E)){if(!b(_)){["ArrowDown","ArrowUp","Enter"," "].includes(z.key)&&(z.preventDefault(),Y());return}switch(z.key){case"ArrowDown":z.preventDefault(),X(1);break;case"ArrowUp":z.preventDefault(),X(-1);break;case"Home":z.preventDefault(),ue("start");break;case"End":z.preventDefault(),ue("end");break;case"Enter":case" ":z.preventDefault(),b(y)>=0&&O(b(y));break;case"Escape":z.preventDefault(),Q();break;case"Tab":Q();break;default:z.key.length===1&&!z.metaKey&&!z.ctrlKey&&pe(z.key)}}}var me=ra(),Pe=J(me);ur(Pe,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...u}),void 0,void 0,void 0,"svelte-1hwvamm");var Le=J(Pe);ir(Le,()=>s.children??rn),wi(Pe,z=>G(c,z),()=>b(c));var xe=ye(Pe,2);let Xe;xe.__click=ee,xe.__keydown=ge;var Z=J(xe);let $e;var ct=J(Z);wi(xe,z=>G(d,z),()=>b(d));var Ue=ye(xe,2);vi(Ue,23,()=>b(m),(z,ie)=>z.value+"\0"+ie,(z,ie,ce)=>{var we=na();let Ye;we.__click=()=>O(b(ce)),we.__pointermove=()=>G(y,b(ce),!0);var St=J(we);be(()=>{Ze(we,"id",`${h}-opt-${b(ce)??""}`),Ye=ei(we,1,"option svelte-1hwvamm",null,Ye,{active:b(ce)===b(y),selected:b(ie).value===b(S)}),Ze(we,"aria-selected",b(ie).value===b(S)),Ze(we,"aria-disabled",b(ie).disabled),_e(St,b(ie).label)}),fe(z,we)}),wi(Ue,z=>G(v,z),()=>b(v)),be(()=>{ei(me,1,`select-wrapper ${n()??""}`,"svelte-1hwvamm"),qi(me,o()),Xe=ei(xe,1,"select svelte-1hwvamm",null,Xe,{ghost:i(),open:b(_)}),qi(xe,b(a)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(_)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(_)&&b(y)>=0?`${h}-opt-${b(y)}`:void 0),Ze(xe,"aria-label",u["aria-label"]),$e=ei(Z,1,"select-label svelte-1hwvamm",null,$e,{placeholder:b(P)?.disabled}),_e(ct,b(P)?.label??""),Ze(Ue,"id",h)}),ws(Pe,e),fe(r,me),Oi()}Kn(["click","keydown","pointermove"]);function Lt(r){var s,e;return r?.id||r?.["@id"]||((s=r?.__jsonld)==null?void 0:s.id)||((e=r?.__jsonld)==null?void 0:e["@id"])||(typeof r?.getId=="function"?r.getId():null)||null}function zt(r){return Lt(r)||(typeof r?.getCanvasId=="function"?r.getCanvasId():null)||(typeof r?.getId=="function"?r.getId():null)||""}function oa(r){var s;const e=r?.behavior||((s=r?.__jsonld)==null?void 0:s.behavior)||(typeof r?.getBehavior=="function"?r.getBehavior():[]);return e?(Array.isArray(e)?e:[e]).map(t=>{const i=String(t).trim().toLowerCase(),n=i.split(/[#/:]/);return n[n.length-1]||i}):[]}function wr(r){const s=oa(r);return s.includes("non-paged")||s.includes("facing-pages")}function sa(r,s){const e=[];for(let t=0;t<Math.min(s,r.length);t++){const i=r[t],n=zt(i);e.push({startIndex:t,endIndex:t,entries:n?[{canvasId:n,canvas:i}]:[]})}for(let t=s;t<r.length;){const i=r[t],n=zt(i),o=r[t+1],u=zt(o),l=!!o&&!!n&&!!u&&!wr(i)&&!wr(o);e.push({startIndex:t,endIndex:l?t+1:t,entries:[...n?[{canvasId:n,canvas:i}]:[],...l?[{canvasId:u,canvas:o}]:[]]}),t+=l?2:1}return e}function aa({canvases:r,currentCanvasId:s,currentCanvasIndex:e,viewingMode:t,pagedOffset:i}){if(!s)return[];if(e<0||e>=r.length)return[];const n=[],o=r[e];if(!o)return n;if(t!=="paged")return n.push({canvasId:s,canvas:o}),n;const u=sa(r,i).find(({startIndex:l,endIndex:a})=>e>=l&&e<=a);return u?.entries??n}function Ti(r,s){if(!r)return"";if(typeof r=="string")return r;if(typeof r=="object"&&!Array.isArray(r)){const e=r;if("@value"in e){const n=e["@value"];return Array.isArray(n)&&n.length>0?String(n[0]):n===void 0?"":String(n)}const t=Object.keys(e),i=n=>{const o=e[n];if(o!==void 0)return Array.isArray(o)&&o.length>0?String(o[0]):String(o)};for(const n of["en","none"]){const o=i(n);if(o!==void 0)return o}return t.length>0?i(t[0])??"":""}if(Array.isArray(r)&&r.length>0){if(typeof r[0]=="string")return r[0];const e=r,t=o=>o?.value??o?._value,i=(o=>e.find(u=>u.locale===o||u._locale===o||u.language===o))("en");{const o=t(i);if(o)return o}const n=e.find(o=>!o.locale&&!o._locale&&!o.language);{const o=t(n);if(o)return o}return t(e[0])??""}return String(r)}function yr(r,s){var e,t;const i=s===void 0?"Untitled canvas":`Canvas ${s+1}`;try{const o=(e=r.getLabel)==null?void 0:e.call(r);if(Array.isArray(o)&&o.length>0)return Ti(o)||i}catch{}const n=r.label||((t=r.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}return i}function Xi(r){if(!r)return null;const s=r.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return s?[Number(s[1]),Number(s[2]),Number(s[3]),Number(s[4])]:null}function la(r){const[s]=r.split("#");return s||null}function $i(r){if(!r)return null;if(typeof r=="string")return r;if(Array.isArray(r)){for(const e of r){const t=$i(e);if(t)return t}return null}if(typeof r!="object")return null;const s=r;return typeof s.id=="string"?s.id:typeof s["@id"]=="string"?s["@id"]:s.source?$i(s.source):null}function Yi(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(e=>Yi(e));if(typeof r!="object")return[];const s=r;return s.item?Yi(s.item):[s]}function ua(r){const s=r.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(s)return Xi(s.value);const e=r.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Xi(e.value):null}function _r(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(i=>_r(i));const s=$i(r),e=typeof r=="object"&&r&&"selector"in r?Yi(r.selector):[],t=ua(e)||(s?Xi(s):null);return[{raw:r,targetId:s,canvasId:s?la(s):null,selectors:e,xywh:t}]}function xr(r){return r.endsWith("/info.json")?r.slice(0,-10):r}function Ht(r){return typeof r=="number"&&Number.isFinite(r)&&r>0?r:null}function ha(r){const s=r?.__jsonld||r;return{width:Ht(r?.width)||Ht(s?.width)||(typeof r?.getWidth=="function"?Ht(r.getWidth()):null),height:Ht(r?.height)||Ht(s?.height)||(typeof r?.getHeight=="function"?Ht(r.getHeight()):null)}}function Tr(r){const s=r?.__jsonld||r;return s?.type==="SpecificResource"&&s!=null&&s.source?s.source:null}function ca(r,s){return s?.type==="Choice"||s?.type==="oa:Choice"||!!r&&!Array.isArray(r)&&(r.type==="Choice"||r.type==="oa:Choice")}function Er(r,s){return s&&(s.items||s.item)?s.items||s.item:Array.isArray(r)?r:r&&(r.items||r.item)?r.items||r.item:[]}function da({body:r,rawBody:s,canvasId:e,getSelectedChoice:t}){const i=Array.isArray(r)?r:Er(r,null),n=Er(null,s),o=t?.(e);if(o){const u=i.find(a=>Lt(a)===o);if(u)return u;const l=n.findIndex(a=>Lt(a)===o);if(l>=0)return i[l]||n[l]}return i[0]||n[0]||null}function pa(r){var s;let e=((s=r.getImages)==null?void 0:s.call(r))||[];return(!e||!e.length)&&r.getContent&&(e=r.getContent()),e||[]}function fa(r){var s,e;const t=r?.width||((s=r?.__jsonld)==null?void 0:s.width)||(typeof r?.getWidth=="function"?r.getWidth():null),i=r?.height||((e=r?.__jsonld)==null?void 0:e.height)||(typeof r?.getHeight=="function"?r.getHeight():null);return typeof t!="number"||typeof i!="number"?null:{width:t,height:i}}function ga(r){var s,e;const t=(e=_r(r?.target||((s=r?.__jsonld)==null?void 0:s.target)).find(i=>i.xywh))==null?void 0:e.xywh;return t?{x:t[0],y:t[1],width:t[2],height:t[3]}:null}function va(r,s){if(typeof r!="string"||!r.trim())return null;const e=r.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(n=>Number(n.trim()));return i.length!==4||i.some(n=>!Number.isFinite(n)||n<0)?null:t?typeof s.width!="number"||typeof s.height!="number"?null:{x:i[0]/100*s.width,y:i[1]/100*s.height,width:i[2]/100*s.width,height:i[3]/100*s.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function ma(r,s){var e;const t=r?.__jsonld||r;return va(((e=t?.selector)==null?void 0:e.type)==="ImageApiSelector"?t.selector.region:null,s)}function wa(r){return[r.x,r.y,r.width,r.height].map(s=>Math.round(s)).join(",")}function ya(r){const s=r?.__jsonld||r,e=Tr(r);return!!(r&&(r.id||r["@id"]||s!=null&&s.service||e||s!=null&&s.id||s!=null&&s["@id"]))}function _a(r,s,e){var t;let i=r.getResource?r.getResource():null;if(!i&&r.getBody){const n=r.getBody(),o=((t=r.__jsonld)==null?void 0:t.body)||r.body;ca(n,o)?i=da({body:n,rawBody:o,canvasId:s,getSelectedChoice:e}):Array.isArray(n)&&n.length>0?i=n[0]:n&&(i=n)}if(i&&!ya(i)&&(i=null),!i){const n=r.__jsonld||r;if(n.body){let o=n.body;if(o.type==="Choice"||o.type==="oa:Choice"){const u=o.items||o.item||[],l=e?.(s);o=(l?u.find(a=>Lt(a)===l):null)||u[0]||null}i=Array.isArray(o)?o[0]:o}}return i}function br(r){return typeof r=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(r)||r==="level0"||r==="level1"||r==="level2":Array.isArray(r)?r.some(s=>br(s)):!1}function xa(r){return typeof r=="string"?r||null:Array.isArray(r)&&r.find(s=>typeof s=="string")||null}function Ta(r){let s=[];const e=r?.__jsonld||r;return e!=null&&e.service&&(s=Array.isArray(e.service)?e.service:[e.service]),!s.length&&r!=null&&r.getServices&&(s=r.getServices()),s.length&&s.find(t=>{const i=t.getType?t.getType():t.type||t["@type"]||"",n=t.getProfile?t.getProfile():t.profile||"";return i==="ImageService1"||i==="ImageService2"||i==="ImageService3"||br(n)})||null}function Ea(r,s){var e,t;for(const i of[r,s]){if(!i)continue;try{const o=(e=i.getLabel)==null?void 0:e.call(i);if(Array.isArray(o)&&o.length>0){const u=Ti(o);if(u)return u}}catch{}const n=i.label||((t=i.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}}return null}function ba(r){const s=Ta(r),e=Lt(s),t=s?s.getProfile?s.getProfile():s.profile||"":null;return{serviceId:e?xr(e):null,serviceProfile:xa(t)}}function Sa(r){if(!r||!r.includes("/iiif/"))return null;const s=r.split("/"),e=s.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?s.slice(0,e).join("/"):null}function Ei(r,s={}){const e=zt(r);if(!e)return[];const t=fa(r);if(!t)return[];const i=pa(r);return i.length?i.map(n=>{const o=_a(n,e,s.getSelectedChoice),u=Tr(o)||o;if(!u)return null;const l=Lt(u),a=ha(u),h=ba(u),c=h.serviceId||Sa(l),d=ga(n),v=ma(o,a);return{canvasId:e,annotation:n,resource:u,resourceId:l,label:Ea(u,n),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:v?.width||a.width,resourceHeight:v?.height||a.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:v,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(n=>n!==null):[]}function Pa(r,s={width:1600}){const e=xr(r),t=s.region||"full",i=s.quality||"default",n=s.format||"jpg",o=typeof s.width=="number"?Math.max(1,Math.round(s.width)):null,u=typeof s.height=="number"?Math.max(1,Math.round(s.height)):null,l=s.size||(o?`${o},`:`,${u||1600}`);return`${e}/${t}/${l}/0/${i}.${n}`}function Ca(r){return typeof r=="string"?r:Array.isArray(r)&&typeof r[0]=="string"?r[0]:null}function bi(r){const s=Ca(r);return s?s==="level0"||s.endsWith("/level0.json")||s.endsWith("#level0"):!1}function Ra(r,s,e,t){var i;if(!((i=r?.IIIFTileSource)!=null&&i.prototype))return s;try{const n=r.IIIFTileSource.prototype.configure.call({},s,e,null),o=new r.IIIFTileSource(n);return Da(o,t),o}catch{return s}}function Da(r,s){if(!bi(r?.profile)||typeof r?.getTileUrl!="function"||r.__triiiceratopsLevel0LowZoomPrepared)return;const e=r.getTileUrl.bind(r),t=typeof r.getNumTiles=="function"?r.getNumTiles.bind(r):null,i=ka(),n=Aa(r),o=Ia(r,n,t);t&&(r.getNumTiles=function(u){return Pr(u,o,n,this)?{x:0,y:0}:Sr(this,u,i,n,t,o)?{x:1,y:1}:t(u)}),typeof r?.minLevel=="number"&&o>=0&&(r.minLevel=Math.max(r.minLevel,o)),r.getTileUrl=function(u,l,a){if(Pr(u,o,n,this)){const h=o>=0?o:u;return e(h,l,a)}return Sr(this,u,i,n,t,o)?Cr(this,u):e(u,l,a)},r.__triiiceratopsLevel0LowZoomPrepared=!0}function Sr(r,s,e,t,i,n){if(n>=0)return!1;if(!Ki(r,s,t))return!0;if(!i)return!1;const o=i(s);return o?.x===1&&o?.y===1}function Ia(r,s,e){if(!e||typeof r?.minLevel!="number"||typeof r?.maxLevel!="number"||s.size===0)return-1;for(let t=r.minLevel;t<=r.maxLevel;t++){if(!Ki(r,t,s))continue;const i=e(t);if(i?.x>1||i?.y>1)return t}return-1}function Pr(r,s,e,t){return s<0?!1:r<s?!0:!Ki(t,r,e)}function Aa(r){const s=new Set,e=r?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&s.add(t);return s}function Ki(r,s,e){if(e.size===0||typeof r?.maxLevel!="number"||typeof s!="number")return!0;const t=Math.pow(2,r.maxLevel-s);return e.has(t)}function ka(r,s){return-1}function Cr(r,s){const e=r.getLevelScale(s),t=Math.ceil(r.width*e),i=Math.ceil(r.height*e),n=r.version===3,o=bi(r?.profile),u=n?t===r.width&&i===r.height?"max":o?`${t},`:`${t},${i}`:t===r.width?"full":`${t},`,l=n?"default":"native";return`${r._id}/full/${u}/0/${l}.${r.tileFormat}`}const Si=8e3,Rr=4e7;function Oa(r,s,e,t){const i=Math.max(1,Math.round(r.width*s*t)),n=r.resourceWidth&&r.resourceHeight?r.resourceHeight/r.resourceWidth:e/s;return{x:Math.round(r.x*s*t),y:Math.round(r.y*e*t),width:i,height:Math.max(1,Math.round(i*n))}}function Ba(r,s){const e=URL.createObjectURL(r),t=document.createElement("a");t.href=e,t.download=s,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function Qi(r,s){const e=await fetch(r,s);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function Fa(r){const s=URL.createObjectURL(r);try{return await new Promise((e,t)=>{const i=new Image;i.onload=()=>e(i),i.onerror=()=>t(new Error("Unable to decode image for export.")),i.src=s})}finally{URL.revokeObjectURL(s)}}async function Dr(r,s,e,t="image/png"){const i=document.createElement("canvas");i.width=Math.max(1,Math.round(s)),i.height=Math.max(1,Math.round(e));const n=i.getContext("2d");if(!n)throw new Error("Unable to create a canvas for image export.");for(const o of r){const u=await Fa(o.blob);n.drawImage(u,o.x,o.y,o.width,o.height)}return new Promise((o,u)=>{i.toBlob(l=>{if(l){o(l);return}u(new Error("Unable to export composed image."))},t)})}function Ir(r,s){let e=1;r>Si&&(e=Math.min(e,Si/r)),s>Si&&(e=Math.min(e,Si/s));const t=r*s;return t*e*e>Rr&&(e=Math.min(e,Math.sqrt(Rr/t))),e>=1?{width:Math.round(r),height:Math.round(s),clamped:!1}:{width:Math.max(1,Math.round(r*e)),height:Math.max(1,Math.round(s*e)),clamped:!0}}function ni(r,s={}){if(bi(r.serviceProfile))return r.resourceId??null;if(r.serviceId){const e=r.imageApiRegion?wa(r.imageApiRegion):void 0,t=!!(s.width||s.height);return Pa(r.serviceId,{region:e,size:t?void 0:"max",width:s.width,height:s.height})}return r.resourceId??null}async function Ma(r){if(!r.serviceId)return[];const s=r.serviceId.endsWith("/info.json")?r.serviceId:`${r.serviceId}/info.json`;try{const e=await fetch(s);if(!e.ok)return[];const t=await e.json(),i=await Promise.resolve().then(()=>Dl).then(a=>a.o),n=i.default||i,o=Ra(n,t,s);if(!o||typeof o.minLevel!="number"||typeof o.maxLevel!="number"||typeof o.getLevelScale!="function")return[];const u=new Set,l=[];for(let a=o.minLevel;a<=o.maxLevel;a+=1){const h=o.getLevelScale(a),c=Math.ceil(o.width*h),d=Math.ceil(o.height*h),v=`${c}x${d}`;u.has(v)||(u.add(v),l.push({width:c,height:d,label:`${c} × ${d}px`,url:Cr(o,a)}))}return l.sort((a,h)=>h.width-a.width)}catch{return[]}}const La=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function Ji(r,s,e){return La.map(({fraction:t,label:i})=>{const n=Math.max(1,Math.round(r*t)),o=Math.max(1,Math.round(s*t)),u=e?.({width:n,height:o,isOriginal:t===1});return{width:n,height:o,label:`${i} (${n} × ${o}px)`,url:u??void 0}}).filter(t=>!e||!!t.url)}function za(r){const s=r.resourceWidth,e=r.resourceHeight;if(!r.serviceId||!s||!e){const t=ni(r);return t?[{width:s??0,height:e??0,label:"Original",url:t}]:[]}return Ji(s,e,({width:t,height:i,isOriginal:n})=>ni(r,n?{}:{width:t,height:i}))}async function Ha(r){if(bi(r.serviceProfile)){const s=await Ma(r);return s.length?s:r.resourceId?[{width:r.resourceWidth??0,height:r.resourceHeight??0,label:"Original",url:r.resourceId}]:[]}return za(r)}const Na=.0125;function Ua(r){return!!r&&typeof r=="object"&&"tileSource"in r}function Ar(r,s){if(!r||typeof r!="object")return null;const e=r[s];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Wa(r,s,e){return Math.min(e,Math.max(s,r))}function ja(r){const s=[...r].sort((t,i)=>t-i),e=Math.floor(s.length/2);return s.length%2===0?(s[e-1]+s[e])/2:s[e]}function Va(r){const s=new Map;return r.forEach((e,t)=>{const i=Ua(e),n=i?e.tileSource:e,o=i?e.canvasId??`canvas-${t}`:`canvas-${t}`,u=i?e.x??0:0,l=i?e.y??0:0,a=i?e.width??1:1,h=Ar(n,"width"),c=Ar(n,"height"),d=h&&c?a*c/h:null;let v=s.get(o);v||(v={canvasId:o,sources:[],width:0,height:null},s.set(o,v)),v.sources.push({source:e,tileSource:n,localX:u,localY:l,localWidth:a,localHeight:d}),v.width=Math.max(v.width,u+a),v.height=d===null?null:Math.max(v.height??0,l+d)}),[...s.values()]}function Ga(r){return{layouts:r.map(s=>({canvasId:s.canvasId,x:0,y:0,width:s.width,height:s.height??1})),sources:r.flatMap(s=>s.sources.map(({tileSource:e,localX:t,localY:i,localWidth:n})=>({tileSource:e,x:t,y:i,width:n,canvasId:s.canvasId})))}}function qa(r,s){const e=Va(r);if(s.mode==="individuals"||e.length<=1)return Ga(e);const t=!s.preserveCanvasScale&&e.every(o=>o.height!==null),i=t?ja(e.map(o=>o.height)):1,n=e.map(o=>{const u=t?Wa(i/o.height,.25,4):1;return{group:o,scale:u,width:o.width*u,height:(o.height??1)*u,x:0,y:0}});if(s.mode==="continuous"){let o=0;const u=s.direction==="top-to-bottom"||s.direction==="bottom-to-top",l=s.direction==="right-to-left"||s.direction==="bottom-to-top";for(const a of n)u?(a.y=l?-o:o,o+=(t?a.height:1)+s.gap):(a.x=l?-o:o,o+=(t?a.width:1)+s.gap)}else if(s.mode==="paged"){const o=Math.max(...n.map(l=>l.height)),u=s.direction==="right-to-left";n.forEach((l,a)=>{const h=u?n.slice(a+1):n.slice(0,a);l.x=h.reduce((c,d)=>c+(t?d.width:1)+s.gap,0),l.y=(o-l.height)/2})}return{layouts:n.map(o=>({canvasId:o.group.canvasId,x:o.x,y:o.y,width:o.width,height:o.height})),sources:n.flatMap(o=>o.group.sources.map(({tileSource:u,localX:l,localY:a,localWidth:h})=>({tileSource:u,x:o.x+l*o.scale,y:o.y+a*o.scale,width:h*o.scale,canvasId:o.group.canvasId})))}}function Za(r,s,e){Ys(r,"@triiiceratops/plugin-image-export","1.0.0-rc.0",s,e)}function Xa(r){return r.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function $a(r,s,e){const i=Xa(r)||"image",n=s==="single"?"":`-${s}`;return`${i}${n}.png`}function kr(r,s){return Ei(r,{getSelectedChoice:s})}function Ya(r){return Ha(r)}function Ka(r,s){const t=Ei(r,{getSelectedChoice:s})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:Ji(t.canvasWidth,t.canvasHeight)}async function Qa(r,s){const e=s.url??ni(r,{width:s.width,height:s.height});if(!e)throw new Error("No exportable image found for this canvas.");return Qi(e)}async function Ja(r,s,e={}){const t=Ei(r,{getSelectedChoice:e.getSelectedChoice}),i=t[0];if(!i)throw new Error("No exportable image found for this canvas.");const{canvasWidth:n,canvasHeight:o}=i;if(!n||!o)throw new Error("Unable to determine canvas dimensions for export.");const{width:u,height:l}=Ir(s.width,s.height),a=u/n,h=await Promise.all(t.map(async c=>el(c,n,o,a)));return Dr(h,u,l,e.format??"image/png")}async function el(r,s,e,t){const i=Oa(r,s,e,t),n=ni(r,{width:i.width});if(!n)throw new Error("No exportable image found for this canvas.");return{blob:await Qi(n),...i}}function Or(r){return aa({canvases:r.canvases,currentCanvasId:r.canvasId,currentCanvasIndex:r.currentCanvasIndex,viewingMode:r.viewingMode,pagedOffset:r.pagedOffset}).map(s=>s.canvas)}function Br(r,s){const e=Or(r);if(!e.length)return null;const t=e.flatMap((c,d)=>{const v=zt(c)??`canvas-${d}`;return Ei(c,{getSelectedChoice:s}).map(m=>({canvasId:v,x:m.x,y:m.y,width:m.width,tileSource:{width:m.resourceWidth||m.canvasWidth,height:m.resourceHeight||m.canvasHeight,resolved:m}}))});if(!t.length)return null;const{layouts:i,sources:n}=qa(t,{mode:r.viewingMode,direction:r.viewingDirection,preserveCanvasScale:r.preserveCanvasScale,gap:Na});if(!i.length)return null;const o=Math.min(...i.map(c=>c.x)),u=Math.min(...i.map(c=>c.y)),l=Math.max(...i.map(c=>c.x+c.width)),a=Math.max(...i.map(c=>c.y+c.height));return{entries:n.map(c=>({resolved:c.tileSource.resolved,x:c.x-o,y:c.y-u,width:c.width})),worldWidth:l-o,worldHeight:a-u}}function tl(r,s){const e=Br(r,s);if(!e)return[];const t=e.entries[0],i=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,n=Math.round(e.worldWidth*i),o=Math.round(e.worldHeight*i);return!n||!o?[]:Ji(n,o)}async function il(r,s,e={}){const t=Br(r,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:i,height:n}=Ir(s.width,s.height),o=i/t.worldWidth,u=await Promise.all(t.entries.map(async({resolved:l,x:a,y:h,width:c})=>{const d=Math.max(1,Math.round(c*o)),v=l.resourceWidth&&l.resourceHeight?l.resourceHeight/l.resourceWidth:1,m=Math.max(1,Math.round(d*v)),_=ni(l,{width:d});if(!_)throw new Error("No exportable image found for the current view.");return{blob:await Qi(_),x:Math.round(a*o),y:Math.round(h*o),width:d,height:m}}));return Dr(u,i,n,e.format??"image/png")}var nl=ve("<option> </option>"),rl=ve("<option> </option>"),ol=ve("<!> <option> </option> <!>",1),sl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),al=ve("<option> </option>"),ll=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),ul=ve("<option> </option>"),hl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),cl=ve("<option> </option>"),dl=ve("<option disabled> </option> <!>",1),pl=ve('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),fl=ve('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),gl=ve('<div class="tri-id-alert"><span> </span></div>'),vl=ve('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),ml=ve('<span aria-hidden="true"></span> ',1),wl=ve('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');function yl(r,s){ki(s,!0);const{context:e}=xo(vr),{viewerState:t,selectors:i,locale:n,ui:o}=e;let u=le(0),l=le(0);i.select(A=>[A.canvasId,A.currentCanvasIndex,A.canvases,A.viewingMode,A.viewingDirection,A.pagedOffset,A.preserveCanvasScale]).subscribe(()=>{Tn(u)}),n.subscribe(()=>{Tn(l)});const a=(A,D)=>(b(l),n.t(A,D));let h=le("single"),c=le(0),d=le(0),v=le(lt([])),m=le(null),_=le(!1),y=le(!1),E=le(""),S=le(""),P=le(null);const B=A=>t.getSelectedChoice(A),O=ae(()=>(b(u),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),M=ae(()=>(b(u),b(O)?kr(b(O),B):[])),L=ae(()=>b(M).length>1),W=ae(()=>b(L)),Y=ae(()=>(b(u),Or(t))),Q=ae(()=>b(Y).length>1),ee=ae(()=>b(Q)),X=ae(()=>b(W)||b(ee)),ue=ae(()=>(b(u),b(h)==="single"&&b(Q)?b(Y)[b(c)]??b(O):b(O))),he=ae(()=>(b(u),b(ue)?kr(b(ue),B):[])),de=ae(()=>b(he).length>1),pe=ae(()=>b(m)!==null?b(v)[b(m)]??null:null),ge=ae(()=>!b(y)&&!b(_)&&!!b(O)&&!!b(pe)),me=ae(()=>(b(l),b(O)?!b(_)&&!b(v).length?a("image_download_disabled_no_resolution"):null:a("image_download_disabled_no_canvas")));Zt(()=>{(b(h)==="composite"&&!b(W)||b(h)==="world"&&!b(ee))&&G(h,"single")}),Zt(()=>{b(u);const A=t.canvasId,D=b(Y).findIndex(H=>zt(H)===A);G(c,D>=0?D:0,!0)}),Zt(()=>{b(ue),G(d,0)}),Zt(()=>{const A=b(O),D=b(h),H=b(d);let V=!1;if(G(v,[],!0),G(m,null),!!A){if(D==="single"){const q=b(he)[H];if(!q)return;G(_,!0),Ya(q).then(U=>{V||(G(v,U,!0),G(m,U.length?0:null,!0))}).finally(()=>{V||G(_,!1)})}else if(D==="composite"){const q=Ka(A,B);G(v,q,!0),G(m,q.length?0:null,!0)}else{const q=tl(t,B);G(v,q,!0),G(m,q.length?0:null,!0)}return()=>{V=!0}}});function Pe(A){const D=Number(A);return Number.isInteger(D)?D:0}async function Le(){if(!(!b(O)||!b(pe)||!b(ge))){G(y,!0),G(E,""),G(S,"");try{let A,D=b(O);if(b(h)==="single"){D=b(ue);const V=b(he)[b(d)];if(!V)return;A=await Qa(V,b(pe))}else b(h)==="composite"?A=await Ja(b(O),b(pe),{getSelectedChoice:B}):A=await il(t,b(pe),{getSelectedChoice:B});const H=$a(yr(D,t.currentCanvasIndex),b(h),"image/png");Ba(A,H),G(S,a("image_download_result_downloaded",{filename:H}),!0)}catch(A){G(E,a("image_download_error_failed"),!0),b(P)&&Za(b(P),A,()=>void Le())}finally{G(y,!1)}}}function xe(A){return{destroy:o.renderIcon(mr,A)}}var Xe=wl(),Z=J(Xe),$e=J(Z),ct=J($e),Ue=ye($e,2),z=J(Ue);{var ie=A=>{var D=sl(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_mode"));xi(U,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(h)},onchange:g=>{G(h,g.currentTarget.value,!0)},children:(g,f)=>{var w=ol(),T=Gt(w);{var R=oe=>{var re=nl(),Ke=J(re);re.value=re.__value="composite",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_composite")]),fe(oe,re)};ot(T,oe=>{b(W)&&oe(R)})}var I=ye(T,2),N=J(I);I.value=I.__value="single";var K=ye(I,2);{var j=oe=>{var re=rl(),Ke=J(re);re.value=re.__value="world",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_world")]),fe(oe,re)};ot(K,oe=>{b(ee)&&oe(j)})}be(oe=>_e(N,oe),[()=>a("image_download_mode_single")]),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_mode")]),fe(A,D)};ot(z,A=>{b(X)&&A(ie)})}var ce=ye(z,2);{var we=A=>{var D=ll(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_canvas"));xi(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(c)},onchange:g=>{G(c,Pe(g.currentTarget.value),!0)},children:(g,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b(Y),Wi,(R,I,N)=>{var K=al(),j=J(K);K.value=K.__value=N,be(oe=>_e(j,oe),[()=>yr(b(I),N)]),fe(R,K)}),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_canvas")]),fe(A,D)};ot(ce,A=>{b(h)==="single"&&b(Q)&&A(we)})}var Ye=ye(ce,2);{var St=A=>{var D=hl(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_image"));xi(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(d)},onchange:g=>{G(d,Pe(g.currentTarget.value),!0)},children:(g,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b(he),Wi,(R,I,N)=>{var K=ul(),j=J(K);K.value=K.__value=N,be(oe=>_e(j,oe),[()=>b(I).label??`${a("image_download_image")} ${N+1}`]),fe(R,K)}),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_image")]),fe(A,D)};ot(Ye,A=>{b(h)==="single"&&b(de)&&A(St)})}var Nt=ye(Ye,2),Ut=J(Nt),Pt=J(Ut),dt=J(Pt),p=ye(Ut,2);{let A=ae(()=>a("image_download_resolution")),D=ae(()=>b(y)||b(_)||!b(v).length),H=ae(()=>b(m)??"");xi(p,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(A)},get disabled(){return b(D)},get value(){return b(H)},onchange:V=>{G(m,Pe(V.currentTarget.value),!0)},children:(V,q)=>{var U=dl(),$=Gt(U),g=J($);$.value=$.__value="";var f=ye($,2);vi(f,17,()=>b(v),Wi,(w,T,R)=>{var I=cl(),N=J(I);I.value=I.__value=R,be(()=>_e(N,b(T).label)),fe(w,I)}),be(w=>_e(g,w),[()=>a("image_download_resolution_placeholder")]),fe(V,U)},$$slots:{default:!0}})}var x=ye(Ue,2);{var C=A=>{var D=vl(),H=J(D),V=J(H);{var q=w=>{var T=pl(),R=J(T),I=J(R);be(()=>_e(I,b(S))),fe(w,T)};ot(V,w=>{b(S)&&w(q)})}var U=ye(V,2);{var $=w=>{var T=fl(),R=J(T),I=J(R);be(()=>_e(I,b(E))),fe(w,T)};ot(U,w=>{b(E)&&w($)})}var g=ye(U,2);{var f=w=>{var T=gl(),R=J(T),I=J(R);be(()=>_e(I,b(me))),fe(w,T)};ot(g,w=>{b(me)&&w(f)})}fe(A,D)};ot(x,A=>{(b(S)||b(E)||b(me))&&A(C)})}var k=ye(Z,2),F=J(k);{let A=ae(()=>!b(ge));ta(F,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(A)},onclick:Le,children:(D,H)=>{var V=ml(),q=Gt(V);ds(q,$=>xe?.($));var U=ye(q);be($=>_e(U,` ${$??""}`),[()=>b(y)?a("image_download_downloading"):a("image_download_download")]),fe(D,V)},$$slots:{default:!0}})}wi(Xe,A=>G(P,A),()=>b(P)),be((A,D)=>{_e(ct,A),_e(dt,D)},[()=>a("image_download_description"),()=>a("image_download_resolution")]),fe(r,Xe),Oi()}const{STYLES:_l,STYLE_ID:xl}=$s(`
|
|
6
6
|
.tri-id {
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-direction: column;
|
|
@@ -119,20 +119,20 @@ Update the plugin or the core viewer so their declared ranges and capabilities o
|
|
|
119
119
|
height: 1.125rem;
|
|
120
120
|
fill: currentColor;
|
|
121
121
|
}
|
|
122
|
-
`,"panel"),
|
|
122
|
+
`,"panel"),Tl=Vs({name:"@triiiceratops/plugin-image-export",uiId:"image-download",version:"1.0.0-rc.0",coreRange:">=1.0.0-rc.0",pluginApiRange:"^1.0.0",requiredCapabilities:["osd@5"],icon:mr,target:"panel",catalog:Qs,view:{mount(r,s){const e=s.styles.install(_l,xl),t=s.styles.install(Ks,"bundled"),i=ss(yl,{target:r,context:new Map([[vr,{context:s}]])});return()=>{ls(i),t(),e()}}}});function El(){const r=new Map;return{register(s){const e=r.get(s.name);if(!e){r.set(s.name,s);return}e.version!==s.version&&console.warn(`[triiiceratops] Ignoring plugin "${s.name}" version ${s.version}: version ${e.version} is already registered on this page and wins (first registration wins).`)},get(s){return r.get(s)},has(s){return r.has(s)},list(){return[...r.values()]}}}function bl(r){(window.Triiiceratops??={coreVersion:"",pluginApiVersion:"",capabilities:[],plugins:El()}).plugins.register(r)}bl(Tl);function Sl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Pl(r,s){for(var e=0;e<s.length;e++){const t=s[e];if(typeof t!="string"&&!Array.isArray(t)){for(const i in t)if(i!=="default"&&!(i in r)){const n=Object.getOwnPropertyDescriptor(t,i);n&&Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var en={exports:{}},Cl=en.exports,Fr;function Rl(){return Fr||(Fr=1,(function(r){//! openseadragon 5.0.1
|
|
123
123
|
//! Built on 2024-12-09
|
|
124
124
|
//! Git commit: v5.0.1-0-480de92d
|
|
125
125
|
//! http://openseadragon.github.io
|
|
126
126
|
//! License: http://openseadragon.github.io/license/
|
|
127
|
-
function o(e){return new o.Viewer(e)}(function(e){e.version={versionStr:"5.0.1",major:parseInt("5",10),minor:parseInt("0",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"},r=Object.prototype.toString,i=Object.prototype.hasOwnProperty;e.isFunction=function(s){return e.type(s)==="function"},e.isArray=Array.isArray||function(s){return e.type(s)==="array"},e.isWindow=function(s){return s&&typeof s=="object"&&"setInterval"in s},e.type=function(s){return s==null?String(s):t[r.call(s)]||"object"},e.isPlainObject=function(s){if(!s||o.type(s)!=="object"||s.nodeType||e.isWindow(s)||s.constructor&&!i.call(s,"constructor")&&!i.call(s.constructor.prototype,"isPrototypeOf"))return!1;var l;for(var a in s)l=a;return l===void 0||i.call(s,l)},e.isEmptyObject=function(s){for(var l in s)return!1;return!0},e.freezeObject=function(s){return Object.freeze?e.freezeObject=Object.freeze:e.freezeObject=function(l){return l},e.freezeObject(s)},e.supportsCanvas=(function(){var s=document.createElement("canvas");return!!(e.isFunction(s.getContext)&&s.getContext("2d"))})(),e.isCanvasTainted=function(s){var l=!1;try{s.getContext("2d").getImageData(0,0,1,1)}catch{l=!0}return l},e.supportsAddEventListener=(function(){return!!(document.documentElement.addEventListener&&document.addEventListener)})(),e.supportsRemoveEventListener=(function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)})(),e.supportsEventListenerOptions=(function(){var s=0;if(e.supportsAddEventListener)try{var l={get capture(){return s++,!1},get once(){return s++,!1},get passive(){return s++,!1}};window.addEventListener("test",null,l),window.removeEventListener("test",null,l)}catch{s=0}return s>=3})(),e.getCurrentPixelDensityRatio=function(){if(e.supportsCanvas){var s=document.createElement("canvas").getContext("2d"),l=window.devicePixelRatio||1,a=s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1;return Math.max(l,1)/a}else return 1},e.pixelDensityRatio=e.getCurrentPixelDensityRatio()})(o),(function(e){e.extend=function(){var a,u,h,c,d,m,v=arguments[0]||{},y=arguments.length,_=!1,E=1;for(typeof v=="boolean"&&(_=v,v=arguments[1]||{},E=2),typeof v!="object"&&!o.isFunction(v)&&(v={}),y===E&&(v=this,--E);E<y;E++)if(a=arguments[E],a!==null||a!==void 0)for(u in a){var S=Object.getOwnPropertyDescriptor(a,u);if(S!==void 0){if(S.get||S.set){Object.defineProperty(v,u,S);continue}c=S.value}else{e.console.warn('Could not copy inherited property "'+u+'".');continue}v!==c&&(_&&c&&(o.isPlainObject(c)||(d=o.isArray(c)))?(h=v[u],d?(d=!1,m=h&&o.isArray(h)?h:[]):m=h&&o.isPlainObject(h)?h:{},v[u]=o.extend(_,m,c)):c!==void 0&&(v[u]=c))}return v};var t=function(){if(typeof navigator!="object")return!1;var a=navigator.userAgent;return typeof a!="string"?!1:a.indexOf("iPhone")!==-1||a.indexOf("iPad")!==-1||a.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,maxTilesPerFrame:1,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,overlayPreserveContentDirection:!0,opacity:1,compositeOperation:null,drawer:["webgl","canvas","html"],drawerOptions:{webgl:{},canvas:{},html:{},custom:{}},preload:!1,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,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},delegate:function(a,u){return function(){var h=arguments;return h===void 0&&(h=[]),u.apply(a,h)}},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(a){return e._viewers.get(this.getElement(a))},getElement:function(a){return typeof a=="string"&&(a=document.getElementById(a)),a},getElementPosition:function(a){var u=new e.Point,h,c;for(a=e.getElement(a),h=e.getElementStyle(a).position==="fixed",c=l(a,h);c;)u.x+=a.offsetLeft,u.y+=a.offsetTop,h&&(u=u.plus(e.getPageScroll())),a=c,h=e.getElementStyle(a).position==="fixed",c=l(a,h);return u},getElementOffset:function(a){a=e.getElement(a);var u=a&&a.ownerDocument,h,c,d={top:0,left:0};return u?(h=u.documentElement,typeof a.getBoundingClientRect<"u"&&(d=a.getBoundingClientRect()),c=u===u.window?u:u.nodeType===9?u.defaultView||u.parentWindow:!1,new e.Point(d.left+(c.pageXOffset||h.scrollLeft)-(h.clientLeft||0),d.top+(c.pageYOffset||h.scrollTop)-(h.clientTop||0))):new e.Point},getElementSize:function(a){return a=e.getElement(a),new e.Point(a.clientWidth,a.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(a){return a=e.getElement(a),a.currentStyle}:function(a){return a=e.getElement(a),window.getComputedStyle(a,"")},getCssPropertyWithVendorPrefix:function(a){var u={};return e.getCssPropertyWithVendorPrefix=function(h){if(u[h]!==void 0)return u[h];var c=document.createElement("div").style,d=null;if(c[h]!==void 0)d=h;else for(var m=["Webkit","Moz","MS","O","webkit","moz","ms","o"],v=e.capitalizeFirstLetter(h),y=0;y<m.length;y++){var _=m[y]+v;if(c[_]!==void 0){d=_;break}}return u[h]=d,d},e.getCssPropertyWithVendorPrefix(a)},capitalizeFirstLetter:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},positiveModulo:function(a,u){var h=a%u;return h<0&&(h+=u),h},pointInElement:function(a,u){a=e.getElement(a);var h=e.getElementOffset(a),c=e.getElementSize(a);return u.x>=h.x&&u.x<h.x+c.x&&u.y<h.y+c.y&&u.y>=h.y},getMousePosition:function(a){if(typeof a.pageX=="number")e.getMousePosition=function(u){var h=new e.Point;return h.x=u.pageX,h.y=u.pageY,h};else if(typeof a.clientX=="number")e.getMousePosition=function(u){var h=new e.Point;return h.x=u.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h.y=u.clientY+document.body.scrollTop+document.documentElement.scrollTop,h};else throw new Error("Unknown event mouse position, no known technique.");return e.getMousePosition(a)},getPageScroll:function(){var a=document.documentElement||{},u=document.body||{};if(typeof window.pageXOffset=="number")e.getPageScroll=function(){return new e.Point(window.pageXOffset,window.pageYOffset)};else if(u.scrollLeft||u.scrollTop)e.getPageScroll=function(){return new e.Point(document.body.scrollLeft,document.body.scrollTop)};else if(a.scrollLeft||a.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(a){if(typeof window.scrollTo<"u")e.setPageScroll=function(c){window.scrollTo(c.x,c.y)};else{var u=e.getPageScroll();if(u.x===a.x&&u.y===a.y)return;document.body.scrollLeft=a.x,document.body.scrollTop=a.y;var h=e.getPageScroll();if(h.x!==u.x&&h.y!==u.y){e.setPageScroll=function(c){document.body.scrollLeft=c.x,document.body.scrollTop=c.y};return}if(document.documentElement.scrollLeft=a.x,document.documentElement.scrollTop=a.y,h=e.getPageScroll(),h.x!==u.x&&h.y!==u.y){e.setPageScroll=function(c){document.documentElement.scrollLeft=c.x,document.documentElement.scrollTop=c.y};return}e.setPageScroll=function(c){}}e.setPageScroll(a)},getWindowSize:function(){var a=document.documentElement||{},u=document.body||{};if(typeof window.innerWidth=="number")e.getWindowSize=function(){return new e.Point(window.innerWidth,window.innerHeight)};else if(a.clientWidth||a.clientHeight)e.getWindowSize=function(){return new e.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(u.clientWidth||u.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(a){a=e.getElement(a);var u=[e.makeNeutralElement("div"),e.makeNeutralElement("div"),e.makeNeutralElement("div")];return e.extend(u[0].style,{display:"table",height:"100%",width:"100%"}),e.extend(u[1].style,{display:"table-row"}),e.extend(u[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),u[0].appendChild(u[1]),u[1].appendChild(u[2]),u[2].appendChild(a),u[0]},makeNeutralElement:function(a){var u=document.createElement(a),h=u.style;return h.background="transparent none",h.border="none",h.margin="0px",h.padding="0px",h.position="static",u},now:function(){return Date.now?e.now=Date.now:e.now=function(){return new Date().getTime()},e.now()},makeTransparentImage:function(a){var u=e.makeNeutralElement("img");return u.src=a,u},setElementOpacity:function(a,u,h){var c,d;a=e.getElement(a),h&&!e.Browser.alpha&&(u=Math.round(u)),e.Browser.opacity?a.style.opacity=u<1?u:"":u<1?(c=Math.round(100*u),d="alpha(opacity="+c+")",a.style.filter=d):a.style.filter=""},setElementTouchActionNone:function(a){a=e.getElement(a),typeof a.style.touchAction<"u"?a.style.touchAction="none":typeof a.style.msTouchAction<"u"&&(a.style.msTouchAction="none")},setElementPointerEvents:function(a,u){a=e.getElement(a),typeof a.style<"u"&&typeof a.style.pointerEvents<"u"&&(a.style.pointerEvents=u)},setElementPointerEventsNone:function(a){e.setElementPointerEvents(a,"none")},addClass:function(a,u){a=e.getElement(a),a.className?(" "+a.className+" ").indexOf(" "+u+" ")===-1&&(a.className+=" "+u):a.className=u},indexOf:function(a,u,h){return Array.prototype.indexOf?this.indexOf=function(c,d,m){return c.indexOf(d,m)}:this.indexOf=function(c,d,m){var v,y=m||0,_;if(!c)throw new TypeError;if(_=c.length,_===0||y>=_)return-1;for(y<0&&(y=_-Math.abs(y)),v=y;v<_;v++)if(c[v]===d)return v;return-1},this.indexOf(a,u,h)},removeClass:function(a,u){var h,c=[],d;for(a=e.getElement(a),h=a.className.split(/\s+/),d=0;d<h.length;d++)h[d]&&h[d]!==u&&c.push(h[d]);a.className=c.join(" ")},normalizeEventListenerOptions:function(a){var u;return typeof a<"u"?typeof a=="boolean"?u=e.supportsEventListenerOptions?{capture:a}:a:u=e.supportsEventListenerOptions?a:typeof a.capture<"u"?a.capture:!1:u=e.supportsEventListenerOptions?{capture:!1}:!1,u},addEvent:(function(){if(e.supportsAddEventListener)return function(a,u,h,c){c=e.normalizeEventListenerOptions(c),a=e.getElement(a),a.addEventListener(u,h,c)};if(document.documentElement.attachEvent&&document.attachEvent)return function(a,u,h){a=e.getElement(a),a.attachEvent("on"+u,h)};throw new Error("No known event model.")})(),removeEvent:(function(){if(e.supportsRemoveEventListener)return function(a,u,h,c){c=e.normalizeEventListenerOptions(c),a=e.getElement(a),a.removeEventListener(u,h,c)};if(document.documentElement.detachEvent&&document.detachEvent)return function(a,u,h){a=e.getElement(a),a.detachEvent("on"+u,h)};throw new Error("No known event model.")})(),cancelEvent:function(a){a.preventDefault()},eventIsCanceled:function(a){return a.defaultPrevented},stopEvent:function(a){a.stopPropagation()},createCallback:function(a,u){console.error("The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.");var h=[],c;for(c=2;c<arguments.length;c++)h.push(arguments[c]);return function(){var d=h.concat([]),m;for(m=0;m<arguments.length;m++)d.push(arguments[m]);return u.apply(a,d)}},getUrlParameter:function(a){var u=s[a];return u||null},getUrlProtocol:function(a){var u=a.match(/^([a-z]+:)\/\//i);return u===null?window.location.protocol:u[1].toLowerCase()},createAjaxRequest:function(){if(window.XMLHttpRequest)return e.createAjaxRequest=function(){return new XMLHttpRequest},new XMLHttpRequest;throw new Error("Browser doesn't support XMLHttpRequest.")},makeAjaxRequest:function(a,u,h){var c,d,m,v;e.isPlainObject(a)&&(u=a.success,h=a.error,c=a.withCredentials,d=a.headers,m=a.responseType||null,v=a.postData||null,a=a.url);var y=e.getUrlProtocol(a),_=e.createAjaxRequest();if(!e.isFunction(u))throw new Error("makeAjaxRequest requires a success callback");_.onreadystatechange=function(){_.readyState===4&&(_.onreadystatechange=function(){},_.status>=200&&_.status<300||_.status===0&&y!=="http:"&&y!=="https:"?u(_):e.isFunction(h)?h(_):e.console.error("AJAX request returned %d: %s",_.status,a))};var E=v?"POST":"GET";try{if(_.open(E,a,!0),m&&(_.responseType=m),d)for(var S in d)Object.prototype.hasOwnProperty.call(d,S)&&d[S]&&_.setRequestHeader(S,d[S]);c&&(_.withCredentials=!0),_.send(v)}catch(P){e.console.error("%s while making AJAX request: %s",P.name,P.message),_.onreadystatechange=function(){},e.isFunction(h)&&h(_,P)}return _},jsonp:function(a){var u,h=a.url,c=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=a.callbackName||"openseadragon"+e.now(),m=window[d],v="$1"+d+"$2",y=a.param||"callback",_=a.callback;h=h.replace(/(=)\?(&|$)|\?\?/i,v),h+=(/\?/.test(h)?"&":"?")+y+"="+d,window[d]=function(E){if(m)window[d]=m;else try{delete window[d]}catch{}_&&e.isFunction(_)&&_(E)},u=document.createElement("script"),(a.async!==void 0||a.async!==!1)&&(u.async="async"),a.scriptCharset&&(u.charset=a.scriptCharset),u.src=h,u.onload=u.onreadystatechange=function(E,S){(S||!u.readyState||/loaded|complete/.test(u.readyState))&&(u.onload=u.onreadystatechange=null,c&&u.parentNode&&c.removeChild(u),u=void 0)},c.insertBefore(u,c.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(a){if(window.DOMParser)e.parseXml=function(u){var h=null,c;return c=new DOMParser,h=c.parseFromString(u,"text/xml"),h};else throw new Error("Browser doesn't support XML DOM.");return e.parseXml(a)},parseJSON:function(a){return e.parseJSON=window.JSON.parse,e.parseJSON(a)},imageFormatSupported:function(a){return a=a||"",!!i[a.toLowerCase()]},setImageFormatsSupported:function(a){e.extend(i,a)}});var r=function(a){};e.console=window.console||{log:r,debug:r,info:r,warn:r,error:r,assert:r},e.Browser={vendor:e.BROWSERS.UNKNOWN,version:0,alpha:!0};var i={avif:!0,bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0},s={};(function(){var a=navigator.appVersion,u=navigator.userAgent,h;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(u.substring(u.indexOf("MSIE")+5,u.indexOf(";",u.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(u.indexOf("Edge")>=0?(e.Browser.vendor=e.BROWSERS.EDGE,e.Browser.version=parseFloat(u.substring(u.indexOf("Edge")+5))):u.indexOf("Edg")>=0?(e.Browser.vendor=e.BROWSERS.CHROMEEDGE,e.Browser.version=parseFloat(u.substring(u.indexOf("Edg")+4))):u.indexOf("Firefox")>=0?(e.Browser.vendor=e.BROWSERS.FIREFOX,e.Browser.version=parseFloat(u.substring(u.indexOf("Firefox")+8))):u.indexOf("Safari")>=0?(e.Browser.vendor=u.indexOf("Chrome")>=0?e.BROWSERS.CHROME:e.BROWSERS.SAFARI,e.Browser.version=parseFloat(u.substring(u.substring(0,u.indexOf("Safari")).lastIndexOf("/")+1,u.indexOf("Safari")))):(h=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),h.exec(u)!==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(a);break}var c=window.location.search.substring(1),d=c.split("&"),m,v,y;for(y=0;y<d.length;y++)if(m=d[y],v=m.indexOf("="),v>0){var _=m.substring(0,v),E=m.substring(v+1);try{s[_]=decodeURIComponent(E)}catch{e.console.error("Ignoring malformed URL parameter: %s=%s",_,E)}}e.Browser.alpha=!(e.Browser.vendor===e.BROWSERS.CHROME&&e.Browser.version<2),e.Browser.opacity=!0,e.Browser.vendor===e.BROWSERS.IE&&e.console.error("Internet Explorer is not supported by OpenSeadragon")})(),(function(a){var u=a.requestAnimationFrame||a.mozRequestAnimationFrame||a.webkitRequestAnimationFrame||a.msRequestAnimationFrame,h=a.cancelAnimationFrame||a.mozCancelAnimationFrame||a.webkitCancelAnimationFrame||a.msCancelAnimationFrame;if(u&&h)e.requestAnimationFrame=function(){return u.apply(a,arguments)},e.cancelAnimationFrame=function(){return h.apply(a,arguments)};else{var c=[],d=[],m=0,v;e.requestAnimationFrame=function(y){return c.push([++m,y]),v||(v=setInterval(function(){if(c.length){var _=e.now(),E=d;for(d=c,c=E;d.length;)d.shift()[1](_)}else clearInterval(v),v=void 0},1e3/50)),m},e.cancelAnimationFrame=function(y){var _,E;for(_=0,E=c.length;_<E;_+=1)if(c[_][0]===y){c.splice(_,1);return}for(_=0,E=d.length;_<E;_+=1)if(d[_][0]===y){d.splice(_,1);return}}}})(window);function l(a,u){return u&&a!==document.body?document.body:a.offsetParent}})(o),(function(e,t){n.exports?n.exports=t():e.OpenSeadragon=t()})(Cl,function(){return o}),(function(e){class t{constructor(i){i||(i=[0,0,0,0,0,0,0,0,0]),this.values=i}static makeIdentity(){return new t([1,0,0,0,1,0,0,0,1])}static makeTranslation(i,s){return new t([1,0,0,0,1,0,i,s,1])}static makeRotation(i){var s=Math.cos(i),l=Math.sin(i);return new t([s,-l,0,l,s,0,0,0,1])}static makeScaling(i,s){return new t([i,0,0,0,s,0,0,0,1])}multiply(i){let s=this.values,l=i.values;var a=s[0],u=s[1],h=s[2],c=s[3],d=s[4],m=s[5],v=s[6],y=s[7],_=s[8],E=l[0],S=l[1],P=l[2],L=l[3],F=l[4],H=l[5],B=l[6],V=l[7],Y=l[8];return new t([E*a+S*c+P*v,E*u+S*d+P*y,E*h+S*m+P*_,L*a+F*c+H*v,L*u+F*d+H*y,L*h+F*m+H*_,B*a+V*c+Y*v,B*u+V*d+Y*y,B*h+V*m+Y*_])}}e.Mat3=t})(o),(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(r){return r.requestFullscreen().catch(function(i){e.console.error("Fullscreen request failed: ",i)})},t.exitFullScreen=function(){document.exitFullscreen().catch(function(r){e.console.error("Error while exiting fullscreen: ",r)})},t.fullScreenEventName="fullscreenchange",t.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.msFullscreenElement},t.requestFullScreen=function(r){return r.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(r){return r.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(r){return r.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(r){return r.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)})(o),(function(e){e.EventSource=function(){this.events={},this._rejectedEventList={}},e.EventSource.prototype={addOnceHandler:function(t,r,i,s,l){var a=this;s=s||1;var u=0,h=function(c){return u++,u===s&&a.removeHandler(t,h),r(c)};return this.addHandler(t,h,i,l)},addHandler:function(t,r,i,s){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var l=this.events[t];if(l||(this.events[t]=l=[]),r&&e.isFunction(r)){var a=l.length,u={handler:r,userData:i||null,priority:s||0};for(l[a]=u;a>0&&l[a-1].priority<l[a].priority;)l[a]=l[a-1],l[a-1]=u,a--}return!0},removeHandler:function(t,r){var i=this.events[t],s=[],l;if(i&&e.isArray(i)){for(l=0;l<i.length;l++)i[l].handler!==r&&s.push(i[l]);this.events[t]=s}},numberOfHandlers:function(t){var r=this.events[t];return r?r.length:0},removeAllHandlers:function(t){if(t)this.events[t]=[];else for(var r in this.events)this.events[r]=[]},getHandler:function(t){var r=this.events[t];return!r||!r.length?null:(r=r.length===1?[r[0]]:Array.apply(null,r),function(i,s){var l,a=r.length;for(l=0;l<a;l++)r[l]&&(s.eventSource=i,s.userData=r[l].userData,r[l].handler(s))})},raiseEvent:function(t,r){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var i=this.getHandler(t);return i&&i(this,r||{}),!0},rejectEventHandler(t,r=""){this._rejectedEventList[t]=r},allowEventHandler(t){delete this._rejectedEventList[t]}}})(o),(function(e){var t={};e.MouseTracker=function(g){var p=arguments;e.isPlainObject(g)||(g={element:p[0],clickTimeThreshold:p[1],clickDistThreshold:p[2]}),this.hash=Math.random(),this.element=e.getElement(g.element),this.clickTimeThreshold=g.clickTimeThreshold||e.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=g.clickDistThreshold||e.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=g.dblClickTimeThreshold||e.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=g.dblClickDistThreshold||e.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=g.userData||null,this.stopDelay=g.stopDelay||50,this.preProcessEventHandler=g.preProcessEventHandler||null,this.contextMenuHandler=g.contextMenuHandler||null,this.enterHandler=g.enterHandler||null,this.leaveHandler=g.leaveHandler||null,this.exitHandler=g.exitHandler||null,this.overHandler=g.overHandler||null,this.outHandler=g.outHandler||null,this.pressHandler=g.pressHandler||null,this.nonPrimaryPressHandler=g.nonPrimaryPressHandler||null,this.releaseHandler=g.releaseHandler||null,this.nonPrimaryReleaseHandler=g.nonPrimaryReleaseHandler||null,this.moveHandler=g.moveHandler||null,this.scrollHandler=g.scrollHandler||null,this.clickHandler=g.clickHandler||null,this.dblClickHandler=g.dblClickHandler||null,this.dragHandler=g.dragHandler||null,this.dragEndHandler=g.dragEndHandler||null,this.pinchHandler=g.pinchHandler||null,this.stopHandler=g.stopHandler||null,this.keyDownHandler=g.keyDownHandler||null,this.keyUpHandler=g.keyUpHandler||null,this.keyHandler=g.keyHandler||null,this.focusHandler=g.focusHandler||null,this.blurHandler=g.blurHandler||null;var w=this;t[this.hash]={click:function(x){P(w,x)},dblclick:function(x){L(w,x)},keydown:function(x){F(w,x)},keyup:function(x){H(w,x)},keypress:function(x){B(w,x)},focus:function(x){V(w,x)},blur:function(x){Y(w,x)},contextmenu:function(x){J(w,x)},wheel:function(x){re(w,x)},mousewheel:function(x){Z(w,x)},DOMMouseScroll:function(x){Z(w,x)},MozMousePixelScroll:function(x){Z(w,x)},losecapture:function(x){he(w,x)},mouseenter:function(x){X(w,x)},mouseleave:function(x){Ye(w,x)},mouseover:function(x){ct(w,x)},mouseout:function(x){Ue(w,x)},mousedown:function(x){k(w,x)},mouseup:function(x){te(w,x)},mousemove:function(x){Ke(w,x)},touchstart:function(x){pe(w,x)},touchend:function(x){ce(w,x)},touchmove:function(x){ve(w,x)},touchcancel:function(x){fe(w,x)},gesturestart:function(x){we(w,x)},gesturechange:function(x){He(w,x)},gotpointercapture:function(x){xe(w,x)},lostpointercapture:function(x){Xe(w,x)},pointerenter:function(x){X(w,x)},pointerleave:function(x){Ye(w,x)},pointerover:function(x){ct(w,x)},pointerout:function(x){Ue(w,x)},pointerdown:function(x){k(w,x)},pointerup:function(x){te(w,x)},pointermove:function(x){Ke(w,x)},pointercancel:function(x){Nt(w,x)},pointerupcaptured:function(x){de(w,x)},pointermovecaptured:function(x){St(w,x)},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."),g.startDisabled||this.setTracking(!0)},e.MouseTracker.prototype={destroy:function(){a(this),this.element=null,t[this.hash]=null,delete t[this.hash]},isTracking:function(){return t[this.hash].tracking},setTracking:function(g){return g?l(this):a(this),this},getActivePointersListByType:function(g){var p=t[this.hash],w,x=p?p.activePointersLists.length:0,C;for(w=0;w<x;w++)if(p.activePointersLists[w].type===g)return p.activePointersLists[w];return C=new e.MouseTracker.GesturePointList(g),p&&p.activePointersLists.push(C),C},getActivePointerCount:function(){var g=t[this.hash],p,w=g.activePointersLists.length,x=0;for(p=0;p<w;p++)x+=g.activePointersLists[p].getLength();return x},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 r=(function(){try{return window.self!==window.top}catch{return!0}})();function i(g){try{return g.addEventListener&&g.removeEventListener}catch{return!1}}e.MouseTracker.gesturePointVelocityTracker=(function(){var g=[],p=0,w=0,x=function(Q,W){return Q.hash.toString()+W.type+W.id.toString()},C=function(){var Q,W=g.length,oe,se,Qe=e.now(),Ut,zn,kn;for(Ut=Qe-w,w=Qe,Q=0;Q<W;Q++)oe=g[Q],se=oe.gPoint,se.direction=Math.atan2(se.currentPos.y-oe.lastPos.y,se.currentPos.x-oe.lastPos.x),zn=oe.lastPos.distanceTo(se.currentPos),oe.lastPos=se.currentPos,kn=1e3*zn/(Ut+1),se.speed=.75*kn+.25*se.speed},A=function(Q,W){var oe=x(Q,W);g.push({guid:oe,gPoint:W,lastPos:W.currentPos}),g.length===1&&(w=e.now(),p=window.setInterval(C,50))},N=function(Q,W){var oe=x(Q,W),se,Qe=g.length;for(se=0;se<Qe;se++)if(g[se].guid===oe){g.splice(se,1),Qe--,Qe===0&&window.clearInterval(p);break}};return{addPoint:A,removePoint:N}})(),e.MouseTracker.captureElement=document,e.MouseTracker.wheelEventName="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 g=document.createElement("div");return e.isFunction(g.setPointerCapture)&&e.isFunction(g.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 g=document.createElement("div");return e.isFunction(g.setCapture)&&e.isFunction(g.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(g){this._gPoints=[],this.type=g,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(g){return this._gPoints.push(g)},removeById:function(g){var p,w=this._gPoints.length;for(p=0;p<w;p++)if(this._gPoints[p].id===g){this._gPoints.splice(p,1);break}return this._gPoints.length},getByIndex:function(g){return g<this._gPoints.length?this._gPoints[g]:null},getById:function(g){var p,w=this._gPoints.length;for(p=0;p<w;p++)if(this._gPoints[p].id===g)return this._gPoints[p];return null},getPrimary:function(g){var p,w=this._gPoints.length;for(p=0;p<w;p++)if(this._gPoints[p].isPrimary)return this._gPoints[p];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 s(g){var p=t[g.hash],w,x,C,A,N,Q=p.activePointersLists.length;for(w=0;w<Q;w++)if(C=p.activePointersLists[w],C.getLength()>0){for(N=[],A=C.asArray(),x=0;x<A.length;x++)N.push(A[x]);for(x=0;x<N.length;x++)dt(g,C,N[x])}for(w=0;w<Q;w++)p.activePointersLists.pop();p.sentDragEvent=!1}function l(g){var p=t[g.hash],w,x;if(!p.tracking){for(x=0;x<e.MouseTracker.subscribeEvents.length;x++)w=e.MouseTracker.subscribeEvents[x],e.addEvent(g.element,w,p[w],w===e.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);s(g),p.tracking=!0}}function a(g){var p=t[g.hash],w,x;if(p.tracking){for(x=0;x<e.MouseTracker.subscribeEvents.length;x++)w=e.MouseTracker.subscribeEvents[x],e.removeEvent(g.element,w,p[w],!1);s(g),p.tracking=!1}}function u(g,p){var w=t[g.hash];if(p==="pointerevent")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(p==="mouse")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(p==="touch")return{upName:"touchend",upHandler:w.touchendcaptured,moveName:"touchmove",moveHandler:w.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function h(g,p){var w;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents)try{g.element.setPointerCapture(p.id)}catch{e.console.warn("setPointerCapture() called on invalid pointer ID");return}else g.element.setCapture(!0);else w=u(g,e.MouseTracker.havePointerEvents?"pointerevent":p.type),r&&i(window.top)&&e.addEvent(window.top,w.upName,w.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,w.upName,w.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,w.moveName,w.moveHandler,!0);R(g,p,!0)}function c(g,p){var w,x,C;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents){if(x=g.getActivePointersListByType(p.type),C=x.getById(p.id),!C||!C.captured)return;try{g.element.releasePointerCapture(p.id)}catch{}}else g.element.releaseCapture();else w=u(g,e.MouseTracker.havePointerEvents?"pointerevent":p.type),r&&i(window.top)&&e.removeEvent(window.top,w.upName,w.upHandler,!0),e.removeEvent(e.MouseTracker.captureElement,w.moveName,w.moveHandler,!0),e.removeEvent(e.MouseTracker.captureElement,w.upName,w.upHandler,!0);R(g,p,!1)}function d(g){return e.MouseTracker.havePointerEvents?g.pointerId:e.MouseTracker.mousePointerId}function m(g){return e.MouseTracker.havePointerEvents&&g.pointerType?g.pointerType:"mouse"}function v(g){return e.MouseTracker.havePointerEvents?g.isPrimary:!0}function y(g){return e.getMousePosition(g)}function _(g,p){return E(y(g),p)}function E(g,p){var w=e.getElementOffset(p);return g.minus(w)}function S(g,p){return new e.Point((g.x+p.x)/2,(g.y+p.y)/2)}function P(g,p){var w={originalEvent:p,eventType:"click",pointerType:"mouse",isEmulated:!1};T(g,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(p),w.stopPropagation&&e.stopEvent(p)}function L(g,p){var w={originalEvent:p,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};T(g,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(p),w.stopPropagation&&e.stopEvent(p)}function F(g,p){var w=null,x={originalEvent:p,eventType:"keydown",pointerType:"",isEmulated:!1};T(g,x),g.keyDownHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,keyCode:p.keyCode?p.keyCode:p.charCode,ctrl:p.ctrlKey,shift:p.shiftKey,alt:p.altKey,meta:p.metaKey,originalEvent:p,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.keyDownHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function H(g,p){var w=null,x={originalEvent:p,eventType:"keyup",pointerType:"",isEmulated:!1};T(g,x),g.keyUpHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,keyCode:p.keyCode?p.keyCode:p.charCode,ctrl:p.ctrlKey,shift:p.shiftKey,alt:p.altKey,meta:p.metaKey,originalEvent:p,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.keyUpHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function B(g,p){var w=null,x={originalEvent:p,eventType:"keypress",pointerType:"",isEmulated:!1};T(g,x),g.keyHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,keyCode:p.keyCode?p.keyCode:p.charCode,ctrl:p.ctrlKey,shift:p.shiftKey,alt:p.altKey,meta:p.metaKey,originalEvent:p,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.keyHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function V(g,p){var w={originalEvent:p,eventType:"focus",pointerType:"",isEmulated:!1};T(g,w),g.focusHandler&&!w.preventGesture&&g.focusHandler({eventSource:g,originalEvent:p,userData:g.userData})}function Y(g,p){var w={originalEvent:p,eventType:"blur",pointerType:"",isEmulated:!1};T(g,w),g.blurHandler&&!w.preventGesture&&g.blurHandler({eventSource:g,originalEvent:p,userData:g.userData})}function J(g,p){var w=null,x={originalEvent:p,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};T(g,x),g.contextMenuHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,position:E(y(p),g.element),originalEvent:x.originalEvent,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.contextMenuHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function re(g,p){ie(g,p,p)}function Z(g,p){var w={target:p.target||p.srcElement,type:"wheel",shiftKey:p.shiftKey||!1,clientX:p.clientX,clientY:p.clientY,pageX:p.pageX?p.pageX:p.clientX,pageY:p.pageY?p.pageY:p.clientY,deltaMode:p.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};e.MouseTracker.wheelEventName==="mousewheel"?w.deltaY=-p.wheelDelta/e.DEFAULT_SETTINGS.pixelsPerWheelLine:w.deltaY=p.detail,ie(g,w,p)}function ie(g,p,w){var x=0,C,A=null;x=p.deltaY?p.deltaY<0?1:-1:0,C={originalEvent:p,eventType:"wheel",pointerType:"mouse",isEmulated:p!==w},T(g,C),g.scrollHandler&&!C.preventGesture&&!C.defaultPrevented&&(A={eventSource:g,pointerType:"mouse",position:_(p,g.element),scroll:x,shift:p.shiftKey,isTouchEvent:!1,originalEvent:w,preventDefault:C.preventDefault||C.defaultPrevented,userData:g.userData},g.scrollHandler(A)),C.stopPropagation&&e.stopEvent(w),(A&&A.preventDefault||C.preventDefault&&!C.defaultPrevented)&&e.cancelEvent(w)}function he(g,p){var w={id:e.MouseTracker.mousePointerId,type:"mouse"},x={originalEvent:p,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};T(g,x),p.target===g.element&&R(g,w,!1),x.stopPropagation&&e.stopEvent(p)}function pe(g,p){var w,x,C=p.changedTouches.length,A,N=g.getActivePointersListByType("touch");w=e.now(),N.getLength()>p.touches.length-C&&e.console.warn("Tracked touch contact count doesn't match event.touches.length");var Q={originalEvent:p,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(T(g,Q),x=0;x<C;x++)A={id:p.changedTouches[x].identifier,type:"touch",isPrimary:N.getLength()===0,currentPos:y(p.changedTouches[x]),currentTime:w},O(g,Q,A),z(g,Q,A,0),R(g,A,!0);Q.preventDefault&&!Q.defaultPrevented&&e.cancelEvent(p),Q.stopPropagation&&e.stopEvent(p)}function ce(g,p){var w,x,C=p.changedTouches.length,A;w=e.now();var N={originalEvent:p,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(T(g,N),x=0;x<C;x++)A={id:p.changedTouches[x].identifier,type:"touch",currentPos:y(p.changedTouches[x]),currentTime:w},j(g,N,A,0),R(g,A,!1),M(g,N,A);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(p),N.stopPropagation&&e.stopEvent(p)}function ve(g,p){var w,x,C=p.changedTouches.length,A;w=e.now();var N={originalEvent:p,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(T(g,N),x=0;x<C;x++)A={id:p.changedTouches[x].identifier,type:"touch",currentPos:y(p.changedTouches[x]),currentTime:w},q(g,N,A);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(p),N.stopPropagation&&e.stopEvent(p)}function fe(g,p){var w=p.changedTouches.length,x,C,A={originalEvent:p,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(T(g,A),x=0;x<w;x++)C={id:p.changedTouches[x].identifier,type:"touch"},U(g,A,C);A.stopPropagation&&e.stopEvent(p)}function we(g,p){return e.eventIsCanceled(p)||p.preventDefault(),!1}function He(g,p){return e.eventIsCanceled(p)||p.preventDefault(),!1}function xe(g,p){var w={originalEvent:p,eventType:"gotpointercapture",pointerType:m(p),isEmulated:!1};T(g,w),p.target===g.element&&R(g,{id:p.pointerId,type:m(p)},!0),w.stopPropagation&&e.stopEvent(p)}function Xe(g,p){var w={originalEvent:p,eventType:"lostpointercapture",pointerType:m(p),isEmulated:!1};T(g,w),p.target===g.element&&R(g,{id:p.pointerId,type:m(p)},!1),w.stopPropagation&&e.stopEvent(p)}function X(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerenter",pointerType:w.type,isEmulated:!1};T(g,x),O(g,x,w)}function Ye(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerleave",pointerType:w.type,isEmulated:!1};T(g,x),M(g,x,w)}function ct(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerover",pointerType:w.type,isEmulated:!1};T(g,x),I(g,x,w),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function Ue(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerout",pointerType:w.type,isEmulated:!1};T(g,x),D(g,x,w),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function k(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x=e.MouseTracker.havePointerEvents&&w.type==="touch",C={originalEvent:p,eventType:"pointerdown",pointerType:w.type,isEmulated:!1};T(g,C),z(g,C,w,p.button),C.preventDefault&&!C.defaultPrevented&&e.cancelEvent(p),C.stopPropagation&&e.stopEvent(p),C.shouldCapture&&(x?R(g,w,!0):h(g,w))}function te(g,p){ye(g,p)}function de(g,p){var w=g.getActivePointersListByType(m(p));w.getById(p.pointerId)&&ye(g,p),e.stopEvent(p)}function ye(g,p){var w;w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()};var x={originalEvent:p,eventType:"pointerup",pointerType:w.type,isEmulated:!1};T(g,x),j(g,x,w,p.button),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p),x.shouldReleaseCapture&&(p.target===g.element?c(g,w):R(g,w,!1))}function Ke(g,p){kt(g,p)}function St(g,p){var w=g.getActivePointersListByType(m(p));w.getById(p.pointerId)&&kt(g,p),e.stopEvent(p)}function kt(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointermove",pointerType:w.type,isEmulated:!1};T(g,x),q(g,x,w),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function Nt(g,p){var w={id:p.pointerId,type:m(p)},x={originalEvent:p,eventType:"pointercancel",pointerType:w.type,isEmulated:!1};T(g,x),U(g,x,w),x.stopPropagation&&e.stopEvent(p)}function Pt(g,p){return p.speed=0,p.direction=0,p.contactPos=p.currentPos,p.contactTime=p.currentTime,p.lastPos=p.currentPos,p.lastTime=p.currentTime,g.add(p)}function dt(g,p,w){var x,C=p.getById(w.id);return C?(C.captured&&(e.console.warn("stopTrackingPointer() called on captured pointer"),c(g,C)),p.removeContact(),x=p.removeById(w.id)):x=p.getLength(),x}function f(g,p){switch(p.eventType){case"pointermove":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasGestureHandlers,p.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!1,p.stopPropagation=!1;break;case"pointerdown":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasGestureHandlers,p.stopPropagation=!1;break;case"pointerup":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasGestureHandlers,p.stopPropagation=!1;break;case"wheel":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasScrollHandler,p.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":p.isStoppable=!0,p.isCancelable=!1,p.preventDefault=!1,p.preventGesture=!1,p.stopPropagation=!1;break;case"click":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!!g.clickHandler,p.preventGesture=!1,p.stopPropagation=!1;break;case"dblclick":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!!g.dblClickHandler,p.preventGesture=!1,p.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:p.isStoppable=!1,p.isCancelable=!1,p.preventDefault=!1,p.preventGesture=!1,p.stopPropagation=!1;break}}function T(g,p){p.eventSource=g,p.eventPhase=p.originalEvent&&typeof p.originalEvent.eventPhase<"u"?p.originalEvent.eventPhase:0,p.defaultPrevented=e.eventIsCanceled(p.originalEvent),p.shouldCapture=!1,p.shouldReleaseCapture=!1,p.userData=g.userData,f(g,p),g.preProcessEventHandler&&g.preProcessEventHandler(p)}function R(g,p,w){var x=g.getActivePointersListByType(p.type),C=x.getById(p.id);C?w&&!C.captured?(C.captured=!0,x.captureCount++):!w&&C.captured&&(C.captured=!1,x.captureCount--,x.captureCount<0&&(x.captureCount=0,e.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):e.console.warn("updatePointerCaptured() called on untracked pointer")}function O(g,p,w){var x=g.getActivePointersListByType(w.type),C;C=x.getById(w.id),C?(C.insideElement=!0,C.lastPos=C.currentPos,C.lastTime=C.currentTime,C.currentPos=w.currentPos,C.currentTime=w.currentTime,w=C):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(x,w)),g.enterHandler&&g.enterHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData})}function M(g,p,w){var x=g.getActivePointersListByType(w.type),C,A;C=x.getById(w.id),C?(C.captured?(C.insideElement=!1,C.lastPos=C.currentPos,C.lastTime=C.currentTime,C.currentPos=w.currentPos,C.currentTime=w.currentTime):dt(g,x,C),w=C):(w.captured=!1,w.insideElementPressed=!1),(g.leaveHandler||g.exitHandler)&&(A={eventSource:g,pointerType:w.type,position:w.currentPos&&E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData},g.leaveHandler&&g.leaveHandler(A),g.exitHandler&&g.exitHandler(A))}function I(g,p,w){var x,C;x=g.getActivePointersListByType(w.type),C=x.getById(w.id),C?w=C:(w.captured=!1,w.insideElementPressed=!1),g.overHandler&&g.overHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData})}function D(g,p,w){var x,C;x=g.getActivePointersListByType(w.type),C=x.getById(w.id),C?w=C:(w.captured=!1,w.insideElementPressed=!1),g.outHandler&&g.outHandler({eventSource:g,pointerType:w.type,position:w.currentPos&&E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData})}function z(g,p,w,x){var C=t[g.hash],A=g.getActivePointersListByType(w.type),N;if(typeof p.originalEvent.buttons<"u"?A.buttons=p.originalEvent.buttons:x===0?A.buttons|=1:x===1?A.buttons|=4:x===2?A.buttons|=2:x===3?A.buttons|=8:x===4?A.buttons|=16:x===5&&(A.buttons|=32),x!==0){p.shouldCapture=!1,p.shouldReleaseCapture=!1,g.nonPrimaryPressHandler&&!p.preventGesture&&!p.defaultPrevented&&(p.preventDefault=!0,g.nonPrimaryPressHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),button:x,buttons:A.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}));return}N=A.getById(w.id),N?(N.insideElementPressed=!0,N.insideElement=!0,N.originalTarget=p.originalEvent.target,N.contactPos=w.currentPos,N.contactTime=w.currentTime,N.lastPos=N.currentPos,N.lastTime=N.currentTime,N.currentPos=w.currentPos,N.currentTime=w.currentTime,w=N):(w.captured=!1,w.insideElementPressed=!0,w.insideElement=!0,w.originalTarget=p.originalEvent.target,Pt(A,w)),A.addContact(),!p.preventGesture&&!p.defaultPrevented?(p.shouldCapture=!0,p.shouldReleaseCapture=!1,p.preventDefault=!0,(g.dragHandler||g.dragEndHandler||g.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.addPoint(g,w),A.contacts===1?g.pressHandler&&!p.preventGesture&&g.pressHandler({eventSource:g,pointerType:w.type,position:E(w.contactPos,g.element),buttons:A.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}):A.contacts===2&&g.pinchHandler&&w.type==="touch"&&(C.pinchGPoints=A.asArray(),C.lastPinchDist=C.currentPinchDist=C.pinchGPoints[0].currentPos.distanceTo(C.pinchGPoints[1].currentPos),C.lastPinchCenter=C.currentPinchCenter=S(C.pinchGPoints[0].currentPos,C.pinchGPoints[1].currentPos))):(p.shouldCapture=!1,p.shouldReleaseCapture=!1)}function j(g,p,w,x){var C=t[g.hash],A=g.getActivePointersListByType(w.type),N,Q,W,oe=!1,se;if(typeof p.originalEvent.buttons<"u"?A.buttons=p.originalEvent.buttons:x===0?A.buttons^=-2:x===1?A.buttons^=-5:x===2?A.buttons^=-3:x===3?A.buttons^=-9:x===4?A.buttons^=-17:x===5&&(A.buttons^=-33),p.shouldCapture=!1,x!==0){p.shouldReleaseCapture=!1,g.nonPrimaryReleaseHandler&&!p.preventGesture&&!p.defaultPrevented&&(p.preventDefault=!0,g.nonPrimaryReleaseHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),button:x,buttons:A.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}));return}W=A.getById(w.id),W?(A.removeContact(),W.captured&&(oe=!0),W.lastPos=W.currentPos,W.lastTime=W.currentTime,W.currentPos=w.currentPos,W.currentTime=w.currentTime,W.insideElement||dt(g,A,W),N=W.currentPos,Q=W.currentTime):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(A,w),W=w),!p.preventGesture&&!p.defaultPrevented&&(oe?(p.shouldReleaseCapture=!0,p.preventDefault=!0,(g.dragHandler||g.dragEndHandler||g.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.removePoint(g,W),A.contacts===0?(g.releaseHandler&&N&&g.releaseHandler({eventSource:g,pointerType:W.type,position:E(N,g.element),buttons:A.buttons,insideElementPressed:W.insideElementPressed,insideElementReleased:W.insideElement,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),g.dragEndHandler&&C.sentDragEvent&&g.dragEndHandler({eventSource:g,pointerType:W.type,position:E(W.currentPos,g.element),speed:W.speed,direction:W.direction,shift:p.originalEvent.shiftKey,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),C.sentDragEvent=!1,(g.clickHandler||g.dblClickHandler)&&W.insideElement&&(se=Q-W.contactTime<=g.clickTimeThreshold&&W.contactPos.distanceTo(N)<=g.clickDistThreshold,g.clickHandler&&g.clickHandler({eventSource:g,pointerType:W.type,position:E(W.currentPos,g.element),quick:se,shift:p.originalEvent.shiftKey,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,originalTarget:W.originalTarget,userData:g.userData}),g.dblClickHandler&&se&&(A.clicks++,A.clicks===1?(C.lastClickPos=N,C.dblClickTimeOut=setTimeout(function(){A.clicks=0},g.dblClickTimeThreshold)):A.clicks===2&&(clearTimeout(C.dblClickTimeOut),A.clicks=0,C.lastClickPos.distanceTo(N)<=g.dblClickDistThreshold&&g.dblClickHandler({eventSource:g,pointerType:W.type,position:E(W.currentPos,g.element),shift:p.originalEvent.shiftKey,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),C.lastClickPos=null)))):A.contacts===2&&g.pinchHandler&&W.type==="touch"&&(C.pinchGPoints=A.asArray(),C.lastPinchDist=C.currentPinchDist=C.pinchGPoints[0].currentPos.distanceTo(C.pinchGPoints[1].currentPos),C.lastPinchCenter=C.currentPinchCenter=S(C.pinchGPoints[0].currentPos,C.pinchGPoints[1].currentPos))):(p.shouldReleaseCapture=!1,g.releaseHandler&&N&&(g.releaseHandler({eventSource:g,pointerType:W.type,position:E(N,g.element),buttons:A.buttons,insideElementPressed:W.insideElementPressed,insideElementReleased:W.insideElement,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),p.preventDefault=!0)))}function q(g,p,w){var x=t[g.hash],C=g.getActivePointersListByType(w.type),A,N,Q;if(typeof p.originalEvent.buttons<"u"&&(C.buttons=p.originalEvent.buttons),A=C.getById(w.id),A)A.lastPos=A.currentPos,A.lastTime=A.currentTime,A.currentPos=w.currentPos,A.currentTime=w.currentTime;else return;p.shouldCapture=!1,p.shouldReleaseCapture=!1,g.stopHandler&&w.type==="mouse"&&(clearTimeout(g.stopTimeOut),g.stopTimeOut=setTimeout(function(){K(g,p.originalEvent,w.type)},g.stopDelay)),C.contacts===0?g.moveHandler&&g.moveHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:C.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}):C.contacts===1?(g.moveHandler&&(A=C.asArray()[0],g.moveHandler({eventSource:g,pointerType:A.type,position:E(A.currentPos,g.element),buttons:C.buttons,isTouchEvent:A.type==="touch",originalEvent:p.originalEvent,userData:g.userData})),g.dragHandler&&!p.preventGesture&&!p.defaultPrevented&&(A=C.asArray()[0],Q=A.currentPos.minus(A.lastPos),g.dragHandler({eventSource:g,pointerType:A.type,position:E(A.currentPos,g.element),buttons:C.buttons,delta:Q,speed:A.speed,direction:A.direction,shift:p.originalEvent.shiftKey,isTouchEvent:A.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),p.preventDefault=!0,x.sentDragEvent=!0)):C.contacts===2&&(g.moveHandler&&(N=C.asArray(),g.moveHandler({eventSource:g,pointerType:N[0].type,position:E(S(N[0].currentPos,N[1].currentPos),g.element),buttons:C.buttons,isTouchEvent:N[0].type==="touch",originalEvent:p.originalEvent,userData:g.userData})),g.pinchHandler&&w.type==="touch"&&!p.preventGesture&&!p.defaultPrevented&&(Q=x.pinchGPoints[0].currentPos.distanceTo(x.pinchGPoints[1].currentPos),Q!==x.currentPinchDist&&(x.lastPinchDist=x.currentPinchDist,x.currentPinchDist=Q,x.lastPinchCenter=x.currentPinchCenter,x.currentPinchCenter=S(x.pinchGPoints[0].currentPos,x.pinchGPoints[1].currentPos),g.pinchHandler({eventSource:g,pointerType:"touch",gesturePoints:x.pinchGPoints,lastCenter:E(x.lastPinchCenter,g.element),center:E(x.currentPinchCenter,g.element),lastDistance:x.lastPinchDist,distance:x.currentPinchDist,shift:p.originalEvent.shiftKey,originalEvent:p.originalEvent,userData:g.userData}),p.preventDefault=!0)))}function U(g,p,w){var x=g.getActivePointersListByType(w.type),C;C=x.getById(w.id),C&&dt(g,x,C)}function K(g,p,w){g.stopHandler&&g.stopHandler({eventSource:g,pointerType:w,position:_(p,g.element),buttons:g.getActivePointersListByType(w).buttons,isTouchEvent:w==="touch",originalEvent:p,userData:g.userData})}})(o),(function(e){e.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},e.Control=function(t,r,i){var s=t.parentNode;typeof r=="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"),r={anchor:r}),r.attachToViewer=typeof r.attachToViewer>"u"?!0:r.attachToViewer,this.autoFade=typeof r.autoFade>"u"?!0:r.autoFade,this.element=t,this.anchor=r.anchor,this.container=i,this.anchor===e.ControlAnchor.ABSOLUTE?(this.wrapper=e.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof r.top=="number"?r.top+"px":r.top,this.wrapper.style.left=typeof r.left=="number"?r.left+"px":r.left,this.wrapper.style.height=typeof r.height=="number"?r.height+"px":r.height,this.wrapper.style.width=typeof r.width=="number"?r.width+"px":r.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),r.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):s.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){e.setElementOpacity(this.wrapper,t,!0)}}})(o),(function(e){e.ControlDock=function(r){var i=["topleft","topright","bottomright","bottomleft"],s,l;for(e.extend(!0,this,{id:"controldock-"+e.now()+"-"+Math.floor(Math.random()*1e6),container:e.makeNeutralElement("div"),controls:[]},r),this.container.onsubmit=function(){return!1},this.element&&(this.element=e.getElement(this.element),this.element.appendChild(this.container),e.getElementStyle(this.element).position==="static"&&(this.element.style.position="relative"),this.container.style.width="100%",this.container.style.height="100%"),l=0;l<i.length;l++)s=i[l],this.controls[s]=e.makeNeutralElement("div"),this.controls[s].style.position="absolute",s.match("left")&&(this.controls[s].style.left="0px"),s.match("right")&&(this.controls[s].style.right="0px"),s.match("top")&&(this.controls[s].style.top="0px"),s.match("bottom")&&(this.controls[s].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(r,i){r=e.getElement(r);var s=null;if(!(t(this,r)>=0)){switch(i.anchor){case e.ControlAnchor.TOP_RIGHT:s=this.controls.topright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingTop="0px";break;case e.ControlAnchor.BOTTOM_RIGHT:s=this.controls.bottomright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingBottom="0px";break;case e.ControlAnchor.BOTTOM_LEFT:s=this.controls.bottomleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingBottom="0px";break;case e.ControlAnchor.TOP_LEFT:s=this.controls.topleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingTop="0px";break;case e.ControlAnchor.ABSOLUTE:s=this.container,r.style.margin="0px",r.style.padding="0px";break;default:case e.ControlAnchor.NONE:s=this.container,r.style.margin="0px",r.style.padding="0px";break}this.controls.push(new e.Control(r,i,s)),r.style.display="inline-block"}},removeControl:function(r){r=e.getElement(r);var i=t(this,r);return i>=0&&(this.controls[i].destroy(),this.controls.splice(i,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var r;for(r=this.controls.length-1;r>=0;r--)if(this.controls[r].isVisible())return!0;return!1},setControlsEnabled:function(r){var i;for(i=this.controls.length-1;i>=0;i--)this.controls[i].setVisible(r);return this}};function t(r,i){var s=r.controls,l;for(l=s.length-1;l>=0;l--)if(s[l].element===i)return l;return-1}})(o),(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}}})})(o),(function(e){var t={},r=1;e.Viewer=function(f){var T=arguments,R=this,O;e.isPlainObject(f)||(f={id:T[0],xmlPath:T.length>1?T[1]:void 0,prefixUrl:T.length>2?T[2]:void 0,controls:T.length>3?T[3]:void 0,overlays:T.length>4?T[4]:void 0}),f.config&&(e.extend(!0,f,f.config),delete f.config);let M=["useCanvas"];if(f.drawerOptions=Object.assign({},M.reduce((D,z)=>(D[z]=f[z],delete f[z],D),{}),f.drawerOptions),e.extend(!0,this,{id:f.id,hash:f.hash||r++,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,f),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");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(D){var z=e.getString("Errors.OpenFailed",D.eventSource,D.message);R._showMessage(z)}),e.ControlDock.call(this,f),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(D){D.width="100%",D.height="100%",D.overflow="hidden",D.position="absolute",D.top="0px",D.left="0px"})(this.canvas.style),e.setElementTouchActionNone(this.canvas),f.tabIndex!==""&&(this.canvas.tabIndex=f.tabIndex===void 0?0:f.tabIndex),this.container.className="openseadragon-container",(function(D){D.width="100%",D.height="100%",D.position="relative",D.overflow="hidden",D.left="0px",D.top="0px",D.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,_),keyDownHandler:e.delegate(this,E),keyHandler:e.delegate(this,S),clickHandler:e.delegate(this,P),dblClickHandler:e.delegate(this,L),dragHandler:e.delegate(this,F),dragEndHandler:e.delegate(this,H),enterHandler:e.delegate(this,B),leaveHandler:e.delegate(this,V),pressHandler:e.delegate(this,Y),releaseHandler:e.delegate(this,J),nonPrimaryPressHandler:e.delegate(this,re),nonPrimaryReleaseHandler:e.delegate(this,Z),scrollHandler:e.delegate(this,ce),pinchHandler:e.delegate(this,ie),focusHandler:e.delegate(this,he),blurHandler:e.delegate(this,pe)}),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,ve),leaveHandler:e.delegate(this,fe)}),this.toolbar&&(this.toolbar=new e.ControlDock({element:this.toolbar})),this.bindStandardControls(),t[this.hash].prevContainerSize=i(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){t[R.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new e.World({viewer:this}),this.world.addHandler("add-item",function(D){R.source=R.world.getItemAt(0).source,t[R.hash].forceRedraw=!0,R._updateRequestId||(R._updateRequestId=u(R,we))}),this.world.addHandler("remove-item",function(D){R.world.getItemCount()?R.source=R.world.getItemAt(0).source:R.source=null,t[R.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(D){R.viewport&&R.viewport._setContentBounds(R.world.getHomeBounds(),R.world.getContentFactor())}),this.world.addHandler("item-index-change",function(D){R.source=R.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,overlayPreserveContentDirection:this.overlayPreserveContentDirection,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:f.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay}),this.tileCache=new e.TileCache({maxImageCacheCount:this.maxImageCacheCount}),Object.prototype.hasOwnProperty.call(this.drawerOptions,"useCanvas")&&(e.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)'),this.drawerOptions.useCanvas||(this.drawer=e.HTMLDrawer),delete this.drawerOptions.useCanvas);let I=Array.isArray(this.drawer)?this.drawer:[this.drawer];I.length===0&&(I=[e.DEFAULT_SETTINGS.drawer].flat(),e.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const D of I)if(this.requestDrawer(D,{mainDrawer:!0,redrawImmediately:!1}))break;if(!this.drawer)throw e.console.error("No drawer could be created!"),"Error with creating the selected drawer(s)";for(this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),this.overlaysContainer=e.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(O=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(O,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(O=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(O,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,drawer:this.drawer.getType(),loadTilesWithAjax:this.loadTilesWithAjax,ajaxHeaders:this.ajaxHeaders,ajaxWithCredentials:this.ajaxWithCredentials})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),O=0;O<this.customControls.length;O++)this.addControl(this.customControls[O].id,{anchor:this.customControls[O].anchor});e.requestAnimationFrame(function(){c(R)}),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(f){return e.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(f)},openTileSource:function(f){return e.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(f)},get buttons(){return e.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(f,T){var R=this;if(this.close(),!f)return this;if(this.sequenceMode&&e.isArray(f))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof T<"u"&&!isNaN(T)&&(this.initialPage=T),this.tileSources=f,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(f)||(f=[f]),!f.length)return this;this._opening=!0;for(var O=f.length,M=0,I=0,D,z=function(){if(M+I===O)if(M){(R._firstOpen||!R.preserveViewport)&&(R.viewport.goHome(!0),R.viewport.update()),R._firstOpen=!1;var U=f[0];if(U.tileSource&&(U=U.tileSource),R.overlays&&!R.preserveOverlays)for(var K=0;K<R.overlays.length;K++)R.currentOverlays[K]=l(R,R.overlays[K]);R._drawOverlays(),R._opening=!1,R.raiseEvent("open",{source:U})}else R._opening=!1,R.raiseEvent("open-failed",D)},j=function(U){(!e.isPlainObject(U)||!U.tileSource)&&(U={tileSource:U}),U.index!==void 0&&(e.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete U.index),U.collectionImmediately===void 0&&(U.collectionImmediately=!0);var K=U.success;U.success=function(p){if(M++,U.tileSource.overlays)for(var w=0;w<U.tileSource.overlays.length;w++)R.addOverlay(U.tileSource.overlays[w]);K&&K(p),z()};var g=U.error;U.error=function(p){I++,D||(D=p),g&&g(p),z()},R.addTiledImage(U)},q=0;q<f.length;q++)j(f[q]);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()}},requestDrawer(f,T){const R={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};T=e.extend(!0,R,T);const O=T.mainDrawer,M=T.redrawImmediately,I=T.drawerOptions,D=this.drawer;let z=null;if(f&&f.prototype instanceof e.DrawerBase?(z=f,f="custom"):typeof f=="string"&&(z=e.determineDrawer(f)),z||e.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),z&&z.isSupported()){D&&O&&D.destroy();const j=new z({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:I||this.drawerOptions[f]});return O&&(this.drawer=j,M&&this.forceRedraw()),j}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(f){return this.innerTracker.setTracking(f),this.outerTracker.setTracking(f),this.raiseEvent("mouse-enabled",{enabled:f}),this},areControlsEnabled:function(){var f=this.controls.length,T;for(T=0;T<this.controls.length;T++)f=f&&this.controls[T].isVisible();return f},setControlsEnabled:function(f){return f?m(this):c(this),this.raiseEvent("controls-enabled",{enabled:f}),this},setDebugMode:function(f){for(var T=0;T<this.world.getItemCount();T++)this.world.getItemAt(T).debugMode=f;this.debugMode=f,this.forceRedraw()},setAjaxHeaders:function(f,T){if(f===null&&(f={}),!e.isPlainObject(f)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(T===void 0&&(T=!0),this.ajaxHeaders=f,T){for(var R=0;R<this.world.getItemCount();R++)this.world.getItemAt(R)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var O in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[O].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(f){this.buttonGroup.addButton(f)},isFullPage:function(){return t[this.hash]&&t[this.hash].fullPage},setFullPage:function(f){var T=document.body,R=T.style,O=document.documentElement.style,M=this,I,D;if(f===this.isFullPage())return this;var z={fullPage:f,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",z),z.preventDefaultAction)return this;if(f&&this.element){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=R.margin,this.docMargin=O.margin,R.margin="0",O.margin="0",this.bodyPadding=R.padding,this.docPadding=O.padding,R.padding="0",O.padding="0",this.bodyWidth=R.width,this.docWidth=O.width,R.width="100%",O.width="100%",this.bodyHeight=R.height,this.docHeight=O.height,R.height="100%",O.height="100%",this.bodyDisplay=R.display,R.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,I=T.childNodes.length,D=0;D<I;D++)this.previousBody.push(T.childNodes[0]),T.removeChild(T.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,T.appendChild(this.toolbar.element),e.addClass(this.toolbar.element,"fullpage")),e.addClass(this.element,"fullpage"),T.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,ve)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,R.margin=this.bodyMargin,O.margin=this.docMargin,R.padding=this.bodyPadding,O.padding=this.docPadding,R.width=this.bodyWidth,O.width=this.docWidth,R.height=this.bodyHeight,O.height=this.docHeight,R.display=this.bodyDisplay,T.removeChild(this.element),I=this.previousBody.length,D=0;D<I;D++)T.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&&(T.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 j=0,q=function(){e.setPageScroll(M.pageScroll);var U=e.getPageScroll();j++,j<10&&(U.x!==M.pageScroll.x||U.y!==M.pageScroll.y)&&e.requestAnimationFrame(q)};e.requestAnimationFrame(q),t[this.hash].fullPage=!1,e.delegate(this,fe)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:f}),this},setFullScreen:function(f){var T=this;if(!e.supportsFullScreen)return this.setFullPage(f);if(e.isFullScreen()===f)return this;var R={fullScreen:f,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",R),R.preventDefaultAction)return this;if(f){if(this.setFullPage(!0),!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width,this.fullPageStyleHeight=this.element.style.height,this.element.style.width="100%",this.element.style.height="100%";var O=function(){var M=e.isFullScreen();M||(e.removeEvent(document,e.fullScreenEventName,O),e.removeEvent(document,e.fullScreenErrorEventName,O),T.setFullPage(!1),T.isFullPage()&&(T.element.style.width=T.fullPageStyleWidth,T.element.style.height=T.fullPageStyleHeight)),T.navigator&&T.viewport&&setTimeout(function(){T.navigator.update(T.viewport)}),T.raiseEvent("full-screen",{fullScreen:M})};e.addEvent(document,e.fullScreenEventName,O),e.addEvent(document,e.fullScreenErrorEventName,O),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(f){return this.container.style.visibility=f?"":"hidden",this.raiseEvent("visible",{visible:f}),this},addTiledImage:function(f){e.console.assert(f,"[Viewer.addTiledImage] options is required"),e.console.assert(f.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),e.console.assert(!f.replace||f.index>-1&&f.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var T=this;f.replace&&(f.replaceItem=T.world.getItemAt(f.index)),this._hideMessage(),f.placeholderFillStyle===void 0&&(f.placeholderFillStyle=this.placeholderFillStyle),f.opacity===void 0&&(f.opacity=this.opacity),f.preload===void 0&&(f.preload=this.preload),f.compositeOperation===void 0&&(f.compositeOperation=this.compositeOperation),f.crossOriginPolicy===void 0&&(f.crossOriginPolicy=f.tileSource.crossOriginPolicy!==void 0?f.tileSource.crossOriginPolicy:this.crossOriginPolicy),f.ajaxWithCredentials===void 0&&(f.ajaxWithCredentials=this.ajaxWithCredentials),f.loadTilesWithAjax===void 0&&(f.loadTilesWithAjax=this.loadTilesWithAjax),e.isPlainObject(f.ajaxHeaders)||(f.ajaxHeaders={});var R={options:f};function O(D){for(var z=0;z<T._loadQueue.length;z++)if(T._loadQueue[z]===R){T._loadQueue.splice(z,1);break}T._loadQueue.length===0&&M(R),T.raiseEvent("add-item-failed",D),f.error&&f.error(D)}function M(D){T.collectionMode&&(T.world.arrange({immediately:D.options.collectionImmediately,rows:T.collectionRows,columns:T.collectionColumns,layout:T.collectionLayout,tileSize:T.collectionTileSize,tileMargin:T.collectionTileMargin}),T.world.setAutoRefigureSizes(!0))}if(e.isArray(f.tileSource)){setTimeout(function(){O({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:f.tileSource,options:f})});return}this._loadQueue.push(R);function I(){for(var D,z,j;T._loadQueue.length&&(D=T._loadQueue[0],!!D.tileSource);){if(T._loadQueue.splice(0,1),D.options.replace){var q=T.world.getIndexOfItem(D.options.replaceItem);q!==-1&&(D.options.index=q),T.world.removeItem(D.options.replaceItem)}z=new e.TiledImage({viewer:T,source:D.tileSource,viewport:T.viewport,drawer:T.drawer,tileCache:T.tileCache,imageLoader:T.imageLoader,x:D.options.x,y:D.options.y,width:D.options.width,height:D.options.height,fitBounds:D.options.fitBounds,fitBoundsPlacement:D.options.fitBoundsPlacement,clip:D.options.clip,placeholderFillStyle:D.options.placeholderFillStyle,opacity:D.options.opacity,preload:D.options.preload,degrees:D.options.degrees,flipped:D.options.flipped,compositeOperation:D.options.compositeOperation,springStiffness:T.springStiffness,animationTime:T.animationTime,minZoomImageRatio:T.minZoomImageRatio,wrapHorizontal:T.wrapHorizontal,wrapVertical:T.wrapVertical,maxTilesPerFrame:T.maxTilesPerFrame,immediateRender:T.immediateRender,blendTime:T.blendTime,alwaysBlend:T.alwaysBlend,minPixelRatio:T.minPixelRatio,smoothTileEdgesMinZoom:T.smoothTileEdgesMinZoom,iOSDevice:T.iOSDevice,crossOriginPolicy:D.options.crossOriginPolicy,ajaxWithCredentials:D.options.ajaxWithCredentials,loadTilesWithAjax:D.options.loadTilesWithAjax,ajaxHeaders:D.options.ajaxHeaders,debugMode:T.debugMode,subPixelRoundingForTransparency:T.subPixelRoundingForTransparency}),T.collectionMode&&T.world.setAutoRefigureSizes(!1),T.navigator&&(j=e.extend({},D.options,{replace:!1,originalTiledImage:z,tileSource:D.tileSource}),T.navigator.addTiledImage(j)),T.world.addItem(z,{index:D.options.index}),T._loadQueue.length===0&&M(D),T.world.getItemCount()===1&&!T.preserveViewport&&T.viewport.goHome(!0),D.options.success&&D.options.success({item:z})}}s(this,f.tileSource,f,function(D){R.tileSource=D,I()},function(D){D.options=f,O(D),I()})},addSimpleImage:function(f){e.console.assert(f,"[Viewer.addSimpleImage] options is required"),e.console.assert(f.url,"[Viewer.addSimpleImage] options.url is required");var T=e.extend({},f,{tileSource:{type:"image",url:f.url}});delete T.url,this.addTiledImage(T)},addLayer:function(f){var T=this;e.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var R=e.extend({},f,{success:function(O){T.raiseEvent("add-layer",{options:f,drawer:O.item})},error:function(O){T.raiseEvent("add-layer-failed",O)}});return this.addTiledImage(R),this},getLayerAtLevel:function(f){return e.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(f)},getLevelOfLayer:function(f){return e.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(f)},getLayersCount:function(){return e.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(f,T){return e.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(f,T)},removeLayer:function(f){return e.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(f)},forceRedraw:function(){return t[this.hash].forceRedraw=!0,this},forceResize:function(){t[this.hash].needsResize=!0,t[this.hash].forceResize=!0},bindSequenceControls:function(){var f=e.delegate(this,v),T=e.delegate(this,y),R=e.delegate(this,this.goToNextPage),O=e.delegate(this,this.goToPreviousPage),M=this.navImages,I=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(I=!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:X(this.prefixUrl,M.previous.REST),srcGroup:X(this.prefixUrl,M.previous.GROUP),srcHover:X(this.prefixUrl,M.previous.HOVER),srcDown:X(this.prefixUrl,M.previous.DOWN),onRelease:O,onFocus:f,onBlur:T}),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:X(this.prefixUrl,M.next.REST),srcGroup:X(this.prefixUrl,M.next.GROUP),srcHover:X(this.prefixUrl,M.next.HOVER),srcDown:X(this.prefixUrl,M.next.DOWN),onRelease:R,onFocus:f,onBlur:T}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),I&&(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 f=e.delegate(this,Ye),T=e.delegate(this,Ue),R=e.delegate(this,de),O=e.delegate(this,ct),M=e.delegate(this,ye),I=e.delegate(this,St),D=e.delegate(this,kt),z=e.delegate(this,Nt),j=e.delegate(this,Pt),q=e.delegate(this,dt),U=e.delegate(this,v),K=e.delegate(this,y),g=this.navImages,p=[],w=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(w=!1),this.showZoomControl&&(p.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:X(this.prefixUrl,g.zoomIn.REST),srcGroup:X(this.prefixUrl,g.zoomIn.GROUP),srcHover:X(this.prefixUrl,g.zoomIn.HOVER),srcDown:X(this.prefixUrl,g.zoomIn.DOWN),onPress:f,onRelease:T,onClick:R,onEnter:f,onExit:T,onFocus:U,onBlur:K})),p.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:X(this.prefixUrl,g.zoomOut.REST),srcGroup:X(this.prefixUrl,g.zoomOut.GROUP),srcHover:X(this.prefixUrl,g.zoomOut.HOVER),srcDown:X(this.prefixUrl,g.zoomOut.DOWN),onPress:O,onRelease:T,onClick:M,onEnter:O,onExit:T,onFocus:U,onBlur:K}))),this.showHomeControl&&p.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:X(this.prefixUrl,g.home.REST),srcGroup:X(this.prefixUrl,g.home.GROUP),srcHover:X(this.prefixUrl,g.home.HOVER),srcDown:X(this.prefixUrl,g.home.DOWN),onRelease:I,onFocus:U,onBlur:K})),this.showFullPageControl&&p.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:X(this.prefixUrl,g.fullpage.REST),srcGroup:X(this.prefixUrl,g.fullpage.GROUP),srcHover:X(this.prefixUrl,g.fullpage.HOVER),srcDown:X(this.prefixUrl,g.fullpage.DOWN),onRelease:D,onFocus:U,onBlur:K})),this.showRotationControl&&(p.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:X(this.prefixUrl,g.rotateleft.REST),srcGroup:X(this.prefixUrl,g.rotateleft.GROUP),srcHover:X(this.prefixUrl,g.rotateleft.HOVER),srcDown:X(this.prefixUrl,g.rotateleft.DOWN),onRelease:z,onFocus:U,onBlur:K})),p.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:X(this.prefixUrl,g.rotateright.REST),srcGroup:X(this.prefixUrl,g.rotateright.GROUP),srcHover:X(this.prefixUrl,g.rotateright.HOVER),srcDown:X(this.prefixUrl,g.rotateright.DOWN),onRelease:j,onFocus:U,onBlur:K}))),this.showFlipControl&&p.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:X(this.prefixUrl,g.flip.REST),srcGroup:X(this.prefixUrl,g.flip.GROUP),srcHover:X(this.prefixUrl,g.flip.HOVER),srcDown:X(this.prefixUrl,g.flip.DOWN),onRelease:q,onFocus:U,onBlur:K})),w?(this.buttonGroup=new e.ButtonGroup({buttons:p,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",e.delegate(this,Ke)),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=p),this},currentPage:function(){return this._sequenceIndex},goToPage:function(f){return this.tileSources&&f>=0&&f<this.tileSources.length&&(this._sequenceIndex=f,this._updateSequenceButtons(f),this.open(this.tileSources[f]),this.referenceStrip&&this.referenceStrip.setFocus(f),this.raiseEvent("page",{page:f})),this},addOverlay:function(f,T,R,O){var M;if(e.isPlainObject(f)?M=f:M={element:f,location:T,placement:R,onDraw:O},f=e.getElement(M.element),a(this.currentOverlays,f)>=0)return this;var I=l(this,M);return this.currentOverlays.push(I),I.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:f,location:M.location,placement:M.placement}),this},updateOverlay:function(f,T,R){var O;return f=e.getElement(f),O=a(this.currentOverlays,f),O>=0&&(this.currentOverlays[O].update(T,R),t[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:f,location:T,placement:R})),this},removeOverlay:function(f){var T;return f=e.getElement(f),T=a(this.currentOverlays,f),T>=0&&(this.currentOverlays[T].destroy(),this.currentOverlays.splice(T,1),t[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:f})),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(f){var T;return f=e.getElement(f),T=a(this.currentOverlays,f),T>=0?this.currentOverlays[T]:null},_updateSequenceButtons:function(f){this.nextButton&&(!this.tileSources||this.tileSources.length-1===f?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(f>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(f){this._hideMessage();var T=e.makeNeutralElement("div");T.appendChild(document.createTextNode(f)),this.messageDiv=e.makeCenteredNode(T),e.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var f=this.messageDiv;f&&(f.parentNode.removeChild(f),delete this.messageDiv)},gestureSettingsByDeviceType:function(f){switch(f){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var f,T=this.currentOverlays.length;for(f=0;f<T;f++)this.currentOverlays[f].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,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 f=e.pixelDensityRatio,T=e.getCurrentPixelDensityRatio();f!==T&&(e.pixelDensityRatio=T,this.forceResize())},goToPreviousPage:function(){var f=this._sequenceIndex-1;this.navPrevNextWrap&&f<0&&(f+=this.tileSources.length),this.goToPage(f)},goToNextPage:function(){var f=this._sequenceIndex+1;this.navPrevNextWrap&&f>=this.tileSources.length&&(f=0),this.goToPage(f)},isAnimating:function(){return t[this.hash].animating}});function i(f){return f=e.getElement(f),new e.Point(f.clientWidth===0?1:f.clientWidth,f.clientHeight===0?1:f.clientHeight)}function s(f,T,R,O,M){var I=f;if(e.type(T)==="string"){if(T.match(/^\s*<.*>\s*$/))T=e.parseXml(T);else if(T.match(/^\s*[{[].*[}\]]\s*$/))try{var D=e.parseJSON(T);T=D}catch{}}function z(j,q){j.ready?O(j):(j.addHandler("ready",function(){O(j)}),j.addHandler("open-failed",function(U){M({message:U.message,source:q})}))}setTimeout(function(){if(e.type(T)==="string")T=new e.TileSource({url:T,crossOriginPolicy:R.crossOriginPolicy!==void 0?R.crossOriginPolicy:f.crossOriginPolicy,ajaxWithCredentials:f.ajaxWithCredentials,ajaxHeaders:R.ajaxHeaders?R.ajaxHeaders:f.ajaxHeaders,splitHashDataForPost:f.splitHashDataForPost,success:function(K){O(K.tileSource)}}),T.addHandler("open-failed",function(K){M(K)});else if(e.isPlainObject(T)||T.nodeType)if(T.crossOriginPolicy===void 0&&(R.crossOriginPolicy!==void 0||f.crossOriginPolicy!==void 0)&&(T.crossOriginPolicy=R.crossOriginPolicy!==void 0?R.crossOriginPolicy:f.crossOriginPolicy),T.ajaxWithCredentials===void 0&&(T.ajaxWithCredentials=f.ajaxWithCredentials),e.isFunction(T.getTileUrl)){var j=new e.TileSource(T);j.getTileUrl=T.getTileUrl,O(j)}else{var q=e.TileSource.determineType(I,T);if(!q){M({message:"Unable to load TileSource",source:T});return}var U=q.prototype.configure.apply(I,[T]);z(new q(U),T)}else z(T,T)})}function l(f,T){if(T instanceof e.Overlay)return T;var R=null;if(T.element)R=e.getElement(T.element);else{var O=T.id?T.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);R=e.getElement(T.id),R||(R=document.createElement("a"),R.href="#/overlay/"+O),R.id=O,e.addClass(R,T.className?T.className:"openseadragon-overlay")}var M=T.location,I=T.width,D=T.height;if(!M){var z=T.x,j=T.y;if(T.px!==void 0){var q=f.viewport.imageToViewportRectangle(new e.Rect(T.px,T.py,I||0,D||0));z=q.x,j=q.y,I=I!==void 0?q.width:void 0,D=D!==void 0?q.height:void 0}M=new e.Point(z,j)}var U=T.placement;return U&&e.type(U)==="string"&&(U=e.Placement[T.placement.toUpperCase()]),new e.Overlay({element:R,location:M,placement:U,onDraw:T.onDraw,checkResize:T.checkResize,width:I,height:D,rotationMode:T.rotationMode})}function a(f,T){var R;for(R=f.length-1;R>=0;R--)if(f[R].element===T)return R;return-1}function u(f,T){return e.requestAnimationFrame(function(){T(f)})}function h(f){e.requestAnimationFrame(function(){d(f)})}function c(f){f.autoHideControls&&(f.controlsShouldFade=!0,f.controlsFadeBeginTime=e.now()+f.controlsFadeDelay,window.setTimeout(function(){h(f)},f.controlsFadeDelay))}function d(f){var T,R,O,M;if(f.controlsShouldFade){for(T=e.now(),R=T-f.controlsFadeBeginTime,O=1-R/f.controlsFadeLength,O=Math.min(1,O),O=Math.max(0,O),M=f.controls.length-1;M>=0;M--)f.controls[M].autoFade&&f.controls[M].setOpacity(O);O>0&&h(f)}}function m(f){var T;for(f.controlsShouldFade=!1,T=f.controls.length-1;T>=0;T--)f.controls[T].setOpacity(1)}function v(){m(this)}function y(){c(this)}function _(f){var T={tracker:f.eventSource,position:f.position,originalEvent:f.originalEvent,preventDefault:f.preventDefault};this.raiseEvent("canvas-contextmenu",T),f.preventDefault=T.preventDefault}function E(f){var T={originalEvent:f.originalEvent,preventDefaultAction:!1,preventVerticalPan:f.preventVerticalPan||!this.panVertical,preventHorizontalPan:f.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",T),!T.preventDefaultAction&&!f.ctrl&&!f.alt&&!f.meta)switch(f.keyCode){case 38:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 40:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 37:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 39:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),f.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),f.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),f.preventDefault=!0;break;case 87:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-40))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 83:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,40))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 65:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-40,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 68:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(40,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 82:f.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(),f.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),f.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:f.preventDefault=!1;break}else f.preventDefault=!1}function S(f){var T={originalEvent:f.originalEvent};this.raiseEvent("canvas-key-press",T)}function P(f){var T,R=document.activeElement===this.canvas;R||this.canvas.focus(),this.viewport.flipped&&(f.position.x=this.viewport.getContainerSize().x-f.position.x);var O={tracker:f.eventSource,position:f.position,quick:f.quick,shift:f.shift,originalEvent:f.originalEvent,originalTarget:f.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",O),!O.preventDefaultAction&&this.viewport&&f.quick&&(T=this.gestureSettingsByDeviceType(f.pointerType),T.clickToZoom===!0&&(this.viewport.zoomBy(f.shift?1/this.zoomPerClick:this.zoomPerClick,T.zoomToRefPoint?this.viewport.pointFromPixel(f.position,!0):null),this.viewport.applyConstraints()),T.dblClickDragToZoom&&(t[this.hash].draggingToZoom===!0?(t[this.hash].lastClickTime=null,t[this.hash].draggingToZoom=!1):t[this.hash].lastClickTime=e.now()))}function L(f){var T,R={tracker:f.eventSource,position:f.position,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",R),!R.preventDefaultAction&&this.viewport&&(T=this.gestureSettingsByDeviceType(f.pointerType),T.dblClickToZoom&&(this.viewport.zoomBy(f.shift?1/this.zoomPerClick:this.zoomPerClick,T.zoomToRefPoint?this.viewport.pointFromPixel(f.position,!0):null),this.viewport.applyConstraints()))}function F(f){var T,R={tracker:f.eventSource,pointerType:f.pointerType,position:f.position,delta:f.delta,speed:f.speed,direction:f.direction,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",R),T=this.gestureSettingsByDeviceType(f.pointerType),!R.preventDefaultAction&&this.viewport){if(T.dblClickDragToZoom&&t[this.hash].draggingToZoom){var O=Math.pow(this.zoomPerDblClickDrag,f.delta.y/50);this.viewport.zoomBy(O)}else if(T.dragToPan&&!t[this.hash].draggingToZoom){if(this.panHorizontal||(f.delta.x=0),this.panVertical||(f.delta.y=0),this.viewport.flipped&&(f.delta.x=-f.delta.x),this.constrainDuringPan){var M=this.viewport.deltaPointsFromPixels(f.delta.negate());this.viewport.centerSpringX.target.value+=M.x,this.viewport.centerSpringY.target.value+=M.y;var I=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=M.x,this.viewport.centerSpringY.target.value-=M.y,I.xConstrained&&(f.delta.x=0),I.yConstrained&&(f.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(f.delta.negate()),T.flickEnabled&&!this.constrainDuringPan)}}}function H(f){var T,R={tracker:f.eventSource,pointerType:f.pointerType,position:f.position,speed:f.speed,direction:f.direction,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",R),T=this.gestureSettingsByDeviceType(f.pointerType),!R.preventDefaultAction&&this.viewport){if(!t[this.hash].draggingToZoom&&T.dragToPan&&T.flickEnabled&&f.speed>=T.flickMinSpeed){var O=0;this.panHorizontal&&(O=T.flickMomentum*f.speed*Math.cos(f.direction));var M=0;this.panVertical&&(M=T.flickMomentum*f.speed*Math.sin(f.direction));var I=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),D=this.viewport.pointFromPixel(new e.Point(I.x-O,I.y-M));this.viewport.panTo(D,!1)}this.viewport.applyConstraints()}T.dblClickDragToZoom&&t[this.hash].draggingToZoom===!0&&(t[this.hash].draggingToZoom=!1)}function B(f){this.raiseEvent("canvas-enter",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function V(f){this.raiseEvent("canvas-exit",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function Y(f){var T;if(this.raiseEvent("canvas-press",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,insideElementPressed:f.insideElementPressed,insideElementReleased:f.insideElementReleased,originalEvent:f.originalEvent}),T=this.gestureSettingsByDeviceType(f.pointerType),T.dblClickDragToZoom){var R=t[this.hash].lastClickTime,O=e.now();if(R===null)return;O-R<this.dblClickTimeThreshold&&(t[this.hash].draggingToZoom=!0),t[this.hash].lastClickTime=null}}function J(f){this.raiseEvent("canvas-release",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,insideElementPressed:f.insideElementPressed,insideElementReleased:f.insideElementReleased,originalEvent:f.originalEvent})}function re(f){this.raiseEvent("canvas-nonprimary-press",{tracker:f.eventSource,position:f.position,pointerType:f.pointerType,button:f.button,buttons:f.buttons,originalEvent:f.originalEvent})}function Z(f){this.raiseEvent("canvas-nonprimary-release",{tracker:f.eventSource,position:f.position,pointerType:f.pointerType,button:f.button,buttons:f.buttons,originalEvent:f.originalEvent})}function ie(f){var T,R,O,M,I={tracker:f.eventSource,pointerType:f.pointerType,gesturePoints:f.gesturePoints,lastCenter:f.lastCenter,center:f.center,lastDistance:f.lastDistance,distance:f.distance,shift:f.shift,originalEvent:f.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",I),this.viewport&&(T=this.gestureSettingsByDeviceType(f.pointerType),T.pinchToZoom&&(!I.preventDefaultPanAction||!I.preventDefaultZoomAction)&&(R=this.viewport.pointFromPixel(f.center,!0),T.zoomToRefPoint&&!I.preventDefaultPanAction&&(O=this.viewport.pointFromPixel(f.lastCenter,!0),M=O.minus(R),this.panHorizontal||(M.x=0),this.panVertical||(M.y=0),this.viewport.panBy(M,!0)),I.preventDefaultZoomAction||this.viewport.zoomBy(f.distance/f.lastDistance,R,!0),this.viewport.applyConstraints()),T.pinchRotate&&!I.preventDefaultRotateAction)){var D=Math.atan2(f.gesturePoints[0].currentPos.y-f.gesturePoints[1].currentPos.y,f.gesturePoints[0].currentPos.x-f.gesturePoints[1].currentPos.x),z=Math.atan2(f.gesturePoints[0].lastPos.y-f.gesturePoints[1].lastPos.y,f.gesturePoints[0].lastPos.x-f.gesturePoints[1].lastPos.x);R=this.viewport.pointFromPixel(f.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(D-z)*(180/Math.PI),R,!0)}}function he(f){this.raiseEvent("canvas-focus",{tracker:f.eventSource,originalEvent:f.originalEvent})}function pe(f){this.raiseEvent("canvas-blur",{tracker:f.eventSource,originalEvent:f.originalEvent})}function ce(f){var T,R,O,M,I;M=e.now(),I=M-this._lastScrollTime,I>this.minScrollDeltaTime?(this._lastScrollTime=M,T={tracker:f.eventSource,position:f.position,scroll:f.scroll,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",T),!T.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(f.position.x=this.viewport.getContainerSize().x-f.position.x),R=this.gestureSettingsByDeviceType(f.pointerType),R.scrollToZoom&&(O=Math.pow(this.zoomPerScroll,f.scroll),this.viewport.zoomBy(O,R.zoomToRefPoint?this.viewport.pointFromPixel(f.position,!0):null),this.viewport.applyConstraints())),f.preventDefault=T.preventDefault):f.preventDefault=!0}function ve(f){t[this.hash].mouseInside=!0,m(this),this.raiseEvent("container-enter",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function fe(f){f.pointers<1&&(t[this.hash].mouseInside=!1,t[this.hash].animating||c(this)),this.raiseEvent("container-exit",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function we(f){xe(f),f.isOpen()?f._updateRequestId=u(f,we):f._updateRequestId=!1}function He(f,T){var R=f.viewport,O=R.getZoom(),M=R.getCenter();R.resize(T,f.preserveImageSizeOnResize),R.panTo(M,!0);var I;if(f.preserveImageSizeOnResize)I=t[f.hash].prevContainerSize.x/T.x;else{var D=new e.Point(0,0),z=new e.Point(t[f.hash].prevContainerSize.x,t[f.hash].prevContainerSize.y).distanceTo(D),j=new e.Point(T.x,T.y).distanceTo(D);I=j/z*t[f.hash].prevContainerSize.x/T.x}R.zoomTo(O*I,null,!0),t[f.hash].prevContainerSize=T,t[f.hash].forceRedraw=!0,t[f.hash].needsResize=!1,t[f.hash].forceResize=!1}function xe(f){if(!(f._opening||!t[f.hash])){if(f.autoResize||t[f.hash].forceResize){var T;if(f._autoResizePolling){T=i(f.container);var R=t[f.hash].prevContainerSize;T.equals(R)||(t[f.hash].needsResize=!0)}t[f.hash].needsResize&&He(f,T||i(f.container))}var O=f.viewport.update(),M=f.world.update(O)||O;O&&f.raiseEvent("viewport-change"),f.referenceStrip&&(M=f.referenceStrip.update(f.viewport)||M);var I=t[f.hash].animating;!I&&M&&(f.raiseEvent("animation-start"),m(f));var D=I&&!M;D&&(t[f.hash].animating=!1),(M||D||t[f.hash].forceRedraw||f.world.needsDraw())&&(Xe(f),f._drawOverlays(),f.navigator&&f.navigator.update(f.viewport),t[f.hash].forceRedraw=!1,M&&f.raiseEvent("animation")),D&&(f.raiseEvent("animation-finish"),t[f.hash].mouseInside||c(f)),t[f.hash].animating=M}}function Xe(f){f.imageLoader.clear(),f.world.draw(),f.raiseEvent("update-viewport",{})}function X(f,T){return f?f+T:T}function Ye(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=this.zoomPerSecond,t[this.hash].zooming=!0,k(this)}function ct(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=1/this.zoomPerSecond,t[this.hash].zooming=!0,k(this)}function Ue(){t[this.hash].zooming=!1}function k(f){e.requestAnimationFrame(e.delegate(f,te))}function te(){var f,T,R;t[this.hash].zooming&&this.viewport&&(f=e.now(),T=f-t[this.hash].lastZoomTime,R=Math.pow(t[this.hash].zoomFactor,T/1e3),this.viewport.zoomBy(R),this.viewport.applyConstraints(),t[this.hash].lastZoomTime=f,k(this))}function de(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function ye(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function Ke(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function St(){this.viewport&&this.viewport.goHome()}function kt(){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 Nt(){if(this.viewport){var f=this.viewport.getRotation();this.viewport.flipped?f+=this.rotationIncrement:f-=this.rotationIncrement,this.viewport.setRotation(f)}}function Pt(){if(this.viewport){var f=this.viewport.getRotation();this.viewport.flipped?f-=this.rotationIncrement:f+=this.rotationIncrement,this.viewport.setRotation(f)}}function dt(){this.viewport.toggleFlip()}e.determineDrawer=function(f){for(let T in o){const R=o[T],O=R.prototype;if(O&&O instanceof o.DrawerBase&&e.isFunction(O.getType)&&O.getType.call(R)===f)return R}return null}})(o),(function(e){e.Navigator=function(u){var h=u.viewer,c=this,d,m;u.element||u.id?(u.element?(u.id&&e.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),u.element.id?u.id=u.element.id:u.id="navigator-"+e.now(),this.element=u.element):this.element=document.getElementById(u.id),u.controlOptions={anchor:e.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(u.id="navigator-"+e.now(),this.element=e.makeNeutralElement("div"),u.controlOptions={anchor:e.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:u.autoFade},u.position&&(u.position==="BOTTOM_RIGHT"?u.controlOptions.anchor=e.ControlAnchor.BOTTOM_RIGHT:u.position==="BOTTOM_LEFT"?u.controlOptions.anchor=e.ControlAnchor.BOTTOM_LEFT:u.position==="TOP_RIGHT"?u.controlOptions.anchor=e.ControlAnchor.TOP_RIGHT:u.position==="TOP_LEFT"?u.controlOptions.anchor=e.ControlAnchor.TOP_LEFT:u.position==="ABSOLUTE"&&(u.controlOptions.anchor=e.ControlAnchor.ABSOLUTE,u.controlOptions.top=u.top,u.controlOptions.left=u.left,u.controlOptions.height=u.height,u.controlOptions.width=u.width))),this.element.id=u.id,this.element.className+=" navigator",u=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.navigatorSizeRatio},u,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:u.animationTime,autoResize:!1,minZoomImageRatio:1,background:u.background,opacity:u.opacity,borderColor:u.borderColor,displayRegionColor:u.displayRegionColor}),u.minPixelRatio=this.minPixelRatio=h.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),u.controlOptions.anchor!==e.ControlAnchor.NONE&&(function(_,E){_.margin="0px",_.border=E+"px solid "+u.borderColor,_.padding="0px",_.background=u.background,_.opacity=u.opacity,_.overflow="hidden"})(this.element.style,this.borderWidth),this.displayRegion=e.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",(function(_,E){_.position="relative",_.top="0px",_.left="0px",_.fontSize="0px",_.overflow="hidden",_.border=E+"px solid "+u.displayRegionColor,_.margin="0px",_.padding="0px",_.background="transparent",_.float="left",_.cssFloat="left",_.zIndex=999999999,_.cursor="default",_.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),h.addControl(this.element,u.controlOptions),this._resizeWithViewer=u.controlOptions.anchor!==e.ControlAnchor.ABSOLUTE&&u.controlOptions.anchor!==e.ControlAnchor.NONE,u.width&&u.height?(this.setWidth(u.width),this.setHeight(u.height)):this._resizeWithViewer&&(d=e.getElementSize(h.element),this.element.style.height=Math.round(d.y*u.sizeRatio)+"px",this.element.style.width=Math.round(d.x*u.sizeRatio)+"px",this.oldViewerSize=d,m=e.getElementSize(this.element),this.elementArea=m.x*m.y),this.oldContainerSize=new e.Point(0,0),e.Viewer.apply(this,[u]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function v(_,E){l(c.displayRegionContainer,_),l(c.displayRegion,-_),c.viewport.setRotation(_,E)}if(u.navigatorRotate){var y=u.viewer.viewport?u.viewer.viewport.getRotation():u.viewer.degrees||0;v(y,!0),u.viewer.addHandler("rotate",function(_){v(_.degrees,_.immediately)})}this.innerTracker.destroy(),this.innerTracker=new e.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:e.delegate(this,r),clickHandler:e.delegate(this,t),releaseHandler:e.delegate(this,i),scrollHandler:e.delegate(this,s),preProcessEventHandler:function(_){_.eventType==="wheel"&&(_.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",e.setElementPointerEventsNone(this.canvas),e.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){c.viewport&&c.viewport.goHome(!0)}),h.world.addHandler("item-index-change",function(_){window.setTimeout(function(){var E=c.world.getItemAt(_.previousIndex);c.world.setItemIndex(E,_.newIndex)},1)}),h.world.addHandler("remove-item",function(_){var E=_.item,S=c._getMatchingItem(E);S&&c.world.removeItem(S)}),this.update(h.viewport)},e.extend(e.Navigator.prototype,e.EventSource.prototype,e.Viewer.prototype,{updateSize:function(){if(this.viewport){var u=new e.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);u.equals(this.oldContainerSize)||(this.viewport.resize(u,!0),this.viewport.goHome(!0),this.oldContainerSize=u,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(u){this.width=u,this.element.style.width=typeof u=="number"?u+"px":u,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(u){this.height=u,this.element.style.height=typeof u=="number"?u+"px":u,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(u){return this.viewport.setFlip(u),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(u){a(this.canvas,u),a(this.element,u)},update:function(u){var h,c,d,m,v,y;if(u||(u=this.viewer.viewport),h=e.getElementSize(this.viewer.element),this._resizeWithViewer&&h.x&&h.y&&!h.equals(this.oldViewerSize)&&(this.oldViewerSize=h,this.maintainSizeRatio||!this.elementArea?(c=h.x*this.sizeRatio,d=h.y*this.sizeRatio):(c=Math.sqrt(this.elementArea*(h.x/h.y)),d=this.elementArea/c),this.element.style.width=Math.round(c)+"px",this.element.style.height=Math.round(d)+"px",this.elementArea||(this.elementArea=c*d),this.updateSize()),u&&this.viewport){if(m=u.getBoundsNoRotate(!0),v=this.viewport.pixelFromPointNoRotate(m.getTopLeft(),!1),y=this.viewport.pixelFromPointNoRotate(m.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var _=u.getRotation(!0);l(this.displayRegion,-_)}var E=this.displayRegion.style;E.display=this.world.getItemCount()?"block":"none",E.top=v.y.toFixed(2)+"px",E.left=v.x.toFixed(2)+"px";var S=y.x-v.x,P=y.y-v.y;E.width=Math.round(Math.max(S,0))+"px",E.height=Math.round(Math.max(P,0))+"px"}},addTiledImage:function(u){var h=this,c=u.originalTiledImage;delete u.original;var d=e.extend({},u,{success:function(m){var v=m.item;v._originalForNavigator=c,h._matchBounds(v,c,!0),h._matchOpacity(v,c),h._matchCompositeOperation(v,c);function y(){h._matchBounds(v,c)}function _(){h._matchOpacity(v,c)}function E(){h._matchCompositeOperation(v,c)}c.addHandler("bounds-change",y),c.addHandler("clip-change",y),c.addHandler("opacity-change",_),c.addHandler("composite-operation-change",E)}});return e.Viewer.prototype.addTiledImage.apply(this,[d])},destroy:function(){return e.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(u){for(var h=this.world.getItemCount(),c,d=0;d<h;d++)if(c=this.world.getItemAt(d),c._originalForNavigator===u)return c;return null},_matchBounds:function(u,h,c){var d=h.getBoundsNoRotate();u.setPosition(d.getTopLeft(),c),u.setWidth(d.width,c),u.setRotation(h.getRotation(),c),u.setClip(h.getClip()),u.setFlip(h.getFlip())},_matchOpacity:function(u,h){u.setOpacity(h.opacity)},_matchCompositeOperation:function(u,h){u.setCompositeOperation(h.compositeOperation)}});function t(u){var h={tracker:u.eventSource,position:u.position,quick:u.quick,shift:u.shift,originalEvent:u.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",h),!h.preventDefaultAction&&u.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(u.position.x=this.viewport.getContainerSize().x-u.position.x);var c=this.viewport.pointFromPixel(u.position);this.panVertical?this.panHorizontal||(c.x=this.viewer.viewport.getCenter(!0).x):c.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(c),this.viewer.viewport.applyConstraints()}}function r(u){var h={tracker:u.eventSource,position:u.position,delta:u.delta,speed:u.speed,direction:u.direction,shift:u.shift,originalEvent:u.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",h),!h.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(u.delta.x=0),this.panVertical||(u.delta.y=0),this.viewer.viewport.flipped&&(u.delta.x=-u.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(u.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function i(u){u.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function s(u){var h={tracker:u.eventSource,position:u.position,scroll:u.scroll,shift:u.shift,originalEvent:u.originalEvent,preventDefault:u.preventDefault};this.viewer.raiseEvent("navigator-scroll",h),u.preventDefault=h.preventDefault}function l(u,h){a(u,"rotate("+h+"deg)")}function a(u,h){u.style.webkitTransform=h,u.style.mozTransform=h,u.style.msTransform=h,u.style.oTransform=h,u.style.transform=h}})(o),(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(r){var i=r.split("."),s=null,l=arguments,a=t,u;for(u=0;u<i.length-1;u++)a=a[i[u]]||{};return s=a[i[u]],typeof s!="string"&&(e.console.error("Untranslated source string:",r),s=""),s.replace(/\{\d+\}/g,function(h){var c=parseInt(h.match(/\d+/),10)+1;return c<l.length?l[c]:""})},setString:function(r,i){var s=r.split("."),l=t,a;for(a=0;a<s.length-1;a++)l[s[a]]||(l[s[a]]={}),l=l[s[a]];l[s[a]]=i}})})(o),(function(e){e.Point=function(t,r){this.x=typeof t=="number"?t:0,this.y=typeof r=="number"?r: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,r){r=r||new e.Point(0,0);var i,s;if(t%90===0){var l=e.positiveModulo(t,360);switch(l){case 0:i=1,s=0;break;case 90:i=0,s=1;break;case 180:i=-1,s=0;break;case 270:i=0,s=-1;break}}else{var a=t*Math.PI/180;i=Math.cos(a),s=Math.sin(a)}var u=i*(this.x-r.x)-s*(this.y-r.y)+r.x,h=s*(this.x-r.x)+i*(this.y-r.y)+r.y;return new e.Point(u,h)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(o),(function(e){e.TileSource=function(r,i,s,l,a,u){var h=this,c=arguments,d,m;if(e.isPlainObject(r)?d=r:d={width:c[0],height:c[1],tileSize:c[2],tileOverlap:c[3],minLevel:c[4],maxLevel:c[5]},e.EventSource.call(this),e.extend(!0,this,d),!this.success){for(m=0;m<arguments.length;m++)if(e.isFunction(arguments[m])){this.success=arguments[m];break}}this.success&&this.addHandler("ready",function(v){h.success(v)}),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=d.width&&d.height?d.width/d.height:1,this.dimensions=new e.Point(d.width,d.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=d.tileOverlap?d.tileOverlap:0,this.minLevel=d.minLevel?d.minLevel:0,this.maxLevel=d.maxLevel!==void 0&&d.maxLevel!==null?d.maxLevel:d.width&&d.height?Math.ceil(Math.log(Math.max(d.width,d.height))/Math.log(2)):0,this.success&&e.isFunction(this.success)&&this.success(this))},e.TileSource.prototype={getTileSize:function(r){return e.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(r){return this._tileWidth?this._tileWidth:this.getTileSize(r)},getTileHeight:function(r){return this._tileHeight?this._tileHeight:this.getTileSize(r)},setMaxLevel:function(r){this.maxLevel=r,this._memoizeLevelScale()},getLevelScale:function(r){return this._memoizeLevelScale(),this.getLevelScale(r)},_memoizeLevelScale:function(){var r={},i;for(i=0;i<=this.maxLevel;i++)r[i]=1/Math.pow(2,this.maxLevel-i);this.getLevelScale=function(s){return r[s]}},getNumTiles:function(r){var i=this.getLevelScale(r),s=Math.ceil(i*this.dimensions.x/this.getTileWidth(r)),l=Math.ceil(i*this.dimensions.y/this.getTileHeight(r));return new e.Point(s,l)},getPixelRatio:function(r){var i=this.dimensions.times(this.getLevelScale(r)),s=1/i.x*e.pixelDensityRatio,l=1/i.y*e.pixelDensityRatio;return new e.Point(s,l)},getClosestLevel:function(){var r,i;for(r=this.minLevel+1;r<=this.maxLevel&&(i=this.getNumTiles(r),!(i.x>1||i.y>1));r++);return r-1},getTileAtPoint:function(r,i){var s=i.x>=0&&i.x<=1&&i.y>=0&&i.y<=1/this.aspectRatio;e.console.assert(s,"[TileSource.getTileAtPoint] must be called with a valid point.");var l=this.dimensions.x*this.getLevelScale(r),a=i.x*l,u=i.y*l,h=Math.floor(a/this.getTileWidth(r)),c=Math.floor(u/this.getTileHeight(r));i.x>=1&&(h=this.getNumTiles(r).x-1);var d=1e-15;return i.y>=1/this.aspectRatio-d&&(c=this.getNumTiles(r).y-1),new e.Point(h,c)},getTileBounds:function(r,i,s,l){var a=this.dimensions.times(this.getLevelScale(r)),u=this.getTileWidth(r),h=this.getTileHeight(r),c=i===0?0:u*i-this.tileOverlap,d=s===0?0:h*s-this.tileOverlap,m=u+(i===0?1:2)*this.tileOverlap,v=h+(s===0?1:2)*this.tileOverlap,y=1/a.x;return m=Math.min(m,a.x-c),v=Math.min(v,a.y-d),l?new e.Rect(0,0,m,v):new e.Rect(c*y,d*y,m*y,v*y)},getImageInfo:function(r){var i=this,s,l,a,u,h,c,d;r&&(h=r.split("/"),c=h[h.length-1],d=c.lastIndexOf("."),d>-1&&(h[h.length-1]=c.slice(0,d)));var m=null;if(this.splitHashDataForPost){var v=r.indexOf("#");v!==-1&&(m=r.substring(v+1),r=r.substr(0,v))}l=function(y){typeof y=="string"&&(y=e.parseXml(y));var _=e.TileSource.determineType(i,y,r);if(!_){i.raiseEvent("open-failed",{message:"Unable to load TileSource",source:r});return}u=_.prototype.configure.apply(i,[y,r,m]),u.ajaxWithCredentials===void 0&&(u.ajaxWithCredentials=i.ajaxWithCredentials),a=new _(u),i.ready=!0,i.raiseEvent("ready",{tileSource:a})},r.match(/\.js$/)?(s=r.split("/").pop().replace(".js",""),e.jsonp({url:r,async:!1,callbackName:s,callback:l})):e.makeAjaxRequest({url:r,postData:m,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(y){var _=t(y);l(_)},error:function(y,_){var E;try{E="HTTP "+y.status+" attempting to load TileSource: "+r}catch{var S;typeof _>"u"||!_.toString?S="Unknown error":S=_.toString(),E=S+" attempting to load TileSource: "+r}e.console.error(E),i.raiseEvent("open-failed",{message:E,source:r,postData:m})}})},supports:function(r,i){return!1},configure:function(r,i,s){throw new Error("Method not implemented.")},getTileUrl:function(r,i,s){throw new Error("Method not implemented.")},getTilePostData:function(r,i,s){return null},getTileAjaxHeaders:function(r,i,s){return{}},getTileHashKey:function(r,i,s,l,a,u){function h(c){return a?c+"+"+JSON.stringify(a):c}return h(typeof l!="string"?r+"/"+i+"_"+s:l)},tileExists:function(r,i,s){var l=this.getNumTiles(r);return r>=this.minLevel&&r<=this.maxLevel&&i>=0&&s>=0&&i<l.x&&s<l.y},hasTransparency:function(r,i,s,l){return!!r||i.match(".png")},downloadTileStart:function(r){var i=r.userData,s=new Image;i.image=s,i.request=null;var l=function(a){if(!s){r.finish(null,i.request,"Image load failed: undefined Image instance.");return}s.onload=s.onerror=s.onabort=null,r.finish(a?null:s,i.request,a)};s.onload=function(){l()},s.onabort=s.onerror=function(){l("Image load aborted.")},r.loadWithAjax?i.request=e.makeAjaxRequest({url:r.src,withCredentials:r.ajaxWithCredentials,headers:r.ajaxHeaders,responseType:"arraybuffer",postData:r.postData,success:function(a){var u;try{u=new window.Blob([a.response])}catch(d){var h=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&h){var c=new h;c.append(a.response),u=c.getBlob()}}u.size===0?l("Empty image response."):s.src=(window.URL||window.webkitURL).createObjectURL(u)},error:function(a){l("Image load aborted - XHR error")}}):(r.crossOriginPolicy!==!1&&(s.crossOrigin=r.crossOriginPolicy),s.src=r.src)},downloadTileAbort:function(r){r.userData.request&&r.userData.request.abort();var i=r.userData.image;r.userData.image&&(i.onload=i.onerror=i.onabort=null)},createTileCache:function(r,i,s){r._data=i},destroyTileCache:function(r){r._data=null,r._renderedContext=null},getTileCacheData:function(r){return r._data},getTileCacheDataAsImage:function(r){return r._data},getTileCacheDataAsContext2D:function(r){if(!r._renderedContext){var i=document.createElement("canvas");i.width=r._data.width,i.height=r._data.height,r._renderedContext=i.getContext("2d"),r._renderedContext.drawImage(r._data,0,0),r._data=null}return r._renderedContext}},e.extend(!0,e.TileSource.prototype,e.EventSource.prototype);function t(r){var i=r.responseText,s=r.status,l,a;if(r){if(r.status!==200&&r.status!==0)throw s=r.status,l=s===404?"Not Found":r.statusText,new Error(e.getString("Errors.Status",s,l))}else throw new Error(e.getString("Errors.Security"));if(i.match(/^\s*<.*/))try{a=r.responseXML&&r.responseXML.documentElement?r.responseXML:e.parseXml(i)}catch{a=r.responseText}else if(i.match(/\s*[{[].*/))try{a=e.parseJSON(i)}catch{a=i}else a=i;return a}e.TileSource.determineType=function(r,i,s){var l;for(l in o)if(l.match(/.+TileSource$/)&&e.isFunction(o[l])&&e.isFunction(o[l].prototype.supports)&&o[l].prototype.supports.call(r,i,s))return o[l];return e.console.error("No TileSource was able to open %s %s",s,i),null}})(o),(function(e){e.DziTileSource=function(i,s,l,a,u,h,c,d,m){var v,y,_,E;if(e.isPlainObject(i)?E=i:E={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=E.tilesUrl,this.fileFormat=E.fileFormat,this.displayRects=E.displayRects,this.displayRects)for(v=this.displayRects.length-1;v>=0;v--)for(y=this.displayRects[v],_=y.minLevel;_<=y.maxLevel;_++)this._levelRects[_]||(this._levelRects[_]=[]),this._levelRects[_].push(y);e.TileSource.apply(this,[E])},e.extend(e.DziTileSource.prototype,e.TileSource.prototype,{supports:function(i,s){var l;return i.Image?l=i.Image.xmlns:i.documentElement&&(i.documentElement.localName==="Image"||i.documentElement.tagName==="Image")&&(l=i.documentElement.namespaceURI),l=(l||"").toLowerCase(),l.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||l.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(i,s,l){var a;return e.isPlainObject(i)?a=r(this,i):a=t(this,i),s&&!a.tilesUrl&&(a.tilesUrl=s.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),s.search(/\.(dzi|xml|js)\?/)!==-1?a.queryParams=s.match(/\?.*/):a.queryParams=""),a},getTileUrl:function(i,s,l){return[this.tilesUrl,i,"/",s,"_",l,".",this.fileFormat,this.queryParams].join("")},tileExists:function(i,s,l){var a=this._levelRects[i],u,h,c,d,m,v,y;if(this.minLevel&&i<this.minLevel||this.maxLevel&&i>this.maxLevel)return!1;if(!a||!a.length)return!0;for(y=a.length-1;y>=0;y--)if(u=a[y],!(i<u.minLevel||i>u.maxLevel)&&(h=this.getLevelScale(i),c=u.x*h,d=u.y*h,m=c+u.width*h,v=d+u.height*h,c=Math.floor(c/this._tileWidth),d=Math.floor(d/this._tileWidth),m=Math.ceil(m/this._tileWidth),v=Math.ceil(v/this._tileWidth),c<=s&&s<m&&d<=l&&l<v))return!0;return!1}});function t(i,s){if(!s||!s.documentElement)throw new Error(e.getString("Errors.Xml"));var l=s.documentElement,a=l.localName||l.tagName,u=s.documentElement.namespaceURI,h=null,c=[],d,m,v,y,_;if(a==="Image")try{if(y=l.getElementsByTagName("Size")[0],y===void 0&&(y=l.getElementsByTagNameNS(u,"Size")[0]),h={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:l.getAttribute("Url"),Format:l.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(l.getAttribute("Overlap"),10),TileSize:parseInt(l.getAttribute("TileSize"),10),Size:{Height:parseInt(y.getAttribute("Height"),10),Width:parseInt(y.getAttribute("Width"),10)}}},!e.imageFormatSupported(h.Image.Format))throw new Error(e.getString("Errors.ImageFormat",h.Image.Format.toUpperCase()));for(d=l.getElementsByTagName("DisplayRect"),d===void 0&&(d=l.getElementsByTagNameNS(u,"DisplayRect")[0]),_=0;_<d.length;_++)m=d[_],v=m.getElementsByTagName("Rect")[0],v===void 0&&(v=m.getElementsByTagNameNS(u,"Rect")[0]),c.push({Rect:{X:parseInt(v.getAttribute("X"),10),Y:parseInt(v.getAttribute("Y"),10),Width:parseInt(v.getAttribute("Width"),10),Height:parseInt(v.getAttribute("Height"),10),MinLevel:parseInt(m.getAttribute("MinLevel"),10),MaxLevel:parseInt(m.getAttribute("MaxLevel"),10)}});return c.length&&(h.Image.DisplayRect=c),r(i,h)}catch(P){throw P instanceof Error?P:new Error(e.getString("Errors.Dzi"))}else{if(a==="Collection")throw new Error(e.getString("Errors.Dzc"));if(a==="Error"){var E=l.getElementsByTagName("Message")[0],S=E.firstChild.nodeValue;throw new Error(S)}}throw new Error(e.getString("Errors.Dzi"))}function r(i,s){var l=s.Image,a=l.Url,u=l.Format,h=l.Size,c=l.DisplayRect||[],d=parseInt(h.Width,10),m=parseInt(h.Height,10),v=parseInt(l.TileSize,10),y=parseInt(l.Overlap,10),_=[],E,S;for(S=0;S<c.length;S++)E=c[S].Rect,_.push(new e.DisplayRect(parseInt(E.X,10),parseInt(E.Y,10),parseInt(E.Width,10),parseInt(E.Height,10),parseInt(E.MinLevel,10),parseInt(E.MaxLevel,10)));return e.extend(!0,{width:d,height:m,tileSize:v,tileOverlap:y,minLevel:null,maxLevel:null,tilesUrl:a,fileFormat:u,displayRects:_},s)}})(o),(function(e){e.IIIFTileSource=function(l){if(e.extend(!0,this,l),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(l.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=l.version,this.tile_width&&this.tile_height)l.tileWidth=this.tile_width,l.tileHeight=this.tile_height;else if(this.tile_width)l.tileSize=this.tile_width;else if(this.tile_height)l.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)l.tileWidth=this.tiles[0].width,l.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var a=0;a<this.tiles.length;a++)for(var u=0;u<this.tiles[a].scaleFactors.length;u++){var h=this.tiles[a].scaleFactors[u];this.scale_factors.push(h),l.tileSizePerScaleFactor[h]={width:this.tiles[a].width,height:this.tiles[a].height||this.tiles[a].width}}}else if(t(l)){for(var c=Math.min(this.height,this.width),d=[256,512,1024],m=[],v=0;v<d.length;v++)d[v]<=c&&m.push(d[v]);m.length>0?l.tileSize=Math.max.apply(null,m):l.tileSize=c}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,l.levels=r(this),e.extend(!0,l,{width:l.levels[l.levels.length-1].width,height:l.levels[l.levels.length-1].height,tileSize:Math.max(l.height,l.width),tileOverlap:0,minLevel:0,maxLevel:l.levels.length-1}),this.levels=l.levels):e.console.error("Nothing in the info.json to construct image pyramids from");if(!l.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)l.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var y=Math.max.apply(null,this.scale_factors);l.maxLevel=Math.round(Math.log(y)*Math.LOG2E)}if(this.sizes){var _=this.sizes.length;(_===l.maxLevel||_===l.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((E,S)=>E.width-S.width),_===l.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}e.TileSource.apply(this,[l])},e.extend(e.IIIFTileSource.prototype,e.TileSource.prototype,{supports:function(l,a){return l.protocol&&l.protocol==="http://iiif.io/api/image"||l["@context"]&&(l["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||l["@context"]==="http://iiif.io/api/image/1/context.json")||l.profile&&l.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||l.identifier&&l.width&&l.height?!0:!!(l.documentElement&&l.documentElement.tagName==="info"&&l.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(l,a,u){if(e.isPlainObject(l)){if(!l["@context"])l["@context"]="http://iiif.io/api/image/1.0/context.json",l["@id"]=a.replace("/info.json",""),l.version=1;else{var c=l["@context"];if(Array.isArray(c)){for(var d=0;d<c.length;d++)if(typeof c[d]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(c[d])||c[d]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){c=c[d];break}}switch(c){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":l.version=1;break;case"http://iiif.io/api/image/2/context.json":l.version=2;break;case"http://iiif.io/api/image/3/context.json":l.version=3;break;default:e.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(l.preferredFormats){for(var m=0;m<l.preferredFormats.length;m++)if(o.imageFormatSupported(l.preferredFormats[m])){l.tileFormat=l.preferredFormats[m];break}}return l}else{var h=i(l);return h["@context"]="http://iiif.io/api/image/1.0/context.json",h["@id"]=a.replace("/info.xml",""),h.version=1,h}},getTileWidth:function(l){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileWidth.call(this,l);var a=Math.pow(2,this.maxLevel-l);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[a]?this.tileSizePerScaleFactor[a].width:this._tileWidth},getTileHeight:function(l){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileHeight.call(this,l);var a=Math.pow(2,this.maxLevel-l);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[a]?this.tileSizePerScaleFactor[a].height:this._tileHeight},getLevelScale:function(l){if(this.emulateLegacyImagePyramid){var a=NaN;return this.levels.length>0&&l>=this.minLevel&&l<=this.maxLevel&&(a=this.levels[l].width/this.levels[this.maxLevel].width),a}return e.TileSource.prototype.getLevelScale.call(this,l)},getNumTiles:function(l){if(this.emulateLegacyImagePyramid){var a=this.getLevelScale(l);return a?new e.Point(1,1):new e.Point(0,0)}if(this.levelSizes){var u=this.levelSizes[l],h=Math.ceil(u.width/this.getTileWidth(l)),c=Math.ceil(u.height/this.getTileHeight(l));return new e.Point(h,c)}else return e.TileSource.prototype.getNumTiles.call(this,l)},getTileAtPoint:function(l,a){if(this.emulateLegacyImagePyramid)return new e.Point(0,0);if(this.levelSizes){var u=a.x>=0&&a.x<=1&&a.y>=0&&a.y<=1/this.aspectRatio;e.console.assert(u,"[TileSource.getTileAtPoint] must be called with a valid point.");var h=this.levelSizes[l].width,c=a.x*h,d=a.y*h,m=Math.floor(c/this.getTileWidth(l)),v=Math.floor(d/this.getTileHeight(l));a.x>=1&&(m=this.getNumTiles(l).x-1);var y=1e-15;return a.y>=1/this.aspectRatio-y&&(v=this.getNumTiles(l).y-1),new e.Point(m,v)}return e.TileSource.prototype.getTileAtPoint.call(this,l,a)},getTileUrl:function(l,a,u){if(this.emulateLegacyImagePyramid){var h=null;return this.levels.length>0&&l>=this.minLevel&&l<=this.maxLevel&&(h=this.levels[l].url),h}var c="0",d=Math.pow(.5,this.maxLevel-l),m,v,y,_,E,S,P,L,F,H,B,V,Y,J,re,Z;return this.levelSizes?(m=this.levelSizes[l].width,v=this.levelSizes[l].height):(m=Math.ceil(this.width*d),v=Math.ceil(this.height*d)),y=this.getTileWidth(l),_=this.getTileHeight(l),E=Math.round(y/d),S=Math.round(_/d),this.version===1?re="native."+this.tileFormat:re="default."+this.tileFormat,m<y&&v<_?(this.version===2&&m===this.width?V="full":this.version===3&&m===this.width&&v===this.height?V="max":this.version===3?V=m+","+v:V=m+",",P="full"):(L=a*E,F=u*S,H=Math.min(E,this.width-L),B=Math.min(S,this.height-F),a===0&&u===0&&H===this.width&&B===this.height?P="full":P=[L,F,H,B].join(","),Y=Math.min(y,m-a*y),J=Math.min(_,v-u*_),this.version===2&&Y===this.width?V="full":this.version===3&&Y===this.width&&J===this.height?V="max":this.version===3?V=Y+","+J:V=Y+","),Z=[this._id,P,V,c,re].join("/"),Z},__testonly__:{canBeTiled:t,constructLevels:r}});function t(l){var a=["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"],u=Array.isArray(l.profile)?l.profile[0]:l.profile,h=a.indexOf(u)!==-1,c=!1;return l.version===2&&l.profile.length>1&&l.profile[1].supports&&(c=l.profile[1].supports.indexOf("sizeByW")!==-1),l.version===3&&l.extraFeatures&&(c=l.extraFeatures.indexOf("sizeByWh")!==-1),!h||c}function r(l){for(var a=[],u=0;u<l.sizes.length;u++)a.push({url:l._id+"/full/"+l.sizes[u].width+","+(l.version===3?l.sizes[u].height:"")+"/0/default."+l.tileFormat,width:l.sizes[u].width,height:l.sizes[u].height});return a.sort(function(h,c){return h.width-c.width})}function i(l){if(!l||!l.documentElement)throw new Error(e.getString("Errors.Xml"));var a=l.documentElement,u=a.tagName,h=null;if(u==="info")try{return h={},s(a,h),h}catch(c){throw c instanceof Error?c:new Error(e.getString("Errors.IIIF"))}throw new Error(e.getString("Errors.IIIF"))}function s(l,a,u){var h,c;if(l.nodeType===3&&u)c=l.nodeValue.trim(),c.match(/^\d*$/)&&(c=Number(c)),a[u]?(e.isArray(a[u])||(a[u]=[a[u]]),a[u].push(c)):a[u]=c;else if(l.nodeType===1)for(h=0;h<l.childNodes.length;h++)s(l.childNodes[h],a,l.nodeName)}})(o),(function(e){e.OsmTileSource=function(t,r,i,s,l){var a;e.isPlainObject(t)?a=t:a={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!a.width||!a.height)&&(a.width=65572864,a.height=65572864),a.tileSize||(a.tileSize=256,a.tileOverlap=0),a.tilesUrl||(a.tilesUrl="http://tile.openstreetmap.org/"),a.minLevel=8,e.TileSource.apply(this,[a])},e.extend(e.OsmTileSource.prototype,e.TileSource.prototype,{supports:function(t,r){return t.type&&t.type==="openstreetmaps"},configure:function(t,r,i){return t},getTileUrl:function(t,r,i){return this.tilesUrl+(t-8)+"/"+r+"/"+i+".png"}})})(o),(function(e){e.TmsTileSource=function(t,r,i,s,l){var a;e.isPlainObject(t)?a=t:a={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var u=Math.ceil(a.width/256)*256,h=Math.ceil(a.height/256)*256,c;u>h?c=u/256:c=h/256,a.maxLevel=Math.ceil(Math.log(c)/Math.log(2))-1,a.tileSize=256,a.width=u,a.height=h,e.TileSource.apply(this,[a])},e.extend(e.TmsTileSource.prototype,e.TileSource.prototype,{supports:function(t,r){return t.type&&t.type==="tiledmapservice"},configure:function(t,r,i){return t},getTileUrl:function(t,r,i){var s=this.getNumTiles(t).y-1;return this.tilesUrl+t+"/"+r+"/"+(s-i)+".png"}})})(o),(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 r={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(r.x,10)>t.tileSize||parseInt(r.y,10)>t.tileSize;)r.x=Math.floor(r.x/2),r.y=Math.floor(r.y/2),t.imageSizes.push({x:r.x,y:r.y}),t.gridSize.push(this._getGridSize(r.x,r.y,t.tileSize));t.imageSizes.reverse(),t.gridSize.reverse(),t.minLevel=0,t.maxLevel=t.gridSize.length-1,o.TileSource.apply(this,[t])},e.extend(e.ZoomifyTileSource.prototype,e.TileSource.prototype,{_getGridSize:function(t,r,i){return{x:Math.ceil(t/i),y:Math.ceil(r/i)}},_calculateAbsoluteTileNumber:function(t,r,i){for(var s=0,l={},a=0;a<t;a++)l=this.gridSize[a],s+=l.x*l.y;return l=this.gridSize[t],s+=l.x*i+r,s},supports:function(t,r){return t.type&&t.type==="zoomifytileservice"},configure:function(t,r,i){return t},getTileUrl:function(t,r,i){var s=0,l=this._calculateAbsoluteTileNumber(t,r,i);return s=Math.floor(l/256),this.tilesUrl+"TileGroup"+s+"/"+t+"-"+r+"-"+i+"."+this.fileFormat}})})(o),(function(e){e.LegacyTileSource=function(s){var l,a,u;e.isArray(s)&&(l={type:"legacy-image-pyramid",levels:s}),l.levels=t(l.levels),l.levels.length>0?(a=l.levels[l.levels.length-1].width,u=l.levels[l.levels.length-1].height):(a=0,u=0,e.console.error("No supported image formats found")),e.extend(!0,l,{width:a,height:u,tileSize:Math.max(u,a),tileOverlap:0,minLevel:0,maxLevel:l.levels.length>0?l.levels.length-1:0}),e.TileSource.apply(this,[l]),this.levels=l.levels},e.extend(e.LegacyTileSource.prototype,e.TileSource.prototype,{supports:function(s,l){return s.type&&s.type==="legacy-image-pyramid"||s.documentElement&&s.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(s,l,a){var u;return e.isPlainObject(s)?u=i(this,s):u=r(this,s),u},getLevelScale:function(s){var l=NaN;return this.levels.length>0&&s>=this.minLevel&&s<=this.maxLevel&&(l=this.levels[s].width/this.levels[this.maxLevel].width),l},getNumTiles:function(s){var l=this.getLevelScale(s);return l?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(s,l,a){var u=null;return this.levels.length>0&&s>=this.minLevel&&s<=this.maxLevel&&(u=this.levels[s].url),u}});function t(s){var l=[],a,u;for(u=0;u<s.length;u++)a=s[u],a.height&&a.width&&a.url?l.push({url:a.url,width:Number(a.width),height:Number(a.height)}):e.console.error("Unsupported image format: %s",a.url?a.url:"<no URL>");return l.sort(function(h,c){return h.height-c.height})}function r(s,l){if(!l||!l.documentElement)throw new Error(e.getString("Errors.Xml"));var a=l.documentElement,u=a.tagName,h=null,c=[],d,m;if(u==="image")try{for(h={type:a.getAttribute("type"),levels:[]},c=a.getElementsByTagName("level"),m=0;m<c.length;m++)d=c[m],h.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return i(s,h)}catch(v){throw v instanceof Error?v:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(u==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(u==="error")throw new Error("Error: "+l)}throw new Error("Unknown element "+u)}function i(s,l){return l.levels}})(o),(function(e){e.ImageTileSource=function(t){t=e.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1},t),e.TileSource.apply(this,[t])},e.extend(e.ImageTileSource.prototype,e.TileSource.prototype,{supports:function(t,r){return t.type&&t.type==="image"},configure:function(t,r,i){return t},getImageInfo:function(t){var r=this._image=new Image,i=this;this.crossOriginPolicy&&(r.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(r.useCredentials=this.ajaxWithCredentials),e.addEvent(r,"load",function(){i.width=r.naturalWidth,i.height=r.naturalHeight,i.aspectRatio=i.width/i.height,i.dimensions=new e.Point(i.width,i.height),i._tileWidth=i.width,i._tileHeight=i.height,i.tileOverlap=0,i.minLevel=0,i.levels=i._buildLevels(),i.maxLevel=i.levels.length-1,i.ready=!0,i.raiseEvent("ready",{tileSource:i})}),e.addEvent(r,"error",function(){i.raiseEvent("open-failed",{message:"Error loading image at "+t,source:t})}),r.src=t},getLevelScale:function(t){var r=NaN;return t>=this.minLevel&&t<=this.maxLevel&&(r=this.levels[t].width/this.levels[this.maxLevel].width),r},getNumTiles:function(t){var r=this.getLevelScale(t);return r?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(t,r,i){var s=null;return t>=this.minLevel&&t<=this.maxLevel&&(s=this.levels[t].url),s},getContext2D:function(t,r,i){var s=null;return t>=this.minLevel&&t<=this.maxLevel&&(s=this.levels[t].context2D),s},destroy:function(t){this._freeupCanvasMemory(t)},_buildLevels:function(){var t=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!e.supportsCanvas)return delete this._image,t;var r=this._image.naturalWidth,i=this._image.naturalHeight,s=document.createElement("canvas"),l=s.getContext("2d");if(s.width=r,s.height=i,l.drawImage(this._image,0,0,r,i),t[0].context2D=l,delete this._image,e.isCanvasTainted(s))return t;for(;r>=2&&i>=2;){r=Math.floor(r/2),i=Math.floor(i/2);var a=document.createElement("canvas"),u=a.getContext("2d");a.width=r,a.height=i,u.drawImage(s,0,0,r,i),t.splice(0,0,{context2D:u,width:r,height:i}),s=a,l=u}return t},_freeupCanvasMemory:function(t){for(var r=0;r<this.levels.length;r++)this.levels[r].context2D&&(this.levels[r].context2D.canvas.height=0,this.levels[r].context2D.canvas.width=0,t&&t.raiseEvent("image-unloaded",{context2D:this.levels[r].context2D}))}})})(o),(function(e){e.TileSourceCollection=function(t,r,i,s){e.console.error("TileSourceCollection is deprecated; use World instead")}})(o),(function(e){e.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},e.Button=function(u){var h=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},u),this.element=u.element||e.makeNeutralElement("div"),u.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",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(c){c.insideElementPressed?(l(h,e.ButtonState.DOWN),h.raiseEvent("enter",{originalEvent:c.originalEvent})):c.buttonDownAny||l(h,e.ButtonState.HOVER)},focusHandler:function(c){h.tracker.enterHandler(c),h.raiseEvent("focus",{originalEvent:c.originalEvent})},leaveHandler:function(c){a(h,e.ButtonState.GROUP),c.insideElementPressed&&h.raiseEvent("exit",{originalEvent:c.originalEvent})},blurHandler:function(c){h.tracker.leaveHandler(c),h.raiseEvent("blur",{originalEvent:c.originalEvent})},pressHandler:function(c){l(h,e.ButtonState.DOWN),h.raiseEvent("press",{originalEvent:c.originalEvent})},releaseHandler:function(c){c.insideElementPressed&&c.insideElementReleased?(a(h,e.ButtonState.HOVER),h.raiseEvent("release",{originalEvent:c.originalEvent})):c.insideElementPressed?a(h,e.ButtonState.GROUP):l(h,e.ButtonState.HOVER)},clickHandler:function(c){c.quick&&h.raiseEvent("click",{originalEvent:c.originalEvent})},keyHandler:function(c){c.keyCode===13?(h.raiseEvent("click",{originalEvent:c.originalEvent}),h.raiseEvent("release",{originalEvent:c.originalEvent}),c.preventDefault=!0):c.preventDefault=!1}}),a(this,e.ButtonState.REST)},e.extend(e.Button.prototype,e.EventSource.prototype,{notifyGroupEnter:function(){l(this,e.ButtonState.GROUP)},notifyGroupExit:function(){a(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(u){e.requestAnimationFrame(function(){r(u)})}function r(u){var h,c,d;u.shouldFade&&(h=e.now(),c=h-u.fadeBeginTime,d=1-c/u.fadeLength,d=Math.min(1,d),d=Math.max(0,d),u.imgGroup&&e.setElementOpacity(u.imgGroup,d,!0),d>0&&t(u))}function i(u){u.shouldFade=!0,u.fadeBeginTime=e.now()+u.fadeDelay,window.setTimeout(function(){t(u)},u.fadeDelay)}function s(u){u.shouldFade=!1,u.imgGroup&&e.setElementOpacity(u.imgGroup,1,!0)}function l(u,h){u.element.disabled||(h>=e.ButtonState.GROUP&&u.currentState===e.ButtonState.REST&&(s(u),u.currentState=e.ButtonState.GROUP),h>=e.ButtonState.HOVER&&u.currentState===e.ButtonState.GROUP&&(u.imgHover&&(u.imgHover.style.visibility=""),u.currentState=e.ButtonState.HOVER),h>=e.ButtonState.DOWN&&u.currentState===e.ButtonState.HOVER&&(u.imgDown&&(u.imgDown.style.visibility=""),u.currentState=e.ButtonState.DOWN))}function a(u,h){u.element.disabled||(h<=e.ButtonState.HOVER&&u.currentState===e.ButtonState.DOWN&&(u.imgDown&&(u.imgDown.style.visibility="hidden"),u.currentState=e.ButtonState.HOVER),h<=e.ButtonState.GROUP&&u.currentState===e.ButtonState.HOVER&&(u.imgHover&&(u.imgHover.style.visibility="hidden"),u.currentState=e.ButtonState.GROUP),h<=e.ButtonState.REST&&u.currentState===e.ButtonState.GROUP&&(i(u),u.currentState=e.ButtonState.REST))}})(o),(function(e){e.ButtonGroup=function(t){e.extend(!0,this,{buttons:[],clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},t);var r=this.buttons.concat([]),i=this,s;if(this.element=t.element||e.makeNeutralElement("div"),!t.group)for(this.element.style.display="inline-block",s=0;s<r.length;s++)this.element.appendChild(r[s].element);e.setElementTouchActionNone(this.element),this.tracker=new e.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(l){var a;for(a=0;a<i.buttons.length;a++)i.buttons[a].notifyGroupEnter()},leaveHandler:function(l){var a;if(!l.insideElementPressed)for(a=0;a<i.buttons.length;a++)i.buttons[a].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}}})(o),(function(e){e.Rect=function(t,r,i,s,l){this.x=typeof t=="number"?t:0,this.y=typeof r=="number"?r:0,this.width=typeof i=="number"?i:0,this.height=typeof s=="number"?s:0,this.degrees=typeof l=="number"?l:0,this.degrees=e.positiveModulo(this.degrees,360);var a,u;this.degrees>=270?(a=this.getTopRight(),this.x=a.x,this.y=a.y,u=this.height,this.height=this.width,this.width=u,this.degrees-=270):this.degrees>=180?(a=this.getBottomRight(),this.x=a.x,this.y=a.y,this.degrees-=180):this.degrees>=90&&(a=this.getBottomLeft(),this.x=a.x,this.y=a.y,u=this.height,this.height=this.width,this.width=u,this.degrees-=90)},e.Rect.fromSummits=function(t,r,i){var s=t.distanceTo(r),l=t.distanceTo(i),a=r.minus(t),u=Math.atan(a.y/a.x);return a.x<0?u+=Math.PI:a.y<0&&(u+=2*Math.PI),new e.Rect(t.x,t.y,s,l,u/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 r=this.getBoundingBox(),i=t.getBoundingBox(),s=Math.min(r.x,i.x),l=Math.min(r.y,i.y),a=Math.max(r.x+r.width,i.x+i.width),u=Math.max(r.y+r.height,i.y+i.height);return new e.Rect(s,l,a-s,u-l)},intersection:function(t){var r=1e-10,i=[],s=this.getTopLeft();t.containsPoint(s,r)&&i.push(s);var l=this.getTopRight();t.containsPoint(l,r)&&i.push(l);var a=this.getBottomLeft();t.containsPoint(a,r)&&i.push(a);var u=this.getBottomRight();t.containsPoint(u,r)&&i.push(u);var h=t.getTopLeft();this.containsPoint(h,r)&&i.push(h);var c=t.getTopRight();this.containsPoint(c,r)&&i.push(c);var d=t.getBottomLeft();this.containsPoint(d,r)&&i.push(d);var m=t.getBottomRight();this.containsPoint(m,r)&&i.push(m);for(var v=this._getSegments(),y=t._getSegments(),_=0;_<v.length;_++)for(var E=v[_],S=0;S<y.length;S++){var P=y[S],L=F(E[0],E[1],P[0],P[1]);L&&i.push(L)}function F(Z,ie,he,pe){var ce=ie.minus(Z),ve=pe.minus(he),fe=-ve.x*ce.y+ce.x*ve.y;if(fe===0)return null;var we=(ce.x*(Z.y-he.y)-ce.y*(Z.x-he.x))/fe,He=(ve.x*(Z.y-he.y)-ve.y*(Z.x-he.x))/fe;return-r<=we&&we<=1-r&&-r<=He&&He<=1-r?new e.Point(Z.x+He*ce.x,Z.y+He*ce.y):null}if(i.length===0)return null;for(var H=i[0].x,B=i[0].x,V=i[0].y,Y=i[0].y,J=1;J<i.length;J++){var re=i[J];re.x<H&&(H=re.x),re.x>B&&(B=re.x),re.y<V&&(V=re.y),re.y>Y&&(Y=re.y)}return new e.Rect(H,V,B-H,Y-V)},_getSegments:function(){var t=this.getTopLeft(),r=this.getTopRight(),i=this.getBottomLeft(),s=this.getBottomRight();return[[t,r],[r,s],[s,i],[i,t]]},rotate:function(t,r){if(t=e.positiveModulo(t,360),t===0)return this.clone();r=r||this.getCenter();var i=this.getTopLeft().rotate(t,r),s=this.getTopRight().rotate(t,r),l=s.minus(i);l=l.apply(function(u){var h=1e-15;return Math.abs(u)<h?0:u});var a=Math.atan(l.y/l.x);return l.x<0?a+=Math.PI:l.y<0&&(a+=2*Math.PI),new e.Rect(i.x,i.y,this.width,this.height,a/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var t=this.getTopLeft(),r=this.getTopRight(),i=this.getBottomLeft(),s=this.getBottomRight(),l=Math.min(t.x,r.x,i.x,s.x),a=Math.max(t.x,r.x,i.x,s.x),u=Math.min(t.y,r.y,i.y,s.y),h=Math.max(t.y,r.y,i.y,s.y);return new e.Rect(l,u,a-l,h-u)},getIntegerBoundingBox:function(){var t=this.getBoundingBox(),r=Math.floor(t.x),i=Math.floor(t.y),s=Math.ceil(t.width+t.x-r),l=Math.ceil(t.height+t.y-i);return new e.Rect(r,i,s,l)},containsPoint:function(t,r){r=r||0;var i=this.getTopLeft(),s=this.getTopRight(),l=this.getBottomLeft(),a=s.minus(i),u=l.minus(i);return(t.x-i.x)*a.x+(t.y-i.y)*a.y>=-r&&(t.x-s.x)*a.x+(t.y-s.y)*a.y<=r&&(t.x-i.x)*u.x+(t.y-i.y)*u.y>=-r&&(t.x-l.x)*u.x+(t.y-l.y)*u.y<=r},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]"}}})(o),(function(e){var t={};e.ReferenceStrip=function(d){var m=this,v=d.viewer,y=e.getElementSize(v.element),_,E,S;for(d.id||(d.id="referencestrip-"+e.now(),this.element=e.makeNeutralElement("div"),this.element.id=d.id,this.element.className="referencestrip"),d=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.referenceStripSizeRatio,position:e.DEFAULT_SETTINGS.referenceStripPosition,scroll:e.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold},d,{element:this.element}),e.extend(this,d),t[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,E=this.element.style,E.marginTop="0px",E.marginRight="0px",E.marginBottom="0px",E.marginLeft="0px",E.left="0px",E.bottom="0px",E.border="0px",E.background="#000",E.position="relative",e.setElementTouchActionNone(this.element),e.setElementOpacity(this.element,.8),this.viewer=v,this.tracker=new e.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:e.delegate(this,r),dragHandler:e.delegate(this,i),scrollHandler:e.delegate(this,s),enterHandler:e.delegate(this,a),leaveHandler:e.delegate(this,u),keyDownHandler:e.delegate(this,h),keyHandler:e.delegate(this,c),preProcessEventHandler:function(P){P.eventType==="wheel"&&(P.preventDefault=!0)}}),d.width&&d.height?(this.element.style.width=d.width+"px",this.element.style.height=d.height+"px",v.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):d.scroll==="horizontal"?(this.element.style.width=y.x*d.sizeRatio*v.tileSources.length+12*v.tileSources.length+"px",this.element.style.height=y.y*d.sizeRatio+"px",v.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=y.y*d.sizeRatio*v.tileSources.length+12*v.tileSources.length+"px",this.element.style.width=y.x*d.sizeRatio+"px",v.addControl(this.element,{anchor:e.ControlAnchor.TOP_LEFT})),this.panelWidth=y.x*this.sizeRatio+8,this.panelHeight=y.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},S=0;S<v.tileSources.length;S++)_=e.makeNeutralElement("div"),_.id=this.element.id+"-"+S,_.style.width=m.panelWidth+"px",_.style.height=m.panelHeight+"px",_.style.display="inline",_.style.float="left",_.style.cssFloat="left",_.style.padding="2px",e.setElementTouchActionNone(_),e.setElementPointerEventsNone(_),this.element.appendChild(_),_.activePanel=!1,this.panels.push(_);l(this,this.scroll==="vertical"?y.y:y.x,0),this.setFocus(0)},e.ReferenceStrip.prototype={setFocus:function(d){var m=this.element.querySelector("#"+this.element.id+"-"+d),v=e.getElementSize(this.viewer.canvas),y=Number(this.element.style.width.replace("px","")),_=Number(this.element.style.height.replace("px","")),E=-Number(this.element.style.marginLeft.replace("px","")),S=-Number(this.element.style.marginTop.replace("px","")),P;this.currentSelected!==m&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=m,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(P=Number(d)*(this.panelWidth+3),P>E+v.x-this.panelWidth?(P=Math.min(P,y-v.x),this.element.style.marginLeft=-P+"px",l(this,v.x,-P)):P<E&&(P=Math.max(0,P-v.x/2),this.element.style.marginLeft=-P+"px",l(this,v.x,-P))):(P=Number(d)*(this.panelHeight+3),P>S+v.y-this.panelHeight?(P=Math.min(P,_-v.y),this.element.style.marginTop=-P+"px",l(this,v.y,-P)):P<S&&(P=Math.max(0,P-v.y/2),this.element.style.marginTop=-P+"px",l(this,v.y,-P))),this.currentPage=d,a.call(this,{eventSource:this.tracker}))},update:function(){return!!t[this.id].animating},destroy:function(){if(this.miniViewers)for(var d in this.miniViewers)this.miniViewers[d].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}};function r(d){if(d.quick){var m;this.scroll==="horizontal"?m=Math.floor(d.position.x/(this.panelWidth+4)):m=Math.floor(d.position.y/this.panelHeight),this.viewer.goToPage(m)}this.element.focus()}function i(d){if(this.dragging=!0,this.element){var m=Number(this.element.style.marginLeft.replace("px","")),v=Number(this.element.style.marginTop.replace("px","")),y=Number(this.element.style.width.replace("px","")),_=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?m>-(y-E.x)&&(this.element.style.marginLeft=m+d.delta.x*2+"px",l(this,E.x,m+d.delta.x*2)):-d.delta.x<0&&m<0&&(this.element.style.marginLeft=m+d.delta.x*2+"px",l(this,E.x,m+d.delta.x*2)):-d.delta.y>0?v>-(_-E.y)&&(this.element.style.marginTop=v+d.delta.y*2+"px",l(this,E.y,v+d.delta.y*2)):-d.delta.y<0&&v<0&&(this.element.style.marginTop=v+d.delta.y*2+"px",l(this,E.y,v+d.delta.y*2))}}function s(d){if(this.element){var m=Number(this.element.style.marginLeft.replace("px","")),v=Number(this.element.style.marginTop.replace("px","")),y=Number(this.element.style.width.replace("px","")),_=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?m>-(y-E.x)&&(this.element.style.marginLeft=m-d.scroll*60+"px",l(this,E.x,m-d.scroll*60)):d.scroll<0&&m<0&&(this.element.style.marginLeft=m-d.scroll*60+"px",l(this,E.x,m-d.scroll*60)):d.scroll<0?v>E.y-_&&(this.element.style.marginTop=v+d.scroll*60+"px",l(this,E.y,v+d.scroll*60)):d.scroll>0&&v<0&&(this.element.style.marginTop=v+d.scroll*60+"px",l(this,E.y,v+d.scroll*60)),d.preventDefault=!0}}function l(d,m,v){var y,_,E,S,P,L;for(d.scroll==="horizontal"?y=d.panelWidth:y=d.panelHeight,_=Math.ceil(m/y)+5,E=Math.ceil((Math.abs(v)+m)/y)+1,_=E-_,_=_<0?0:_,P=_;P<E&&P<d.panels.length;P++)if(L=d.panels[P],!L.activePanel){var F,H=d.viewer.tileSources[P];H.referenceStripThumbnailUrl?F={type:"image",url:H.referenceStripThumbnailUrl}:F=H,S=new e.Viewer({id:L.id,tileSources:[F],element:L,navigatorSizeRatio:d.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:d.viewer.loadTilesWithAjax,ajaxHeaders:d.viewer.ajaxHeaders,drawer:"canvas"}),e.setElementPointerEventsNone(S.canvas),e.setElementPointerEventsNone(S.container),S.innerTracker.setTracking(!1),S.outerTracker.setTracking(!1),d.miniViewers[L.id]=S,L.activePanel=!0}}function a(d){var m=d.eventSource.element;this.scroll==="horizontal"?m.style.marginBottom="0px":m.style.marginLeft="0px"}function u(d){var m=d.eventSource.element;this.scroll==="horizontal"?m.style.marginBottom="-"+e.getElementSize(m).y/2+"px":m.style.marginLeft="-"+e.getElementSize(m).x/2+"px"}function h(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 38:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 40:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 37:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 39:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}function c(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 61:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 45:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 48:case 119:case 87:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 115:case 83:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 97:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 100:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}})(o),(function(e){e.DisplayRect=function(t,r,i,s,l,a){e.Rect.apply(this,[t,r,i,s]),this.minLevel=l,this.maxLevel=a},e.extend(e.DisplayRect.prototype,e.Rect.prototype)})(o),(function(e){e.Spring=function(r){var i=arguments;typeof r!="object"&&(r={initial:i.length&&typeof i[0]=="number"?i[0]:void 0,springStiffness:i.length>1?i[1].springStiffness:5,animationTime:i.length>1?i[1].animationTime:1.5}),e.console.assert(typeof r.springStiffness=="number"&&r.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),e.console.assert(typeof r.animationTime=="number"&&r.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),r.exponential&&(this._exponential=!0,delete r.exponential),e.extend(!0,this,r),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(r){e.console.assert(!this._exponential||r!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=r,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(r){e.console.assert(!this._exponential||r!==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=r,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(r){this.start.value+=r,this.target.value+=r,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(r){this._exponential=r,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();let r,i;if(this._exponential?(r=this.start._logValue,i=this.target._logValue):(r=this.start.value,i=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let s=r+(i-r)*t(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));this._exponential?this.current.value=Math.exp(s):this.current.value=s}return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function t(r,i){return(1-Math.exp(r*-i))/(1-Math.exp(-r))}})(o),(function(e){e.ImageJob=function(r){e.extend(!0,this,{timeout:e.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},r),this.data=null,this.userData={},this.errorMsg=null},e.ImageJob.prototype={start:function(){this.tries++;var r=this,i=this.abort;this.jobId=window.setTimeout(function(){r.finish(null,null,"Image load exceeded timeout ("+r.timeout+" ms)")},this.timeout),this.abort=function(){r.source.downloadTileAbort(r),typeof i=="function"&&i()},this.source.downloadTileStart(this)},finish:function(r,i,s){this.data=r,this.request=i,this.errorMsg=s,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},e.ImageLoader=function(r){e.extend(!0,this,{jobLimit:e.DEFAULT_SETTINGS.imageLoaderLimit,timeout:e.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},r)},e.ImageLoader.prototype={addJob:function(r){if(!r.source){e.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var i=e.TileSource.prototype;r.source={downloadTileStart:i.downloadTileStart,downloadTileAbort:i.downloadTileAbort}}var s=this,l=function(h){t(s,h,r.callback)},a={src:r.src,tile:r.tile||{},source:r.source,loadWithAjax:r.loadWithAjax,ajaxHeaders:r.loadWithAjax?r.ajaxHeaders:null,crossOriginPolicy:r.crossOriginPolicy,ajaxWithCredentials:r.ajaxWithCredentials,postData:r.postData,callback:l,abort:r.abort,timeout:this.timeout},u=new e.ImageJob(a);!this.jobLimit||this.jobsInProgress<this.jobLimit?(u.start(),this.jobsInProgress++):this.jobQueue.push(u)},clear:function(){for(var r=0;r<this.jobQueue.length;r++){var i=this.jobQueue[r];typeof i.abort=="function"&&i.abort()}this.jobQueue=[]}};function t(r,i,s){i.errorMsg!==""&&(i.data===null||i.data===void 0)&&i.tries<1+r.tileRetryMax&&r.failedTiles.push(i);var l;r.jobsInProgress--,(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.jobQueue.length>0&&(l=r.jobQueue.shift(),l.start(),r.jobsInProgress++),r.tileRetryMax>0&&r.jobQueue.length===0&&(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.failedTiles.length>0&&(l=r.failedTiles.shift(),setTimeout(function(){l.start()},r.tileRetryDelay),r.jobsInProgress++),s(i.data,i.errorMsg,i.request)}})(o),(function(e){e.Tile=function(t,r,i,s,l,a,u,h,c,d,m,v){this.level=t,this.x=r,this.y=i,this.bounds=s,this.positionedBounds=new o.Rect(s.x,s.y,s.width,s.height),this.sourceBounds=d,this.exists=l,this._url=a,this.postData=m,this.context2D=u,this.loadWithAjax=h,this.ajaxHeaders=c,v===void 0&&(e.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),v=e.TileSource.prototype.getTileHashKey(t,r,i,a,c,m)),this.cacheKey=v,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")},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&&this.cacheImageRecord.getRenderedContext()},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,r,i){var s=Math.max(1,Math.ceil((i.x-r.x)/2)),l=Math.max(1,Math.ceil((i.y-r.y)/2));return new e.Point(s,l).minus(this.position.times(e.pixelDensityRatio).times(t||1).apply(function(a){return a%1}))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.imgElement=null,this.loaded=!1,this.loading=!1}}})(o),(function(e){e.OverlayPlacement=e.Placement,e.OverlayRotationMode=e.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),e.Overlay=function(t,r,i){var s;e.isPlainObject(t)?s=t:s={element:t,location:r,placement:i},this.elementWrapper=document.createElement("div"),this.element=s.element,this.elementWrapper.appendChild(this.element),this.element.id?this.elementWrapper.id="overlay-wrapper-"+this.element.id:this.elementWrapper.id="overlay-wrapper",this.style=this.elementWrapper.style,this._init(s)},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,r){var i=e.Placement.properties[this.placement];i&&(i.isHorizontallyCentered?t.x-=r.x/2:i.isRight&&(t.x-=r.x),i.isVerticallyCentered?t.y-=r.y/2:i.isBottom&&(t.y-=r.y))},destroy:function(){var t=this.elementWrapper,r=this.style;t.parentNode&&(t.parentNode.removeChild(t),t.prevElementParent&&(r.display="none",document.body.appendChild(t))),this.onDraw=null,r.top="",r.left="",r.position="",this.width!==null&&(r.width=""),this.height!==null&&(r.height="");var i=e.getCssPropertyWithVendorPrefix("transformOrigin"),s=e.getCssPropertyWithVendorPrefix("transform");i&&s&&(r[i]="",r[s]="")},drawHTML:function(t,r){var i=this.elementWrapper;i.parentNode!==t&&(i.prevElementParent=i.parentNode,i.prevNextSibling=i.nextSibling,t.appendChild(i),this.style.position="absolute",this.size=e.getElementSize(this.elementWrapper));var s=this._getOverlayPositionAndSize(r),l=s.position,a=this.size=s.size,u="";r.overlayPreserveContentDirection&&(u=r.flipped?" scaleX(-1)":" scaleX(1)");var h=r.flipped?-s.rotate:s.rotate,c=r.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(l,a,this.element);else{var d=this.style,m=this.element.style;m.display="block",d.left=l.x+"px",d.top=l.y+"px",this.width!==null&&(m.width=a.x+"px"),this.height!==null&&(m.height=a.y+"px");var v=e.getCssPropertyWithVendorPrefix("transformOrigin"),y=e.getCssPropertyWithVendorPrefix("transform");v&&y&&(h&&!r.flipped?(m[y]="",d[v]=this._getTransformOrigin(),d[y]="rotate("+h+"deg)"):!h&&r.flipped?(m[y]=u,d[v]=this._getTransformOrigin(),d[y]=c):h&&r.flipped?(m[y]=u,d[v]=this._getTransformOrigin(),d[y]="rotate("+h+"deg)"+c):(m[y]="",d[v]="",d[y]="")),d.display="flex"}},_getOverlayPositionAndSize:function(t){var r=t.pixelFromPoint(this.location,!0),i=this._getSizeInPixels(t);this.adjust(r,i);var s=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 l=new e.Rect(r.x,r.y,i.x,i.y),a=this._getBoundingBox(l,t.getRotation(!0));r=a.getTopLeft(),i=a.getSize()}else s=t.getRotation(!0);return t.flipped&&(r.x=t.getContainerSize().x-r.x),{position:r,size:i,rotate:s}},_getSizeInPixels:function(t){var r=this.size.x,i=this.size.y;if(this.width!==null||this.height!==null){var s=t.deltaPixelsFromPointsNoRotate(new e.Point(this.width||0,this.height||0),!0);this.width!==null&&(r=s.x),this.height!==null&&(i=s.y)}if(this.checkResize&&(this.width===null||this.height===null)){var l=this.size=e.getElementSize(this.elementWrapper);this.width===null&&(r=l.x),this.height===null&&(i=l.y)}return new e.Point(r,i)},_getBoundingBox:function(t,r){var i=this._getPlacementPoint(t);return t.rotate(r,i).getBoundingBox()},_getPlacementPoint:function(t){var r=new e.Point(t.x,t.y),i=e.Placement.properties[this.placement];return i&&(i.isHorizontallyCentered?r.x+=t.width/2:i.isRight&&(r.x+=t.width),i.isVerticallyCentered?r.y+=t.height/2:i.isBottom&&(r.y+=t.height)),r},_getTransformOrigin:function(){var t="",r=e.Placement.properties[this.placement];return r&&(r.isLeft?t="left":r.isRight&&(t="right"),r.isTop?t+=" top":r.isBottom&&(t+=" bottom")),t},update:function(t,r){var i=e.isPlainObject(t)?t:{location:t,placement:r};this._init({location:i.location||this.location,placement:i.placement!==void 0?i.placement:this.placement,onDraw:i.onDraw||this.onDraw,checkResize:i.checkResize||this.checkResize,width:i.width!==void 0?i.width:this.width,height:i.height!==void 0?i.height:this.height,rotationMode:i.rotationMode||this.rotationMode})},getBounds:function(t){e.console.assert(t,"A viewport must now be passed to Overlay.getBounds.");var r=this.width,i=this.height;if(r===null||i===null){var s=t.deltaPointsFromPixelsNoRotate(this.size,!0);r===null&&(r=s.x),i===null&&(i=s.y)}var l=this.location.clone();return this.adjust(l,new e.Point(r,i)),this._adjustBoundsForRotation(t,new e.Rect(l.x,l.y,r,i))},_adjustBoundsForRotation:function(t,r){if(!t||t.getRotation(!0)===0||this.rotationMode===e.OverlayRotationMode.EXACT)return r;if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return r;var i=this._getOverlayPositionAndSize(t);return t.viewerElementToViewportRectangle(new e.Rect(i.position.x,i.position.y,i.size.x,i.size.y))}return r.rotate(-t.getRotation(!0),this._getPlacementPoint(r))}}})(o),(function(e){const t=e;t.DrawerBase=class{constructor(i){e.console.assert(i.viewer,"[Drawer] options.viewer is required"),e.console.assert(i.viewport,"[Drawer] options.viewport is required"),e.console.assert(i.element,"[Drawer] options.element is required"),this.viewer=i.viewer,this.viewport=i.viewport,this.debugGridColor=typeof i.debugGridColor=="string"?[i.debugGridColor]:i.debugGridColor||e.DEFAULT_SETTINGS.debugGridColor,this.options=i.options||{},this.container=e.getElement(i.element),this._renderingTarget=this._createDrawingElement(),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="absolute",this.canvas.style.left="0",e.setElementOpacity(this.canvas,this.viewer.opacity,!0),e.setElementPointerEventsNone(this.canvas),e.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._checkForAPIOverrides()}get canvas(){return this._renderingTarget}get element(){return e.console.error("Drawer.element is deprecated. Use Drawer.container instead."),this.container}getType(){e.console.error("Drawer.getType must be implemented by child class")}static isSupported(){e.console.error("Drawer.isSupported must be implemented by child class")}_createDrawingElement(){return e.console.error("Drawer._createDrawingElement must be implemented by child class"),null}draw(i){e.console.error("Drawer.draw must be implemented by child class")}canRotate(){e.console.error("Drawer.canRotate must be implemented by child class")}destroy(){e.console.error("Drawer.destroy must be implemented by child class")}minimumOverlapRequired(i){return!1}setImageSmoothingEnabled(i){e.console.error("Drawer.setImageSmoothingEnabled must be implemented by child class")}drawDebuggingRect(i){e.console.warn("[drawer].drawDebuggingRect is not implemented by this drawer")}clear(){e.console.warn("[drawer].clear() is deprecated. The drawer is responsible for clearing itself as needed before drawing tiles.")}_checkForAPIOverrides(){if(this._createDrawingElement===e.DrawerBase.prototype._createDrawingElement)throw new Error("[drawer]._createDrawingElement must be implemented by child class");if(this.draw===e.DrawerBase.prototype.draw)throw new Error("[drawer].draw must be implemented by child class");if(this.canRotate===e.DrawerBase.prototype.canRotate)throw new Error("[drawer].canRotate must be implemented by child class");if(this.destroy===e.DrawerBase.prototype.destroy)throw new Error("[drawer].destroy must be implemented by child class");if(this.setImageSmoothingEnabled===e.DrawerBase.prototype.setImageSmoothingEnabled)throw new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")}viewportToDrawerRectangle(i){var s=this.viewport.pixelFromPointNoRotate(i.getTopLeft(),!0),l=this.viewport.deltaPixelsFromPointsNoRotate(i.getSize(),!0);return new e.Rect(s.x*e.pixelDensityRatio,s.y*e.pixelDensityRatio,l.x*e.pixelDensityRatio,l.y*e.pixelDensityRatio)}viewportCoordToDrawerCoord(i){var s=this.viewport.pixelFromPointNoRotate(i,!0);return new e.Point(s.x*e.pixelDensityRatio,s.y*e.pixelDensityRatio)}_calculateCanvasSize(){var i=e.pixelDensityRatio,s=this.viewport.getContainerSize();return new t.Point(Math.round(s.x*i),Math.round(s.y*i))}_raiseTiledImageDrawnEvent(i,s){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:i,tiles:s})}_raiseDrawerErrorEvent(i,s){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:i,drawer:this,error:s})}}})(o),(function(e){const t=e;class r extends t.DrawerBase{constructor(s){super(s),this.viewer.rejectEventHandler("tile-drawing","The HTMLDrawer does not raise the tile-drawing event"),this.viewer.allowEventHandler("tile-drawn")}static isSupported(){return!0}getType(){return"html"}minimumOverlapRequired(s){return!0}_createDrawingElement(){return e.makeNeutralElement("div")}draw(s){var l=this;this._prepareNewFrame(),s.forEach(function(a){a.opacity!==0&&l._drawTiles(a)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(s){var l=s.getTilesToDraw().map(h=>h.tile);if(!(s.opacity===0||l.length===0&&!s.placeholderFillStyle))for(var a=l.length-1;a>=0;a--){var u=l[a];this._drawTile(u),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:s,tile:u})}}_drawTile(s){e.console.assert(s,"[Drawer._drawTile] tile is required");let l=this.canvas;if(!s.cacheImageRecord){e.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",s.toString());return}if(!s.loaded){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",s.toString());return}if(!s.element){var a=s.getImage();if(!a)return;s.element=e.makeNeutralElement("div"),s.imgElement=a.cloneNode(),s.imgElement.style.msInterpolationMode="nearest-neighbor",s.imgElement.style.width="100%",s.imgElement.style.height="100%",s.style=s.element.style,s.style.position="absolute"}s.element.parentNode!==l&&l.appendChild(s.element),s.imgElement.parentNode!==s.element&&s.element.appendChild(s.imgElement),s.style.top=s.position.y+"px",s.style.left=s.position.x+"px",s.style.height=s.size.y+"px",s.style.width=s.size.x+"px",s.flipped&&(s.style.transform="scaleX(-1)"),e.setElementOpacity(s.element,s.opacity)}}e.HTMLDrawer=r})(o),(function(e){const t=e;class r extends t.DrawerBase{constructor(h){super(h),this.context=this.canvas.getContext("2d"),this.sketchCanvas=null,this.sketchContext=null,this._imageSmoothingEnabled=!0,this.viewer.allowEventHandler("tile-drawn"),this.viewer.allowEventHandler("tile-drawing")}static isSupported(){return e.supportsCanvas}getType(){return"canvas"}_createDrawingElement(){let h=e.makeNeutralElement("canvas"),c=this._calculateCanvasSize();return h.width=c.x,h.height=c.y,h}draw(h){this._prepareNewFrame(),this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const c of h)c.opacity!==0&&this._drawTiles(c)}canRotate(){return!0}destroy(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null,this.container.removeChild(this.canvas)}minimumOverlapRequired(h){return!0}setImageSmoothingEnabled(h){this._imageSmoothingEnabled=!!h,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw()}drawDebuggingRect(h){var c=this.context;c.save(),c.lineWidth=2*e.pixelDensityRatio,c.strokeStyle=this.debugGridColor[0],c.fillStyle=this.debugGridColor[0],c.strokeRect(h.x*e.pixelDensityRatio,h.y*e.pixelDensityRatio,h.width*e.pixelDensityRatio,h.height*e.pixelDensityRatio),c.restore()}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(h,c,d,m){this.viewer.raiseEvent("tile-drawing",{tiledImage:h,context:c,tile:d,rendered:m})}_prepareNewFrame(){var h=this._calculateCanvasSize();if((this.canvas.width!==h.x||this.canvas.height!==h.y)&&(this.canvas.width=h.x,this.canvas.height=h.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var c=this._calculateSketchCanvasSize();this.sketchCanvas.width=c.x,this.sketchCanvas.height=c.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}_clear(h,c){var d=this._getContext(h);if(c)d.clearRect(c.x,c.y,c.width,c.height);else{var m=d.canvas;d.clearRect(0,0,m.width,m.height)}}_drawTiles(h){var c=h.getTilesToDraw().map(Z=>Z.tile);if(!(h.opacity===0||c.length===0&&!h.placeholderFillStyle)){var d=c[0],m;d&&(m=h.opacity<1||h.compositeOperation&&h.compositeOperation!=="source-over"||!h._isBottomItem()&&h.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var v,y,_=this.viewport.getZoom(!0),E=h.viewportToImageZoom(_);c.length>1&&E>h.smoothTileEdgesMinZoom&&!h.iOSDevice&&h.getRotation(!0)%360===0&&(m=!0,v=d.getScaleForEdgeSmoothing(),y=d.getTranslationForEdgeSmoothing(v,this._getCanvasSize(!1),this._getCanvasSize(!0)));var S;m&&(v||(S=this.viewport.viewportToViewerElementRectangle(h.getClippedBounds(!0)).getIntegerBoundingBox(),S=S.times(e.pixelDensityRatio)),this._clear(!0,S)),v||this._setRotations(h,m);var P=!1;if(h._clip){this._saveContext(m);var L=h.imageToViewportRectangle(h._clip,!0);L=L.rotate(-h.getRotation(!0),h._getRotationPoint(!0));var F=this.viewportToDrawerRectangle(L);v&&(F=F.times(v)),y&&(F=F.translate(y)),this._setClip(F,m),P=!0}if(h._croppingPolygons){var H=this;P||this._saveContext(m);try{var B=h._croppingPolygons.map(function(Z){return Z.map(function(ie){var he=h.imageToViewportCoordinates(ie.x,ie.y,!0).rotate(-h.getRotation(!0),h._getRotationPoint(!0)),pe=H.viewportCoordToDrawerCoord(he);return v&&(pe=pe.times(v)),y&&(pe=pe.plus(y)),pe})});this._clipWithPolygons(B,m)}catch(Z){e.console.error(Z)}P=!0}if(h._hasOpaqueTile=!1,h.placeholderFillStyle&&h._hasOpaqueTile===!1){let Z=this.viewportToDrawerRectangle(h.getBoundsNoRotate(!0));v&&(Z=Z.times(v)),y&&(Z=Z.translate(y));let ie=null;typeof h.placeholderFillStyle=="function"?ie=h.placeholderFillStyle(h,this.context):ie=h.placeholderFillStyle,this._drawRectangle(Z,ie,m)}var V=a(h.subPixelRoundingForTransparency),Y=!1;if(V===e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)Y=!0;else if(V===e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var J=this.viewer&&this.viewer.isAnimating();Y=!J}for(var re=0;re<c.length;re++)d=c[re],this._drawTile(d,h,m,v,y,Y,h.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:h,tile:d});P&&this._restoreContext(m),v||(h.getRotation(!0)%360!==0&&this._restoreRotationChanges(m),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(m)),m&&(v&&this._setRotations(h),this.blendSketch({opacity:h.opacity,scale:v,translate:y,compositeOperation:h.compositeOperation,bounds:S}),v&&(h.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1))),this._drawDebugInfo(h,c),this._raiseTiledImageDrawnEvent(h,c)}}_drawDebugInfo(h,c){if(h.debugMode)for(var d=c.length-1;d>=0;d--){var m=c[d];try{this._drawDebugInfoOnTile(m,c.length,d,h)}catch(v){e.console.error(v)}}}_clipWithPolygons(h,c){var d=this._getContext(c);d.beginPath();for(const m of h)for(const[v,y]of m.entries())d[v===0?"moveTo":"lineTo"](y.x,y.y);d.clip()}_drawTile(h,c,d,m,v,y,_){e.console.assert(h,"[Drawer._drawTile] tile is required"),e.console.assert(c,"[Drawer._drawTile] drawingHandler is required");var E=this._getContext(d);m=m||1,this._drawTileToCanvas(h,E,c,m,v,y,_)}_drawTileToCanvas(h,c,d,m,v,y,_){var E=h.position.times(e.pixelDensityRatio),S=h.size.times(e.pixelDensityRatio),P;if(!h.context2D&&!h.cacheImageRecord){e.console.warn("[Drawer._drawTileToCanvas] attempting to draw tile %s when it's not cached",h.toString());return}if(P=h.getCanvasContext(),!h.loaded||!P){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",h.toString());return}c.save(),typeof m=="number"&&m!==1&&(E=E.times(m),S=S.times(m)),v instanceof e.Point&&(E=E.plus(v)),c.globalAlpha===1&&h.hasTransparency&&(y&&(E.x=Math.round(E.x),E.y=Math.round(E.y),S.x=Math.round(S.x),S.y=Math.round(S.y)),c.clearRect(E.x,E.y,S.x,S.y)),this._raiseTileDrawingEvent(d,c,h,P);var L,F;h.sourceBounds?(L=Math.min(h.sourceBounds.width,P.canvas.width),F=Math.min(h.sourceBounds.height,P.canvas.height)):(L=P.canvas.width,F=P.canvas.height),c.translate(E.x+S.x/2,0),h.flipped&&c.scale(-1,1),c.drawImage(P.canvas,0,0,L,F,-S.x/2,E.y,S.x,S.y),c.restore()}_getContext(h){var c=this.context;if(h){if(this.sketchCanvas===null){this.sketchCanvas=document.createElement("canvas");var d=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=d.x,this.sketchCanvas.height=d.y,this.sketchContext=this.sketchCanvas.getContext("2d"),this.viewport.getRotation()===0){var m=this;this.viewer.addHandler("rotate",function v(){if(m.viewport.getRotation()!==0){m.viewer.removeHandler("rotate",v);var y=m._calculateSketchCanvasSize();m.sketchCanvas.width=y.x,m.sketchCanvas.height=y.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}c=this.sketchContext}return c}_saveContext(h){this._getContext(h).save()}_restoreContext(h){this._getContext(h).restore()}_setClip(h,c){var d=this._getContext(c);d.beginPath(),d.rect(h.x,h.y,h.width,h.height),d.clip()}_drawRectangle(h,c,d){var m=this._getContext(d);m.save(),m.fillStyle=c,m.fillRect(h.x,h.y,h.width,h.height),m.restore()}blendSketch(h,c,d,m){var v=h;e.isPlainObject(v)||(v={opacity:h,scale:c,translate:d,compositeOperation:m}),h=v.opacity,m=v.compositeOperation;var y=v.bounds;if(this.context.save(),this.context.globalAlpha=h,m&&(this.context.globalCompositeOperation=m),y)y.x<0&&(y.width+=y.x,y.x=0),y.x+y.width>this.canvas.width&&(y.width=this.canvas.width-y.x),y.y<0&&(y.height+=y.y,y.y=0),y.y+y.height>this.canvas.height&&(y.height=this.canvas.height-y.y),this.context.drawImage(this.sketchCanvas,y.x,y.y,y.width,y.height,y.x,y.y,y.width,y.height);else{c=v.scale||1,d=v.translate;var _=d instanceof e.Point?d:new e.Point(0,0),E=0,S=0;if(d){var P=this.sketchCanvas.width-this.canvas.width,L=this.sketchCanvas.height-this.canvas.height;E=Math.round(P/2),S=Math.round(L/2)}this.context.drawImage(this.sketchCanvas,_.x-E*c,_.y-S*c,(this.canvas.width+2*E)*c,(this.canvas.height+2*S)*c,-E,-S,this.canvas.width+2*E,this.canvas.height+2*S)}this.context.restore()}_drawDebugInfoOnTile(h,c,d,m){var v=this.viewer.world.getIndexOfItem(m)%this.debugGridColor.length,y=this.context;y.save(),y.lineWidth=2*e.pixelDensityRatio,y.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",y.strokeStyle=this.debugGridColor[v],y.fillStyle=this.debugGridColor[v],this._setRotations(m),this._viewportFlipped&&this._flip({point:h.position.plus(h.size.divide(2))}),y.strokeRect(h.position.x*e.pixelDensityRatio,h.position.y*e.pixelDensityRatio,h.size.x*e.pixelDensityRatio,h.size.y*e.pixelDensityRatio);var _=(h.position.x+h.size.x/2)*e.pixelDensityRatio,E=(h.position.y+h.size.y/2)*e.pixelDensityRatio;y.translate(_,E);const S=this.viewport.getRotation(!0);y.rotate(Math.PI/180*-S),y.translate(-_,-E),h.x===0&&h.y===0&&(y.fillText("Zoom: "+this.viewport.getZoom(),h.position.x*e.pixelDensityRatio,(h.position.y-30)*e.pixelDensityRatio),y.fillText("Pan: "+this.viewport.getBounds().toString(),h.position.x*e.pixelDensityRatio,(h.position.y-20)*e.pixelDensityRatio)),y.fillText("Level: "+h.level,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+20)*e.pixelDensityRatio),y.fillText("Column: "+h.x,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+30)*e.pixelDensityRatio),y.fillText("Row: "+h.y,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+40)*e.pixelDensityRatio),y.fillText("Order: "+d+" of "+c,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+50)*e.pixelDensityRatio),y.fillText("Size: "+h.size.toString(),(h.position.x+10)*e.pixelDensityRatio,(h.position.y+60)*e.pixelDensityRatio),y.fillText("Position: "+h.position.toString(),(h.position.x+10)*e.pixelDensityRatio,(h.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),m.getRotation(!0)%360!==0&&this._restoreRotationChanges(),y.restore()}_updateImageSmoothingEnabled(h){h.msImageSmoothingEnabled=this._imageSmoothingEnabled,h.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(h){var c=this._getContext(h).canvas;return new e.Point(c.width,c.height)}_getCanvasCenter(){return new e.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(h,c=!1){var d=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:c,saveContext:d}),d=!1),h.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:h.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(h._getRotationPoint(!0),!0),useSketch:c,saveContext:d})}_offsetForRotation(h){var c=h.point?h.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(h.useSketch);d.save(),d.translate(c.x,c.y),d.rotate(Math.PI/180*h.degrees),d.translate(-c.x,-c.y)}_flip(h){h=h||{};var c=h.point?h.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(h.useSketch);d.translate(c.x,0),d.scale(-1,1),d.translate(-c.x,0)}_restoreRotationChanges(h){var c=this._getContext(h);c.restore()}_calculateCanvasSize(){var h=e.pixelDensityRatio,c=this.viewport.getContainerSize();return{x:Math.round(c.x*h),y:Math.round(c.y*h)}}_calculateSketchCanvasSize(){var h=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return h;var c=Math.ceil(Math.sqrt(h.x*h.x+h.y*h.y));return{x:c,y:c}}}e.CanvasDrawer=r;var i=e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function s(u){return u!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&u!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&u!==e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function l(u){return s(u)?i:u}function a(u){if(typeof u=="number")return l(u);if(!u||!e.Browser)return i;var h=u[e.Browser.vendor];return s(h)&&(h=u["*"]),l(h)}})(o),(function(e){const t=e;t.WebGLDrawer=class extends t.DrawerBase{constructor(i){super(i),this._destroyed=!1,this._TextureMap=new Map,this._TileMap=new Map,this._gl=null,this._firstPass=null,this._secondPass=null,this._glFrameBuffer=null,this._renderToTexture=null,this._glFramebufferToCanvasTransform=null,this._outputCanvas=null,this._outputContext=null,this._clippingCanvas=null,this._clippingContext=null,this._renderingCanvas=null,this._backupCanvasDrawer=null,this._imageSmoothingEnabled=!0,this._boundToTileReady=s=>this._tileReadyHandler(s),this._boundToImageUnloaded=s=>this._imageUnloadedHandler(s),this.viewer.addHandler("tile-ready",this._boundToTileReady),this.viewer.addHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.rejectEventHandler("tile-drawn","The WebGLDrawer does not raise the tile-drawn event"),this.viewer.rejectEventHandler("tile-drawing","The WebGLDrawer does not raise the tile-drawing event"),this._setupCanvases(),this._setupRenderer(),this.context=this._outputContext}destroy(){if(this._destroyed)return;let i=this._gl;var s=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);for(let a=0;a<s;++a)i.activeTexture(i.TEXTURE0+a),i.bindTexture(i.TEXTURE_2D,null),i.bindTexture(i.TEXTURE_CUBE_MAP,null);i.bindBuffer(i.ARRAY_BUFFER,null),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),i.bindRenderbuffer(i.RENDERBUFFER,null),i.bindFramebuffer(i.FRAMEBUFFER,null),this._unloadTextures(),i.deleteBuffer(this._secondPass.bufferOutputPosition),i.deleteFramebuffer(this._glFrameBuffer),this._renderingCanvas.width=this._renderingCanvas.height=1,this._clippingCanvas.width=this._clippingCanvas.height=1,this._outputCanvas.width=this._outputCanvas.height=1,this._renderingCanvas=null,this._clippingCanvas=this._clippingContext=null,this._outputCanvas=this._outputContext=null;let l=i.getExtension("WEBGL_lose_context");l&&l.loseContext(),this.viewer.removeHandler("tile-ready",this._boundToTileReady),this.viewer.removeHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.removeHandler("resize",this._resizeHandler),this._gl=null,this._backupCanvasDrawer&&(this._backupCanvasDrawer.destroy(),this._backupCanvasDrawer=null),this.container.removeChild(this.canvas),this.viewer.drawer===this&&(this.viewer.drawer=null),this._destroyed=!0}canRotate(){return!0}static isSupported(){let i=document.createElement("canvas"),s=e.isFunction(i.getContext)&&i.getContext("webgl"),l=s&&s.getExtension("WEBGL_lose_context");return l&&l.loseContext(),!!s}getType(){return"webgl"}minimumOverlapRequired(i){return i.isTainted()}_createDrawingElement(){let i=e.makeNeutralElement("canvas"),s=this._calculateCanvasSize();return i.width=s.x,i.height=s.y,i}_getBackupCanvasDrawer(){return this._backupCanvasDrawer||(this._backupCanvasDrawer=this.viewer.requestDrawer("canvas",{mainDrawer:!1}),this._backupCanvasDrawer.canvas.style.setProperty("visibility","hidden")),this._backupCanvasDrawer}draw(i){let s=this._gl;const l=this.viewport.getBoundsNoRotateWithMargins(!0);let a={bounds:l,center:new t.Point(l.x+l.width/2,l.y+l.height/2),rotation:this.viewport.getRotation(!0)*Math.PI/180},u=this.viewport.flipped?-1:1,h=e.Mat3.makeTranslation(-a.center.x,-a.center.y),c=e.Mat3.makeScaling(2/a.bounds.width*u,-2/a.bounds.height),d=e.Mat3.makeRotation(-a.rotation),m=c.multiply(d).multiply(h);s.bindFramebuffer(s.FRAMEBUFFER,null),s.clear(s.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let v=!1;i.forEach((y,_)=>{if(y.isTainted()){v&&(this._outputContext.drawImage(this._renderingCanvas,0,0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.clear(s.COLOR_BUFFER_BIT),v=!1);const E=this._getBackupCanvasDrawer();E.draw([y]),this._outputContext.drawImage(E.canvas,0,0)}else{let E=y.getTilesToDraw();if(y.placeholderFillStyle&&y._hasOpaqueTile===!1&&this._drawPlaceholder(y),E.length===0||y.getOpacity()===0)return;let S=E[0],P=y.compositeOperation||this.viewer.compositeOperation||y._clip||y._croppingPolygons||y.debugMode,L=P||y.opacity<1||S.hasTransparency;P&&(v&&this._outputContext.drawImage(this._renderingCanvas,0,0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.clear(s.COLOR_BUFFER_BIT)),s.useProgram(this._firstPass.shaderProgram),L?(s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.clear(s.COLOR_BUFFER_BIT)):s.bindFramebuffer(s.FRAMEBUFFER,null);let F=m,H=y.getRotation(!0);if(H%360!==0){let Z=e.Mat3.makeRotation(-H*Math.PI/180),ie=y.getBoundsNoRotate(!0).getCenter(),he=e.Mat3.makeTranslation(ie.x,ie.y),pe=e.Mat3.makeTranslation(-ie.x,-ie.y),ce=he.multiply(Z).multiply(pe);F=m.multiply(ce)}let B=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(B<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${B}). This could happen
|
|
128
|
-
if too many contexts have been created and not released, or there is another problem with the graphics card.`);let
|
|
129
|
-
`),
|
|
130
|
-
`);const
|
|
127
|
+
function s(e){return new s.Viewer(e)}(function(e){e.version={versionStr:"5.0.1",major:parseInt("5",10),minor:parseInt("0",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,n=Object.prototype.hasOwnProperty;e.isFunction=function(o){return e.type(o)==="function"},e.isArray=Array.isArray||function(o){return e.type(o)==="array"},e.isWindow=function(o){return o&&typeof o=="object"&&"setInterval"in o},e.type=function(o){return o==null?String(o):t[i.call(o)]||"object"},e.isPlainObject=function(o){if(!o||s.type(o)!=="object"||o.nodeType||e.isWindow(o)||o.constructor&&!n.call(o,"constructor")&&!n.call(o.constructor.prototype,"isPrototypeOf"))return!1;var u;for(var l in o)u=l;return u===void 0||n.call(o,u)},e.isEmptyObject=function(o){for(var u in o)return!1;return!0},e.freezeObject=function(o){return Object.freeze?e.freezeObject=Object.freeze:e.freezeObject=function(u){return u},e.freezeObject(o)},e.supportsCanvas=(function(){var o=document.createElement("canvas");return!!(e.isFunction(o.getContext)&&o.getContext("2d"))})(),e.isCanvasTainted=function(o){var u=!1;try{o.getContext("2d").getImageData(0,0,1,1)}catch{u=!0}return u},e.supportsAddEventListener=(function(){return!!(document.documentElement.addEventListener&&document.addEventListener)})(),e.supportsRemoveEventListener=(function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)})(),e.supportsEventListenerOptions=(function(){var o=0;if(e.supportsAddEventListener)try{var u={get capture(){return o++,!1},get once(){return o++,!1},get passive(){return o++,!1}};window.addEventListener("test",null,u),window.removeEventListener("test",null,u)}catch{o=0}return o>=3})(),e.getCurrentPixelDensityRatio=function(){if(e.supportsCanvas){var o=document.createElement("canvas").getContext("2d"),u=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;return Math.max(u,1)/l}else return 1},e.pixelDensityRatio=e.getCurrentPixelDensityRatio()})(s),(function(e){e.extend=function(){var l,a,h,c,d,v,m=arguments[0]||{},_=arguments.length,y=!1,E=1;for(typeof m=="boolean"&&(y=m,m=arguments[1]||{},E=2),typeof m!="object"&&!s.isFunction(m)&&(m={}),_===E&&(m=this,--E);E<_;E++)if(l=arguments[E],l!==null||l!==void 0)for(a in l){var S=Object.getOwnPropertyDescriptor(l,a);if(S!==void 0){if(S.get||S.set){Object.defineProperty(m,a,S);continue}c=S.value}else{e.console.warn('Could not copy inherited property "'+a+'".');continue}m!==c&&(y&&c&&(s.isPlainObject(c)||(d=s.isArray(c)))?(h=m[a],d?(d=!1,v=h&&s.isArray(h)?h:[]):v=h&&s.isPlainObject(h)?h:{},m[a]=s.extend(y,v,c)):c!==void 0&&(m[a]=c))}return m};var t=function(){if(typeof navigator!="object")return!1;var l=navigator.userAgent;return typeof l!="string"?!1:l.indexOf("iPhone")!==-1||l.indexOf("iPad")!==-1||l.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,maxTilesPerFrame:1,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,overlayPreserveContentDirection:!0,opacity:1,compositeOperation:null,drawer:["webgl","canvas","html"],drawerOptions:{webgl:{},canvas:{},html:{},custom:{}},preload:!1,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,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},delegate:function(l,a){return function(){var h=arguments;return h===void 0&&(h=[]),a.apply(l,h)}},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(l){return e._viewers.get(this.getElement(l))},getElement:function(l){return typeof l=="string"&&(l=document.getElementById(l)),l},getElementPosition:function(l){var a=new e.Point,h,c;for(l=e.getElement(l),h=e.getElementStyle(l).position==="fixed",c=u(l,h);c;)a.x+=l.offsetLeft,a.y+=l.offsetTop,h&&(a=a.plus(e.getPageScroll())),l=c,h=e.getElementStyle(l).position==="fixed",c=u(l,h);return a},getElementOffset:function(l){l=e.getElement(l);var a=l&&l.ownerDocument,h,c,d={top:0,left:0};return a?(h=a.documentElement,typeof l.getBoundingClientRect<"u"&&(d=l.getBoundingClientRect()),c=a===a.window?a:a.nodeType===9?a.defaultView||a.parentWindow:!1,new e.Point(d.left+(c.pageXOffset||h.scrollLeft)-(h.clientLeft||0),d.top+(c.pageYOffset||h.scrollTop)-(h.clientTop||0))):new e.Point},getElementSize:function(l){return l=e.getElement(l),new e.Point(l.clientWidth,l.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(l){return l=e.getElement(l),l.currentStyle}:function(l){return l=e.getElement(l),window.getComputedStyle(l,"")},getCssPropertyWithVendorPrefix:function(l){var a={};return e.getCssPropertyWithVendorPrefix=function(h){if(a[h]!==void 0)return a[h];var c=document.createElement("div").style,d=null;if(c[h]!==void 0)d=h;else for(var v=["Webkit","Moz","MS","O","webkit","moz","ms","o"],m=e.capitalizeFirstLetter(h),_=0;_<v.length;_++){var y=v[_]+m;if(c[y]!==void 0){d=y;break}}return a[h]=d,d},e.getCssPropertyWithVendorPrefix(l)},capitalizeFirstLetter:function(l){return l.charAt(0).toUpperCase()+l.slice(1)},positiveModulo:function(l,a){var h=l%a;return h<0&&(h+=a),h},pointInElement:function(l,a){l=e.getElement(l);var h=e.getElementOffset(l),c=e.getElementSize(l);return a.x>=h.x&&a.x<h.x+c.x&&a.y<h.y+c.y&&a.y>=h.y},getMousePosition:function(l){if(typeof l.pageX=="number")e.getMousePosition=function(a){var h=new e.Point;return h.x=a.pageX,h.y=a.pageY,h};else if(typeof l.clientX=="number")e.getMousePosition=function(a){var h=new e.Point;return h.x=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h.y=a.clientY+document.body.scrollTop+document.documentElement.scrollTop,h};else throw new Error("Unknown event mouse position, no known technique.");return e.getMousePosition(l)},getPageScroll:function(){var l=document.documentElement||{},a=document.body||{};if(typeof window.pageXOffset=="number")e.getPageScroll=function(){return new e.Point(window.pageXOffset,window.pageYOffset)};else if(a.scrollLeft||a.scrollTop)e.getPageScroll=function(){return new e.Point(document.body.scrollLeft,document.body.scrollTop)};else if(l.scrollLeft||l.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(l){if(typeof window.scrollTo<"u")e.setPageScroll=function(c){window.scrollTo(c.x,c.y)};else{var a=e.getPageScroll();if(a.x===l.x&&a.y===l.y)return;document.body.scrollLeft=l.x,document.body.scrollTop=l.y;var h=e.getPageScroll();if(h.x!==a.x&&h.y!==a.y){e.setPageScroll=function(c){document.body.scrollLeft=c.x,document.body.scrollTop=c.y};return}if(document.documentElement.scrollLeft=l.x,document.documentElement.scrollTop=l.y,h=e.getPageScroll(),h.x!==a.x&&h.y!==a.y){e.setPageScroll=function(c){document.documentElement.scrollLeft=c.x,document.documentElement.scrollTop=c.y};return}e.setPageScroll=function(c){}}e.setPageScroll(l)},getWindowSize:function(){var l=document.documentElement||{},a=document.body||{};if(typeof window.innerWidth=="number")e.getWindowSize=function(){return new e.Point(window.innerWidth,window.innerHeight)};else if(l.clientWidth||l.clientHeight)e.getWindowSize=function(){return new e.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(a.clientWidth||a.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(l){l=e.getElement(l);var a=[e.makeNeutralElement("div"),e.makeNeutralElement("div"),e.makeNeutralElement("div")];return e.extend(a[0].style,{display:"table",height:"100%",width:"100%"}),e.extend(a[1].style,{display:"table-row"}),e.extend(a[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),a[0].appendChild(a[1]),a[1].appendChild(a[2]),a[2].appendChild(l),a[0]},makeNeutralElement:function(l){var a=document.createElement(l),h=a.style;return h.background="transparent none",h.border="none",h.margin="0px",h.padding="0px",h.position="static",a},now:function(){return Date.now?e.now=Date.now:e.now=function(){return new Date().getTime()},e.now()},makeTransparentImage:function(l){var a=e.makeNeutralElement("img");return a.src=l,a},setElementOpacity:function(l,a,h){var c,d;l=e.getElement(l),h&&!e.Browser.alpha&&(a=Math.round(a)),e.Browser.opacity?l.style.opacity=a<1?a:"":a<1?(c=Math.round(100*a),d="alpha(opacity="+c+")",l.style.filter=d):l.style.filter=""},setElementTouchActionNone:function(l){l=e.getElement(l),typeof l.style.touchAction<"u"?l.style.touchAction="none":typeof l.style.msTouchAction<"u"&&(l.style.msTouchAction="none")},setElementPointerEvents:function(l,a){l=e.getElement(l),typeof l.style<"u"&&typeof l.style.pointerEvents<"u"&&(l.style.pointerEvents=a)},setElementPointerEventsNone:function(l){e.setElementPointerEvents(l,"none")},addClass:function(l,a){l=e.getElement(l),l.className?(" "+l.className+" ").indexOf(" "+a+" ")===-1&&(l.className+=" "+a):l.className=a},indexOf:function(l,a,h){return Array.prototype.indexOf?this.indexOf=function(c,d,v){return c.indexOf(d,v)}:this.indexOf=function(c,d,v){var m,_=v||0,y;if(!c)throw new TypeError;if(y=c.length,y===0||_>=y)return-1;for(_<0&&(_=y-Math.abs(_)),m=_;m<y;m++)if(c[m]===d)return m;return-1},this.indexOf(l,a,h)},removeClass:function(l,a){var h,c=[],d;for(l=e.getElement(l),h=l.className.split(/\s+/),d=0;d<h.length;d++)h[d]&&h[d]!==a&&c.push(h[d]);l.className=c.join(" ")},normalizeEventListenerOptions:function(l){var a;return typeof l<"u"?typeof l=="boolean"?a=e.supportsEventListenerOptions?{capture:l}:l:a=e.supportsEventListenerOptions?l:typeof l.capture<"u"?l.capture:!1:a=e.supportsEventListenerOptions?{capture:!1}:!1,a},addEvent:(function(){if(e.supportsAddEventListener)return function(l,a,h,c){c=e.normalizeEventListenerOptions(c),l=e.getElement(l),l.addEventListener(a,h,c)};if(document.documentElement.attachEvent&&document.attachEvent)return function(l,a,h){l=e.getElement(l),l.attachEvent("on"+a,h)};throw new Error("No known event model.")})(),removeEvent:(function(){if(e.supportsRemoveEventListener)return function(l,a,h,c){c=e.normalizeEventListenerOptions(c),l=e.getElement(l),l.removeEventListener(a,h,c)};if(document.documentElement.detachEvent&&document.detachEvent)return function(l,a,h){l=e.getElement(l),l.detachEvent("on"+a,h)};throw new Error("No known event model.")})(),cancelEvent:function(l){l.preventDefault()},eventIsCanceled:function(l){return l.defaultPrevented},stopEvent:function(l){l.stopPropagation()},createCallback:function(l,a){console.error("The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.");var h=[],c;for(c=2;c<arguments.length;c++)h.push(arguments[c]);return function(){var d=h.concat([]),v;for(v=0;v<arguments.length;v++)d.push(arguments[v]);return a.apply(l,d)}},getUrlParameter:function(l){var a=o[l];return a||null},getUrlProtocol:function(l){var a=l.match(/^([a-z]+:)\/\//i);return a===null?window.location.protocol:a[1].toLowerCase()},createAjaxRequest:function(){if(window.XMLHttpRequest)return e.createAjaxRequest=function(){return new XMLHttpRequest},new XMLHttpRequest;throw new Error("Browser doesn't support XMLHttpRequest.")},makeAjaxRequest:function(l,a,h){var c,d,v,m;e.isPlainObject(l)&&(a=l.success,h=l.error,c=l.withCredentials,d=l.headers,v=l.responseType||null,m=l.postData||null,l=l.url);var _=e.getUrlProtocol(l),y=e.createAjaxRequest();if(!e.isFunction(a))throw new Error("makeAjaxRequest requires a success callback");y.onreadystatechange=function(){y.readyState===4&&(y.onreadystatechange=function(){},y.status>=200&&y.status<300||y.status===0&&_!=="http:"&&_!=="https:"?a(y):e.isFunction(h)?h(y):e.console.error("AJAX request returned %d: %s",y.status,l))};var E=m?"POST":"GET";try{if(y.open(E,l,!0),v&&(y.responseType=v),d)for(var S in d)Object.prototype.hasOwnProperty.call(d,S)&&d[S]&&y.setRequestHeader(S,d[S]);c&&(y.withCredentials=!0),y.send(m)}catch(P){e.console.error("%s while making AJAX request: %s",P.name,P.message),y.onreadystatechange=function(){},e.isFunction(h)&&h(y,P)}return y},jsonp:function(l){var a,h=l.url,c=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=l.callbackName||"openseadragon"+e.now(),v=window[d],m="$1"+d+"$2",_=l.param||"callback",y=l.callback;h=h.replace(/(=)\?(&|$)|\?\?/i,m),h+=(/\?/.test(h)?"&":"?")+_+"="+d,window[d]=function(E){if(v)window[d]=v;else try{delete window[d]}catch{}y&&e.isFunction(y)&&y(E)},a=document.createElement("script"),(l.async!==void 0||l.async!==!1)&&(a.async="async"),l.scriptCharset&&(a.charset=l.scriptCharset),a.src=h,a.onload=a.onreadystatechange=function(E,S){(S||!a.readyState||/loaded|complete/.test(a.readyState))&&(a.onload=a.onreadystatechange=null,c&&a.parentNode&&c.removeChild(a),a=void 0)},c.insertBefore(a,c.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(l){if(window.DOMParser)e.parseXml=function(a){var h=null,c;return c=new DOMParser,h=c.parseFromString(a,"text/xml"),h};else throw new Error("Browser doesn't support XML DOM.");return e.parseXml(l)},parseJSON:function(l){return e.parseJSON=window.JSON.parse,e.parseJSON(l)},imageFormatSupported:function(l){return l=l||"",!!n[l.toLowerCase()]},setImageFormatsSupported:function(l){e.extend(n,l)}});var i=function(l){};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 n={avif:!0,bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0},o={};(function(){var l=navigator.appVersion,a=navigator.userAgent,h;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(a.substring(a.indexOf("MSIE")+5,a.indexOf(";",a.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(a.indexOf("Edge")>=0?(e.Browser.vendor=e.BROWSERS.EDGE,e.Browser.version=parseFloat(a.substring(a.indexOf("Edge")+5))):a.indexOf("Edg")>=0?(e.Browser.vendor=e.BROWSERS.CHROMEEDGE,e.Browser.version=parseFloat(a.substring(a.indexOf("Edg")+4))):a.indexOf("Firefox")>=0?(e.Browser.vendor=e.BROWSERS.FIREFOX,e.Browser.version=parseFloat(a.substring(a.indexOf("Firefox")+8))):a.indexOf("Safari")>=0?(e.Browser.vendor=a.indexOf("Chrome")>=0?e.BROWSERS.CHROME:e.BROWSERS.SAFARI,e.Browser.version=parseFloat(a.substring(a.substring(0,a.indexOf("Safari")).lastIndexOf("/")+1,a.indexOf("Safari")))):(h=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),h.exec(a)!==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(l);break}var c=window.location.search.substring(1),d=c.split("&"),v,m,_;for(_=0;_<d.length;_++)if(v=d[_],m=v.indexOf("="),m>0){var y=v.substring(0,m),E=v.substring(m+1);try{o[y]=decodeURIComponent(E)}catch{e.console.error("Ignoring malformed URL parameter: %s=%s",y,E)}}e.Browser.alpha=!(e.Browser.vendor===e.BROWSERS.CHROME&&e.Browser.version<2),e.Browser.opacity=!0,e.Browser.vendor===e.BROWSERS.IE&&e.console.error("Internet Explorer is not supported by OpenSeadragon")})(),(function(l){var a=l.requestAnimationFrame||l.mozRequestAnimationFrame||l.webkitRequestAnimationFrame||l.msRequestAnimationFrame,h=l.cancelAnimationFrame||l.mozCancelAnimationFrame||l.webkitCancelAnimationFrame||l.msCancelAnimationFrame;if(a&&h)e.requestAnimationFrame=function(){return a.apply(l,arguments)},e.cancelAnimationFrame=function(){return h.apply(l,arguments)};else{var c=[],d=[],v=0,m;e.requestAnimationFrame=function(_){return c.push([++v,_]),m||(m=setInterval(function(){if(c.length){var y=e.now(),E=d;for(d=c,c=E;d.length;)d.shift()[1](y)}else clearInterval(m),m=void 0},1e3/50)),v},e.cancelAnimationFrame=function(_){var y,E;for(y=0,E=c.length;y<E;y+=1)if(c[y][0]===_){c.splice(y,1);return}for(y=0,E=d.length;y<E;y+=1)if(d[y][0]===_){d.splice(y,1);return}}}})(window);function u(l,a){return a&&l!==document.body?document.body:l.offsetParent}})(s),(function(e,t){r.exports?r.exports=t():e.OpenSeadragon=t()})(Cl,function(){return s}),(function(e){class t{constructor(n){n||(n=[0,0,0,0,0,0,0,0,0]),this.values=n}static makeIdentity(){return new t([1,0,0,0,1,0,0,0,1])}static makeTranslation(n,o){return new t([1,0,0,0,1,0,n,o,1])}static makeRotation(n){var o=Math.cos(n),u=Math.sin(n);return new t([o,-u,0,u,o,0,0,0,1])}static makeScaling(n,o){return new t([n,0,0,0,o,0,0,0,1])}multiply(n){let o=this.values,u=n.values;var l=o[0],a=o[1],h=o[2],c=o[3],d=o[4],v=o[5],m=o[6],_=o[7],y=o[8],E=u[0],S=u[1],P=u[2],B=u[3],O=u[4],M=u[5],L=u[6],W=u[7],Y=u[8];return new t([E*l+S*c+P*m,E*a+S*d+P*_,E*h+S*v+P*y,B*l+O*c+M*m,B*a+O*d+M*_,B*h+O*v+M*y,L*l+W*c+Y*m,L*a+W*d+Y*_,L*h+W*v+Y*y])}}e.Mat3=t})(s),(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().catch(function(n){e.console.error("Fullscreen request failed: ",n)})},t.exitFullScreen=function(){document.exitFullscreen().catch(function(i){e.console.error("Error while exiting fullscreen: ",i)})},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)})(s),(function(e){e.EventSource=function(){this.events={},this._rejectedEventList={}},e.EventSource.prototype={addOnceHandler:function(t,i,n,o,u){var l=this;o=o||1;var a=0,h=function(c){return a++,a===o&&l.removeHandler(t,h),i(c)};return this.addHandler(t,h,n,u)},addHandler:function(t,i,n,o){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var u=this.events[t];if(u||(this.events[t]=u=[]),i&&e.isFunction(i)){var l=u.length,a={handler:i,userData:n||null,priority:o||0};for(u[l]=a;l>0&&u[l-1].priority<u[l].priority;)u[l]=u[l-1],u[l-1]=a,l--}return!0},removeHandler:function(t,i){var n=this.events[t],o=[],u;if(n&&e.isArray(n)){for(u=0;u<n.length;u++)n[u].handler!==i&&o.push(n[u]);this.events[t]=o}},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(n,o){var u,l=i.length;for(u=0;u<l;u++)i[u]&&(o.eventSource=n,o.userData=i[u].userData,i[u].handler(o))})},raiseEvent:function(t,i){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var n=this.getHandler(t);return n&&n(this,i||{}),!0},rejectEventHandler(t,i=""){this._rejectedEventList[t]=i},allowEventHandler(t){delete this._rejectedEventList[t]}}})(s),(function(e){var t={};e.MouseTracker=function(g){var f=arguments;e.isPlainObject(g)||(g={element:f[0],clickTimeThreshold:f[1],clickDistThreshold:f[2]}),this.hash=Math.random(),this.element=e.getElement(g.element),this.clickTimeThreshold=g.clickTimeThreshold||e.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=g.clickDistThreshold||e.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=g.dblClickTimeThreshold||e.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=g.dblClickDistThreshold||e.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=g.userData||null,this.stopDelay=g.stopDelay||50,this.preProcessEventHandler=g.preProcessEventHandler||null,this.contextMenuHandler=g.contextMenuHandler||null,this.enterHandler=g.enterHandler||null,this.leaveHandler=g.leaveHandler||null,this.exitHandler=g.exitHandler||null,this.overHandler=g.overHandler||null,this.outHandler=g.outHandler||null,this.pressHandler=g.pressHandler||null,this.nonPrimaryPressHandler=g.nonPrimaryPressHandler||null,this.releaseHandler=g.releaseHandler||null,this.nonPrimaryReleaseHandler=g.nonPrimaryReleaseHandler||null,this.moveHandler=g.moveHandler||null,this.scrollHandler=g.scrollHandler||null,this.clickHandler=g.clickHandler||null,this.dblClickHandler=g.dblClickHandler||null,this.dragHandler=g.dragHandler||null,this.dragEndHandler=g.dragEndHandler||null,this.pinchHandler=g.pinchHandler||null,this.stopHandler=g.stopHandler||null,this.keyDownHandler=g.keyDownHandler||null,this.keyUpHandler=g.keyUpHandler||null,this.keyHandler=g.keyHandler||null,this.focusHandler=g.focusHandler||null,this.blurHandler=g.blurHandler||null;var w=this;t[this.hash]={click:function(T){P(w,T)},dblclick:function(T){B(w,T)},keydown:function(T){O(w,T)},keyup:function(T){M(w,T)},keypress:function(T){L(w,T)},focus:function(T){W(w,T)},blur:function(T){Y(w,T)},contextmenu:function(T){Q(w,T)},wheel:function(T){ee(w,T)},mousewheel:function(T){X(w,T)},DOMMouseScroll:function(T){X(w,T)},MozMousePixelScroll:function(T){X(w,T)},losecapture:function(T){he(w,T)},mouseenter:function(T){Z(w,T)},mouseleave:function(T){$e(w,T)},mouseover:function(T){ct(w,T)},mouseout:function(T){Ue(w,T)},mousedown:function(T){z(w,T)},mouseup:function(T){ie(w,T)},mousemove:function(T){Ye(w,T)},touchstart:function(T){de(w,T)},touchend:function(T){pe(w,T)},touchmove:function(T){ge(w,T)},touchcancel:function(T){me(w,T)},gesturestart:function(T){Pe(w,T)},gesturechange:function(T){Le(w,T)},gotpointercapture:function(T){xe(w,T)},lostpointercapture:function(T){Xe(w,T)},pointerenter:function(T){Z(w,T)},pointerleave:function(T){$e(w,T)},pointerover:function(T){ct(w,T)},pointerout:function(T){Ue(w,T)},pointerdown:function(T){z(w,T)},pointerup:function(T){ie(w,T)},pointermove:function(T){Ye(w,T)},pointercancel:function(T){Ut(w,T)},pointerupcaptured:function(T){ce(w,T)},pointermovecaptured:function(T){St(w,T)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null,sentDragEvent:!1},this.hasGestureHandlers=!!(this.pressHandler||this.nonPrimaryPressHandler||this.releaseHandler||this.nonPrimaryReleaseHandler||this.clickHandler||this.dblClickHandler||this.dragHandler||this.dragEndHandler||this.pinchHandler),this.hasScrollHandler=!!this.scrollHandler,e.MouseTracker.havePointerEvents&&e.setElementPointerEvents(this.element,"auto"),this.exitHandler&&e.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead."),g.startDisabled||this.setTracking(!0)},e.MouseTracker.prototype={destroy:function(){l(this),this.element=null,t[this.hash]=null,delete t[this.hash]},isTracking:function(){return t[this.hash].tracking},setTracking:function(g){return g?u(this):l(this),this},getActivePointersListByType:function(g){var f=t[this.hash],w,T=f?f.activePointersLists.length:0,R;for(w=0;w<T;w++)if(f.activePointersLists[w].type===g)return f.activePointersLists[w];return R=new e.MouseTracker.GesturePointList(g),f&&f.activePointersLists.push(R),R},getActivePointerCount:function(){var g=t[this.hash],f,w=g.activePointersLists.length,T=0;for(f=0;f<w;f++)T+=g.activePointersLists[f].getLength();return T},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 n(g){try{return g.addEventListener&&g.removeEventListener}catch{return!1}}e.MouseTracker.gesturePointVelocityTracker=(function(){var g=[],f=0,w=0,T=function(K,j){return K.hash.toString()+j.type+j.id.toString()},R=function(){var K,j=g.length,oe,re,Ke=e.now(),Wt,Lr,zr;for(Wt=Ke-w,w=Ke,K=0;K<j;K++)oe=g[K],re=oe.gPoint,re.direction=Math.atan2(re.currentPos.y-oe.lastPos.y,re.currentPos.x-oe.lastPos.x),Lr=oe.lastPos.distanceTo(re.currentPos),oe.lastPos=re.currentPos,zr=1e3*Lr/(Wt+1),re.speed=.75*zr+.25*re.speed},I=function(K,j){var oe=T(K,j);g.push({guid:oe,gPoint:j,lastPos:j.currentPos}),g.length===1&&(w=e.now(),f=window.setInterval(R,50))},N=function(K,j){var oe=T(K,j),re,Ke=g.length;for(re=0;re<Ke;re++)if(g[re].guid===oe){g.splice(re,1),Ke--,Ke===0&&window.clearInterval(f);break}};return{addPoint:I,removePoint:N}})(),e.MouseTracker.captureElement=document,e.MouseTracker.wheelEventName="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 g=document.createElement("div");return e.isFunction(g.setPointerCapture)&&e.isFunction(g.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 g=document.createElement("div");return e.isFunction(g.setCapture)&&e.isFunction(g.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(g){this._gPoints=[],this.type=g,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(g){return this._gPoints.push(g)},removeById:function(g){var f,w=this._gPoints.length;for(f=0;f<w;f++)if(this._gPoints[f].id===g){this._gPoints.splice(f,1);break}return this._gPoints.length},getByIndex:function(g){return g<this._gPoints.length?this._gPoints[g]:null},getById:function(g){var f,w=this._gPoints.length;for(f=0;f<w;f++)if(this._gPoints[f].id===g)return this._gPoints[f];return null},getPrimary:function(g){var f,w=this._gPoints.length;for(f=0;f<w;f++)if(this._gPoints[f].isPrimary)return this._gPoints[f];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 o(g){var f=t[g.hash],w,T,R,I,N,K=f.activePointersLists.length;for(w=0;w<K;w++)if(R=f.activePointersLists[w],R.getLength()>0){for(N=[],I=R.asArray(),T=0;T<I.length;T++)N.push(I[T]);for(T=0;T<N.length;T++)dt(g,R,N[T])}for(w=0;w<K;w++)f.activePointersLists.pop();f.sentDragEvent=!1}function u(g){var f=t[g.hash],w,T;if(!f.tracking){for(T=0;T<e.MouseTracker.subscribeEvents.length;T++)w=e.MouseTracker.subscribeEvents[T],e.addEvent(g.element,w,f[w],w===e.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);o(g),f.tracking=!0}}function l(g){var f=t[g.hash],w,T;if(f.tracking){for(T=0;T<e.MouseTracker.subscribeEvents.length;T++)w=e.MouseTracker.subscribeEvents[T],e.removeEvent(g.element,w,f[w],!1);o(g),f.tracking=!1}}function a(g,f){var w=t[g.hash];if(f==="pointerevent")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(f==="mouse")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(f==="touch")return{upName:"touchend",upHandler:w.touchendcaptured,moveName:"touchmove",moveHandler:w.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function h(g,f){var w;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents)try{g.element.setPointerCapture(f.id)}catch{e.console.warn("setPointerCapture() called on invalid pointer ID");return}else g.element.setCapture(!0);else w=a(g,e.MouseTracker.havePointerEvents?"pointerevent":f.type),i&&n(window.top)&&e.addEvent(window.top,w.upName,w.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,w.upName,w.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,w.moveName,w.moveHandler,!0);C(g,f,!0)}function c(g,f){var w,T,R;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents){if(T=g.getActivePointersListByType(f.type),R=T.getById(f.id),!R||!R.captured)return;try{g.element.releasePointerCapture(f.id)}catch{}}else g.element.releaseCapture();else w=a(g,e.MouseTracker.havePointerEvents?"pointerevent":f.type),i&&n(window.top)&&e.removeEvent(window.top,w.upName,w.upHandler,!0),e.removeEvent(e.MouseTracker.captureElement,w.moveName,w.moveHandler,!0),e.removeEvent(e.MouseTracker.captureElement,w.upName,w.upHandler,!0);C(g,f,!1)}function d(g){return e.MouseTracker.havePointerEvents?g.pointerId:e.MouseTracker.mousePointerId}function v(g){return e.MouseTracker.havePointerEvents&&g.pointerType?g.pointerType:"mouse"}function m(g){return e.MouseTracker.havePointerEvents?g.isPrimary:!0}function _(g){return e.getMousePosition(g)}function y(g,f){return E(_(g),f)}function E(g,f){var w=e.getElementOffset(f);return g.minus(w)}function S(g,f){return new e.Point((g.x+f.x)/2,(g.y+f.y)/2)}function P(g,f){var w={originalEvent:f,eventType:"click",pointerType:"mouse",isEmulated:!1};x(g,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(f),w.stopPropagation&&e.stopEvent(f)}function B(g,f){var w={originalEvent:f,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};x(g,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(f),w.stopPropagation&&e.stopEvent(f)}function O(g,f){var w=null,T={originalEvent:f,eventType:"keydown",pointerType:"",isEmulated:!1};x(g,T),g.keyDownHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:g,keyCode:f.keyCode?f.keyCode:f.charCode,ctrl:f.ctrlKey,shift:f.shiftKey,alt:f.altKey,meta:f.metaKey,originalEvent:f,preventDefault:T.preventDefault||T.defaultPrevented,userData:g.userData},g.keyDownHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function M(g,f){var w=null,T={originalEvent:f,eventType:"keyup",pointerType:"",isEmulated:!1};x(g,T),g.keyUpHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:g,keyCode:f.keyCode?f.keyCode:f.charCode,ctrl:f.ctrlKey,shift:f.shiftKey,alt:f.altKey,meta:f.metaKey,originalEvent:f,preventDefault:T.preventDefault||T.defaultPrevented,userData:g.userData},g.keyUpHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function L(g,f){var w=null,T={originalEvent:f,eventType:"keypress",pointerType:"",isEmulated:!1};x(g,T),g.keyHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:g,keyCode:f.keyCode?f.keyCode:f.charCode,ctrl:f.ctrlKey,shift:f.shiftKey,alt:f.altKey,meta:f.metaKey,originalEvent:f,preventDefault:T.preventDefault||T.defaultPrevented,userData:g.userData},g.keyHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function W(g,f){var w={originalEvent:f,eventType:"focus",pointerType:"",isEmulated:!1};x(g,w),g.focusHandler&&!w.preventGesture&&g.focusHandler({eventSource:g,originalEvent:f,userData:g.userData})}function Y(g,f){var w={originalEvent:f,eventType:"blur",pointerType:"",isEmulated:!1};x(g,w),g.blurHandler&&!w.preventGesture&&g.blurHandler({eventSource:g,originalEvent:f,userData:g.userData})}function Q(g,f){var w=null,T={originalEvent:f,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};x(g,T),g.contextMenuHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:g,position:E(_(f),g.element),originalEvent:T.originalEvent,preventDefault:T.preventDefault||T.defaultPrevented,userData:g.userData},g.contextMenuHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function ee(g,f){ue(g,f,f)}function X(g,f){var w={target:f.target||f.srcElement,type:"wheel",shiftKey:f.shiftKey||!1,clientX:f.clientX,clientY:f.clientY,pageX:f.pageX?f.pageX:f.clientX,pageY:f.pageY?f.pageY:f.clientY,deltaMode:f.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};e.MouseTracker.wheelEventName==="mousewheel"?w.deltaY=-f.wheelDelta/e.DEFAULT_SETTINGS.pixelsPerWheelLine:w.deltaY=f.detail,ue(g,w,f)}function ue(g,f,w){var T=0,R,I=null;T=f.deltaY?f.deltaY<0?1:-1:0,R={originalEvent:f,eventType:"wheel",pointerType:"mouse",isEmulated:f!==w},x(g,R),g.scrollHandler&&!R.preventGesture&&!R.defaultPrevented&&(I={eventSource:g,pointerType:"mouse",position:y(f,g.element),scroll:T,shift:f.shiftKey,isTouchEvent:!1,originalEvent:w,preventDefault:R.preventDefault||R.defaultPrevented,userData:g.userData},g.scrollHandler(I)),R.stopPropagation&&e.stopEvent(w),(I&&I.preventDefault||R.preventDefault&&!R.defaultPrevented)&&e.cancelEvent(w)}function he(g,f){var w={id:e.MouseTracker.mousePointerId,type:"mouse"},T={originalEvent:f,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};x(g,T),f.target===g.element&&C(g,w,!1),T.stopPropagation&&e.stopEvent(f)}function de(g,f){var w,T,R=f.changedTouches.length,I,N=g.getActivePointersListByType("touch");w=e.now(),N.getLength()>f.touches.length-R&&e.console.warn("Tracked touch contact count doesn't match event.touches.length");var K={originalEvent:f,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(x(g,K),T=0;T<R;T++)I={id:f.changedTouches[T].identifier,type:"touch",isPrimary:N.getLength()===0,currentPos:_(f.changedTouches[T]),currentTime:w},k(g,K,I),H(g,K,I,0),C(g,I,!0);K.preventDefault&&!K.defaultPrevented&&e.cancelEvent(f),K.stopPropagation&&e.stopEvent(f)}function pe(g,f){var w,T,R=f.changedTouches.length,I;w=e.now();var N={originalEvent:f,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(x(g,N),T=0;T<R;T++)I={id:f.changedTouches[T].identifier,type:"touch",currentPos:_(f.changedTouches[T]),currentTime:w},V(g,N,I,0),C(g,I,!1),F(g,N,I);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(f),N.stopPropagation&&e.stopEvent(f)}function ge(g,f){var w,T,R=f.changedTouches.length,I;w=e.now();var N={originalEvent:f,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(x(g,N),T=0;T<R;T++)I={id:f.changedTouches[T].identifier,type:"touch",currentPos:_(f.changedTouches[T]),currentTime:w},q(g,N,I);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(f),N.stopPropagation&&e.stopEvent(f)}function me(g,f){var w=f.changedTouches.length,T,R,I={originalEvent:f,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(x(g,I),T=0;T<w;T++)R={id:f.changedTouches[T].identifier,type:"touch"},U(g,I,R);I.stopPropagation&&e.stopEvent(f)}function Pe(g,f){return e.eventIsCanceled(f)||f.preventDefault(),!1}function Le(g,f){return e.eventIsCanceled(f)||f.preventDefault(),!1}function xe(g,f){var w={originalEvent:f,eventType:"gotpointercapture",pointerType:v(f),isEmulated:!1};x(g,w),f.target===g.element&&C(g,{id:f.pointerId,type:v(f)},!0),w.stopPropagation&&e.stopEvent(f)}function Xe(g,f){var w={originalEvent:f,eventType:"lostpointercapture",pointerType:v(f),isEmulated:!1};x(g,w),f.target===g.element&&C(g,{id:f.pointerId,type:v(f)},!1),w.stopPropagation&&e.stopEvent(f)}function Z(g,f){var w={id:d(f),type:v(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerenter",pointerType:w.type,isEmulated:!1};x(g,T),k(g,T,w)}function $e(g,f){var w={id:d(f),type:v(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerleave",pointerType:w.type,isEmulated:!1};x(g,T),F(g,T,w)}function ct(g,f){var w={id:d(f),type:v(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerover",pointerType:w.type,isEmulated:!1};x(g,T),A(g,T,w),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function Ue(g,f){var w={id:d(f),type:v(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerout",pointerType:w.type,isEmulated:!1};x(g,T),D(g,T,w),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function z(g,f){var w={id:d(f),type:v(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T=e.MouseTracker.havePointerEvents&&w.type==="touch",R={originalEvent:f,eventType:"pointerdown",pointerType:w.type,isEmulated:!1};x(g,R),H(g,R,w,f.button),R.preventDefault&&!R.defaultPrevented&&e.cancelEvent(f),R.stopPropagation&&e.stopEvent(f),R.shouldCapture&&(T?C(g,w,!0):h(g,w))}function ie(g,f){we(g,f)}function ce(g,f){var w=g.getActivePointersListByType(v(f));w.getById(f.pointerId)&&we(g,f),e.stopEvent(f)}function we(g,f){var w;w={id:d(f),type:v(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()};var T={originalEvent:f,eventType:"pointerup",pointerType:w.type,isEmulated:!1};x(g,T),V(g,T,w,f.button),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f),T.shouldReleaseCapture&&(f.target===g.element?c(g,w):C(g,w,!1))}function Ye(g,f){Nt(g,f)}function St(g,f){var w=g.getActivePointersListByType(v(f));w.getById(f.pointerId)&&Nt(g,f),e.stopEvent(f)}function Nt(g,f){var w={id:d(f),type:v(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointermove",pointerType:w.type,isEmulated:!1};x(g,T),q(g,T,w),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function Ut(g,f){var w={id:f.pointerId,type:v(f)},T={originalEvent:f,eventType:"pointercancel",pointerType:w.type,isEmulated:!1};x(g,T),U(g,T,w),T.stopPropagation&&e.stopEvent(f)}function Pt(g,f){return f.speed=0,f.direction=0,f.contactPos=f.currentPos,f.contactTime=f.currentTime,f.lastPos=f.currentPos,f.lastTime=f.currentTime,g.add(f)}function dt(g,f,w){var T,R=f.getById(w.id);return R?(R.captured&&(e.console.warn("stopTrackingPointer() called on captured pointer"),c(g,R)),f.removeContact(),T=f.removeById(w.id)):T=f.getLength(),T}function p(g,f){switch(f.eventType){case"pointermove":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!g.hasGestureHandlers,f.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!1,f.stopPropagation=!1;break;case"pointerdown":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!g.hasGestureHandlers,f.stopPropagation=!1;break;case"pointerup":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!g.hasGestureHandlers,f.stopPropagation=!1;break;case"wheel":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!g.hasScrollHandler,f.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":f.isStoppable=!0,f.isCancelable=!1,f.preventDefault=!1,f.preventGesture=!1,f.stopPropagation=!1;break;case"click":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!!g.clickHandler,f.preventGesture=!1,f.stopPropagation=!1;break;case"dblclick":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!!g.dblClickHandler,f.preventGesture=!1,f.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:f.isStoppable=!1,f.isCancelable=!1,f.preventDefault=!1,f.preventGesture=!1,f.stopPropagation=!1;break}}function x(g,f){f.eventSource=g,f.eventPhase=f.originalEvent&&typeof f.originalEvent.eventPhase<"u"?f.originalEvent.eventPhase:0,f.defaultPrevented=e.eventIsCanceled(f.originalEvent),f.shouldCapture=!1,f.shouldReleaseCapture=!1,f.userData=g.userData,p(g,f),g.preProcessEventHandler&&g.preProcessEventHandler(f)}function C(g,f,w){var T=g.getActivePointersListByType(f.type),R=T.getById(f.id);R?w&&!R.captured?(R.captured=!0,T.captureCount++):!w&&R.captured&&(R.captured=!1,T.captureCount--,T.captureCount<0&&(T.captureCount=0,e.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):e.console.warn("updatePointerCaptured() called on untracked pointer")}function k(g,f,w){var T=g.getActivePointersListByType(w.type),R;R=T.getById(w.id),R?(R.insideElement=!0,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=w.currentPos,R.currentTime=w.currentTime,w=R):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(T,w)),g.enterHandler&&g.enterHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:T.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData})}function F(g,f,w){var T=g.getActivePointersListByType(w.type),R,I;R=T.getById(w.id),R?(R.captured?(R.insideElement=!1,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=w.currentPos,R.currentTime=w.currentTime):dt(g,T,R),w=R):(w.captured=!1,w.insideElementPressed=!1),(g.leaveHandler||g.exitHandler)&&(I={eventSource:g,pointerType:w.type,position:w.currentPos&&E(w.currentPos,g.element),buttons:T.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData},g.leaveHandler&&g.leaveHandler(I),g.exitHandler&&g.exitHandler(I))}function A(g,f,w){var T,R;T=g.getActivePointersListByType(w.type),R=T.getById(w.id),R?w=R:(w.captured=!1,w.insideElementPressed=!1),g.overHandler&&g.overHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:T.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData})}function D(g,f,w){var T,R;T=g.getActivePointersListByType(w.type),R=T.getById(w.id),R?w=R:(w.captured=!1,w.insideElementPressed=!1),g.outHandler&&g.outHandler({eventSource:g,pointerType:w.type,position:w.currentPos&&E(w.currentPos,g.element),buttons:T.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData})}function H(g,f,w,T){var R=t[g.hash],I=g.getActivePointersListByType(w.type),N;if(typeof f.originalEvent.buttons<"u"?I.buttons=f.originalEvent.buttons:T===0?I.buttons|=1:T===1?I.buttons|=4:T===2?I.buttons|=2:T===3?I.buttons|=8:T===4?I.buttons|=16:T===5&&(I.buttons|=32),T!==0){f.shouldCapture=!1,f.shouldReleaseCapture=!1,g.nonPrimaryPressHandler&&!f.preventGesture&&!f.defaultPrevented&&(f.preventDefault=!0,g.nonPrimaryPressHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),button:T,buttons:I.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData}));return}N=I.getById(w.id),N?(N.insideElementPressed=!0,N.insideElement=!0,N.originalTarget=f.originalEvent.target,N.contactPos=w.currentPos,N.contactTime=w.currentTime,N.lastPos=N.currentPos,N.lastTime=N.currentTime,N.currentPos=w.currentPos,N.currentTime=w.currentTime,w=N):(w.captured=!1,w.insideElementPressed=!0,w.insideElement=!0,w.originalTarget=f.originalEvent.target,Pt(I,w)),I.addContact(),!f.preventGesture&&!f.defaultPrevented?(f.shouldCapture=!0,f.shouldReleaseCapture=!1,f.preventDefault=!0,(g.dragHandler||g.dragEndHandler||g.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.addPoint(g,w),I.contacts===1?g.pressHandler&&!f.preventGesture&&g.pressHandler({eventSource:g,pointerType:w.type,position:E(w.contactPos,g.element),buttons:I.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData}):I.contacts===2&&g.pinchHandler&&w.type==="touch"&&(R.pinchGPoints=I.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=S(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(f.shouldCapture=!1,f.shouldReleaseCapture=!1)}function V(g,f,w,T){var R=t[g.hash],I=g.getActivePointersListByType(w.type),N,K,j,oe=!1,re;if(typeof f.originalEvent.buttons<"u"?I.buttons=f.originalEvent.buttons:T===0?I.buttons^=-2:T===1?I.buttons^=-5:T===2?I.buttons^=-3:T===3?I.buttons^=-9:T===4?I.buttons^=-17:T===5&&(I.buttons^=-33),f.shouldCapture=!1,T!==0){f.shouldReleaseCapture=!1,g.nonPrimaryReleaseHandler&&!f.preventGesture&&!f.defaultPrevented&&(f.preventDefault=!0,g.nonPrimaryReleaseHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),button:T,buttons:I.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData}));return}j=I.getById(w.id),j?(I.removeContact(),j.captured&&(oe=!0),j.lastPos=j.currentPos,j.lastTime=j.currentTime,j.currentPos=w.currentPos,j.currentTime=w.currentTime,j.insideElement||dt(g,I,j),N=j.currentPos,K=j.currentTime):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(I,w),j=w),!f.preventGesture&&!f.defaultPrevented&&(oe?(f.shouldReleaseCapture=!0,f.preventDefault=!0,(g.dragHandler||g.dragEndHandler||g.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.removePoint(g,j),I.contacts===0?(g.releaseHandler&&N&&g.releaseHandler({eventSource:g,pointerType:j.type,position:E(N,g.element),buttons:I.buttons,insideElementPressed:j.insideElementPressed,insideElementReleased:j.insideElement,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:g.userData}),g.dragEndHandler&&R.sentDragEvent&&g.dragEndHandler({eventSource:g,pointerType:j.type,position:E(j.currentPos,g.element),speed:j.speed,direction:j.direction,shift:f.originalEvent.shiftKey,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:g.userData}),R.sentDragEvent=!1,(g.clickHandler||g.dblClickHandler)&&j.insideElement&&(re=K-j.contactTime<=g.clickTimeThreshold&&j.contactPos.distanceTo(N)<=g.clickDistThreshold,g.clickHandler&&g.clickHandler({eventSource:g,pointerType:j.type,position:E(j.currentPos,g.element),quick:re,shift:f.originalEvent.shiftKey,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,originalTarget:j.originalTarget,userData:g.userData}),g.dblClickHandler&&re&&(I.clicks++,I.clicks===1?(R.lastClickPos=N,R.dblClickTimeOut=setTimeout(function(){I.clicks=0},g.dblClickTimeThreshold)):I.clicks===2&&(clearTimeout(R.dblClickTimeOut),I.clicks=0,R.lastClickPos.distanceTo(N)<=g.dblClickDistThreshold&&g.dblClickHandler({eventSource:g,pointerType:j.type,position:E(j.currentPos,g.element),shift:f.originalEvent.shiftKey,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:g.userData}),R.lastClickPos=null)))):I.contacts===2&&g.pinchHandler&&j.type==="touch"&&(R.pinchGPoints=I.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=S(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(f.shouldReleaseCapture=!1,g.releaseHandler&&N&&(g.releaseHandler({eventSource:g,pointerType:j.type,position:E(N,g.element),buttons:I.buttons,insideElementPressed:j.insideElementPressed,insideElementReleased:j.insideElement,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:g.userData}),f.preventDefault=!0)))}function q(g,f,w){var T=t[g.hash],R=g.getActivePointersListByType(w.type),I,N,K;if(typeof f.originalEvent.buttons<"u"&&(R.buttons=f.originalEvent.buttons),I=R.getById(w.id),I)I.lastPos=I.currentPos,I.lastTime=I.currentTime,I.currentPos=w.currentPos,I.currentTime=w.currentTime;else return;f.shouldCapture=!1,f.shouldReleaseCapture=!1,g.stopHandler&&w.type==="mouse"&&(clearTimeout(g.stopTimeOut),g.stopTimeOut=setTimeout(function(){$(g,f.originalEvent,w.type)},g.stopDelay)),R.contacts===0?g.moveHandler&&g.moveHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:R.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:g.userData}):R.contacts===1?(g.moveHandler&&(I=R.asArray()[0],g.moveHandler({eventSource:g,pointerType:I.type,position:E(I.currentPos,g.element),buttons:R.buttons,isTouchEvent:I.type==="touch",originalEvent:f.originalEvent,userData:g.userData})),g.dragHandler&&!f.preventGesture&&!f.defaultPrevented&&(I=R.asArray()[0],K=I.currentPos.minus(I.lastPos),g.dragHandler({eventSource:g,pointerType:I.type,position:E(I.currentPos,g.element),buttons:R.buttons,delta:K,speed:I.speed,direction:I.direction,shift:f.originalEvent.shiftKey,isTouchEvent:I.type==="touch",originalEvent:f.originalEvent,userData:g.userData}),f.preventDefault=!0,T.sentDragEvent=!0)):R.contacts===2&&(g.moveHandler&&(N=R.asArray(),g.moveHandler({eventSource:g,pointerType:N[0].type,position:E(S(N[0].currentPos,N[1].currentPos),g.element),buttons:R.buttons,isTouchEvent:N[0].type==="touch",originalEvent:f.originalEvent,userData:g.userData})),g.pinchHandler&&w.type==="touch"&&!f.preventGesture&&!f.defaultPrevented&&(K=T.pinchGPoints[0].currentPos.distanceTo(T.pinchGPoints[1].currentPos),K!==T.currentPinchDist&&(T.lastPinchDist=T.currentPinchDist,T.currentPinchDist=K,T.lastPinchCenter=T.currentPinchCenter,T.currentPinchCenter=S(T.pinchGPoints[0].currentPos,T.pinchGPoints[1].currentPos),g.pinchHandler({eventSource:g,pointerType:"touch",gesturePoints:T.pinchGPoints,lastCenter:E(T.lastPinchCenter,g.element),center:E(T.currentPinchCenter,g.element),lastDistance:T.lastPinchDist,distance:T.currentPinchDist,shift:f.originalEvent.shiftKey,originalEvent:f.originalEvent,userData:g.userData}),f.preventDefault=!0)))}function U(g,f,w){var T=g.getActivePointersListByType(w.type),R;R=T.getById(w.id),R&&dt(g,T,R)}function $(g,f,w){g.stopHandler&&g.stopHandler({eventSource:g,pointerType:w,position:y(f,g.element),buttons:g.getActivePointersListByType(w).buttons,isTouchEvent:w==="touch",originalEvent:f,userData:g.userData})}})(s),(function(e){e.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},e.Control=function(t,i,n){var o=t.parentNode;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=n,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):o.appendChild(this.wrapper)},e.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.anchor!==e.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return 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){e.setElementOpacity(this.wrapper,t,!0)}}})(s),(function(e){e.ControlDock=function(i){var n=["topleft","topright","bottomright","bottomleft"],o,u;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),e.getElementStyle(this.element).position==="static"&&(this.element.style.position="relative"),this.container.style.width="100%",this.container.style.height="100%"),u=0;u<n.length;u++)o=n[u],this.controls[o]=e.makeNeutralElement("div"),this.controls[o].style.position="absolute",o.match("left")&&(this.controls[o].style.left="0px"),o.match("right")&&(this.controls[o].style.right="0px"),o.match("top")&&(this.controls[o].style.top="0px"),o.match("bottom")&&(this.controls[o].style.bottom="0px");this.container.appendChild(this.controls.topleft),this.container.appendChild(this.controls.topright),this.container.appendChild(this.controls.bottomright),this.container.appendChild(this.controls.bottomleft)},e.ControlDock.prototype={addControl:function(i,n){i=e.getElement(i);var o=null;if(!(t(this,i)>=0)){switch(n.anchor){case e.ControlAnchor.TOP_RIGHT:o=this.controls.topright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.BOTTOM_RIGHT:o=this.controls.bottomright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.BOTTOM_LEFT:o=this.controls.bottomleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.TOP_LEFT:o=this.controls.topleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.ABSOLUTE:o=this.container,i.style.margin="0px",i.style.padding="0px";break;default:case e.ControlAnchor.NONE:o=this.container,i.style.margin="0px",i.style.padding="0px";break}this.controls.push(new e.Control(i,n,o)),i.style.display="inline-block"}},removeControl:function(i){i=e.getElement(i);var n=t(this,i);return n>=0&&(this.controls[n].destroy(),this.controls.splice(n,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var i;for(i=this.controls.length-1;i>=0;i--)if(this.controls[i].isVisible())return!0;return!1},setControlsEnabled:function(i){var n;for(n=this.controls.length-1;n>=0;n--)this.controls[n].setVisible(i);return this}};function t(i,n){var o=i.controls,u;for(u=o.length-1;u>=0;u--)if(o[u].element===n)return u;return-1}})(s),(function(e){e.Placement=e.freezeObject({CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8,properties:{0:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1},1:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},2:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},3:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!0,isVerticallyCentered:!1,isBottom:!1},4:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!0,isBottom:!1},5:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!1,isBottom:!0},6:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},7:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},8:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1}}})})(s),(function(e){var t={},i=1;e.Viewer=function(p){var x=arguments,C=this,k;e.isPlainObject(p)||(p={id:x[0],xmlPath:x.length>1?x[1]:void 0,prefixUrl:x.length>2?x[2]:void 0,controls:x.length>3?x[3]:void 0,overlays:x.length>4?x[4]:void 0}),p.config&&(e.extend(!0,p,p.config),delete p.config);let F=["useCanvas"];if(p.drawerOptions=Object.assign({},F.reduce((D,H)=>(D[H]=p[H],delete p[H],D),{}),p.drawerOptions),e.extend(!0,this,{id:p.id,hash:p.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,p),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");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(D){var H=e.getString("Errors.OpenFailed",D.eventSource,D.message);C._showMessage(H)}),e.ControlDock.call(this,p),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(D){D.width="100%",D.height="100%",D.overflow="hidden",D.position="absolute",D.top="0px",D.left="0px"})(this.canvas.style),e.setElementTouchActionNone(this.canvas),p.tabIndex!==""&&(this.canvas.tabIndex=p.tabIndex===void 0?0:p.tabIndex),this.container.className="openseadragon-container",(function(D){D.width="100%",D.height="100%",D.position="relative",D.overflow="hidden",D.left="0px",D.top="0px",D.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,y),keyDownHandler:e.delegate(this,E),keyHandler:e.delegate(this,S),clickHandler:e.delegate(this,P),dblClickHandler:e.delegate(this,B),dragHandler:e.delegate(this,O),dragEndHandler:e.delegate(this,M),enterHandler:e.delegate(this,L),leaveHandler:e.delegate(this,W),pressHandler:e.delegate(this,Y),releaseHandler:e.delegate(this,Q),nonPrimaryPressHandler:e.delegate(this,ee),nonPrimaryReleaseHandler:e.delegate(this,X),scrollHandler:e.delegate(this,pe),pinchHandler:e.delegate(this,ue),focusHandler:e.delegate(this,he),blurHandler:e.delegate(this,de)}),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,ge),leaveHandler:e.delegate(this,me)}),this.toolbar&&(this.toolbar=new e.ControlDock({element:this.toolbar})),this.bindStandardControls(),t[this.hash].prevContainerSize=n(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){t[C.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new e.World({viewer:this}),this.world.addHandler("add-item",function(D){C.source=C.world.getItemAt(0).source,t[C.hash].forceRedraw=!0,C._updateRequestId||(C._updateRequestId=a(C,Pe))}),this.world.addHandler("remove-item",function(D){C.world.getItemCount()?C.source=C.world.getItemAt(0).source:C.source=null,t[C.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(D){C.viewport&&C.viewport._setContentBounds(C.world.getHomeBounds(),C.world.getContentFactor())}),this.world.addHandler("item-index-change",function(D){C.source=C.world.getItemAt(0).source}),this.viewport=new e.Viewport({containerSize:t[this.hash].prevContainerSize,springStiffness:this.springStiffness,animationTime:this.animationTime,minZoomImageRatio:this.minZoomImageRatio,maxZoomPixelRatio:this.maxZoomPixelRatio,visibilityRatio:this.visibilityRatio,wrapHorizontal:this.wrapHorizontal,wrapVertical:this.wrapVertical,defaultZoomLevel:this.defaultZoomLevel,minZoomLevel:this.minZoomLevel,maxZoomLevel:this.maxZoomLevel,viewer:this,degrees:this.degrees,flipped:this.flipped,overlayPreserveContentDirection:this.overlayPreserveContentDirection,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:p.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay}),this.tileCache=new e.TileCache({maxImageCacheCount:this.maxImageCacheCount}),Object.prototype.hasOwnProperty.call(this.drawerOptions,"useCanvas")&&(e.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)'),this.drawerOptions.useCanvas||(this.drawer=e.HTMLDrawer),delete this.drawerOptions.useCanvas);let A=Array.isArray(this.drawer)?this.drawer:[this.drawer];A.length===0&&(A=[e.DEFAULT_SETTINGS.drawer].flat(),e.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const D of A)if(this.requestDrawer(D,{mainDrawer:!0,redrawImmediately:!1}))break;if(!this.drawer)throw e.console.error("No drawer could be created!"),"Error with creating the selected drawer(s)";for(this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),this.overlaysContainer=e.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(k=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(k,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(k=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(k,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,drawer:this.drawer.getType(),loadTilesWithAjax:this.loadTilesWithAjax,ajaxHeaders:this.ajaxHeaders,ajaxWithCredentials:this.ajaxWithCredentials})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),k=0;k<this.customControls.length;k++)this.addControl(this.customControls[k].id,{anchor:this.customControls[k].anchor});e.requestAnimationFrame(function(){c(C)}),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(p){return e.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(p)},openTileSource:function(p){return e.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(p)},get buttons(){return e.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(p,x){var C=this;if(this.close(),!p)return this;if(this.sequenceMode&&e.isArray(p))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof x<"u"&&!isNaN(x)&&(this.initialPage=x),this.tileSources=p,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(p)||(p=[p]),!p.length)return this;this._opening=!0;for(var k=p.length,F=0,A=0,D,H=function(){if(F+A===k)if(F){(C._firstOpen||!C.preserveViewport)&&(C.viewport.goHome(!0),C.viewport.update()),C._firstOpen=!1;var U=p[0];if(U.tileSource&&(U=U.tileSource),C.overlays&&!C.preserveOverlays)for(var $=0;$<C.overlays.length;$++)C.currentOverlays[$]=u(C,C.overlays[$]);C._drawOverlays(),C._opening=!1,C.raiseEvent("open",{source:U})}else C._opening=!1,C.raiseEvent("open-failed",D)},V=function(U){(!e.isPlainObject(U)||!U.tileSource)&&(U={tileSource:U}),U.index!==void 0&&(e.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete U.index),U.collectionImmediately===void 0&&(U.collectionImmediately=!0);var $=U.success;U.success=function(f){if(F++,U.tileSource.overlays)for(var w=0;w<U.tileSource.overlays.length;w++)C.addOverlay(U.tileSource.overlays[w]);$&&$(f),H()};var g=U.error;U.error=function(f){A++,D||(D=f),g&&g(f),H()},C.addTiledImage(U)},q=0;q<p.length;q++)V(p[q]);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()}},requestDrawer(p,x){const C={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};x=e.extend(!0,C,x);const k=x.mainDrawer,F=x.redrawImmediately,A=x.drawerOptions,D=this.drawer;let H=null;if(p&&p.prototype instanceof e.DrawerBase?(H=p,p="custom"):typeof p=="string"&&(H=e.determineDrawer(p)),H||e.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),H&&H.isSupported()){D&&k&&D.destroy();const V=new H({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:A||this.drawerOptions[p]});return k&&(this.drawer=V,F&&this.forceRedraw()),V}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(p){return this.innerTracker.setTracking(p),this.outerTracker.setTracking(p),this.raiseEvent("mouse-enabled",{enabled:p}),this},areControlsEnabled:function(){var p=this.controls.length,x;for(x=0;x<this.controls.length;x++)p=p&&this.controls[x].isVisible();return p},setControlsEnabled:function(p){return p?v(this):c(this),this.raiseEvent("controls-enabled",{enabled:p}),this},setDebugMode:function(p){for(var x=0;x<this.world.getItemCount();x++)this.world.getItemAt(x).debugMode=p;this.debugMode=p,this.forceRedraw()},setAjaxHeaders:function(p,x){if(p===null&&(p={}),!e.isPlainObject(p)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(x===void 0&&(x=!0),this.ajaxHeaders=p,x){for(var C=0;C<this.world.getItemCount();C++)this.world.getItemAt(C)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var k in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[k].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(p){this.buttonGroup.addButton(p)},isFullPage:function(){return t[this.hash]&&t[this.hash].fullPage},setFullPage:function(p){var x=document.body,C=x.style,k=document.documentElement.style,F=this,A,D;if(p===this.isFullPage())return this;var H={fullPage:p,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",H),H.preventDefaultAction)return this;if(p&&this.element){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=C.margin,this.docMargin=k.margin,C.margin="0",k.margin="0",this.bodyPadding=C.padding,this.docPadding=k.padding,C.padding="0",k.padding="0",this.bodyWidth=C.width,this.docWidth=k.width,C.width="100%",k.width="100%",this.bodyHeight=C.height,this.docHeight=k.height,C.height="100%",k.height="100%",this.bodyDisplay=C.display,C.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,A=x.childNodes.length,D=0;D<A;D++)this.previousBody.push(x.childNodes[0]),x.removeChild(x.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,x.appendChild(this.toolbar.element),e.addClass(this.toolbar.element,"fullpage")),e.addClass(this.element,"fullpage"),x.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,ge)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,C.margin=this.bodyMargin,k.margin=this.docMargin,C.padding=this.bodyPadding,k.padding=this.docPadding,C.width=this.bodyWidth,k.width=this.docWidth,C.height=this.bodyHeight,k.height=this.docHeight,C.display=this.bodyDisplay,x.removeChild(this.element),A=this.previousBody.length,D=0;D<A;D++)x.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&&(x.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 V=0,q=function(){e.setPageScroll(F.pageScroll);var U=e.getPageScroll();V++,V<10&&(U.x!==F.pageScroll.x||U.y!==F.pageScroll.y)&&e.requestAnimationFrame(q)};e.requestAnimationFrame(q),t[this.hash].fullPage=!1,e.delegate(this,me)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:p}),this},setFullScreen:function(p){var x=this;if(!e.supportsFullScreen)return this.setFullPage(p);if(e.isFullScreen()===p)return this;var C={fullScreen:p,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",C),C.preventDefaultAction)return this;if(p){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 k=function(){var F=e.isFullScreen();F||(e.removeEvent(document,e.fullScreenEventName,k),e.removeEvent(document,e.fullScreenErrorEventName,k),x.setFullPage(!1),x.isFullPage()&&(x.element.style.width=x.fullPageStyleWidth,x.element.style.height=x.fullPageStyleHeight)),x.navigator&&x.viewport&&setTimeout(function(){x.navigator.update(x.viewport)}),x.raiseEvent("full-screen",{fullScreen:F})};e.addEvent(document,e.fullScreenEventName,k),e.addEvent(document,e.fullScreenErrorEventName,k),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(p){return this.container.style.visibility=p?"":"hidden",this.raiseEvent("visible",{visible:p}),this},addTiledImage:function(p){e.console.assert(p,"[Viewer.addTiledImage] options is required"),e.console.assert(p.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),e.console.assert(!p.replace||p.index>-1&&p.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var x=this;p.replace&&(p.replaceItem=x.world.getItemAt(p.index)),this._hideMessage(),p.placeholderFillStyle===void 0&&(p.placeholderFillStyle=this.placeholderFillStyle),p.opacity===void 0&&(p.opacity=this.opacity),p.preload===void 0&&(p.preload=this.preload),p.compositeOperation===void 0&&(p.compositeOperation=this.compositeOperation),p.crossOriginPolicy===void 0&&(p.crossOriginPolicy=p.tileSource.crossOriginPolicy!==void 0?p.tileSource.crossOriginPolicy:this.crossOriginPolicy),p.ajaxWithCredentials===void 0&&(p.ajaxWithCredentials=this.ajaxWithCredentials),p.loadTilesWithAjax===void 0&&(p.loadTilesWithAjax=this.loadTilesWithAjax),e.isPlainObject(p.ajaxHeaders)||(p.ajaxHeaders={});var C={options:p};function k(D){for(var H=0;H<x._loadQueue.length;H++)if(x._loadQueue[H]===C){x._loadQueue.splice(H,1);break}x._loadQueue.length===0&&F(C),x.raiseEvent("add-item-failed",D),p.error&&p.error(D)}function F(D){x.collectionMode&&(x.world.arrange({immediately:D.options.collectionImmediately,rows:x.collectionRows,columns:x.collectionColumns,layout:x.collectionLayout,tileSize:x.collectionTileSize,tileMargin:x.collectionTileMargin}),x.world.setAutoRefigureSizes(!0))}if(e.isArray(p.tileSource)){setTimeout(function(){k({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:p.tileSource,options:p})});return}this._loadQueue.push(C);function A(){for(var D,H,V;x._loadQueue.length&&(D=x._loadQueue[0],!!D.tileSource);){if(x._loadQueue.splice(0,1),D.options.replace){var q=x.world.getIndexOfItem(D.options.replaceItem);q!==-1&&(D.options.index=q),x.world.removeItem(D.options.replaceItem)}H=new e.TiledImage({viewer:x,source:D.tileSource,viewport:x.viewport,drawer:x.drawer,tileCache:x.tileCache,imageLoader:x.imageLoader,x:D.options.x,y:D.options.y,width:D.options.width,height:D.options.height,fitBounds:D.options.fitBounds,fitBoundsPlacement:D.options.fitBoundsPlacement,clip:D.options.clip,placeholderFillStyle:D.options.placeholderFillStyle,opacity:D.options.opacity,preload:D.options.preload,degrees:D.options.degrees,flipped:D.options.flipped,compositeOperation:D.options.compositeOperation,springStiffness:x.springStiffness,animationTime:x.animationTime,minZoomImageRatio:x.minZoomImageRatio,wrapHorizontal:x.wrapHorizontal,wrapVertical:x.wrapVertical,maxTilesPerFrame:x.maxTilesPerFrame,immediateRender:x.immediateRender,blendTime:x.blendTime,alwaysBlend:x.alwaysBlend,minPixelRatio:x.minPixelRatio,smoothTileEdgesMinZoom:x.smoothTileEdgesMinZoom,iOSDevice:x.iOSDevice,crossOriginPolicy:D.options.crossOriginPolicy,ajaxWithCredentials:D.options.ajaxWithCredentials,loadTilesWithAjax:D.options.loadTilesWithAjax,ajaxHeaders:D.options.ajaxHeaders,debugMode:x.debugMode,subPixelRoundingForTransparency:x.subPixelRoundingForTransparency}),x.collectionMode&&x.world.setAutoRefigureSizes(!1),x.navigator&&(V=e.extend({},D.options,{replace:!1,originalTiledImage:H,tileSource:D.tileSource}),x.navigator.addTiledImage(V)),x.world.addItem(H,{index:D.options.index}),x._loadQueue.length===0&&F(D),x.world.getItemCount()===1&&!x.preserveViewport&&x.viewport.goHome(!0),D.options.success&&D.options.success({item:H})}}o(this,p.tileSource,p,function(D){C.tileSource=D,A()},function(D){D.options=p,k(D),A()})},addSimpleImage:function(p){e.console.assert(p,"[Viewer.addSimpleImage] options is required"),e.console.assert(p.url,"[Viewer.addSimpleImage] options.url is required");var x=e.extend({},p,{tileSource:{type:"image",url:p.url}});delete x.url,this.addTiledImage(x)},addLayer:function(p){var x=this;e.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var C=e.extend({},p,{success:function(k){x.raiseEvent("add-layer",{options:p,drawer:k.item})},error:function(k){x.raiseEvent("add-layer-failed",k)}});return this.addTiledImage(C),this},getLayerAtLevel:function(p){return e.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(p)},getLevelOfLayer:function(p){return e.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(p)},getLayersCount:function(){return e.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(p,x){return e.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(p,x)},removeLayer:function(p){return e.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(p)},forceRedraw:function(){return t[this.hash].forceRedraw=!0,this},forceResize:function(){t[this.hash].needsResize=!0,t[this.hash].forceResize=!0},bindSequenceControls:function(){var p=e.delegate(this,m),x=e.delegate(this,_),C=e.delegate(this,this.goToNextPage),k=e.delegate(this,this.goToPreviousPage),F=this.navImages,A=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(A=!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:Z(this.prefixUrl,F.previous.REST),srcGroup:Z(this.prefixUrl,F.previous.GROUP),srcHover:Z(this.prefixUrl,F.previous.HOVER),srcDown:Z(this.prefixUrl,F.previous.DOWN),onRelease:k,onFocus:p,onBlur:x}),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:Z(this.prefixUrl,F.next.REST),srcGroup:Z(this.prefixUrl,F.next.GROUP),srcHover:Z(this.prefixUrl,F.next.HOVER),srcDown:Z(this.prefixUrl,F.next.DOWN),onRelease:C,onFocus:p,onBlur:x}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),A&&(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 p=e.delegate(this,$e),x=e.delegate(this,Ue),C=e.delegate(this,ce),k=e.delegate(this,ct),F=e.delegate(this,we),A=e.delegate(this,St),D=e.delegate(this,Nt),H=e.delegate(this,Ut),V=e.delegate(this,Pt),q=e.delegate(this,dt),U=e.delegate(this,m),$=e.delegate(this,_),g=this.navImages,f=[],w=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(w=!1),this.showZoomControl&&(f.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:Z(this.prefixUrl,g.zoomIn.REST),srcGroup:Z(this.prefixUrl,g.zoomIn.GROUP),srcHover:Z(this.prefixUrl,g.zoomIn.HOVER),srcDown:Z(this.prefixUrl,g.zoomIn.DOWN),onPress:p,onRelease:x,onClick:C,onEnter:p,onExit:x,onFocus:U,onBlur:$})),f.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:Z(this.prefixUrl,g.zoomOut.REST),srcGroup:Z(this.prefixUrl,g.zoomOut.GROUP),srcHover:Z(this.prefixUrl,g.zoomOut.HOVER),srcDown:Z(this.prefixUrl,g.zoomOut.DOWN),onPress:k,onRelease:x,onClick:F,onEnter:k,onExit:x,onFocus:U,onBlur:$}))),this.showHomeControl&&f.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:Z(this.prefixUrl,g.home.REST),srcGroup:Z(this.prefixUrl,g.home.GROUP),srcHover:Z(this.prefixUrl,g.home.HOVER),srcDown:Z(this.prefixUrl,g.home.DOWN),onRelease:A,onFocus:U,onBlur:$})),this.showFullPageControl&&f.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:Z(this.prefixUrl,g.fullpage.REST),srcGroup:Z(this.prefixUrl,g.fullpage.GROUP),srcHover:Z(this.prefixUrl,g.fullpage.HOVER),srcDown:Z(this.prefixUrl,g.fullpage.DOWN),onRelease:D,onFocus:U,onBlur:$})),this.showRotationControl&&(f.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:Z(this.prefixUrl,g.rotateleft.REST),srcGroup:Z(this.prefixUrl,g.rotateleft.GROUP),srcHover:Z(this.prefixUrl,g.rotateleft.HOVER),srcDown:Z(this.prefixUrl,g.rotateleft.DOWN),onRelease:H,onFocus:U,onBlur:$})),f.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:Z(this.prefixUrl,g.rotateright.REST),srcGroup:Z(this.prefixUrl,g.rotateright.GROUP),srcHover:Z(this.prefixUrl,g.rotateright.HOVER),srcDown:Z(this.prefixUrl,g.rotateright.DOWN),onRelease:V,onFocus:U,onBlur:$}))),this.showFlipControl&&f.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:Z(this.prefixUrl,g.flip.REST),srcGroup:Z(this.prefixUrl,g.flip.GROUP),srcHover:Z(this.prefixUrl,g.flip.HOVER),srcDown:Z(this.prefixUrl,g.flip.DOWN),onRelease:q,onFocus:U,onBlur:$})),w?(this.buttonGroup=new e.ButtonGroup({buttons:f,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",e.delegate(this,Ye)),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=f),this},currentPage:function(){return this._sequenceIndex},goToPage:function(p){return this.tileSources&&p>=0&&p<this.tileSources.length&&(this._sequenceIndex=p,this._updateSequenceButtons(p),this.open(this.tileSources[p]),this.referenceStrip&&this.referenceStrip.setFocus(p),this.raiseEvent("page",{page:p})),this},addOverlay:function(p,x,C,k){var F;if(e.isPlainObject(p)?F=p:F={element:p,location:x,placement:C,onDraw:k},p=e.getElement(F.element),l(this.currentOverlays,p)>=0)return this;var A=u(this,F);return this.currentOverlays.push(A),A.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:p,location:F.location,placement:F.placement}),this},updateOverlay:function(p,x,C){var k;return p=e.getElement(p),k=l(this.currentOverlays,p),k>=0&&(this.currentOverlays[k].update(x,C),t[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:p,location:x,placement:C})),this},removeOverlay:function(p){var x;return p=e.getElement(p),x=l(this.currentOverlays,p),x>=0&&(this.currentOverlays[x].destroy(),this.currentOverlays.splice(x,1),t[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:p})),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(p){var x;return p=e.getElement(p),x=l(this.currentOverlays,p),x>=0?this.currentOverlays[x]:null},_updateSequenceButtons:function(p){this.nextButton&&(!this.tileSources||this.tileSources.length-1===p?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(p>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(p){this._hideMessage();var x=e.makeNeutralElement("div");x.appendChild(document.createTextNode(p)),this.messageDiv=e.makeCenteredNode(x),e.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var p=this.messageDiv;p&&(p.parentNode.removeChild(p),delete this.messageDiv)},gestureSettingsByDeviceType:function(p){switch(p){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var p,x=this.currentOverlays.length;for(p=0;p<x;p++)this.currentOverlays[p].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,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 p=e.pixelDensityRatio,x=e.getCurrentPixelDensityRatio();p!==x&&(e.pixelDensityRatio=x,this.forceResize())},goToPreviousPage:function(){var p=this._sequenceIndex-1;this.navPrevNextWrap&&p<0&&(p+=this.tileSources.length),this.goToPage(p)},goToNextPage:function(){var p=this._sequenceIndex+1;this.navPrevNextWrap&&p>=this.tileSources.length&&(p=0),this.goToPage(p)},isAnimating:function(){return t[this.hash].animating}});function n(p){return p=e.getElement(p),new e.Point(p.clientWidth===0?1:p.clientWidth,p.clientHeight===0?1:p.clientHeight)}function o(p,x,C,k,F){var A=p;if(e.type(x)==="string"){if(x.match(/^\s*<.*>\s*$/))x=e.parseXml(x);else if(x.match(/^\s*[{[].*[}\]]\s*$/))try{var D=e.parseJSON(x);x=D}catch{}}function H(V,q){V.ready?k(V):(V.addHandler("ready",function(){k(V)}),V.addHandler("open-failed",function(U){F({message:U.message,source:q})}))}setTimeout(function(){if(e.type(x)==="string")x=new e.TileSource({url:x,crossOriginPolicy:C.crossOriginPolicy!==void 0?C.crossOriginPolicy:p.crossOriginPolicy,ajaxWithCredentials:p.ajaxWithCredentials,ajaxHeaders:C.ajaxHeaders?C.ajaxHeaders:p.ajaxHeaders,splitHashDataForPost:p.splitHashDataForPost,success:function($){k($.tileSource)}}),x.addHandler("open-failed",function($){F($)});else if(e.isPlainObject(x)||x.nodeType)if(x.crossOriginPolicy===void 0&&(C.crossOriginPolicy!==void 0||p.crossOriginPolicy!==void 0)&&(x.crossOriginPolicy=C.crossOriginPolicy!==void 0?C.crossOriginPolicy:p.crossOriginPolicy),x.ajaxWithCredentials===void 0&&(x.ajaxWithCredentials=p.ajaxWithCredentials),e.isFunction(x.getTileUrl)){var V=new e.TileSource(x);V.getTileUrl=x.getTileUrl,k(V)}else{var q=e.TileSource.determineType(A,x);if(!q){F({message:"Unable to load TileSource",source:x});return}var U=q.prototype.configure.apply(A,[x]);H(new q(U),x)}else H(x,x)})}function u(p,x){if(x instanceof e.Overlay)return x;var C=null;if(x.element)C=e.getElement(x.element);else{var k=x.id?x.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);C=e.getElement(x.id),C||(C=document.createElement("a"),C.href="#/overlay/"+k),C.id=k,e.addClass(C,x.className?x.className:"openseadragon-overlay")}var F=x.location,A=x.width,D=x.height;if(!F){var H=x.x,V=x.y;if(x.px!==void 0){var q=p.viewport.imageToViewportRectangle(new e.Rect(x.px,x.py,A||0,D||0));H=q.x,V=q.y,A=A!==void 0?q.width:void 0,D=D!==void 0?q.height:void 0}F=new e.Point(H,V)}var U=x.placement;return U&&e.type(U)==="string"&&(U=e.Placement[x.placement.toUpperCase()]),new e.Overlay({element:C,location:F,placement:U,onDraw:x.onDraw,checkResize:x.checkResize,width:A,height:D,rotationMode:x.rotationMode})}function l(p,x){var C;for(C=p.length-1;C>=0;C--)if(p[C].element===x)return C;return-1}function a(p,x){return e.requestAnimationFrame(function(){x(p)})}function h(p){e.requestAnimationFrame(function(){d(p)})}function c(p){p.autoHideControls&&(p.controlsShouldFade=!0,p.controlsFadeBeginTime=e.now()+p.controlsFadeDelay,window.setTimeout(function(){h(p)},p.controlsFadeDelay))}function d(p){var x,C,k,F;if(p.controlsShouldFade){for(x=e.now(),C=x-p.controlsFadeBeginTime,k=1-C/p.controlsFadeLength,k=Math.min(1,k),k=Math.max(0,k),F=p.controls.length-1;F>=0;F--)p.controls[F].autoFade&&p.controls[F].setOpacity(k);k>0&&h(p)}}function v(p){var x;for(p.controlsShouldFade=!1,x=p.controls.length-1;x>=0;x--)p.controls[x].setOpacity(1)}function m(){v(this)}function _(){c(this)}function y(p){var x={tracker:p.eventSource,position:p.position,originalEvent:p.originalEvent,preventDefault:p.preventDefault};this.raiseEvent("canvas-contextmenu",x),p.preventDefault=x.preventDefault}function E(p){var x={originalEvent:p.originalEvent,preventDefaultAction:!1,preventVerticalPan:p.preventVerticalPan||!this.panVertical,preventHorizontalPan:p.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",x),!x.preventDefaultAction&&!p.ctrl&&!p.alt&&!p.meta)switch(p.keyCode){case 38:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 40:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 37:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 39:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),p.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),p.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),p.preventDefault=!0;break;case 87:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-40))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 83:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,40))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 65:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-40,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 68:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(40,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 82:p.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(),p.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),p.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:p.preventDefault=!1;break}else p.preventDefault=!1}function S(p){var x={originalEvent:p.originalEvent};this.raiseEvent("canvas-key-press",x)}function P(p){var x,C=document.activeElement===this.canvas;C||this.canvas.focus(),this.viewport.flipped&&(p.position.x=this.viewport.getContainerSize().x-p.position.x);var k={tracker:p.eventSource,position:p.position,quick:p.quick,shift:p.shift,originalEvent:p.originalEvent,originalTarget:p.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",k),!k.preventDefaultAction&&this.viewport&&p.quick&&(x=this.gestureSettingsByDeviceType(p.pointerType),x.clickToZoom===!0&&(this.viewport.zoomBy(p.shift?1/this.zoomPerClick:this.zoomPerClick,x.zoomToRefPoint?this.viewport.pointFromPixel(p.position,!0):null),this.viewport.applyConstraints()),x.dblClickDragToZoom&&(t[this.hash].draggingToZoom===!0?(t[this.hash].lastClickTime=null,t[this.hash].draggingToZoom=!1):t[this.hash].lastClickTime=e.now()))}function B(p){var x,C={tracker:p.eventSource,position:p.position,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",C),!C.preventDefaultAction&&this.viewport&&(x=this.gestureSettingsByDeviceType(p.pointerType),x.dblClickToZoom&&(this.viewport.zoomBy(p.shift?1/this.zoomPerClick:this.zoomPerClick,x.zoomToRefPoint?this.viewport.pointFromPixel(p.position,!0):null),this.viewport.applyConstraints()))}function O(p){var x,C={tracker:p.eventSource,pointerType:p.pointerType,position:p.position,delta:p.delta,speed:p.speed,direction:p.direction,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",C),x=this.gestureSettingsByDeviceType(p.pointerType),!C.preventDefaultAction&&this.viewport){if(x.dblClickDragToZoom&&t[this.hash].draggingToZoom){var k=Math.pow(this.zoomPerDblClickDrag,p.delta.y/50);this.viewport.zoomBy(k)}else if(x.dragToPan&&!t[this.hash].draggingToZoom){if(this.panHorizontal||(p.delta.x=0),this.panVertical||(p.delta.y=0),this.viewport.flipped&&(p.delta.x=-p.delta.x),this.constrainDuringPan){var F=this.viewport.deltaPointsFromPixels(p.delta.negate());this.viewport.centerSpringX.target.value+=F.x,this.viewport.centerSpringY.target.value+=F.y;var A=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=F.x,this.viewport.centerSpringY.target.value-=F.y,A.xConstrained&&(p.delta.x=0),A.yConstrained&&(p.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(p.delta.negate()),x.flickEnabled&&!this.constrainDuringPan)}}}function M(p){var x,C={tracker:p.eventSource,pointerType:p.pointerType,position:p.position,speed:p.speed,direction:p.direction,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",C),x=this.gestureSettingsByDeviceType(p.pointerType),!C.preventDefaultAction&&this.viewport){if(!t[this.hash].draggingToZoom&&x.dragToPan&&x.flickEnabled&&p.speed>=x.flickMinSpeed){var k=0;this.panHorizontal&&(k=x.flickMomentum*p.speed*Math.cos(p.direction));var F=0;this.panVertical&&(F=x.flickMomentum*p.speed*Math.sin(p.direction));var A=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),D=this.viewport.pointFromPixel(new e.Point(A.x-k,A.y-F));this.viewport.panTo(D,!1)}this.viewport.applyConstraints()}x.dblClickDragToZoom&&t[this.hash].draggingToZoom===!0&&(t[this.hash].draggingToZoom=!1)}function L(p){this.raiseEvent("canvas-enter",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function W(p){this.raiseEvent("canvas-exit",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function Y(p){var x;if(this.raiseEvent("canvas-press",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,insideElementPressed:p.insideElementPressed,insideElementReleased:p.insideElementReleased,originalEvent:p.originalEvent}),x=this.gestureSettingsByDeviceType(p.pointerType),x.dblClickDragToZoom){var C=t[this.hash].lastClickTime,k=e.now();if(C===null)return;k-C<this.dblClickTimeThreshold&&(t[this.hash].draggingToZoom=!0),t[this.hash].lastClickTime=null}}function Q(p){this.raiseEvent("canvas-release",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,insideElementPressed:p.insideElementPressed,insideElementReleased:p.insideElementReleased,originalEvent:p.originalEvent})}function ee(p){this.raiseEvent("canvas-nonprimary-press",{tracker:p.eventSource,position:p.position,pointerType:p.pointerType,button:p.button,buttons:p.buttons,originalEvent:p.originalEvent})}function X(p){this.raiseEvent("canvas-nonprimary-release",{tracker:p.eventSource,position:p.position,pointerType:p.pointerType,button:p.button,buttons:p.buttons,originalEvent:p.originalEvent})}function ue(p){var x,C,k,F,A={tracker:p.eventSource,pointerType:p.pointerType,gesturePoints:p.gesturePoints,lastCenter:p.lastCenter,center:p.center,lastDistance:p.lastDistance,distance:p.distance,shift:p.shift,originalEvent:p.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",A),this.viewport&&(x=this.gestureSettingsByDeviceType(p.pointerType),x.pinchToZoom&&(!A.preventDefaultPanAction||!A.preventDefaultZoomAction)&&(C=this.viewport.pointFromPixel(p.center,!0),x.zoomToRefPoint&&!A.preventDefaultPanAction&&(k=this.viewport.pointFromPixel(p.lastCenter,!0),F=k.minus(C),this.panHorizontal||(F.x=0),this.panVertical||(F.y=0),this.viewport.panBy(F,!0)),A.preventDefaultZoomAction||this.viewport.zoomBy(p.distance/p.lastDistance,C,!0),this.viewport.applyConstraints()),x.pinchRotate&&!A.preventDefaultRotateAction)){var D=Math.atan2(p.gesturePoints[0].currentPos.y-p.gesturePoints[1].currentPos.y,p.gesturePoints[0].currentPos.x-p.gesturePoints[1].currentPos.x),H=Math.atan2(p.gesturePoints[0].lastPos.y-p.gesturePoints[1].lastPos.y,p.gesturePoints[0].lastPos.x-p.gesturePoints[1].lastPos.x);C=this.viewport.pointFromPixel(p.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(D-H)*(180/Math.PI),C,!0)}}function he(p){this.raiseEvent("canvas-focus",{tracker:p.eventSource,originalEvent:p.originalEvent})}function de(p){this.raiseEvent("canvas-blur",{tracker:p.eventSource,originalEvent:p.originalEvent})}function pe(p){var x,C,k,F,A;F=e.now(),A=F-this._lastScrollTime,A>this.minScrollDeltaTime?(this._lastScrollTime=F,x={tracker:p.eventSource,position:p.position,scroll:p.scroll,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",x),!x.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(p.position.x=this.viewport.getContainerSize().x-p.position.x),C=this.gestureSettingsByDeviceType(p.pointerType),C.scrollToZoom&&(k=Math.pow(this.zoomPerScroll,p.scroll),this.viewport.zoomBy(k,C.zoomToRefPoint?this.viewport.pointFromPixel(p.position,!0):null),this.viewport.applyConstraints())),p.preventDefault=x.preventDefault):p.preventDefault=!0}function ge(p){t[this.hash].mouseInside=!0,v(this),this.raiseEvent("container-enter",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function me(p){p.pointers<1&&(t[this.hash].mouseInside=!1,t[this.hash].animating||c(this)),this.raiseEvent("container-exit",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function Pe(p){xe(p),p.isOpen()?p._updateRequestId=a(p,Pe):p._updateRequestId=!1}function Le(p,x){var C=p.viewport,k=C.getZoom(),F=C.getCenter();C.resize(x,p.preserveImageSizeOnResize),C.panTo(F,!0);var A;if(p.preserveImageSizeOnResize)A=t[p.hash].prevContainerSize.x/x.x;else{var D=new e.Point(0,0),H=new e.Point(t[p.hash].prevContainerSize.x,t[p.hash].prevContainerSize.y).distanceTo(D),V=new e.Point(x.x,x.y).distanceTo(D);A=V/H*t[p.hash].prevContainerSize.x/x.x}C.zoomTo(k*A,null,!0),t[p.hash].prevContainerSize=x,t[p.hash].forceRedraw=!0,t[p.hash].needsResize=!1,t[p.hash].forceResize=!1}function xe(p){if(!(p._opening||!t[p.hash])){if(p.autoResize||t[p.hash].forceResize){var x;if(p._autoResizePolling){x=n(p.container);var C=t[p.hash].prevContainerSize;x.equals(C)||(t[p.hash].needsResize=!0)}t[p.hash].needsResize&&Le(p,x||n(p.container))}var k=p.viewport.update(),F=p.world.update(k)||k;k&&p.raiseEvent("viewport-change"),p.referenceStrip&&(F=p.referenceStrip.update(p.viewport)||F);var A=t[p.hash].animating;!A&&F&&(p.raiseEvent("animation-start"),v(p));var D=A&&!F;D&&(t[p.hash].animating=!1),(F||D||t[p.hash].forceRedraw||p.world.needsDraw())&&(Xe(p),p._drawOverlays(),p.navigator&&p.navigator.update(p.viewport),t[p.hash].forceRedraw=!1,F&&p.raiseEvent("animation")),D&&(p.raiseEvent("animation-finish"),t[p.hash].mouseInside||c(p)),t[p.hash].animating=F}}function Xe(p){p.imageLoader.clear(),p.world.draw(),p.raiseEvent("update-viewport",{})}function Z(p,x){return p?p+x:x}function $e(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=this.zoomPerSecond,t[this.hash].zooming=!0,z(this)}function ct(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=1/this.zoomPerSecond,t[this.hash].zooming=!0,z(this)}function Ue(){t[this.hash].zooming=!1}function z(p){e.requestAnimationFrame(e.delegate(p,ie))}function ie(){var p,x,C;t[this.hash].zooming&&this.viewport&&(p=e.now(),x=p-t[this.hash].lastZoomTime,C=Math.pow(t[this.hash].zoomFactor,x/1e3),this.viewport.zoomBy(C),this.viewport.applyConstraints(),t[this.hash].lastZoomTime=p,z(this))}function ce(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function we(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function Ye(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function St(){this.viewport&&this.viewport.goHome()}function Nt(){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 Ut(){if(this.viewport){var p=this.viewport.getRotation();this.viewport.flipped?p+=this.rotationIncrement:p-=this.rotationIncrement,this.viewport.setRotation(p)}}function Pt(){if(this.viewport){var p=this.viewport.getRotation();this.viewport.flipped?p-=this.rotationIncrement:p+=this.rotationIncrement,this.viewport.setRotation(p)}}function dt(){this.viewport.toggleFlip()}e.determineDrawer=function(p){for(let x in s){const C=s[x],k=C.prototype;if(k&&k instanceof s.DrawerBase&&e.isFunction(k.getType)&&k.getType.call(C)===p)return C}return null}})(s),(function(e){e.Navigator=function(a){var h=a.viewer,c=this,d,v;a.element||a.id?(a.element?(a.id&&e.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),a.element.id?a.id=a.element.id:a.id="navigator-"+e.now(),this.element=a.element):this.element=document.getElementById(a.id),a.controlOptions={anchor:e.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(a.id="navigator-"+e.now(),this.element=e.makeNeutralElement("div"),a.controlOptions={anchor:e.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:a.autoFade},a.position&&(a.position==="BOTTOM_RIGHT"?a.controlOptions.anchor=e.ControlAnchor.BOTTOM_RIGHT:a.position==="BOTTOM_LEFT"?a.controlOptions.anchor=e.ControlAnchor.BOTTOM_LEFT:a.position==="TOP_RIGHT"?a.controlOptions.anchor=e.ControlAnchor.TOP_RIGHT:a.position==="TOP_LEFT"?a.controlOptions.anchor=e.ControlAnchor.TOP_LEFT:a.position==="ABSOLUTE"&&(a.controlOptions.anchor=e.ControlAnchor.ABSOLUTE,a.controlOptions.top=a.top,a.controlOptions.left=a.left,a.controlOptions.height=a.height,a.controlOptions.width=a.width))),this.element.id=a.id,this.element.className+=" navigator",a=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.navigatorSizeRatio},a,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:a.animationTime,autoResize:!1,minZoomImageRatio:1,background:a.background,opacity:a.opacity,borderColor:a.borderColor,displayRegionColor:a.displayRegionColor}),a.minPixelRatio=this.minPixelRatio=h.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),a.controlOptions.anchor!==e.ControlAnchor.NONE&&(function(y,E){y.margin="0px",y.border=E+"px solid "+a.borderColor,y.padding="0px",y.background=a.background,y.opacity=a.opacity,y.overflow="hidden"})(this.element.style,this.borderWidth),this.displayRegion=e.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",(function(y,E){y.position="relative",y.top="0px",y.left="0px",y.fontSize="0px",y.overflow="hidden",y.border=E+"px solid "+a.displayRegionColor,y.margin="0px",y.padding="0px",y.background="transparent",y.float="left",y.cssFloat="left",y.zIndex=999999999,y.cursor="default",y.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),h.addControl(this.element,a.controlOptions),this._resizeWithViewer=a.controlOptions.anchor!==e.ControlAnchor.ABSOLUTE&&a.controlOptions.anchor!==e.ControlAnchor.NONE,a.width&&a.height?(this.setWidth(a.width),this.setHeight(a.height)):this._resizeWithViewer&&(d=e.getElementSize(h.element),this.element.style.height=Math.round(d.y*a.sizeRatio)+"px",this.element.style.width=Math.round(d.x*a.sizeRatio)+"px",this.oldViewerSize=d,v=e.getElementSize(this.element),this.elementArea=v.x*v.y),this.oldContainerSize=new e.Point(0,0),e.Viewer.apply(this,[a]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function m(y,E){u(c.displayRegionContainer,y),u(c.displayRegion,-y),c.viewport.setRotation(y,E)}if(a.navigatorRotate){var _=a.viewer.viewport?a.viewer.viewport.getRotation():a.viewer.degrees||0;m(_,!0),a.viewer.addHandler("rotate",function(y){m(y.degrees,y.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,n),scrollHandler:e.delegate(this,o),preProcessEventHandler:function(y){y.eventType==="wheel"&&(y.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",e.setElementPointerEventsNone(this.canvas),e.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){c.viewport&&c.viewport.goHome(!0)}),h.world.addHandler("item-index-change",function(y){window.setTimeout(function(){var E=c.world.getItemAt(y.previousIndex);c.world.setItemIndex(E,y.newIndex)},1)}),h.world.addHandler("remove-item",function(y){var E=y.item,S=c._getMatchingItem(E);S&&c.world.removeItem(S)}),this.update(h.viewport)},e.extend(e.Navigator.prototype,e.EventSource.prototype,e.Viewer.prototype,{updateSize:function(){if(this.viewport){var a=new e.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);a.equals(this.oldContainerSize)||(this.viewport.resize(a,!0),this.viewport.goHome(!0),this.oldContainerSize=a,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(a){this.width=a,this.element.style.width=typeof a=="number"?a+"px":a,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(a){this.height=a,this.element.style.height=typeof a=="number"?a+"px":a,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(a){return this.viewport.setFlip(a),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(a){l(this.canvas,a),l(this.element,a)},update:function(a){var h,c,d,v,m,_;if(a||(a=this.viewer.viewport),h=e.getElementSize(this.viewer.element),this._resizeWithViewer&&h.x&&h.y&&!h.equals(this.oldViewerSize)&&(this.oldViewerSize=h,this.maintainSizeRatio||!this.elementArea?(c=h.x*this.sizeRatio,d=h.y*this.sizeRatio):(c=Math.sqrt(this.elementArea*(h.x/h.y)),d=this.elementArea/c),this.element.style.width=Math.round(c)+"px",this.element.style.height=Math.round(d)+"px",this.elementArea||(this.elementArea=c*d),this.updateSize()),a&&this.viewport){if(v=a.getBoundsNoRotate(!0),m=this.viewport.pixelFromPointNoRotate(v.getTopLeft(),!1),_=this.viewport.pixelFromPointNoRotate(v.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var y=a.getRotation(!0);u(this.displayRegion,-y)}var E=this.displayRegion.style;E.display=this.world.getItemCount()?"block":"none",E.top=m.y.toFixed(2)+"px",E.left=m.x.toFixed(2)+"px";var S=_.x-m.x,P=_.y-m.y;E.width=Math.round(Math.max(S,0))+"px",E.height=Math.round(Math.max(P,0))+"px"}},addTiledImage:function(a){var h=this,c=a.originalTiledImage;delete a.original;var d=e.extend({},a,{success:function(v){var m=v.item;m._originalForNavigator=c,h._matchBounds(m,c,!0),h._matchOpacity(m,c),h._matchCompositeOperation(m,c);function _(){h._matchBounds(m,c)}function y(){h._matchOpacity(m,c)}function E(){h._matchCompositeOperation(m,c)}c.addHandler("bounds-change",_),c.addHandler("clip-change",_),c.addHandler("opacity-change",y),c.addHandler("composite-operation-change",E)}});return e.Viewer.prototype.addTiledImage.apply(this,[d])},destroy:function(){return e.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(a){for(var h=this.world.getItemCount(),c,d=0;d<h;d++)if(c=this.world.getItemAt(d),c._originalForNavigator===a)return c;return null},_matchBounds:function(a,h,c){var d=h.getBoundsNoRotate();a.setPosition(d.getTopLeft(),c),a.setWidth(d.width,c),a.setRotation(h.getRotation(),c),a.setClip(h.getClip()),a.setFlip(h.getFlip())},_matchOpacity:function(a,h){a.setOpacity(h.opacity)},_matchCompositeOperation:function(a,h){a.setCompositeOperation(h.compositeOperation)}});function t(a){var h={tracker:a.eventSource,position:a.position,quick:a.quick,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",h),!h.preventDefaultAction&&a.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(a.position.x=this.viewport.getContainerSize().x-a.position.x);var c=this.viewport.pointFromPixel(a.position);this.panVertical?this.panHorizontal||(c.x=this.viewer.viewport.getCenter(!0).x):c.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(c),this.viewer.viewport.applyConstraints()}}function i(a){var h={tracker:a.eventSource,position:a.position,delta:a.delta,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",h),!h.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewer.viewport.flipped&&(a.delta.x=-a.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function n(a){a.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function o(a){var h={tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent,preventDefault:a.preventDefault};this.viewer.raiseEvent("navigator-scroll",h),a.preventDefault=h.preventDefault}function u(a,h){l(a,"rotate("+h+"deg)")}function l(a,h){a.style.webkitTransform=h,a.style.mozTransform=h,a.style.msTransform=h,a.style.oTransform=h,a.style.transform=h}})(s),(function(e){var t={Errors:{Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",OpenFailed:"Unable to open {0}: {1}"},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out",NextPage:"Next page",PreviousPage:"Previous page",RotateLeft:"Rotate left",RotateRight:"Rotate right",Flip:"Flip Horizontally"}};e.extend(e,{getString:function(i){var n=i.split("."),o=null,u=arguments,l=t,a;for(a=0;a<n.length-1;a++)l=l[n[a]]||{};return o=l[n[a]],typeof o!="string"&&(e.console.error("Untranslated source string:",i),o=""),o.replace(/\{\d+\}/g,function(h){var c=parseInt(h.match(/\d+/),10)+1;return c<u.length?u[c]:""})},setString:function(i,n){var o=i.split("."),u=t,l;for(l=0;l<o.length-1;l++)u[o[l]]||(u[o[l]]={}),u=u[o[l]];u[o[l]]=n}})})(s),(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 n,o;if(t%90===0){var u=e.positiveModulo(t,360);switch(u){case 0:n=1,o=0;break;case 90:n=0,o=1;break;case 180:n=-1,o=0;break;case 270:n=0,o=-1;break}}else{var l=t*Math.PI/180;n=Math.cos(l),o=Math.sin(l)}var a=n*(this.x-i.x)-o*(this.y-i.y)+i.x,h=o*(this.x-i.x)+n*(this.y-i.y)+i.y;return new e.Point(a,h)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(s),(function(e){e.TileSource=function(i,n,o,u,l,a){var h=this,c=arguments,d,v;if(e.isPlainObject(i)?d=i:d={width:c[0],height:c[1],tileSize:c[2],tileOverlap:c[3],minLevel:c[4],maxLevel:c[5]},e.EventSource.call(this),e.extend(!0,this,d),!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(m){h.success(m)}),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=d.width&&d.height?d.width/d.height:1,this.dimensions=new e.Point(d.width,d.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=d.tileOverlap?d.tileOverlap:0,this.minLevel=d.minLevel?d.minLevel:0,this.maxLevel=d.maxLevel!==void 0&&d.maxLevel!==null?d.maxLevel:d.width&&d.height?Math.ceil(Math.log(Math.max(d.width,d.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={},n;for(n=0;n<=this.maxLevel;n++)i[n]=1/Math.pow(2,this.maxLevel-n);this.getLevelScale=function(o){return i[o]}},getNumTiles:function(i){var n=this.getLevelScale(i),o=Math.ceil(n*this.dimensions.x/this.getTileWidth(i)),u=Math.ceil(n*this.dimensions.y/this.getTileHeight(i));return new e.Point(o,u)},getPixelRatio:function(i){var n=this.dimensions.times(this.getLevelScale(i)),o=1/n.x*e.pixelDensityRatio,u=1/n.y*e.pixelDensityRatio;return new e.Point(o,u)},getClosestLevel:function(){var i,n;for(i=this.minLevel+1;i<=this.maxLevel&&(n=this.getNumTiles(i),!(n.x>1||n.y>1));i++);return i-1},getTileAtPoint:function(i,n){var o=n.x>=0&&n.x<=1&&n.y>=0&&n.y<=1/this.aspectRatio;e.console.assert(o,"[TileSource.getTileAtPoint] must be called with a valid point.");var u=this.dimensions.x*this.getLevelScale(i),l=n.x*u,a=n.y*u,h=Math.floor(l/this.getTileWidth(i)),c=Math.floor(a/this.getTileHeight(i));n.x>=1&&(h=this.getNumTiles(i).x-1);var d=1e-15;return n.y>=1/this.aspectRatio-d&&(c=this.getNumTiles(i).y-1),new e.Point(h,c)},getTileBounds:function(i,n,o,u){var l=this.dimensions.times(this.getLevelScale(i)),a=this.getTileWidth(i),h=this.getTileHeight(i),c=n===0?0:a*n-this.tileOverlap,d=o===0?0:h*o-this.tileOverlap,v=a+(n===0?1:2)*this.tileOverlap,m=h+(o===0?1:2)*this.tileOverlap,_=1/l.x;return v=Math.min(v,l.x-c),m=Math.min(m,l.y-d),u?new e.Rect(0,0,v,m):new e.Rect(c*_,d*_,v*_,m*_)},getImageInfo:function(i){var n=this,o,u,l,a,h,c,d;i&&(h=i.split("/"),c=h[h.length-1],d=c.lastIndexOf("."),d>-1&&(h[h.length-1]=c.slice(0,d)));var v=null;if(this.splitHashDataForPost){var m=i.indexOf("#");m!==-1&&(v=i.substring(m+1),i=i.substr(0,m))}u=function(_){typeof _=="string"&&(_=e.parseXml(_));var y=e.TileSource.determineType(n,_,i);if(!y){n.raiseEvent("open-failed",{message:"Unable to load TileSource",source:i});return}a=y.prototype.configure.apply(n,[_,i,v]),a.ajaxWithCredentials===void 0&&(a.ajaxWithCredentials=n.ajaxWithCredentials),l=new y(a),n.ready=!0,n.raiseEvent("ready",{tileSource:l})},i.match(/\.js$/)?(o=i.split("/").pop().replace(".js",""),e.jsonp({url:i,async:!1,callbackName:o,callback:u})):e.makeAjaxRequest({url:i,postData:v,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(_){var y=t(_);u(y)},error:function(_,y){var E;try{E="HTTP "+_.status+" attempting to load TileSource: "+i}catch{var S;typeof y>"u"||!y.toString?S="Unknown error":S=y.toString(),E=S+" attempting to load TileSource: "+i}e.console.error(E),n.raiseEvent("open-failed",{message:E,source:i,postData:v})}})},supports:function(i,n){return!1},configure:function(i,n,o){throw new Error("Method not implemented.")},getTileUrl:function(i,n,o){throw new Error("Method not implemented.")},getTilePostData:function(i,n,o){return null},getTileAjaxHeaders:function(i,n,o){return{}},getTileHashKey:function(i,n,o,u,l,a){function h(c){return l?c+"+"+JSON.stringify(l):c}return h(typeof u!="string"?i+"/"+n+"_"+o:u)},tileExists:function(i,n,o){var u=this.getNumTiles(i);return i>=this.minLevel&&i<=this.maxLevel&&n>=0&&o>=0&&n<u.x&&o<u.y},hasTransparency:function(i,n,o,u){return!!i||n.match(".png")},downloadTileStart:function(i){var n=i.userData,o=new Image;n.image=o,n.request=null;var u=function(l){if(!o){i.finish(null,n.request,"Image load failed: undefined Image instance.");return}o.onload=o.onerror=o.onabort=null,i.finish(l?null:o,n.request,l)};o.onload=function(){u()},o.onabort=o.onerror=function(){u("Image load aborted.")},i.loadWithAjax?n.request=e.makeAjaxRequest({url:i.src,withCredentials:i.ajaxWithCredentials,headers:i.ajaxHeaders,responseType:"arraybuffer",postData:i.postData,success:function(l){var a;try{a=new window.Blob([l.response])}catch(d){var h=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&h){var c=new h;c.append(l.response),a=c.getBlob()}}a.size===0?u("Empty image response."):o.src=(window.URL||window.webkitURL).createObjectURL(a)},error:function(l){u("Image load aborted - XHR error")}}):(i.crossOriginPolicy!==!1&&(o.crossOrigin=i.crossOriginPolicy),o.src=i.src)},downloadTileAbort:function(i){i.userData.request&&i.userData.request.abort();var n=i.userData.image;i.userData.image&&(n.onload=n.onerror=n.onabort=null)},createTileCache:function(i,n,o){i._data=n},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 n=document.createElement("canvas");n.width=i._data.width,n.height=i._data.height,i._renderedContext=n.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 n=i.responseText,o=i.status,u,l;if(i){if(i.status!==200&&i.status!==0)throw o=i.status,u=o===404?"Not Found":i.statusText,new Error(e.getString("Errors.Status",o,u))}else throw new Error(e.getString("Errors.Security"));if(n.match(/^\s*<.*/))try{l=i.responseXML&&i.responseXML.documentElement?i.responseXML:e.parseXml(n)}catch{l=i.responseText}else if(n.match(/\s*[{[].*/))try{l=e.parseJSON(n)}catch{l=n}else l=n;return l}e.TileSource.determineType=function(i,n,o){var u;for(u in s)if(u.match(/.+TileSource$/)&&e.isFunction(s[u])&&e.isFunction(s[u].prototype.supports)&&s[u].prototype.supports.call(i,n,o))return s[u];return e.console.error("No TileSource was able to open %s %s",o,n),null}})(s),(function(e){e.DziTileSource=function(n,o,u,l,a,h,c,d,v){var m,_,y,E;if(e.isPlainObject(n)?E=n:E={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=E.tilesUrl,this.fileFormat=E.fileFormat,this.displayRects=E.displayRects,this.displayRects)for(m=this.displayRects.length-1;m>=0;m--)for(_=this.displayRects[m],y=_.minLevel;y<=_.maxLevel;y++)this._levelRects[y]||(this._levelRects[y]=[]),this._levelRects[y].push(_);e.TileSource.apply(this,[E])},e.extend(e.DziTileSource.prototype,e.TileSource.prototype,{supports:function(n,o){var u;return n.Image?u=n.Image.xmlns:n.documentElement&&(n.documentElement.localName==="Image"||n.documentElement.tagName==="Image")&&(u=n.documentElement.namespaceURI),u=(u||"").toLowerCase(),u.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||u.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(n,o,u){var l;return e.isPlainObject(n)?l=i(this,n):l=t(this,n),o&&!l.tilesUrl&&(l.tilesUrl=o.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),o.search(/\.(dzi|xml|js)\?/)!==-1?l.queryParams=o.match(/\?.*/):l.queryParams=""),l},getTileUrl:function(n,o,u){return[this.tilesUrl,n,"/",o,"_",u,".",this.fileFormat,this.queryParams].join("")},tileExists:function(n,o,u){var l=this._levelRects[n],a,h,c,d,v,m,_;if(this.minLevel&&n<this.minLevel||this.maxLevel&&n>this.maxLevel)return!1;if(!l||!l.length)return!0;for(_=l.length-1;_>=0;_--)if(a=l[_],!(n<a.minLevel||n>a.maxLevel)&&(h=this.getLevelScale(n),c=a.x*h,d=a.y*h,v=c+a.width*h,m=d+a.height*h,c=Math.floor(c/this._tileWidth),d=Math.floor(d/this._tileWidth),v=Math.ceil(v/this._tileWidth),m=Math.ceil(m/this._tileWidth),c<=o&&o<v&&d<=u&&u<m))return!0;return!1}});function t(n,o){if(!o||!o.documentElement)throw new Error(e.getString("Errors.Xml"));var u=o.documentElement,l=u.localName||u.tagName,a=o.documentElement.namespaceURI,h=null,c=[],d,v,m,_,y;if(l==="Image")try{if(_=u.getElementsByTagName("Size")[0],_===void 0&&(_=u.getElementsByTagNameNS(a,"Size")[0]),h={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:u.getAttribute("Url"),Format:u.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(u.getAttribute("Overlap"),10),TileSize:parseInt(u.getAttribute("TileSize"),10),Size:{Height:parseInt(_.getAttribute("Height"),10),Width:parseInt(_.getAttribute("Width"),10)}}},!e.imageFormatSupported(h.Image.Format))throw new Error(e.getString("Errors.ImageFormat",h.Image.Format.toUpperCase()));for(d=u.getElementsByTagName("DisplayRect"),d===void 0&&(d=u.getElementsByTagNameNS(a,"DisplayRect")[0]),y=0;y<d.length;y++)v=d[y],m=v.getElementsByTagName("Rect")[0],m===void 0&&(m=v.getElementsByTagNameNS(a,"Rect")[0]),c.push({Rect:{X:parseInt(m.getAttribute("X"),10),Y:parseInt(m.getAttribute("Y"),10),Width:parseInt(m.getAttribute("Width"),10),Height:parseInt(m.getAttribute("Height"),10),MinLevel:parseInt(v.getAttribute("MinLevel"),10),MaxLevel:parseInt(v.getAttribute("MaxLevel"),10)}});return c.length&&(h.Image.DisplayRect=c),i(n,h)}catch(P){throw P instanceof Error?P:new Error(e.getString("Errors.Dzi"))}else{if(l==="Collection")throw new Error(e.getString("Errors.Dzc"));if(l==="Error"){var E=u.getElementsByTagName("Message")[0],S=E.firstChild.nodeValue;throw new Error(S)}}throw new Error(e.getString("Errors.Dzi"))}function i(n,o){var u=o.Image,l=u.Url,a=u.Format,h=u.Size,c=u.DisplayRect||[],d=parseInt(h.Width,10),v=parseInt(h.Height,10),m=parseInt(u.TileSize,10),_=parseInt(u.Overlap,10),y=[],E,S;for(S=0;S<c.length;S++)E=c[S].Rect,y.push(new e.DisplayRect(parseInt(E.X,10),parseInt(E.Y,10),parseInt(E.Width,10),parseInt(E.Height,10),parseInt(E.MinLevel,10),parseInt(E.MaxLevel,10)));return e.extend(!0,{width:d,height:v,tileSize:m,tileOverlap:_,minLevel:null,maxLevel:null,tilesUrl:l,fileFormat:a,displayRects:y},o)}})(s),(function(e){e.IIIFTileSource=function(u){if(e.extend(!0,this,u),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(u.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=u.version,this.tile_width&&this.tile_height)u.tileWidth=this.tile_width,u.tileHeight=this.tile_height;else if(this.tile_width)u.tileSize=this.tile_width;else if(this.tile_height)u.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)u.tileWidth=this.tiles[0].width,u.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var l=0;l<this.tiles.length;l++)for(var a=0;a<this.tiles[l].scaleFactors.length;a++){var h=this.tiles[l].scaleFactors[a];this.scale_factors.push(h),u.tileSizePerScaleFactor[h]={width:this.tiles[l].width,height:this.tiles[l].height||this.tiles[l].width}}}else if(t(u)){for(var c=Math.min(this.height,this.width),d=[256,512,1024],v=[],m=0;m<d.length;m++)d[m]<=c&&v.push(d[m]);v.length>0?u.tileSize=Math.max.apply(null,v):u.tileSize=c}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,u.levels=i(this),e.extend(!0,u,{width:u.levels[u.levels.length-1].width,height:u.levels[u.levels.length-1].height,tileSize:Math.max(u.height,u.width),tileOverlap:0,minLevel:0,maxLevel:u.levels.length-1}),this.levels=u.levels):e.console.error("Nothing in the info.json to construct image pyramids from");if(!u.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)u.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var _=Math.max.apply(null,this.scale_factors);u.maxLevel=Math.round(Math.log(_)*Math.LOG2E)}if(this.sizes){var y=this.sizes.length;(y===u.maxLevel||y===u.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((E,S)=>E.width-S.width),y===u.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}e.TileSource.apply(this,[u])},e.extend(e.IIIFTileSource.prototype,e.TileSource.prototype,{supports:function(u,l){return u.protocol&&u.protocol==="http://iiif.io/api/image"||u["@context"]&&(u["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||u["@context"]==="http://iiif.io/api/image/1/context.json")||u.profile&&u.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||u.identifier&&u.width&&u.height?!0:!!(u.documentElement&&u.documentElement.tagName==="info"&&u.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(u,l,a){if(e.isPlainObject(u)){if(!u["@context"])u["@context"]="http://iiif.io/api/image/1.0/context.json",u["@id"]=l.replace("/info.json",""),u.version=1;else{var h=u["@context"];if(Array.isArray(h)){for(var c=0;c<h.length;c++)if(typeof h[c]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(h[c])||h[c]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){h=h[c];break}}switch(h){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":u.version=1;break;case"http://iiif.io/api/image/2/context.json":u.version=2;break;case"http://iiif.io/api/image/3/context.json":u.version=3;break;default:e.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(u.preferredFormats){for(var d=0;d<u.preferredFormats.length;d++)if(s.imageFormatSupported(u.preferredFormats[d])){u.tileFormat=u.preferredFormats[d];break}}return u}else{var v=n(u);return v["@context"]="http://iiif.io/api/image/1.0/context.json",v["@id"]=l.replace("/info.xml",""),v.version=1,v}},getTileWidth:function(u){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileWidth.call(this,u);var l=Math.pow(2,this.maxLevel-u);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].width:this._tileWidth},getTileHeight:function(u){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileHeight.call(this,u);var l=Math.pow(2,this.maxLevel-u);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].height:this._tileHeight},getLevelScale:function(u){if(this.emulateLegacyImagePyramid){var l=NaN;return this.levels.length>0&&u>=this.minLevel&&u<=this.maxLevel&&(l=this.levels[u].width/this.levels[this.maxLevel].width),l}return e.TileSource.prototype.getLevelScale.call(this,u)},getNumTiles:function(u){if(this.emulateLegacyImagePyramid){var l=this.getLevelScale(u);return l?new e.Point(1,1):new e.Point(0,0)}if(this.levelSizes){var a=this.levelSizes[u],h=Math.ceil(a.width/this.getTileWidth(u)),c=Math.ceil(a.height/this.getTileHeight(u));return new e.Point(h,c)}else return e.TileSource.prototype.getNumTiles.call(this,u)},getTileAtPoint:function(u,l){if(this.emulateLegacyImagePyramid)return new e.Point(0,0);if(this.levelSizes){var a=l.x>=0&&l.x<=1&&l.y>=0&&l.y<=1/this.aspectRatio;e.console.assert(a,"[TileSource.getTileAtPoint] must be called with a valid point.");var h=this.levelSizes[u].width,c=l.x*h,d=l.y*h,v=Math.floor(c/this.getTileWidth(u)),m=Math.floor(d/this.getTileHeight(u));l.x>=1&&(v=this.getNumTiles(u).x-1);var _=1e-15;return l.y>=1/this.aspectRatio-_&&(m=this.getNumTiles(u).y-1),new e.Point(v,m)}return e.TileSource.prototype.getTileAtPoint.call(this,u,l)},getTileUrl:function(u,l,a){if(this.emulateLegacyImagePyramid){var h=null;return this.levels.length>0&&u>=this.minLevel&&u<=this.maxLevel&&(h=this.levels[u].url),h}var c="0",d=Math.pow(.5,this.maxLevel-u),v,m,_,y,E,S,P,B,O,M,L,W,Y,Q,ee,X;return this.levelSizes?(v=this.levelSizes[u].width,m=this.levelSizes[u].height):(v=Math.ceil(this.width*d),m=Math.ceil(this.height*d)),_=this.getTileWidth(u),y=this.getTileHeight(u),E=Math.round(_/d),S=Math.round(y/d),this.version===1?ee="native."+this.tileFormat:ee="default."+this.tileFormat,v<_&&m<y?(this.version===2&&v===this.width?W="full":this.version===3&&v===this.width&&m===this.height?W="max":this.version===3?W=v+","+m:W=v+",",P="full"):(B=l*E,O=a*S,M=Math.min(E,this.width-B),L=Math.min(S,this.height-O),l===0&&a===0&&M===this.width&&L===this.height?P="full":P=[B,O,M,L].join(","),Y=Math.min(_,v-l*_),Q=Math.min(y,m-a*y),this.version===2&&Y===this.width?W="full":this.version===3&&Y===this.width&&Q===this.height?W="max":this.version===3?W=Y+","+Q:W=Y+","),X=[this._id,P,W,c,ee].join("/"),X},__testonly__:{canBeTiled:t,constructLevels:i}});function t(u){var l=["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"],a=Array.isArray(u.profile)?u.profile[0]:u.profile,h=l.indexOf(a)!==-1,c=!1;return u.version===2&&u.profile.length>1&&u.profile[1].supports&&(c=u.profile[1].supports.indexOf("sizeByW")!==-1),u.version===3&&u.extraFeatures&&(c=u.extraFeatures.indexOf("sizeByWh")!==-1),!h||c}function i(u){for(var l=[],a=0;a<u.sizes.length;a++)l.push({url:u._id+"/full/"+u.sizes[a].width+","+(u.version===3?u.sizes[a].height:"")+"/0/default."+u.tileFormat,width:u.sizes[a].width,height:u.sizes[a].height});return l.sort(function(h,c){return h.width-c.width})}function n(u){if(!u||!u.documentElement)throw new Error(e.getString("Errors.Xml"));var l=u.documentElement,a=l.tagName,h=null;if(a==="info")try{return h={},o(l,h),h}catch(c){throw c instanceof Error?c:new Error(e.getString("Errors.IIIF"))}throw new Error(e.getString("Errors.IIIF"))}function o(u,l,a){var h,c;if(u.nodeType===3&&a)c=u.nodeValue.trim(),c.match(/^\d*$/)&&(c=Number(c)),l[a]?(e.isArray(l[a])||(l[a]=[l[a]]),l[a].push(c)):l[a]=c;else if(u.nodeType===1)for(h=0;h<u.childNodes.length;h++)o(u.childNodes[h],l,u.nodeName)}})(s),(function(e){e.OsmTileSource=function(t,i,n,o,u){var l;e.isPlainObject(t)?l=t:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!l.width||!l.height)&&(l.width=65572864,l.height=65572864),l.tileSize||(l.tileSize=256,l.tileOverlap=0),l.tilesUrl||(l.tilesUrl="http://tile.openstreetmap.org/"),l.minLevel=8,e.TileSource.apply(this,[l])},e.extend(e.OsmTileSource.prototype,e.TileSource.prototype,{supports:function(t,i){return t.type&&t.type==="openstreetmaps"},configure:function(t,i,n){return t},getTileUrl:function(t,i,n){return this.tilesUrl+(t-8)+"/"+i+"/"+n+".png"}})})(s),(function(e){e.TmsTileSource=function(t,i,n,o,u){var l;e.isPlainObject(t)?l=t:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var a=Math.ceil(l.width/256)*256,h=Math.ceil(l.height/256)*256,c;a>h?c=a/256:c=h/256,l.maxLevel=Math.ceil(Math.log(c)/Math.log(2))-1,l.tileSize=256,l.width=a,l.height=h,e.TileSource.apply(this,[l])},e.extend(e.TmsTileSource.prototype,e.TileSource.prototype,{supports:function(t,i){return t.type&&t.type==="tiledmapservice"},configure:function(t,i,n){return t},getTileUrl:function(t,i,n){var o=this.getNumTiles(t).y-1;return this.tilesUrl+t+"/"+i+"/"+(o-n)+".png"}})})(s),(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,s.TileSource.apply(this,[t])},e.extend(e.ZoomifyTileSource.prototype,e.TileSource.prototype,{_getGridSize:function(t,i,n){return{x:Math.ceil(t/n),y:Math.ceil(i/n)}},_calculateAbsoluteTileNumber:function(t,i,n){for(var o=0,u={},l=0;l<t;l++)u=this.gridSize[l],o+=u.x*u.y;return u=this.gridSize[t],o+=u.x*n+i,o},supports:function(t,i){return t.type&&t.type==="zoomifytileservice"},configure:function(t,i,n){return t},getTileUrl:function(t,i,n){var o=0,u=this._calculateAbsoluteTileNumber(t,i,n);return o=Math.floor(u/256),this.tilesUrl+"TileGroup"+o+"/"+t+"-"+i+"-"+n+"."+this.fileFormat}})})(s),(function(e){e.LegacyTileSource=function(o){var u,l,a;e.isArray(o)&&(u={type:"legacy-image-pyramid",levels:o}),u.levels=t(u.levels),u.levels.length>0?(l=u.levels[u.levels.length-1].width,a=u.levels[u.levels.length-1].height):(l=0,a=0,e.console.error("No supported image formats found")),e.extend(!0,u,{width:l,height:a,tileSize:Math.max(a,l),tileOverlap:0,minLevel:0,maxLevel:u.levels.length>0?u.levels.length-1:0}),e.TileSource.apply(this,[u]),this.levels=u.levels},e.extend(e.LegacyTileSource.prototype,e.TileSource.prototype,{supports:function(o,u){return o.type&&o.type==="legacy-image-pyramid"||o.documentElement&&o.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(o,u,l){var a;return e.isPlainObject(o)?a=n(this,o):a=i(this,o),a},getLevelScale:function(o){var u=NaN;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(u=this.levels[o].width/this.levels[this.maxLevel].width),u},getNumTiles:function(o){var u=this.getLevelScale(o);return u?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(o,u,l){var a=null;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(a=this.levels[o].url),a}});function t(o){var u=[],l,a;for(a=0;a<o.length;a++)l=o[a],l.height&&l.width&&l.url?u.push({url:l.url,width:Number(l.width),height:Number(l.height)}):e.console.error("Unsupported image format: %s",l.url?l.url:"<no URL>");return u.sort(function(h,c){return h.height-c.height})}function i(o,u){if(!u||!u.documentElement)throw new Error(e.getString("Errors.Xml"));var l=u.documentElement,a=l.tagName,h=null,c=[],d,v;if(a==="image")try{for(h={type:l.getAttribute("type"),levels:[]},c=l.getElementsByTagName("level"),v=0;v<c.length;v++)d=c[v],h.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return n(o,h)}catch(m){throw m instanceof Error?m:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(a==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(a==="error")throw new Error("Error: "+u)}throw new Error("Unknown element "+a)}function n(o,u){return u.levels}})(s),(function(e){e.ImageTileSource=function(t){t=e.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1},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,n){return t},getImageInfo:function(t){var i=this._image=new Image,n=this;this.crossOriginPolicy&&(i.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(i.useCredentials=this.ajaxWithCredentials),e.addEvent(i,"load",function(){n.width=i.naturalWidth,n.height=i.naturalHeight,n.aspectRatio=n.width/n.height,n.dimensions=new e.Point(n.width,n.height),n._tileWidth=n.width,n._tileHeight=n.height,n.tileOverlap=0,n.minLevel=0,n.levels=n._buildLevels(),n.maxLevel=n.levels.length-1,n.ready=!0,n.raiseEvent("ready",{tileSource:n})}),e.addEvent(i,"error",function(){n.raiseEvent("open-failed",{message:"Error loading image at "+t,source:t})}),i.src=t},getLevelScale:function(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,n){var o=null;return t>=this.minLevel&&t<=this.maxLevel&&(o=this.levels[t].url),o},getContext2D:function(t,i,n){var o=null;return t>=this.minLevel&&t<=this.maxLevel&&(o=this.levels[t].context2D),o},destroy:function(t){this._freeupCanvasMemory(t)},_buildLevels:function(){var t=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!e.supportsCanvas)return delete this._image,t;var i=this._image.naturalWidth,n=this._image.naturalHeight,o=document.createElement("canvas"),u=o.getContext("2d");if(o.width=i,o.height=n,u.drawImage(this._image,0,0,i,n),t[0].context2D=u,delete this._image,e.isCanvasTainted(o))return t;for(;i>=2&&n>=2;){i=Math.floor(i/2),n=Math.floor(n/2);var l=document.createElement("canvas"),a=l.getContext("2d");l.width=i,l.height=n,a.drawImage(o,0,0,i,n),t.splice(0,0,{context2D:a,width:i,height:n}),o=l,u=a}return t},_freeupCanvasMemory:function(t){for(var i=0;i<this.levels.length;i++)this.levels[i].context2D&&(this.levels[i].context2D.canvas.height=0,this.levels[i].context2D.canvas.width=0,t&&t.raiseEvent("image-unloaded",{context2D:this.levels[i].context2D}))}})})(s),(function(e){e.TileSourceCollection=function(t,i,n,o){e.console.error("TileSourceCollection is deprecated; use World instead")}})(s),(function(e){e.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},e.Button=function(a){var h=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},a),this.element=a.element||e.makeNeutralElement("div"),a.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",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(c){c.insideElementPressed?(u(h,e.ButtonState.DOWN),h.raiseEvent("enter",{originalEvent:c.originalEvent})):c.buttonDownAny||u(h,e.ButtonState.HOVER)},focusHandler:function(c){h.tracker.enterHandler(c),h.raiseEvent("focus",{originalEvent:c.originalEvent})},leaveHandler:function(c){l(h,e.ButtonState.GROUP),c.insideElementPressed&&h.raiseEvent("exit",{originalEvent:c.originalEvent})},blurHandler:function(c){h.tracker.leaveHandler(c),h.raiseEvent("blur",{originalEvent:c.originalEvent})},pressHandler:function(c){u(h,e.ButtonState.DOWN),h.raiseEvent("press",{originalEvent:c.originalEvent})},releaseHandler:function(c){c.insideElementPressed&&c.insideElementReleased?(l(h,e.ButtonState.HOVER),h.raiseEvent("release",{originalEvent:c.originalEvent})):c.insideElementPressed?l(h,e.ButtonState.GROUP):u(h,e.ButtonState.HOVER)},clickHandler:function(c){c.quick&&h.raiseEvent("click",{originalEvent:c.originalEvent})},keyHandler:function(c){c.keyCode===13?(h.raiseEvent("click",{originalEvent:c.originalEvent}),h.raiseEvent("release",{originalEvent:c.originalEvent}),c.preventDefault=!0):c.preventDefault=!1}}),l(this,e.ButtonState.REST)},e.extend(e.Button.prototype,e.EventSource.prototype,{notifyGroupEnter:function(){u(this,e.ButtonState.GROUP)},notifyGroupExit:function(){l(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(a){e.requestAnimationFrame(function(){i(a)})}function i(a){var h,c,d;a.shouldFade&&(h=e.now(),c=h-a.fadeBeginTime,d=1-c/a.fadeLength,d=Math.min(1,d),d=Math.max(0,d),a.imgGroup&&e.setElementOpacity(a.imgGroup,d,!0),d>0&&t(a))}function n(a){a.shouldFade=!0,a.fadeBeginTime=e.now()+a.fadeDelay,window.setTimeout(function(){t(a)},a.fadeDelay)}function o(a){a.shouldFade=!1,a.imgGroup&&e.setElementOpacity(a.imgGroup,1,!0)}function u(a,h){a.element.disabled||(h>=e.ButtonState.GROUP&&a.currentState===e.ButtonState.REST&&(o(a),a.currentState=e.ButtonState.GROUP),h>=e.ButtonState.HOVER&&a.currentState===e.ButtonState.GROUP&&(a.imgHover&&(a.imgHover.style.visibility=""),a.currentState=e.ButtonState.HOVER),h>=e.ButtonState.DOWN&&a.currentState===e.ButtonState.HOVER&&(a.imgDown&&(a.imgDown.style.visibility=""),a.currentState=e.ButtonState.DOWN))}function l(a,h){a.element.disabled||(h<=e.ButtonState.HOVER&&a.currentState===e.ButtonState.DOWN&&(a.imgDown&&(a.imgDown.style.visibility="hidden"),a.currentState=e.ButtonState.HOVER),h<=e.ButtonState.GROUP&&a.currentState===e.ButtonState.HOVER&&(a.imgHover&&(a.imgHover.style.visibility="hidden"),a.currentState=e.ButtonState.GROUP),h<=e.ButtonState.REST&&a.currentState===e.ButtonState.GROUP&&(n(a),a.currentState=e.ButtonState.REST))}})(s),(function(e){e.ButtonGroup=function(t){e.extend(!0,this,{buttons:[],clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},t);var i=this.buttons.concat([]),n=this,o;if(this.element=t.element||e.makeNeutralElement("div"),!t.group)for(this.element.style.display="inline-block",o=0;o<i.length;o++)this.element.appendChild(i[o].element);e.setElementTouchActionNone(this.element),this.tracker=new e.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(u){var l;for(l=0;l<n.buttons.length;l++)n.buttons[l].notifyGroupEnter()},leaveHandler:function(u){var l;if(!u.insideElementPressed)for(l=0;l<n.buttons.length;l++)n.buttons[l].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}}})(s),(function(e){e.Rect=function(t,i,n,o,u){this.x=typeof t=="number"?t:0,this.y=typeof i=="number"?i:0,this.width=typeof n=="number"?n:0,this.height=typeof o=="number"?o:0,this.degrees=typeof u=="number"?u:0,this.degrees=e.positiveModulo(this.degrees,360);var l,a;this.degrees>=270?(l=this.getTopRight(),this.x=l.x,this.y=l.y,a=this.height,this.height=this.width,this.width=a,this.degrees-=270):this.degrees>=180?(l=this.getBottomRight(),this.x=l.x,this.y=l.y,this.degrees-=180):this.degrees>=90&&(l=this.getBottomLeft(),this.x=l.x,this.y=l.y,a=this.height,this.height=this.width,this.width=a,this.degrees-=90)},e.Rect.fromSummits=function(t,i,n){var o=t.distanceTo(i),u=t.distanceTo(n),l=i.minus(t),a=Math.atan(l.y/l.x);return l.x<0?a+=Math.PI:l.y<0&&(a+=2*Math.PI),new e.Rect(t.x,t.y,o,u,a/Math.PI*180)},e.Rect.prototype={clone:function(){return new e.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new e.Point(this.x,this.y)},getBottomRight:function(){return new e.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new e.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new e.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new e.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new e.Point(this.width,this.height)},equals:function(t){return t instanceof e.Rect&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height&&this.degrees===t.degrees},times:function(t){return new e.Rect(this.x*t,this.y*t,this.width*t,this.height*t,this.degrees)},translate:function(t){return new e.Rect(this.x+t.x,this.y+t.y,this.width,this.height,this.degrees)},union:function(t){var i=this.getBoundingBox(),n=t.getBoundingBox(),o=Math.min(i.x,n.x),u=Math.min(i.y,n.y),l=Math.max(i.x+i.width,n.x+n.width),a=Math.max(i.y+i.height,n.y+n.height);return new e.Rect(o,u,l-o,a-u)},intersection:function(t){var i=1e-10,n=[],o=this.getTopLeft();t.containsPoint(o,i)&&n.push(o);var u=this.getTopRight();t.containsPoint(u,i)&&n.push(u);var l=this.getBottomLeft();t.containsPoint(l,i)&&n.push(l);var a=this.getBottomRight();t.containsPoint(a,i)&&n.push(a);var h=t.getTopLeft();this.containsPoint(h,i)&&n.push(h);var c=t.getTopRight();this.containsPoint(c,i)&&n.push(c);var d=t.getBottomLeft();this.containsPoint(d,i)&&n.push(d);var v=t.getBottomRight();this.containsPoint(v,i)&&n.push(v);for(var m=this._getSegments(),_=t._getSegments(),y=0;y<m.length;y++)for(var E=m[y],S=0;S<_.length;S++){var P=_[S],B=O(E[0],E[1],P[0],P[1]);B&&n.push(B)}function O(X,ue,he,de){var pe=ue.minus(X),ge=de.minus(he),me=-ge.x*pe.y+pe.x*ge.y;if(me===0)return null;var Pe=(pe.x*(X.y-he.y)-pe.y*(X.x-he.x))/me,Le=(ge.x*(X.y-he.y)-ge.y*(X.x-he.x))/me;return-i<=Pe&&Pe<=1-i&&-i<=Le&&Le<=1-i?new e.Point(X.x+Le*pe.x,X.y+Le*pe.y):null}if(n.length===0)return null;for(var M=n[0].x,L=n[0].x,W=n[0].y,Y=n[0].y,Q=1;Q<n.length;Q++){var ee=n[Q];ee.x<M&&(M=ee.x),ee.x>L&&(L=ee.x),ee.y<W&&(W=ee.y),ee.y>Y&&(Y=ee.y)}return new e.Rect(M,W,L-M,Y-W)},_getSegments:function(){var t=this.getTopLeft(),i=this.getTopRight(),n=this.getBottomLeft(),o=this.getBottomRight();return[[t,i],[i,o],[o,n],[n,t]]},rotate:function(t,i){if(t=e.positiveModulo(t,360),t===0)return this.clone();i=i||this.getCenter();var n=this.getTopLeft().rotate(t,i),o=this.getTopRight().rotate(t,i),u=o.minus(n);u=u.apply(function(a){var h=1e-15;return Math.abs(a)<h?0:a});var l=Math.atan(u.y/u.x);return u.x<0?l+=Math.PI:u.y<0&&(l+=2*Math.PI),new e.Rect(n.x,n.y,this.width,this.height,l/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var t=this.getTopLeft(),i=this.getTopRight(),n=this.getBottomLeft(),o=this.getBottomRight(),u=Math.min(t.x,i.x,n.x,o.x),l=Math.max(t.x,i.x,n.x,o.x),a=Math.min(t.y,i.y,n.y,o.y),h=Math.max(t.y,i.y,n.y,o.y);return new e.Rect(u,a,l-u,h-a)},getIntegerBoundingBox:function(){var t=this.getBoundingBox(),i=Math.floor(t.x),n=Math.floor(t.y),o=Math.ceil(t.width+t.x-i),u=Math.ceil(t.height+t.y-n);return new e.Rect(i,n,o,u)},containsPoint:function(t,i){i=i||0;var n=this.getTopLeft(),o=this.getTopRight(),u=this.getBottomLeft(),l=o.minus(n),a=u.minus(n);return(t.x-n.x)*l.x+(t.y-n.y)*l.y>=-i&&(t.x-o.x)*l.x+(t.y-o.y)*l.y<=i&&(t.x-n.x)*a.x+(t.y-n.y)*a.y>=-i&&(t.x-u.x)*a.x+(t.y-u.y)*a.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]"}}})(s),(function(e){var t={};e.ReferenceStrip=function(d){var v=this,m=d.viewer,_=e.getElementSize(m.element),y,E,S;for(d.id||(d.id="referencestrip-"+e.now(),this.element=e.makeNeutralElement("div"),this.element.id=d.id,this.element.className="referencestrip"),d=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.referenceStripSizeRatio,position:e.DEFAULT_SETTINGS.referenceStripPosition,scroll:e.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold},d,{element:this.element}),e.extend(this,d),t[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,E=this.element.style,E.marginTop="0px",E.marginRight="0px",E.marginBottom="0px",E.marginLeft="0px",E.left="0px",E.bottom="0px",E.border="0px",E.background="#000",E.position="relative",e.setElementTouchActionNone(this.element),e.setElementOpacity(this.element,.8),this.viewer=m,this.tracker=new e.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:e.delegate(this,i),dragHandler:e.delegate(this,n),scrollHandler:e.delegate(this,o),enterHandler:e.delegate(this,l),leaveHandler:e.delegate(this,a),keyDownHandler:e.delegate(this,h),keyHandler:e.delegate(this,c),preProcessEventHandler:function(P){P.eventType==="wheel"&&(P.preventDefault=!0)}}),d.width&&d.height?(this.element.style.width=d.width+"px",this.element.style.height=d.height+"px",m.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):d.scroll==="horizontal"?(this.element.style.width=_.x*d.sizeRatio*m.tileSources.length+12*m.tileSources.length+"px",this.element.style.height=_.y*d.sizeRatio+"px",m.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=_.y*d.sizeRatio*m.tileSources.length+12*m.tileSources.length+"px",this.element.style.width=_.x*d.sizeRatio+"px",m.addControl(this.element,{anchor:e.ControlAnchor.TOP_LEFT})),this.panelWidth=_.x*this.sizeRatio+8,this.panelHeight=_.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},S=0;S<m.tileSources.length;S++)y=e.makeNeutralElement("div"),y.id=this.element.id+"-"+S,y.style.width=v.panelWidth+"px",y.style.height=v.panelHeight+"px",y.style.display="inline",y.style.float="left",y.style.cssFloat="left",y.style.padding="2px",e.setElementTouchActionNone(y),e.setElementPointerEventsNone(y),this.element.appendChild(y),y.activePanel=!1,this.panels.push(y);u(this,this.scroll==="vertical"?_.y:_.x,0),this.setFocus(0)},e.ReferenceStrip.prototype={setFocus:function(d){var v=this.element.querySelector("#"+this.element.id+"-"+d),m=e.getElementSize(this.viewer.canvas),_=Number(this.element.style.width.replace("px","")),y=Number(this.element.style.height.replace("px","")),E=-Number(this.element.style.marginLeft.replace("px","")),S=-Number(this.element.style.marginTop.replace("px","")),P;this.currentSelected!==v&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=v,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(P=Number(d)*(this.panelWidth+3),P>E+m.x-this.panelWidth?(P=Math.min(P,_-m.x),this.element.style.marginLeft=-P+"px",u(this,m.x,-P)):P<E&&(P=Math.max(0,P-m.x/2),this.element.style.marginLeft=-P+"px",u(this,m.x,-P))):(P=Number(d)*(this.panelHeight+3),P>S+m.y-this.panelHeight?(P=Math.min(P,y-m.y),this.element.style.marginTop=-P+"px",u(this,m.y,-P)):P<S&&(P=Math.max(0,P-m.y/2),this.element.style.marginTop=-P+"px",u(this,m.y,-P))),this.currentPage=d,l.call(this,{eventSource:this.tracker}))},update:function(){return!!t[this.id].animating},destroy:function(){if(this.miniViewers)for(var d in this.miniViewers)this.miniViewers[d].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}};function i(d){if(d.quick){var v;this.scroll==="horizontal"?v=Math.floor(d.position.x/(this.panelWidth+4)):v=Math.floor(d.position.y/this.panelHeight),this.viewer.goToPage(v)}this.element.focus()}function n(d){if(this.dragging=!0,this.element){var v=Number(this.element.style.marginLeft.replace("px","")),m=Number(this.element.style.marginTop.replace("px","")),_=Number(this.element.style.width.replace("px","")),y=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?v>-(_-E.x)&&(this.element.style.marginLeft=v+d.delta.x*2+"px",u(this,E.x,v+d.delta.x*2)):-d.delta.x<0&&v<0&&(this.element.style.marginLeft=v+d.delta.x*2+"px",u(this,E.x,v+d.delta.x*2)):-d.delta.y>0?m>-(y-E.y)&&(this.element.style.marginTop=m+d.delta.y*2+"px",u(this,E.y,m+d.delta.y*2)):-d.delta.y<0&&m<0&&(this.element.style.marginTop=m+d.delta.y*2+"px",u(this,E.y,m+d.delta.y*2))}}function o(d){if(this.element){var v=Number(this.element.style.marginLeft.replace("px","")),m=Number(this.element.style.marginTop.replace("px","")),_=Number(this.element.style.width.replace("px","")),y=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?v>-(_-E.x)&&(this.element.style.marginLeft=v-d.scroll*60+"px",u(this,E.x,v-d.scroll*60)):d.scroll<0&&v<0&&(this.element.style.marginLeft=v-d.scroll*60+"px",u(this,E.x,v-d.scroll*60)):d.scroll<0?m>E.y-y&&(this.element.style.marginTop=m+d.scroll*60+"px",u(this,E.y,m+d.scroll*60)):d.scroll>0&&m<0&&(this.element.style.marginTop=m+d.scroll*60+"px",u(this,E.y,m+d.scroll*60)),d.preventDefault=!0}}function u(d,v,m){var _,y,E,S,P,B;for(d.scroll==="horizontal"?_=d.panelWidth:_=d.panelHeight,y=Math.ceil(v/_)+5,E=Math.ceil((Math.abs(m)+v)/_)+1,y=E-y,y=y<0?0:y,P=y;P<E&&P<d.panels.length;P++)if(B=d.panels[P],!B.activePanel){var O,M=d.viewer.tileSources[P];M.referenceStripThumbnailUrl?O={type:"image",url:M.referenceStripThumbnailUrl}:O=M,S=new e.Viewer({id:B.id,tileSources:[O],element:B,navigatorSizeRatio:d.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:d.viewer.loadTilesWithAjax,ajaxHeaders:d.viewer.ajaxHeaders,drawer:"canvas"}),e.setElementPointerEventsNone(S.canvas),e.setElementPointerEventsNone(S.container),S.innerTracker.setTracking(!1),S.outerTracker.setTracking(!1),d.miniViewers[B.id]=S,B.activePanel=!0}}function l(d){var v=d.eventSource.element;this.scroll==="horizontal"?v.style.marginBottom="0px":v.style.marginLeft="0px"}function a(d){var v=d.eventSource.element;this.scroll==="horizontal"?v.style.marginBottom="-"+e.getElementSize(v).y/2+"px":v.style.marginLeft="-"+e.getElementSize(v).x/2+"px"}function h(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 38:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 40:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 37:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 39:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}function c(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 61:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 45:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 48:case 119:case 87:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 115:case 83:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 97:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 100:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}})(s),(function(e){e.DisplayRect=function(t,i,n,o,u,l){e.Rect.apply(this,[t,i,n,o]),this.minLevel=u,this.maxLevel=l},e.extend(e.DisplayRect.prototype,e.Rect.prototype)})(s),(function(e){e.Spring=function(i){var n=arguments;typeof i!="object"&&(i={initial:n.length&&typeof n[0]=="number"?n[0]:void 0,springStiffness:n.length>1?n[1].springStiffness:5,animationTime:n.length>1?n[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();let i,n;if(this._exponential?(i=this.start._logValue,n=this.target._logValue):(i=this.start.value,n=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let o=i+(n-i)*t(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));this._exponential?this.current.value=Math.exp(o):this.current.value=o}return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function t(i,n){return(1-Math.exp(i*-n))/(1-Math.exp(-i))}})(s),(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,n=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 n=="function"&&n()},this.source.downloadTileStart(this)},finish:function(i,n,o){this.data=i,this.request=n,this.errorMsg=o,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 n=e.TileSource.prototype;i.source={downloadTileStart:n.downloadTileStart,downloadTileAbort:n.downloadTileAbort}}var o=this,u=function(h){t(o,h,i.callback)},l={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:u,abort:i.abort,timeout:this.timeout},a=new e.ImageJob(l);!this.jobLimit||this.jobsInProgress<this.jobLimit?(a.start(),this.jobsInProgress++):this.jobQueue.push(a)},clear:function(){for(var i=0;i<this.jobQueue.length;i++){var n=this.jobQueue[i];typeof n.abort=="function"&&n.abort()}this.jobQueue=[]}};function t(i,n,o){n.errorMsg!==""&&(n.data===null||n.data===void 0)&&n.tries<1+i.tileRetryMax&&i.failedTiles.push(n);var u;i.jobsInProgress--,(!i.jobLimit||i.jobsInProgress<i.jobLimit)&&i.jobQueue.length>0&&(u=i.jobQueue.shift(),u.start(),i.jobsInProgress++),i.tileRetryMax>0&&i.jobQueue.length===0&&(!i.jobLimit||i.jobsInProgress<i.jobLimit)&&i.failedTiles.length>0&&(u=i.failedTiles.shift(),setTimeout(function(){u.start()},i.tileRetryDelay),i.jobsInProgress++),o(n.data,n.errorMsg,n.request)}})(s),(function(e){e.Tile=function(t,i,n,o,u,l,a,h,c,d,v,m){this.level=t,this.x=i,this.y=n,this.bounds=o,this.positionedBounds=new s.Rect(o.x,o.y,o.width,o.height),this.sourceBounds=d,this.exists=u,this._url=l,this.postData=v,this.context2D=a,this.loadWithAjax=h,this.ajaxHeaders=c,m===void 0&&(e.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),m=e.TileSource.prototype.getTileHashKey(t,i,n,l,c,v)),this.cacheKey=m,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")},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&&this.cacheImageRecord.getRenderedContext()},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,n){var o=Math.max(1,Math.ceil((n.x-i.x)/2)),u=Math.max(1,Math.ceil((n.y-i.y)/2));return new e.Point(o,u).minus(this.position.times(e.pixelDensityRatio).times(t||1).apply(function(l){return l%1}))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.imgElement=null,this.loaded=!1,this.loading=!1}}})(s),(function(e){e.OverlayPlacement=e.Placement,e.OverlayRotationMode=e.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),e.Overlay=function(t,i,n){var o;e.isPlainObject(t)?o=t:o={element:t,location:i,placement:n},this.elementWrapper=document.createElement("div"),this.element=o.element,this.elementWrapper.appendChild(this.element),this.element.id?this.elementWrapper.id="overlay-wrapper-"+this.element.id:this.elementWrapper.id="overlay-wrapper",this.style=this.elementWrapper.style,this._init(o)},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 n=e.Placement.properties[this.placement];n&&(n.isHorizontallyCentered?t.x-=i.x/2:n.isRight&&(t.x-=i.x),n.isVerticallyCentered?t.y-=i.y/2:n.isBottom&&(t.y-=i.y))},destroy:function(){var t=this.elementWrapper,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 n=e.getCssPropertyWithVendorPrefix("transformOrigin"),o=e.getCssPropertyWithVendorPrefix("transform");n&&o&&(i[n]="",i[o]="")},drawHTML:function(t,i){var n=this.elementWrapper;n.parentNode!==t&&(n.prevElementParent=n.parentNode,n.prevNextSibling=n.nextSibling,t.appendChild(n),this.style.position="absolute",this.size=e.getElementSize(this.elementWrapper));var o=this._getOverlayPositionAndSize(i),u=o.position,l=this.size=o.size,a="";i.overlayPreserveContentDirection&&(a=i.flipped?" scaleX(-1)":" scaleX(1)");var h=i.flipped?-o.rotate:o.rotate,c=i.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(u,l,this.element);else{var d=this.style,v=this.element.style;v.display="block",d.left=u.x+"px",d.top=u.y+"px",this.width!==null&&(v.width=l.x+"px"),this.height!==null&&(v.height=l.y+"px");var m=e.getCssPropertyWithVendorPrefix("transformOrigin"),_=e.getCssPropertyWithVendorPrefix("transform");m&&_&&(h&&!i.flipped?(v[_]="",d[m]=this._getTransformOrigin(),d[_]="rotate("+h+"deg)"):!h&&i.flipped?(v[_]=a,d[m]=this._getTransformOrigin(),d[_]=c):h&&i.flipped?(v[_]=a,d[m]=this._getTransformOrigin(),d[_]="rotate("+h+"deg)"+c):(v[_]="",d[m]="",d[_]="")),d.display="flex"}},_getOverlayPositionAndSize:function(t){var i=t.pixelFromPoint(this.location,!0),n=this._getSizeInPixels(t);this.adjust(i,n);var o=0;if(t.getRotation(!0)&&this.rotationMode!==e.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX&&this.width!==null&&this.height!==null){var u=new e.Rect(i.x,i.y,n.x,n.y),l=this._getBoundingBox(u,t.getRotation(!0));i=l.getTopLeft(),n=l.getSize()}else o=t.getRotation(!0);return t.flipped&&(i.x=t.getContainerSize().x-i.x),{position:i,size:n,rotate:o}},_getSizeInPixels:function(t){var i=this.size.x,n=this.size.y;if(this.width!==null||this.height!==null){var o=t.deltaPixelsFromPointsNoRotate(new e.Point(this.width||0,this.height||0),!0);this.width!==null&&(i=o.x),this.height!==null&&(n=o.y)}if(this.checkResize&&(this.width===null||this.height===null)){var u=this.size=e.getElementSize(this.elementWrapper);this.width===null&&(i=u.x),this.height===null&&(n=u.y)}return new e.Point(i,n)},_getBoundingBox:function(t,i){var n=this._getPlacementPoint(t);return t.rotate(i,n).getBoundingBox()},_getPlacementPoint:function(t){var i=new e.Point(t.x,t.y),n=e.Placement.properties[this.placement];return n&&(n.isHorizontallyCentered?i.x+=t.width/2:n.isRight&&(i.x+=t.width),n.isVerticallyCentered?i.y+=t.height/2:n.isBottom&&(i.y+=t.height)),i},_getTransformOrigin:function(){var t="",i=e.Placement.properties[this.placement];return i&&(i.isLeft?t="left":i.isRight&&(t="right"),i.isTop?t+=" top":i.isBottom&&(t+=" bottom")),t},update:function(t,i){var n=e.isPlainObject(t)?t:{location:t,placement:i};this._init({location:n.location||this.location,placement:n.placement!==void 0?n.placement:this.placement,onDraw:n.onDraw||this.onDraw,checkResize:n.checkResize||this.checkResize,width:n.width!==void 0?n.width:this.width,height:n.height!==void 0?n.height:this.height,rotationMode:n.rotationMode||this.rotationMode})},getBounds:function(t){e.console.assert(t,"A viewport must now be passed to Overlay.getBounds.");var i=this.width,n=this.height;if(i===null||n===null){var o=t.deltaPointsFromPixelsNoRotate(this.size,!0);i===null&&(i=o.x),n===null&&(n=o.y)}var u=this.location.clone();return this.adjust(u,new e.Point(i,n)),this._adjustBoundsForRotation(t,new e.Rect(u.x,u.y,i,n))},_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 n=this._getOverlayPositionAndSize(t);return t.viewerElementToViewportRectangle(new e.Rect(n.position.x,n.position.y,n.size.x,n.size.y))}return i.rotate(-t.getRotation(!0),this._getPlacementPoint(i))}}})(s),(function(e){const t=e;t.DrawerBase=class{constructor(i){e.console.assert(i.viewer,"[Drawer] options.viewer is required"),e.console.assert(i.viewport,"[Drawer] options.viewport is required"),e.console.assert(i.element,"[Drawer] options.element is required"),this.viewer=i.viewer,this.viewport=i.viewport,this.debugGridColor=typeof i.debugGridColor=="string"?[i.debugGridColor]:i.debugGridColor||e.DEFAULT_SETTINGS.debugGridColor,this.options=i.options||{},this.container=e.getElement(i.element),this._renderingTarget=this._createDrawingElement(),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="absolute",this.canvas.style.left="0",e.setElementOpacity(this.canvas,this.viewer.opacity,!0),e.setElementPointerEventsNone(this.canvas),e.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._checkForAPIOverrides()}get canvas(){return this._renderingTarget}get element(){return e.console.error("Drawer.element is deprecated. Use Drawer.container instead."),this.container}getType(){e.console.error("Drawer.getType must be implemented by child class")}static isSupported(){e.console.error("Drawer.isSupported must be implemented by child class")}_createDrawingElement(){return e.console.error("Drawer._createDrawingElement must be implemented by child class"),null}draw(i){e.console.error("Drawer.draw must be implemented by child class")}canRotate(){e.console.error("Drawer.canRotate must be implemented by child class")}destroy(){e.console.error("Drawer.destroy must be implemented by child class")}minimumOverlapRequired(i){return!1}setImageSmoothingEnabled(i){e.console.error("Drawer.setImageSmoothingEnabled must be implemented by child class")}drawDebuggingRect(i){e.console.warn("[drawer].drawDebuggingRect is not implemented by this drawer")}clear(){e.console.warn("[drawer].clear() is deprecated. The drawer is responsible for clearing itself as needed before drawing tiles.")}_checkForAPIOverrides(){if(this._createDrawingElement===e.DrawerBase.prototype._createDrawingElement)throw new Error("[drawer]._createDrawingElement must be implemented by child class");if(this.draw===e.DrawerBase.prototype.draw)throw new Error("[drawer].draw must be implemented by child class");if(this.canRotate===e.DrawerBase.prototype.canRotate)throw new Error("[drawer].canRotate must be implemented by child class");if(this.destroy===e.DrawerBase.prototype.destroy)throw new Error("[drawer].destroy must be implemented by child class");if(this.setImageSmoothingEnabled===e.DrawerBase.prototype.setImageSmoothingEnabled)throw new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")}viewportToDrawerRectangle(i){var n=this.viewport.pixelFromPointNoRotate(i.getTopLeft(),!0),o=this.viewport.deltaPixelsFromPointsNoRotate(i.getSize(),!0);return new e.Rect(n.x*e.pixelDensityRatio,n.y*e.pixelDensityRatio,o.x*e.pixelDensityRatio,o.y*e.pixelDensityRatio)}viewportCoordToDrawerCoord(i){var n=this.viewport.pixelFromPointNoRotate(i,!0);return new e.Point(n.x*e.pixelDensityRatio,n.y*e.pixelDensityRatio)}_calculateCanvasSize(){var i=e.pixelDensityRatio,n=this.viewport.getContainerSize();return new t.Point(Math.round(n.x*i),Math.round(n.y*i))}_raiseTiledImageDrawnEvent(i,n){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:i,tiles:n})}_raiseDrawerErrorEvent(i,n){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:i,drawer:this,error:n})}}})(s),(function(e){const t=e;class i extends t.DrawerBase{constructor(o){super(o),this.viewer.rejectEventHandler("tile-drawing","The HTMLDrawer does not raise the tile-drawing event"),this.viewer.allowEventHandler("tile-drawn")}static isSupported(){return!0}getType(){return"html"}minimumOverlapRequired(o){return!0}_createDrawingElement(){return e.makeNeutralElement("div")}draw(o){var u=this;this._prepareNewFrame(),o.forEach(function(l){l.opacity!==0&&u._drawTiles(l)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(o){var u=o.getTilesToDraw().map(h=>h.tile);if(!(o.opacity===0||u.length===0&&!o.placeholderFillStyle))for(var l=u.length-1;l>=0;l--){var a=u[l];this._drawTile(a),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:o,tile:a})}}_drawTile(o){e.console.assert(o,"[Drawer._drawTile] tile is required");let u=this.canvas;if(!o.cacheImageRecord){e.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",o.toString());return}if(!o.loaded){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",o.toString());return}if(!o.element){var l=o.getImage();if(!l)return;o.element=e.makeNeutralElement("div"),o.imgElement=l.cloneNode(),o.imgElement.style.msInterpolationMode="nearest-neighbor",o.imgElement.style.width="100%",o.imgElement.style.height="100%",o.style=o.element.style,o.style.position="absolute"}o.element.parentNode!==u&&u.appendChild(o.element),o.imgElement.parentNode!==o.element&&o.element.appendChild(o.imgElement),o.style.top=o.position.y+"px",o.style.left=o.position.x+"px",o.style.height=o.size.y+"px",o.style.width=o.size.x+"px",o.flipped&&(o.style.transform="scaleX(-1)"),e.setElementOpacity(o.element,o.opacity)}}e.HTMLDrawer=i})(s),(function(e){const t=e;class i extends t.DrawerBase{constructor(h){super(h),this.context=this.canvas.getContext("2d"),this.sketchCanvas=null,this.sketchContext=null,this._imageSmoothingEnabled=!0,this.viewer.allowEventHandler("tile-drawn"),this.viewer.allowEventHandler("tile-drawing")}static isSupported(){return e.supportsCanvas}getType(){return"canvas"}_createDrawingElement(){let h=e.makeNeutralElement("canvas"),c=this._calculateCanvasSize();return h.width=c.x,h.height=c.y,h}draw(h){this._prepareNewFrame(),this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const c of h)c.opacity!==0&&this._drawTiles(c)}canRotate(){return!0}destroy(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null,this.container.removeChild(this.canvas)}minimumOverlapRequired(h){return!0}setImageSmoothingEnabled(h){this._imageSmoothingEnabled=!!h,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw()}drawDebuggingRect(h){var c=this.context;c.save(),c.lineWidth=2*e.pixelDensityRatio,c.strokeStyle=this.debugGridColor[0],c.fillStyle=this.debugGridColor[0],c.strokeRect(h.x*e.pixelDensityRatio,h.y*e.pixelDensityRatio,h.width*e.pixelDensityRatio,h.height*e.pixelDensityRatio),c.restore()}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(h,c,d,v){this.viewer.raiseEvent("tile-drawing",{tiledImage:h,context:c,tile:d,rendered:v})}_prepareNewFrame(){var h=this._calculateCanvasSize();if((this.canvas.width!==h.x||this.canvas.height!==h.y)&&(this.canvas.width=h.x,this.canvas.height=h.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var c=this._calculateSketchCanvasSize();this.sketchCanvas.width=c.x,this.sketchCanvas.height=c.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}_clear(h,c){var d=this._getContext(h);if(c)d.clearRect(c.x,c.y,c.width,c.height);else{var v=d.canvas;d.clearRect(0,0,v.width,v.height)}}_drawTiles(h){var c=h.getTilesToDraw().map(X=>X.tile);if(!(h.opacity===0||c.length===0&&!h.placeholderFillStyle)){var d=c[0],v;d&&(v=h.opacity<1||h.compositeOperation&&h.compositeOperation!=="source-over"||!h._isBottomItem()&&h.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var m,_,y=this.viewport.getZoom(!0),E=h.viewportToImageZoom(y);c.length>1&&E>h.smoothTileEdgesMinZoom&&!h.iOSDevice&&h.getRotation(!0)%360===0&&(v=!0,m=d.getScaleForEdgeSmoothing(),_=d.getTranslationForEdgeSmoothing(m,this._getCanvasSize(!1),this._getCanvasSize(!0)));var S;v&&(m||(S=this.viewport.viewportToViewerElementRectangle(h.getClippedBounds(!0)).getIntegerBoundingBox(),S=S.times(e.pixelDensityRatio)),this._clear(!0,S)),m||this._setRotations(h,v);var P=!1;if(h._clip){this._saveContext(v);var B=h.imageToViewportRectangle(h._clip,!0);B=B.rotate(-h.getRotation(!0),h._getRotationPoint(!0));var O=this.viewportToDrawerRectangle(B);m&&(O=O.times(m)),_&&(O=O.translate(_)),this._setClip(O,v),P=!0}if(h._croppingPolygons){var M=this;P||this._saveContext(v);try{var L=h._croppingPolygons.map(function(X){return X.map(function(ue){var he=h.imageToViewportCoordinates(ue.x,ue.y,!0).rotate(-h.getRotation(!0),h._getRotationPoint(!0)),de=M.viewportCoordToDrawerCoord(he);return m&&(de=de.times(m)),_&&(de=de.plus(_)),de})});this._clipWithPolygons(L,v)}catch(X){e.console.error(X)}P=!0}if(h._hasOpaqueTile=!1,h.placeholderFillStyle&&h._hasOpaqueTile===!1){let X=this.viewportToDrawerRectangle(h.getBoundsNoRotate(!0));m&&(X=X.times(m)),_&&(X=X.translate(_));let ue=null;typeof h.placeholderFillStyle=="function"?ue=h.placeholderFillStyle(h,this.context):ue=h.placeholderFillStyle,this._drawRectangle(X,ue,v)}var W=l(h.subPixelRoundingForTransparency),Y=!1;if(W===e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)Y=!0;else if(W===e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var Q=this.viewer&&this.viewer.isAnimating();Y=!Q}for(var ee=0;ee<c.length;ee++)d=c[ee],this._drawTile(d,h,v,m,_,Y,h.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:h,tile:d});P&&this._restoreContext(v),m||(h.getRotation(!0)%360!==0&&this._restoreRotationChanges(v),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(v)),v&&(m&&this._setRotations(h),this.blendSketch({opacity:h.opacity,scale:m,translate:_,compositeOperation:h.compositeOperation,bounds:S}),m&&(h.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1))),this._drawDebugInfo(h,c),this._raiseTiledImageDrawnEvent(h,c)}}_drawDebugInfo(h,c){if(h.debugMode)for(var d=c.length-1;d>=0;d--){var v=c[d];try{this._drawDebugInfoOnTile(v,c.length,d,h)}catch(m){e.console.error(m)}}}_clipWithPolygons(h,c){var d=this._getContext(c);d.beginPath();for(const v of h)for(const[m,_]of v.entries())d[m===0?"moveTo":"lineTo"](_.x,_.y);d.clip()}_drawTile(h,c,d,v,m,_,y){e.console.assert(h,"[Drawer._drawTile] tile is required"),e.console.assert(c,"[Drawer._drawTile] drawingHandler is required");var E=this._getContext(d);v=v||1,this._drawTileToCanvas(h,E,c,v,m,_,y)}_drawTileToCanvas(h,c,d,v,m,_,y){var E=h.position.times(e.pixelDensityRatio),S=h.size.times(e.pixelDensityRatio),P;if(!h.context2D&&!h.cacheImageRecord){e.console.warn("[Drawer._drawTileToCanvas] attempting to draw tile %s when it's not cached",h.toString());return}if(P=h.getCanvasContext(),!h.loaded||!P){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",h.toString());return}c.save(),typeof v=="number"&&v!==1&&(E=E.times(v),S=S.times(v)),m instanceof e.Point&&(E=E.plus(m)),c.globalAlpha===1&&h.hasTransparency&&(_&&(E.x=Math.round(E.x),E.y=Math.round(E.y),S.x=Math.round(S.x),S.y=Math.round(S.y)),c.clearRect(E.x,E.y,S.x,S.y)),this._raiseTileDrawingEvent(d,c,h,P);var B,O;h.sourceBounds?(B=Math.min(h.sourceBounds.width,P.canvas.width),O=Math.min(h.sourceBounds.height,P.canvas.height)):(B=P.canvas.width,O=P.canvas.height),c.translate(E.x+S.x/2,0),h.flipped&&c.scale(-1,1),c.drawImage(P.canvas,0,0,B,O,-S.x/2,E.y,S.x,S.y),c.restore()}_getContext(h){var c=this.context;if(h){if(this.sketchCanvas===null){this.sketchCanvas=document.createElement("canvas");var d=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=d.x,this.sketchCanvas.height=d.y,this.sketchContext=this.sketchCanvas.getContext("2d"),this.viewport.getRotation()===0){var v=this;this.viewer.addHandler("rotate",function m(){if(v.viewport.getRotation()!==0){v.viewer.removeHandler("rotate",m);var _=v._calculateSketchCanvasSize();v.sketchCanvas.width=_.x,v.sketchCanvas.height=_.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}c=this.sketchContext}return c}_saveContext(h){this._getContext(h).save()}_restoreContext(h){this._getContext(h).restore()}_setClip(h,c){var d=this._getContext(c);d.beginPath(),d.rect(h.x,h.y,h.width,h.height),d.clip()}_drawRectangle(h,c,d){var v=this._getContext(d);v.save(),v.fillStyle=c,v.fillRect(h.x,h.y,h.width,h.height),v.restore()}blendSketch(h,c,d,v){var m=h;e.isPlainObject(m)||(m={opacity:h,scale:c,translate:d,compositeOperation:v}),h=m.opacity,v=m.compositeOperation;var _=m.bounds;if(this.context.save(),this.context.globalAlpha=h,v&&(this.context.globalCompositeOperation=v),_)_.x<0&&(_.width+=_.x,_.x=0),_.x+_.width>this.canvas.width&&(_.width=this.canvas.width-_.x),_.y<0&&(_.height+=_.y,_.y=0),_.y+_.height>this.canvas.height&&(_.height=this.canvas.height-_.y),this.context.drawImage(this.sketchCanvas,_.x,_.y,_.width,_.height,_.x,_.y,_.width,_.height);else{c=m.scale||1,d=m.translate;var y=d instanceof e.Point?d:new e.Point(0,0),E=0,S=0;if(d){var P=this.sketchCanvas.width-this.canvas.width,B=this.sketchCanvas.height-this.canvas.height;E=Math.round(P/2),S=Math.round(B/2)}this.context.drawImage(this.sketchCanvas,y.x-E*c,y.y-S*c,(this.canvas.width+2*E)*c,(this.canvas.height+2*S)*c,-E,-S,this.canvas.width+2*E,this.canvas.height+2*S)}this.context.restore()}_drawDebugInfoOnTile(h,c,d,v){var m=this.viewer.world.getIndexOfItem(v)%this.debugGridColor.length,_=this.context;_.save(),_.lineWidth=2*e.pixelDensityRatio,_.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",_.strokeStyle=this.debugGridColor[m],_.fillStyle=this.debugGridColor[m],this._setRotations(v),this._viewportFlipped&&this._flip({point:h.position.plus(h.size.divide(2))}),_.strokeRect(h.position.x*e.pixelDensityRatio,h.position.y*e.pixelDensityRatio,h.size.x*e.pixelDensityRatio,h.size.y*e.pixelDensityRatio);var y=(h.position.x+h.size.x/2)*e.pixelDensityRatio,E=(h.position.y+h.size.y/2)*e.pixelDensityRatio;_.translate(y,E);const S=this.viewport.getRotation(!0);_.rotate(Math.PI/180*-S),_.translate(-y,-E),h.x===0&&h.y===0&&(_.fillText("Zoom: "+this.viewport.getZoom(),h.position.x*e.pixelDensityRatio,(h.position.y-30)*e.pixelDensityRatio),_.fillText("Pan: "+this.viewport.getBounds().toString(),h.position.x*e.pixelDensityRatio,(h.position.y-20)*e.pixelDensityRatio)),_.fillText("Level: "+h.level,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+20)*e.pixelDensityRatio),_.fillText("Column: "+h.x,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+30)*e.pixelDensityRatio),_.fillText("Row: "+h.y,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+40)*e.pixelDensityRatio),_.fillText("Order: "+d+" of "+c,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+50)*e.pixelDensityRatio),_.fillText("Size: "+h.size.toString(),(h.position.x+10)*e.pixelDensityRatio,(h.position.y+60)*e.pixelDensityRatio),_.fillText("Position: "+h.position.toString(),(h.position.x+10)*e.pixelDensityRatio,(h.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),v.getRotation(!0)%360!==0&&this._restoreRotationChanges(),_.restore()}_updateImageSmoothingEnabled(h){h.msImageSmoothingEnabled=this._imageSmoothingEnabled,h.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(h){var c=this._getContext(h).canvas;return new e.Point(c.width,c.height)}_getCanvasCenter(){return new e.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(h,c=!1){var d=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:c,saveContext:d}),d=!1),h.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:h.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(h._getRotationPoint(!0),!0),useSketch:c,saveContext:d})}_offsetForRotation(h){var c=h.point?h.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(h.useSketch);d.save(),d.translate(c.x,c.y),d.rotate(Math.PI/180*h.degrees),d.translate(-c.x,-c.y)}_flip(h){h=h||{};var c=h.point?h.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(h.useSketch);d.translate(c.x,0),d.scale(-1,1),d.translate(-c.x,0)}_restoreRotationChanges(h){var c=this._getContext(h);c.restore()}_calculateCanvasSize(){var h=e.pixelDensityRatio,c=this.viewport.getContainerSize();return{x:Math.round(c.x*h),y:Math.round(c.y*h)}}_calculateSketchCanvasSize(){var h=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return h;var c=Math.ceil(Math.sqrt(h.x*h.x+h.y*h.y));return{x:c,y:c}}}e.CanvasDrawer=i;var n=e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function o(a){return a!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&a!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&a!==e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function u(a){return o(a)?n:a}function l(a){if(typeof a=="number")return u(a);if(!a||!e.Browser)return n;var h=a[e.Browser.vendor];return o(h)&&(h=a["*"]),u(h)}})(s),(function(e){const t=e;t.WebGLDrawer=class extends t.DrawerBase{constructor(i){super(i),this._destroyed=!1,this._TextureMap=new Map,this._TileMap=new Map,this._gl=null,this._firstPass=null,this._secondPass=null,this._glFrameBuffer=null,this._renderToTexture=null,this._glFramebufferToCanvasTransform=null,this._outputCanvas=null,this._outputContext=null,this._clippingCanvas=null,this._clippingContext=null,this._renderingCanvas=null,this._backupCanvasDrawer=null,this._imageSmoothingEnabled=!0,this._boundToTileReady=n=>this._tileReadyHandler(n),this._boundToImageUnloaded=n=>this._imageUnloadedHandler(n),this.viewer.addHandler("tile-ready",this._boundToTileReady),this.viewer.addHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.rejectEventHandler("tile-drawn","The WebGLDrawer does not raise the tile-drawn event"),this.viewer.rejectEventHandler("tile-drawing","The WebGLDrawer does not raise the tile-drawing event"),this._setupCanvases(),this._setupRenderer(),this.context=this._outputContext}destroy(){if(this._destroyed)return;let i=this._gl;var n=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);for(let u=0;u<n;++u)i.activeTexture(i.TEXTURE0+u),i.bindTexture(i.TEXTURE_2D,null),i.bindTexture(i.TEXTURE_CUBE_MAP,null);i.bindBuffer(i.ARRAY_BUFFER,null),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),i.bindRenderbuffer(i.RENDERBUFFER,null),i.bindFramebuffer(i.FRAMEBUFFER,null),this._unloadTextures(),i.deleteBuffer(this._secondPass.bufferOutputPosition),i.deleteFramebuffer(this._glFrameBuffer),this._renderingCanvas.width=this._renderingCanvas.height=1,this._clippingCanvas.width=this._clippingCanvas.height=1,this._outputCanvas.width=this._outputCanvas.height=1,this._renderingCanvas=null,this._clippingCanvas=this._clippingContext=null,this._outputCanvas=this._outputContext=null;let o=i.getExtension("WEBGL_lose_context");o&&o.loseContext(),this.viewer.removeHandler("tile-ready",this._boundToTileReady),this.viewer.removeHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.removeHandler("resize",this._resizeHandler),this._gl=null,this._backupCanvasDrawer&&(this._backupCanvasDrawer.destroy(),this._backupCanvasDrawer=null),this.container.removeChild(this.canvas),this.viewer.drawer===this&&(this.viewer.drawer=null),this._destroyed=!0}canRotate(){return!0}static isSupported(){let i=document.createElement("canvas"),n=e.isFunction(i.getContext)&&i.getContext("webgl"),o=n&&n.getExtension("WEBGL_lose_context");return o&&o.loseContext(),!!n}getType(){return"webgl"}minimumOverlapRequired(i){return i.isTainted()}_createDrawingElement(){let i=e.makeNeutralElement("canvas"),n=this._calculateCanvasSize();return i.width=n.x,i.height=n.y,i}_getBackupCanvasDrawer(){return this._backupCanvasDrawer||(this._backupCanvasDrawer=this.viewer.requestDrawer("canvas",{mainDrawer:!1}),this._backupCanvasDrawer.canvas.style.setProperty("visibility","hidden")),this._backupCanvasDrawer}draw(i){let n=this._gl;const o=this.viewport.getBoundsNoRotateWithMargins(!0);let u={bounds:o,center:new t.Point(o.x+o.width/2,o.y+o.height/2),rotation:this.viewport.getRotation(!0)*Math.PI/180},l=this.viewport.flipped?-1:1,a=e.Mat3.makeTranslation(-u.center.x,-u.center.y),h=e.Mat3.makeScaling(2/u.bounds.width*l,-2/u.bounds.height),c=e.Mat3.makeRotation(-u.rotation),d=h.multiply(c).multiply(a);n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let v=!1;i.forEach((m,_)=>{if(m.isTainted()){v&&(this._outputContext.drawImage(this._renderingCanvas,0,0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT),v=!1);const y=this._getBackupCanvasDrawer();y.draw([m]),this._outputContext.drawImage(y.canvas,0,0)}else{let y=m.getTilesToDraw();if(m.placeholderFillStyle&&m._hasOpaqueTile===!1&&this._drawPlaceholder(m),y.length===0||m.getOpacity()===0)return;let E=y[0],S=m.compositeOperation||this.viewer.compositeOperation||m._clip||m._croppingPolygons||m.debugMode,P=S||m.opacity<1||E.hasTransparency;S&&(v&&this._outputContext.drawImage(this._renderingCanvas,0,0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT)),n.useProgram(this._firstPass.shaderProgram),P?(n.bindFramebuffer(n.FRAMEBUFFER,this._glFrameBuffer),n.clear(n.COLOR_BUFFER_BIT)):n.bindFramebuffer(n.FRAMEBUFFER,null);let B=d,O=m.getRotation(!0);if(O%360!==0){let ee=e.Mat3.makeRotation(-O*Math.PI/180),X=m.getBoundsNoRotate(!0).getCenter(),ue=e.Mat3.makeTranslation(X.x,X.y),he=e.Mat3.makeTranslation(-X.x,-X.y),de=ue.multiply(ee).multiply(he);B=d.multiply(de)}let M=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(M<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${M}). This could happen
|
|
128
|
+
if too many contexts have been created and not released, or there is another problem with the graphics card.`);let L=new Float32Array(M*12),W=new Array(M),Y=new Array(M),Q=new Array(M);for(let ee=0;ee<y.length;ee++){let X=y[ee].tile,ue=ee%M,he=ue+1,de=X.getCanvasContext(),pe=de?this._TextureMap.get(de.canvas):null;if(pe||(this._tileReadyHandler({tile:X,tiledImage:m}),pe=de?this._TextureMap.get(de.canvas):null),pe&&this._getTileData(X,m,pe,B,ue,L,W,Y,Q),he===M||ee===y.length-1){for(let ge=0;ge<=he;ge++)n.activeTexture(n.TEXTURE0+ge),n.bindTexture(n.TEXTURE_2D,W[ge]);n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),n.bufferData(n.ARRAY_BUFFER,L,n.DYNAMIC_DRAW),Y.forEach((ge,me)=>{n.uniformMatrix3fv(this._firstPass.uTransformMatrices[me],!1,ge)}),n.uniform1fv(this._firstPass.uOpacities,new Float32Array(Q)),n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),n.vertexAttribPointer(this._firstPass.aOutputPosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),n.vertexAttribPointer(this._firstPass.aTexturePosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferIndex),n.vertexAttribPointer(this._firstPass.aIndex,1,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,6*he)}}P&&(n.useProgram(this._secondPass.shaderProgram),n.bindFramebuffer(n.FRAMEBUFFER,null),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,this._renderToTexture),this._gl.uniform1f(this._secondPass.uOpacityMultiplier,m.opacity),n.bindBuffer(n.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),n.vertexAttribPointer(this._secondPass.aTexturePosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),n.vertexAttribPointer(this._secondPass.aOutputPosition,2,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,6)),v=!0,S&&(this._applyContext2dPipeline(m,y,_),v=!1,n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT)),_===0&&this._raiseTiledImageDrawnEvent(m,y.map(ee=>ee.tile))}}),v&&this._outputContext.drawImage(this._renderingCanvas,0,0)}setImageSmoothingEnabled(i){this._imageSmoothingEnabled!==i&&(this._imageSmoothingEnabled=i,this._unloadTextures(),this.viewer.world.draw())}drawDebuggingRect(i){let n=this._outputContext;n.save(),n.lineWidth=2*e.pixelDensityRatio,n.strokeStyle=this.debugGridColor[0],n.fillStyle=this.debugGridColor[0],n.strokeRect(i.x*e.pixelDensityRatio,i.y*e.pixelDensityRatio,i.width*e.pixelDensityRatio,i.height*e.pixelDensityRatio),n.restore()}_getTextureDataFromTile(i){return i.getCanvasContext().canvas}_applyContext2dPipeline(i,n,o){if(this._outputContext.save(),this._outputContext.globalCompositeOperation=o===0?null:i.compositeOperation||this.viewer.compositeOperation,i._croppingPolygons||i._clip?(this._renderToClippingCanvas(i),this._outputContext.drawImage(this._clippingCanvas,0,0)):this._outputContext.drawImage(this._renderingCanvas,0,0),this._outputContext.restore(),i.debugMode){const u=this.viewer.viewport.getFlip();u&&this._flip(),this._drawDebugInfo(n,i,u),u&&this._flip()}}_getTileData(i,n,o,u,l,a,h,c,d){let v=o.texture,m=o.position;a.set(m,l*12);let _=this._calculateOverlapFraction(i,n),y=i.positionedBounds.width*_.x,E=i.positionedBounds.height*_.y,S=i.positionedBounds.x+(i.x===0?0:y),P=i.positionedBounds.y+(i.y===0?0:E),B=i.positionedBounds.x+i.positionedBounds.width-(i.isRightMost?0:y),O=i.positionedBounds.y+i.positionedBounds.height-(i.isBottomMost?0:E),M=B-S,L=O-P,W=new e.Mat3([M,0,0,0,L,0,S,P,1]);if(i.flipped){let Q=e.Mat3.makeTranslation(.5,0),ee=e.Mat3.makeTranslation(-.5,0),X=Q.multiply(e.Mat3.makeScaling(-1,1)).multiply(ee);W=W.multiply(X)}let Y=u.multiply(W);d[l]=i.opacity,h[l]=v,c[l]=Y.values}_textureFilter(){return this._imageSmoothingEnabled?this._gl.LINEAR:this._gl.NEAREST}_setupRenderer(){let i=this._gl;i||e.console.error("_setupCanvases must be called before _setupRenderer"),this._unitQuad=this._makeQuadVertexBuffer(0,1,0,1),this._makeFirstPassShaderProgram(),this._makeSecondPassShaderProgram(),this._renderToTexture=i.createTexture(),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._renderToTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this._renderingCanvas.width,this._renderingCanvas.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this._textureFilter()),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),this._glFrameBuffer=i.createFramebuffer(),i.bindFramebuffer(i.FRAMEBUFFER,this._glFrameBuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this._renderToTexture,0),i.enable(i.BLEND),i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA)}_makeFirstPassShaderProgram(){let i=this._glNumTextures=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),n=()=>[...Array(i).keys()].map(v=>`uniform mat3 u_matrix_${v};`).join(`
|
|
129
|
+
`),o=()=>[...Array(i).keys()].map(v=>`${v>0?"else ":""}if(int(a_index) == ${v}) { transform_matrix = u_matrix_${v}; }`).join(`
|
|
130
|
+
`);const u=`
|
|
131
131
|
attribute vec2 a_output_position;
|
|
132
132
|
attribute vec2 a_texture_position;
|
|
133
133
|
attribute float a_index;
|
|
134
134
|
|
|
135
|
-
${
|
|
135
|
+
${n()} // create a uniform mat3 for each potential tile to draw
|
|
136
136
|
|
|
137
137
|
varying vec2 v_texture_position;
|
|
138
138
|
varying float v_image_index;
|
|
@@ -141,14 +141,14 @@ function o(e){return new o.Viewer(e)}(function(e){e.version={versionStr:"5.0.1",
|
|
|
141
141
|
|
|
142
142
|
mat3 transform_matrix; // value will be set by the if/elses in makeConditional()
|
|
143
143
|
|
|
144
|
-
${
|
|
144
|
+
${o()}
|
|
145
145
|
|
|
146
146
|
gl_Position = vec4(transform_matrix * vec3(a_output_position, 1), 1);
|
|
147
147
|
|
|
148
148
|
v_texture_position = a_texture_position;
|
|
149
149
|
v_image_index = a_index;
|
|
150
150
|
}
|
|
151
|
-
`,
|
|
151
|
+
`,l=`
|
|
152
152
|
precision mediump float;
|
|
153
153
|
|
|
154
154
|
// our textures
|
|
@@ -168,7 +168,7 @@ function o(e){return new o.Viewer(e)}(function(e){e.version={versionStr:"5.0.1",
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
`;let
|
|
171
|
+
`;let a=this._gl,h=this.constructor.initShaderProgram(a,u,l);a.useProgram(h),this._firstPass={shaderProgram:h,aOutputPosition:a.getAttribLocation(h,"a_output_position"),aTexturePosition:a.getAttribLocation(h,"a_texture_position"),aIndex:a.getAttribLocation(h,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(v=>a.getUniformLocation(h,`u_matrix_${v}`)),uImages:a.getUniformLocation(h,"u_images"),uOpacities:a.getUniformLocation(h,"u_opacities"),bufferOutputPosition:a.createBuffer(),bufferTexturePosition:a.createBuffer(),bufferIndex:a.createBuffer()},a.uniform1iv(this._firstPass.uImages,[...Array(i).keys()]);let c=new Float32Array(i*12);for(let v=0;v<i;++v)c.set(Float32Array.from(this._unitQuad),v*12);a.bindBuffer(a.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),a.bufferData(a.ARRAY_BUFFER,c,a.STATIC_DRAW),a.enableVertexAttribArray(this._firstPass.aOutputPosition),a.bindBuffer(a.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),a.enableVertexAttribArray(this._firstPass.aTexturePosition),a.bindBuffer(a.ARRAY_BUFFER,this._firstPass.bufferIndex);let d=[...Array(this._glNumTextures).keys()].map(v=>Array(6).fill(v)).flat();a.bufferData(a.ARRAY_BUFFER,new Float32Array(d),a.STATIC_DRAW),a.enableVertexAttribArray(this._firstPass.aIndex)}_makeSecondPassShaderProgram(){const i=`
|
|
172
172
|
attribute vec2 a_output_position;
|
|
173
173
|
attribute vec2 a_texture_position;
|
|
174
174
|
|
|
@@ -181,7 +181,7 @@ function o(e){return new o.Viewer(e)}(function(e){e.version={versionStr:"5.0.1",
|
|
|
181
181
|
|
|
182
182
|
v_texture_position = a_texture_position;
|
|
183
183
|
}
|
|
184
|
-
`,
|
|
184
|
+
`,n=`
|
|
185
185
|
precision mediump float;
|
|
186
186
|
|
|
187
187
|
// our texture
|
|
@@ -197,4 +197,4 @@ function o(e){return new o.Viewer(e)}(function(e){e.version={versionStr:"5.0.1",
|
|
|
197
197
|
gl_FragColor = texture2D(u_image, v_texture_position);
|
|
198
198
|
gl_FragColor *= u_opacity_multiplier;
|
|
199
199
|
}
|
|
200
|
-
`;let l=this._gl,a=this.constructor.initShaderProgram(l,i,s);l.useProgram(a),this._secondPass={shaderProgram:a,aOutputPosition:l.getAttribLocation(a,"a_output_position"),aTexturePosition:l.getAttribLocation(a,"a_texture_position"),uMatrix:l.getUniformLocation(a,"u_matrix"),uImage:l.getUniformLocation(a,"u_image"),uOpacityMultiplier:l.getUniformLocation(a,"u_opacity_multiplier"),bufferOutputPosition:l.createBuffer(),bufferTexturePosition:l.createBuffer()},l.bindBuffer(l.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),l.bufferData(l.ARRAY_BUFFER,this._unitQuad,l.STATIC_DRAW),l.enableVertexAttribArray(this._secondPass.aOutputPosition),l.bindBuffer(l.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),l.bufferData(l.ARRAY_BUFFER,this._unitQuad,l.DYNAMIC_DRAW),l.enableVertexAttribArray(this._secondPass.aTexturePosition);let u=e.Mat3.makeScaling(2,2).multiply(e.Mat3.makeTranslation(-.5,-.5));l.uniformMatrix3fv(this._secondPass.uMatrix,!1,u.values)}_resizeRenderer(){let i=this._gl,s=this._renderingCanvas.width,l=this._renderingCanvas.height;i.viewport(0,0,s,l),i.deleteTexture(this._renderToTexture),this._renderToTexture=i.createTexture(),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._renderToTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,s,l,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this._textureFilter()),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindFramebuffer(i.FRAMEBUFFER,this._glFrameBuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this._renderToTexture,0)}_setupCanvases(){let i=this;this._outputCanvas=this.canvas,this._outputContext=this._outputCanvas.getContext("2d"),this._renderingCanvas=document.createElement("canvas"),this._clippingCanvas=document.createElement("canvas"),this._clippingContext=this._clippingCanvas.getContext("2d"),this._renderingCanvas.width=this._clippingCanvas.width=this._outputCanvas.width,this._renderingCanvas.height=this._clippingCanvas.height=this._outputCanvas.height,this._gl=this._renderingCanvas.getContext("webgl"),this._resizeHandler=function(){i._outputCanvas!==i.viewer.drawer.canvas&&(i._outputCanvas.style.width=i.viewer.drawer.canvas.clientWidth+"px",i._outputCanvas.style.height=i.viewer.drawer.canvas.clientHeight+"px");let s=i._calculateCanvasSize();(i._outputCanvas.width!==s.x||i._outputCanvas.height!==s.y)&&(i._outputCanvas.width=s.x,i._outputCanvas.height=s.y),i._renderingCanvas.style.width=i._outputCanvas.clientWidth+"px",i._renderingCanvas.style.height=i._outputCanvas.clientHeight+"px",i._renderingCanvas.width=i._clippingCanvas.width=i._outputCanvas.width,i._renderingCanvas.height=i._clippingCanvas.height=i._outputCanvas.height,i._resizeRenderer()},this.viewer.addHandler("resize",this._resizeHandler)}_makeQuadVertexBuffer(i,s,l,a){return new Float32Array([i,a,s,a,i,l,i,l,s,a,s,l])}_tileReadyHandler(i){let s=i.tile,l=i.tiledImage;if(l.isTainted())return;let a=s.getCanvasContext(),u=a&&a.canvas;if(!u||e.isCanvasTainted(u)){l.isTainted()||(l.setTainted(!0),e.console.warn("WebGL cannot be used to draw this TiledImage because it has tainted data. Does crossOriginPolicy need to be set?"),this._raiseDrawerErrorEvent(l,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(u)){let c=this._gl,d=c.createTexture(),m,v=l.source.tileOverlap,y,_;if(s.sourceBounds?(y=Math.min(s.sourceBounds.width,u.width)/u.width,_=Math.min(s.sourceBounds.height,u.height)/u.height):(y=1,_=1),v>0){let S=this._calculateOverlapFraction(s,l),P=(s.x===0?0:S.x)*y,L=(s.y===0?0:S.y)*_,F=(s.isRightMost?1:1-S.x)*y,H=(s.isBottomMost?1:1-S.y)*_;m=this._makeQuadVertexBuffer(P,F,L,H)}else y===1&&_===1?m=this._unitQuad:m=this._makeQuadVertexBuffer(0,y,0,_);let E={texture:d,position:m};this._TextureMap.set(u,E),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,d),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,this._textureFilter()),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,this._textureFilter()),this._uploadImageData(a)}}_calculateOverlapFraction(i,s){let l=s.source.tileOverlap,a=i.sourceBounds.width,u=i.sourceBounds.height,h=(i.x===0?0:l)+(i.isRightMost?0:l),c=(i.y===0?0:l)+(i.isBottomMost?0:l),d=l/(a+h),m=l/(u+c);return{x:d,y:m}}_unloadTextures(){Array.from(this._TextureMap.keys()).forEach(s=>{this._cleanupImageData(s)})}_uploadImageData(i){let s=this._gl,l=i.canvas;try{if(!l)throw i;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,l)}catch(a){e.console.error("Error uploading image data to WebGL",a)}}_imageUnloadedHandler(i){let s=i.context2D.canvas;this._cleanupImageData(s)}_cleanupImageData(i){let s=this._TextureMap.get(i);this._TextureMap.delete(i),s&&this._gl.deleteTexture(s.texture)}_setClip(){}_renderToClippingCanvas(i){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const s=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(s.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-s.x,0)}if(i._clip){let l=[{x:i._clip.x,y:i._clip.y},{x:i._clip.x+i._clip.width,y:i._clip.y},{x:i._clip.x+i._clip.width,y:i._clip.y+i._clip.height},{x:i._clip.x,y:i._clip.y+i._clip.height}].map(a=>{let u=i.imageToViewportCoordinates(a.x,a.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(u)});this._clippingContext.beginPath(),l.forEach((a,u)=>{this._clippingContext[u===0?"moveTo":"lineTo"](a.x,a.y)}),this._clippingContext.clip(),this._setClip()}if(i._croppingPolygons){let s=i._croppingPolygons.map(l=>l.map(a=>{let u=i.imageToViewportCoordinates(a.x,a.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(u)}));this._clippingContext.beginPath(),s.forEach(l=>{l.forEach((a,u)=>{this._clippingContext[u===0?"moveTo":"lineTo"](a.x,a.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const s=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(s.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-s.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(i){var s=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:s}),s=!1),i.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:i.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(i._getRotationPoint(!0),!0),saveContext:s})}_offsetForRotation(i){var s=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),l=this._outputContext;l.save(),l.translate(s.x,s.y),l.rotate(Math.PI/180*i.degrees),l.translate(-s.x,-s.y)}_flip(i){i=i||{};var s=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),l=this._outputContext;l.translate(s.x,0),l.scale(-1,1),l.translate(-s.x,0)}_drawDebugInfo(i,s,l){for(var a=i.length-1;a>=0;a--){var u=i[a].tile;try{this._drawDebugInfoOnTile(u,i.length,a,s,l)}catch(h){e.console.error(h)}}}_drawDebugInfoOnTile(i,s,l,a,u){var h=this.viewer.world.getIndexOfItem(a)%this.debugGridColor.length,c=this.context;c.save(),c.lineWidth=2*e.pixelDensityRatio,c.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",c.strokeStyle=this.debugGridColor[h],c.fillStyle=this.debugGridColor[h],this._setRotations(a),u&&this._flip({point:i.position.plus(i.size.divide(2))}),c.strokeRect(i.position.x*e.pixelDensityRatio,i.position.y*e.pixelDensityRatio,i.size.x*e.pixelDensityRatio,i.size.y*e.pixelDensityRatio);var d=(i.position.x+i.size.x/2)*e.pixelDensityRatio,m=(i.position.y+i.size.y/2)*e.pixelDensityRatio;c.translate(d,m);const v=this.viewport.getRotation(!0);c.rotate(Math.PI/180*-v),c.translate(-d,-m),i.x===0&&i.y===0&&(c.fillText("Zoom: "+this.viewport.getZoom(),i.position.x*e.pixelDensityRatio,(i.position.y-30)*e.pixelDensityRatio),c.fillText("Pan: "+this.viewport.getBounds().toString(),i.position.x*e.pixelDensityRatio,(i.position.y-20)*e.pixelDensityRatio)),c.fillText("Level: "+i.level,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+20)*e.pixelDensityRatio),c.fillText("Column: "+i.x,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+30)*e.pixelDensityRatio),c.fillText("Row: "+i.y,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+40)*e.pixelDensityRatio),c.fillText("Order: "+l+" of "+s,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+50)*e.pixelDensityRatio),c.fillText("Size: "+i.size.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+60)*e.pixelDensityRatio),c.fillText("Position: "+i.position.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),a.getRotation(!0)%360!==0&&this._restoreRotationChanges(),c.restore()}_drawPlaceholder(i){const s=i.getBounds(!0),l=this.viewportToDrawerRectangle(i.getBounds(!0)),a=this._outputContext;let u;typeof i.placeholderFillStyle=="function"?u=i.placeholderFillStyle(i,a):u=i.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),a.fillStyle=u,a.translate(l.x,l.y),a.rotate(Math.PI/180*s.degrees),a.translate(-l.x,-l.y),a.fillRect(l.x,l.y,l.width,l.height),this._restoreRotationChanges()}_getCanvasCenter(){return new e.Point(this.canvas.width/2,this.canvas.height/2)}_restoreRotationChanges(){var i=this._outputContext;i.restore()}static initShaderProgram(i,s,l){function a(d,m,v){const y=d.createShader(m);return d.shaderSource(y,v),d.compileShader(y),d.getShaderParameter(y,d.COMPILE_STATUS)?y:(e.console.error(`An error occurred compiling the shaders: ${d.getShaderInfoLog(y)}`),d.deleteShader(y),null)}const u=a(i,i.VERTEX_SHADER,s),h=a(i,i.FRAGMENT_SHADER,l),c=i.createProgram();return i.attachShader(c,u),i.attachShader(c,h),i.linkProgram(c),i.getProgramParameter(c,i.LINK_STATUS)?c:(e.console.error(`Unable to initialize the shader program: ${i.getProgramInfoLog(c)}`),null)}}})(o),(function(e){e.Viewport=function(t){var r=arguments;r.length&&r[0]instanceof e.Point&&(t={containerSize:r[0],contentSize:r[1],config:r[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,r){e.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(t,r)},_setContentBounds:function(t,r){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(r),this._contentBounds=t.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(r),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:r,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var t=this._contentAspectRatio/this.getAspectRatio(),r;return this.homeFillsViewer?r=t>=1?t:1:r=t>=1?1:t,r/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var t=this._contentBounds.getCenter(),r=1/this.getHomeZoom(),i=r/this.getAspectRatio();return new e.Rect(t.x-r/2,t.y-i/2,r,i)},goHome:function(t){return this.viewer&&this.viewer.raiseEvent("home",{immediately:t}),this.fitBounds(this.getHomeBounds(),t)},getMinZoom:function(){var t=this.getHomeZoom(),r=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*t;return r},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 r=this.getCenter(t),i=1/this.getZoom(t),s=i/this.getAspectRatio();return new e.Rect(r.x-i/2,r.y-s/2,i,s)},getBoundsWithMargins:function(t){return this.getBoundsNoRotateWithMargins(t).rotate(-this.getRotation(t),this.getCenter(t))},getBoundsNoRotateWithMargins:function(t){var r=this.getBoundsNoRotate(t),i=this._containerInnerSize.x*this.getZoom(t);return r.x-=this._margins.left/i,r.y-=this._margins.top/i,r.width+=(this._margins.left+this._margins.right)/i,r.height+=(this._margins.top+this._margins.bottom)/i,r},getCenter:function(t){var r=new e.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),i=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),s,l,a,u,h,c,d,m;return t?r:this.zoomPoint?(s=this.pixelFromPoint(this.zoomPoint,!0),l=this.getZoom(),a=1/l,u=a/this.getAspectRatio(),h=new e.Rect(r.x-a/2,r.y-u/2,a,u),c=this._pixelFromPoint(this.zoomPoint,h),d=c.minus(s).rotate(-this.getRotation(!0)),m=d.divide(this._containerInnerSize.x*l),i.plus(m)):i},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 r=this.viewportToViewerElementRectangle(t).getBoundingBox(),i=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),s=!1,l=!1;if(!this.wrapHorizontal){var a=r.x+r.width,u=i.x+i.width,h,c,d;r.width>i.width?h=this.visibilityRatio*i.width:h=this.visibilityRatio*r.width,c=i.x-a+h,d=u-r.x-h,h>i.width?(r.x+=(c+d)/2,s=!0):d<0?(r.x+=d,s=!0):c>0&&(r.x+=c,s=!0)}if(!this.wrapVertical){var m=r.y+r.height,v=i.y+i.height,y,_,E;r.height>i.height?y=this.visibilityRatio*i.height:y=this.visibilityRatio*r.height,_=i.y-m+y,E=v-r.y-y,y>i.height?(r.y+=(_+E)/2,l=!0):E<0?(r.y+=E,l=!0):_>0&&(r.y+=_,l=!0)}var S=s||l,P=S?this.viewerElementToViewportRectangle(r):t.clone();return P.xConstrained=s,P.yConstrained=l,P.constraintApplied=S,P},_raiseConstraintsEvent:function(t){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:t})},applyConstraints:function(t){var r=this.getZoom(),i=this._applyZoomConstraints(r);r!==i&&this.zoomTo(i,this.zoomPoint,t);var s=this.getConstrainedBounds(!1);return s.constraintApplied&&(this.fitBounds(s,t),this._raiseConstraintsEvent(t)),this},ensureVisible:function(t){return this.applyConstraints(t)},_fitBounds:function(t,r){r=r||{};var i=r.immediately||!1,s=r.constraints||!1,l=this.getAspectRatio(),a=t.getCenter(),u=new e.Rect(t.x,t.y,t.width,t.height,t.degrees+this.getRotation()).getBoundingBox();u.getAspectRatio()>=l?u.height=u.width/l:u.width=u.height*l,u.x=a.x-u.width/2,u.y=a.y-u.height/2;var h=1/u.width;if(i)return this.panTo(a,!0),this.zoomTo(h,null,!0),s&&this.applyConstraints(!0),this;var c=this.getCenter(!0),d=this.getZoom(!0);this.panTo(c,!0),this.zoomTo(d,null,!0);var m=this.getBounds(),v=this.getZoom();if(v===0||Math.abs(h/v-1)<1e-8)return this.zoomTo(h,null,!0),this.panTo(a,i),s&&this.applyConstraints(!1),this;if(s){this.panTo(a,!1),h=this._applyZoomConstraints(h),this.zoomTo(h,null,!1);var y=this.getConstrainedBounds();this.panTo(c,!0),this.zoomTo(d,null,!0),this.fitBounds(y)}else{var _=u.rotate(-this.getRotation()),E=_.getTopLeft().times(h).minus(m.getTopLeft().times(v)).divide(h-v);this.zoomTo(h,E,i)}return this},fitBounds:function(t,r){return this._fitBounds(t,{immediately:r,constraints:!1})},fitBoundsWithConstraints:function(t,r){return this._fitBounds(t,{immediately:r,constraints:!0})},fitVertically:function(t){var r=new e.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(r,t)},fitHorizontally:function(t){var r=new e.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(r,t)},getConstrainedBounds:function(t){var r,i;return r=this.getBounds(t),i=this._applyBoundaryConstraints(r),i},panBy:function(t,r){var i=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(i.plus(t),r)},panTo:function(t,r){return r?(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:r}),this},zoomBy:function(t,r,i){return this.zoomTo(this.zoomSpring.target.value*t,r,i)},zoomTo:function(t,r,i){var s=this;return this.zoomPoint=r instanceof e.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,i?this._adjustCenterSpringsForZoomPoint(function(){s.zoomSpring.resetTo(t)}):this.zoomSpring.springTo(t),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:t,refPoint:r,immediately:i}),this},setRotation:function(t,r){return this.rotateTo(t,null,r)},getRotation:function(t){return t?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(t,r,i){return this.rotateTo(t,r,i)},rotateTo:function(t,r,i){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===t&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=r instanceof e.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,i)if(this.rotationPivot){var s=t-this._oldDegrees;if(!s)return this.rotationPivot=null,this;this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var l=e.positiveModulo(this.degreesSpring.current.value,360),a=e.positiveModulo(t,360),u=a-l;u>180?a-=360:u<-180&&(a+=360);var h=l-a;this.degreesSpring.resetTo(t+h),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:!!i,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(t,r,i){return this.rotateTo(this.degreesSpring.target.value+t,r,i)},resize:function(t,r){var i=this.getBoundsNoRotate(),s=i,l;this.containerSize.x=t.x,this.containerSize.y=t.y,this._updateContainerInnerSize(),r&&(l=t.x/this.containerSize.x,s.width=i.width*l,s.height=s.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:t,maintain:r});var a=this.fitBounds(s,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:t,maintain:r}),a},_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 r=this.centerSpringX.current.value!==this._oldCenterX||this.centerSpringY.current.value!==this._oldCenterY||this.zoomSpring.current.value!==this._oldZoom||this.degreesSpring.current.value!==this._oldDegrees;this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value;var i=r||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return i},_rotateAboutPivot:function(t){var r=t===!0,i=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(i.x),this.centerSpringY.shiftBy(i.y),r?this.degreesSpring.update():this.degreesSpring.resetTo(t);var s=this.degreesSpring.current.value-this._oldDegrees,l=i.rotate(s*-1).times(-1);this.centerSpringX.shiftBy(l.x),this.centerSpringY.shiftBy(l.y)},_adjustCenterSpringsForZoomPoint:function(t){if(this.zoomPoint){var r=this.pixelFromPoint(this.zoomPoint,!0);t();var i=this.pixelFromPoint(this.zoomPoint,!0),s=i.minus(r),l=this.deltaPointsFromPixels(s,!0);this.centerSpringX.shiftBy(l.x),this.centerSpringY.shiftBy(l.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else t()},deltaPixelsFromPointsNoRotate:function(t,r){return t.times(this._containerInnerSize.x*this.getZoom(r))},deltaPixelsFromPoints:function(t,r){return this.deltaPixelsFromPointsNoRotate(t.rotate(this.getRotation(r)),r)},deltaPointsFromPixelsNoRotate:function(t,r){return t.divide(this._containerInnerSize.x*this.getZoom(r))},deltaPointsFromPixels:function(t,r){return this.deltaPointsFromPixelsNoRotate(t,r).rotate(-this.getRotation(r))},pixelFromPointNoRotate:function(t,r){return this._pixelFromPointNoRotate(t,this.getBoundsNoRotate(r))},pixelFromPoint:function(t,r){return this._pixelFromPoint(t,this.getBoundsNoRotate(r))},_pixelFromPointNoRotate:function(t,r){return t.minus(r.getTopLeft()).times(this._containerInnerSize.x/r.width).plus(new e.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(t,r){return this._pixelFromPointNoRotate(t.rotate(this.getRotation(!0),this.getCenter(!0)),r)},pointFromPixelNoRotate:function(t,r){var i=this.getBoundsNoRotate(r);return t.minus(new e.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/i.width).plus(i.getTopLeft())},pointFromPixel:function(t,r){return this.pointFromPixelNoRotate(t,r).rotate(-this.getRotation(r),this.getCenter(r))},_viewportToImageDelta:function(t,r){var i=this._contentBoundsNoRotate.width;return new e.Point(t*this._contentSizeNoRotate.x/i,r*this._contentSizeNoRotate.x/i)},viewportToImageCoordinates:function(t,r){if(t instanceof e.Point)return this.viewportToImageCoordinates(t.x,t.y);if(this.viewer){var i=this.viewer.world.getItemCount();if(i>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(i===1){var s=this.viewer.world.getItemAt(0);return s.viewportToImageCoordinates(t,r,!0)}}return this._viewportToImageDelta(t-this._contentBoundsNoRotate.x,r-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(t,r){var i=this._contentBoundsNoRotate.width;return new e.Point(t/this._contentSizeNoRotate.x*i,r/this._contentSizeNoRotate.x*i)},imageToViewportCoordinates:function(t,r){if(t instanceof e.Point)return this.imageToViewportCoordinates(t.x,t.y);if(this.viewer){var i=this.viewer.world.getItemCount();if(i>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(i===1){var s=this.viewer.world.getItemAt(0);return s.imageToViewportCoordinates(t,r,!0)}}var l=this._imageToViewportDelta(t,r);return l.x+=this._contentBoundsNoRotate.x,l.y+=this._contentBoundsNoRotate.y,l},imageToViewportRectangle:function(t,r,i,s){var l=t;if(l instanceof e.Rect||(l=new e.Rect(t,r,i,s)),this.viewer){var a=this.viewer.world.getItemCount();if(a>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(a===1){var u=this.viewer.world.getItemAt(0);return u.imageToViewportRectangle(t,r,i,s,!0)}}var h=this.imageToViewportCoordinates(l.x,l.y),c=this._imageToViewportDelta(l.width,l.height);return new e.Rect(h.x,h.y,c.x,c.y,l.degrees)},viewportToImageRectangle:function(t,r,i,s){var l=t;if(l instanceof e.Rect||(l=new e.Rect(t,r,i,s)),this.viewer){var a=this.viewer.world.getItemCount();if(a>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(a===1){var u=this.viewer.world.getItemAt(0);return u.viewportToImageRectangle(t,r,i,s,!0)}}var h=this.viewportToImageCoordinates(l.x,l.y),c=this._viewportToImageDelta(l.width,l.height);return new e.Rect(h.x,h.y,c.x,c.y,l.degrees)},viewerElementToImageCoordinates:function(t){var r=this.pointFromPixel(t,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(t){var r=this.imageToViewportCoordinates(t);return this.pixelFromPoint(r,!0)},windowToImageCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var r=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var r=this.imageToViewerElementCoordinates(t);return r.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 r=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(r)},viewportToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var r=this.viewportToViewerElementCoordinates(t);return r.plus(e.getElementPosition(this.viewer.element))},viewportToImageZoom:function(t){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(r===1){var i=this.viewer.world.getItemAt(0);return i.viewportToImageZoom(t)}}var s=this._contentSizeNoRotate.x,l=this._containerInnerSize.x,a=this._contentBoundsNoRotate.width,u=l/s*a;return t*u},imageToViewportZoom:function(t){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image. Instead, use [TiledImage.imageToViewportZoom] for the specific image of interest");else if(r===1){var i=this.viewer.world.getItemAt(0);return i.imageToViewportZoom(t)}}var s=this._contentSizeNoRotate.x,l=this._containerInnerSize.x,a=this._contentBoundsNoRotate.width,u=s/l/a;return t*u},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)},getMaxZoomPixelRatio:function(){return this.maxZoomPixelRatio},setMaxZoomPixelRatio:function(t,r=!0,i=!1){e.console.assert(!isNaN(t),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(t)&&(this.maxZoomPixelRatio=t,r&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(i))}}})(o),(function(e){e.TiledImage=function(t){this._initialized=!1,e.console.assert(t.tileCache,"[TiledImage] options.tileCache is required"),e.console.assert(t.drawer,"[TiledImage] options.drawer is required"),e.console.assert(t.viewer,"[TiledImage] options.viewer is required"),e.console.assert(t.imageLoader,"[TiledImage] options.imageLoader is required"),e.console.assert(t.source,"[TiledImage] options.source is required"),e.console.assert(!t.clip||t.clip instanceof e.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),e.EventSource.call(this),this._tileCache=t.tileCache,delete t.tileCache,this._drawer=t.drawer,delete t.drawer,this._imageLoader=t.imageLoader,delete t.imageLoader,t.clip instanceof e.Rect&&(this._clip=t.clip.clone()),delete t.clip;var r=t.x||0;delete t.x;var i=t.y||0;delete t.y,this.normHeight=t.source.dimensions.y/t.source.dimensions.x,this.contentAspectX=t.source.dimensions.x/t.source.dimensions.y;var s=1;t.width?(s=t.width,delete t.width,t.height&&(e.console.error("specifying both width and height to a tiledImage is not supported"),delete t.height)):t.height&&(s=t.height/this.normHeight,delete t.height);var l=t.fitBounds;delete t.fitBounds;var a=t.fitBoundsPlacement||o.Placement.CENTER;delete t.fitBoundsPlacement;var u=t.degrees||0;delete t.degrees;var h=t.ajaxHeaders;delete t.ajaxHeaders,e.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_needsDraw:!0,_needsUpdate:!0,_hasOpaqueTile:!1,_tilesLoading:0,_tilesToDraw:[],_lastDrawn:[],_isBlending:!1,_wasBlending:!1,_isTainted:!1,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,maxTilesPerFrame:e.DEFAULT_SETTINGS.maxTilesPerFrame},t),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new e.Spring({initial:r,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new e.Spring({initial:i,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new e.Spring({initial:s,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new e.Spring({initial:u,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),l&&this.fitBounds(l,a,!0),this._ownAjaxHeaders={},this.setAjaxHeaders(h,!1),this._initialized=!0},e.extend(e.TiledImage.prototype,e.EventSource.prototype,{needsDraw:function(){return this._needsDraw},redraw:function(){this._needsDraw=!0},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(t){t!==this._fullyLoaded&&(this._fullyLoaded=t,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=e.now(),this._needsDraw=!0},update:function(t){let r=this._xSpring.update(),i=this._ySpring.update(),s=this._scaleSpring.update(),l=this._degreesSpring.update(),a=r||i||s||l||this._needsUpdate;if(a||t||!this._fullyLoaded){let u=this._updateLevelsForViewport();this._setFullyLoaded(u)}return this._needsUpdate=!1,a?(this._updateForScale(),this._raiseBoundsChange(),this._needsDraw=!0,!0):!1},setDrawn:function(){return this._needsDraw=this._isBlending||this._wasBlending,this._needsDraw},setTainted(t){this._isTainted=t},isTainted(){return this._isTainted},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy(this.viewer)},getBounds:function(t){return this.getBoundsNoRotate(t).rotate(this.getRotation(t),this._getRotationPoint(t))},getBoundsNoRotate:function(t){return t?new e.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new e.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return e.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(t){var r=this.getBoundsNoRotate(t);if(this._clip){var i=t?this._worldWidthCurrent:this._worldWidthTarget,s=i/this.source.dimensions.x,l=this._clip.times(s);r=new e.Rect(r.x+l.x,r.y+l.y,l.width,l.height)}return r.rotate(this.getRotation(t),this._getRotationPoint(t))},getTileBounds:function(t,r,i){var s=this.source.getNumTiles(t),l=(s.x+r%s.x)%s.x,a=(s.y+i%s.y)%s.y,u=this.source.getTileBounds(t,l,a);return this.getFlip()&&(u.x=Math.max(0,1-u.x-u.width)),u.x+=(r-l)/s.x,u.y+=this._worldHeightCurrent/this._worldWidthCurrent*((i-a)/s.y),u},getContentSize:function(){return new e.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var t=this.imageToWindowCoordinates(new e.Point(0,0)),r=this.imageToWindowCoordinates(this.getContentSize());return new e.Point(r.x-t.x,r.y-t.y)},_viewportToImageDelta:function(t,r,i){var s=i?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t*(this.source.dimensions.x/s),r*(this.source.dimensions.y*this.contentAspectX/s))},viewportToImageCoordinates:function(t,r,i){var s;return t instanceof e.Point?(i=r,s=t):s=new e.Point(t,r),s=s.rotate(-this.getRotation(i),this._getRotationPoint(i)),i?this._viewportToImageDelta(s.x-this._xSpring.current.value,s.y-this._ySpring.current.value):this._viewportToImageDelta(s.x-this._xSpring.target.value,s.y-this._ySpring.target.value)},_imageToViewportDelta:function(t,r,i){var s=i?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t/this.source.dimensions.x*s,r/this.source.dimensions.y/this.contentAspectX*s)},imageToViewportCoordinates:function(t,r,i){t instanceof e.Point&&(i=r,r=t.y,t=t.x);var s=this._imageToViewportDelta(t,r,i);return i?(s.x+=this._xSpring.current.value,s.y+=this._ySpring.current.value):(s.x+=this._xSpring.target.value,s.y+=this._ySpring.target.value),s.rotate(this.getRotation(i),this._getRotationPoint(i))},imageToViewportRectangle:function(t,r,i,s,l){var a=t;a instanceof e.Rect?l=r:a=new e.Rect(t,r,i,s);var u=this.imageToViewportCoordinates(a.getTopLeft(),l),h=this._imageToViewportDelta(a.width,a.height,l);return new e.Rect(u.x,u.y,h.x,h.y,a.degrees+this.getRotation(l))},viewportToImageRectangle:function(t,r,i,s,l){var a=t;t instanceof e.Rect?l=r:a=new e.Rect(t,r,i,s);var u=this.viewportToImageCoordinates(a.getTopLeft(),l),h=this._viewportToImageDelta(a.width,a.height,l);return new e.Rect(u.x,u.y,h.x,h.y,a.degrees-this.getRotation(l))},viewerElementToImageCoordinates:function(t){var r=this.viewport.pointFromPixel(t,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(t){var r=this.imageToViewportCoordinates(t);return this.viewport.pixelFromPoint(r,!0)},windowToImageCoordinates:function(t){var r=t.minus(o.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(t){var r=this.imageToViewerElementCoordinates(t);return r.plus(o.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(t){var r=this._scaleSpring.current.value;return t=t.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new e.Rect((t.x-this._xSpring.current.value)/r,(t.y-this._ySpring.current.value)/r,t.width/r,t.height/r,t.degrees)},viewportToImageZoom:function(t){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return r*t},imageToViewportZoom:function(t){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return t/r},setPosition:function(t,r){var i=this._xSpring.target.value===t.x&&this._ySpring.target.value===t.y;if(r){if(i&&this._xSpring.current.value===t.x&&this._ySpring.current.value===t.y)return;this._xSpring.resetTo(t.x),this._ySpring.resetTo(t.y),this._needsDraw=!0,this._needsUpdate=!0}else{if(i)return;this._xSpring.springTo(t.x),this._ySpring.springTo(t.y),this._needsDraw=!0,this._needsUpdate=!0}i||this._raiseBoundsChange()},setWidth:function(t,r){this._setScale(t,r)},setHeight:function(t,r){this._setScale(t/this.normHeight,r)},setCroppingPolygons:function(t){var r=function(s){return s instanceof e.Point||typeof s.x=="number"&&typeof s.y=="number"},i=function(s){return s.map(function(l){try{if(r(l))return{x:l.x,y:l.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!e.isArray(t))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=t.map(function(s){return i(s)}),this._needsDraw=!0}catch(s){e.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),e.console.error(s),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(t,r,i){r=r||e.Placement.CENTER;var s=e.Placement.properties[r],l=this.contentAspectX,a=0,u=0,h=1,c=1;if(this._clip&&(l=this._clip.getAspectRatio(),h=this._clip.width/this.source.dimensions.x,c=this._clip.height/this.source.dimensions.y,t.getAspectRatio()>l?(a=this._clip.x/this._clip.height*t.height,u=this._clip.y/this._clip.height*t.height):(a=this._clip.x/this._clip.width*t.width,u=this._clip.y/this._clip.width*t.width)),t.getAspectRatio()>l){var d=t.height/c,m=0;s.isHorizontallyCentered?m=(t.width-t.height*l)/2:s.isRight&&(m=t.width-t.height*l),this.setPosition(new e.Point(t.x-a+m,t.y-u),i),this.setHeight(d,i)}else{var v=t.width/h,y=0;s.isVerticallyCentered?y=(t.height-t.width/l)/2:s.isBottom&&(y=t.height-t.width/l),this.setPosition(new e.Point(t.x-a,t.y-u+y),i),this.setWidth(v,i)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(t){e.console.assert(!t||t instanceof e.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),t instanceof e.Rect?this._clip=t.clone():this._clip=null,this._needsUpdate=!0,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return this.flipped},setFlip:function(t){this.flipped=t},get flipped(){return this._flipped},set flipped(t){let r=this._flipped!==!!t;this._flipped=!!t,r&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(t){let r=this._wrapHorizontal!==!!t;this._wrapHorizontal=!!t,this._initialized&&r&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(t){let r=this._wrapVertical!==!!t;this._wrapVertical=!!t,this._initialized&&r&&(this.update(!0),this._needsDraw=!0)},get debugMode(){return this._debugMode},set debugMode(t){this._debugMode=!!t,this._needsDraw=!0},getOpacity:function(){return this.opacity},setOpacity:function(t){this.opacity=t},get opacity(){return this._opacity},set opacity(t){t!==this.opacity&&(this._opacity=t,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(t){this._preload=!!t,this._needsDraw=!0},getRotation:function(t){return t?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(t,r){this._degreesSpring.target.value===t&&this._degreesSpring.isAtTargetValue()||(r?this._degreesSpring.resetTo(t):this._degreesSpring.springTo(t),this._needsDraw=!0,this._needsUpdate=!0,this._raiseBoundsChange())},getDrawArea:function(){if(this._opacity===0&&!this._preload)return!1;var t=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var r=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));t=t.intersection(r)}return t},getTilesToDraw:function(){let t=this._tilesToDraw.flat();return this._updateTilesInViewport(t),t=this._tilesToDraw.flat(),t.forEach(r=>{r.tile.beingDrawn=!0}),this._lastDrawn=t,t},_getRotationPoint:function(t){return this.getBoundsNoRotate(t).getCenter()},get compositeOperation(){return this._compositeOperation},set compositeOperation(t){t!==this._compositeOperation&&(this._compositeOperation=t,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this._compositeOperation}))},getCompositeOperation:function(){return this._compositeOperation},setCompositeOperation:function(t){this.compositeOperation=t},setAjaxHeaders:function(t,r){if(t===null&&(t={}),!e.isPlainObject(t)){console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}this._ownAjaxHeaders=t,this._updateAjaxHeaders(r)},_updateAjaxHeaders:function(t){if(t===void 0&&(t=!0),e.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=e.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders,t){var r,i,s,l;for(var a in this.tilesMatrix){r=this.source.getNumTiles(a);for(var u in this.tilesMatrix[a]){i=(r.x+u%r.x)%r.x;for(var h in this.tilesMatrix[a][u])if(s=(r.y+h%r.y)%r.y,l=this.tilesMatrix[a][u][h],l.loadWithAjax=this.loadTilesWithAjax,l.loadWithAjax){var c=this.source.getTileAjaxHeaders(a,i,s);l.ajaxHeaders=e.extend({},this.ajaxHeaders,c)}else l.ajaxHeaders=null}}for(var d=0;d<this._imageLoader.jobQueue.length;d++){var m=this._imageLoader.jobQueue[d];m.loadWithAjax=m.tile.loadWithAjax,m.ajaxHeaders=m.tile.loadWithAjax?m.tile.ajaxHeaders:null}}},_setScale:function(t,r){var i=this._scaleSpring.target.value===t;if(r){if(i&&this._scaleSpring.current.value===t)return;this._scaleSpring.resetTo(t),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}else{if(i)return;this._scaleSpring.springTo(t),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}i||this._raiseBoundsChange()},_updateForScale:function(){this._worldWidthTarget=this._scaleSpring.target.value,this._worldHeightTarget=this.normHeight*this._scaleSpring.target.value,this._worldWidthCurrent=this._scaleSpring.current.value,this._worldHeightCurrent=this.normHeight*this._scaleSpring.current.value},_raiseBoundsChange:function(){this.raiseEvent("bounds-change")},_isBottomItem:function(){return this.viewer.world.getItemAt(0)===this},_getLevelsInterval:function(){var t=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,i=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(r/this.minPixelRatio)/Math.log(2))));return i=Math.max(i,this.source.minLevel||0),t=Math.min(t,i),{lowestLevel:t,highestLevel:i}},_updateLevelsForViewport:function(){var t=this._getLevelsInterval(),r=t.lowestLevel,i=t.highestLevel,s=[],l=this.getDrawArea(),a=e.now();if(this._lastDrawn.forEach(F=>{F.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!l)return this._needsDraw=!1,this._fullyLoaded;var u=new Array(i-r+1);for(let F=0,H=i;H>=r;H--,F++)u[F]=H;for(let F=i+1;F<=this.source.maxLevel;F++){var h=this.tilesMatrix[F]&&this.tilesMatrix[F][0]&&this.tilesMatrix[F][0][0];if(h&&h.isBottomMost&&h.isRightMost&&h.loaded){u.push(F);break}}let c=!1;for(let F=0;F<u.length;F++){let H=u[F];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(H),!0).x*this._scaleSpring.current.value;if(F===u.length-1||d>=this.minPixelRatio)c=!0;else if(!c)continue;var m=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(H),!1).x*this._scaleSpring.current.value,v=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,y=this.immediateRender?1:v,_=Math.min(1,(d-.5)/.5),E=y/Math.abs(y-m),S=this._updateLevel(H,_,E,l,a,s);s=S.bestTiles;var P=S.updatedTiles.filter(B=>B.loaded),L=(function(B,V,Y){return function(J){return{tile:J,level:B,levelOpacity:V,currentTime:Y}}})(H,_,a);if(this._tilesToDraw[H]=P.map(L),this._providesCoverage(this.coverage,H))break}return s&&s.length>0?(s.forEach(function(F){F&&!F.context2D&&this._loadTile(F,a)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(t){let r=e.now(),i=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let s=t.length?t[0].level:0;if(!this.getDrawArea())return;function a(h){let c=h.tile;if(c&&c.loaded){let d=i._blendTile(c,c.x,c.y,h.level,h.levelOpacity,r,s);i._isBlending=i._isBlending||d,i._needsDraw=i._needsDraw||d||i._wasBlending}}let u=0;for(let h=0;h<t.length;h++){let c=t[h];a(c),this._providesCoverage(this.coverage,c.level)&&(u=Math.max(u,c.level))}if(u>0)for(let h in this._tilesToDraw)h<u&&delete this._tilesToDraw[h]},_blendTile:function(t,r,i,s,l,a,u){let h=1e3*this.blendTime,c,d;return t.blendStart||(t.blendStart=a),c=a-t.blendStart,d=h?Math.min(1,c/h):1,s===u&&(d=1,c=h),this.alwaysBlend&&(d*=l),t.opacity=d,d===1&&(this._setCoverage(this.coverage,s,r,i,!0),this._hasOpaqueTile=!0),c<h},_updateLevel:function(t,r,i,s,l,a){var u=s.getBoundingBox().getTopLeft(),h=s.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:t,opacity:r,visibility:i,drawArea:s,topleft:u,bottomright:h,currenttime:l,best:a}),this._resetCoverage(this.coverage,t),this._resetCoverage(this.loadingCoverage,t);var c=this._getCornerTiles(t,u,h),d=c.topLeft,m=c.bottomRight,v=this.source.getNumTiles(t),y=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(m.x+=1,this.wrapHorizontal||(m.x=Math.min(m.x,v.x-1)));for(var _=Math.max(0,(m.x-d.x)*(m.y-d.y)),E=new Array(_),S=0,P=d.x;P<=m.x;P++)for(var L=d.y;L<=m.y;L++){var F;if(this.getFlip()){var H=(v.x+P%v.x)%v.x;F=P+v.x-H-H-1}else F=P;if(s.intersection(this.getTileBounds(t,F,L))!==null){var B=this._updateTile(F,L,t,i,y,v,l,a);a=B.bestTiles,E[S]=B.tile,S+=1}}return{bestTiles:a,updatedTiles:E}},_positionTile:function(t,r,i,s,l){var a=t.bounds.getTopLeft();a.x*=this._scaleSpring.current.value,a.y*=this._scaleSpring.current.value,a.x+=this._xSpring.current.value,a.y+=this._ySpring.current.value;var u=t.bounds.getSize();u.x*=this._scaleSpring.current.value,u.y*=this._scaleSpring.current.value,t.positionedBounds.x=a.x,t.positionedBounds.y=a.y,t.positionedBounds.width=u.x,t.positionedBounds.height=u.y;var h=i.pixelFromPointNoRotate(a,!0),c=i.pixelFromPointNoRotate(a,!1),d=i.deltaPixelsFromPointsNoRotate(u,!0),m=i.deltaPixelsFromPointsNoRotate(u,!1),v=c.plus(m.divide(2)),y=s.squaredDistanceTo(v);this.viewer.drawer.minimumOverlapRequired(this)&&(r||(d=d.plus(new e.Point(1,1))),t.isRightMost&&this.wrapHorizontal&&(d.x+=.75),t.isBottomMost&&this.wrapVertical&&(d.y+=.75)),t.position=h,t.size=d,t.squaredDistance=y,t.visibility=l},_updateTile:function(t,r,i,s,l,a,u,h){var c=this._getTile(t,r,i,u,a);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:c}),this._setCoverage(this.coverage,i,t,r,!1);var d=c.loaded||c.loading||this._isCovered(this.loadingCoverage,i,t,r);if(this._setCoverage(this.loadingCoverage,i,t,r,d),!c.exists)return{bestTiles:h,tile:c};if(c.loaded&&c.opacity===1&&this._setCoverage(this.coverage,i,t,r,!0),this._positionTile(c,this.source.tileOverlap,this.viewport,l,s),!c.loaded)if(c.context2D)this._setTileLoaded(c);else{var m=this._tileCache.getImageRecord(c.cacheKey);m&&this._setTileLoaded(c,m.getData())}return c.loading?this._tilesLoading++:d||(h=this._compareTiles(h,c,this.maxTilesPerFrame)),{bestTiles:h,tile:c}},_getCornerTiles:function(t,r,i){var s,l;this.wrapHorizontal?(s=e.positiveModulo(r.x,1),l=e.positiveModulo(i.x,1)):(s=Math.max(0,r.x),l=Math.min(1,i.x));var a,u,h=1/this.source.aspectRatio;this.wrapVertical?(a=e.positiveModulo(r.y,h),u=e.positiveModulo(i.y,h)):(a=Math.max(0,r.y),u=Math.min(h,i.y));var c=this.source.getTileAtPoint(t,new e.Point(s,a)),d=this.source.getTileAtPoint(t,new e.Point(l,u)),m=this.source.getNumTiles(t);return this.wrapHorizontal&&(c.x+=m.x*Math.floor(r.x),d.x+=m.x*Math.floor(i.x)),this.wrapVertical&&(c.y+=m.y*Math.floor(r.y/h),d.y+=m.y*Math.floor(i.y/h)),{topLeft:c,bottomRight:d}},_getTile:function(t,r,i,s,l){var a,u,h,c,d,m,v,y,_,E,S=this.tilesMatrix,P=this.source;return S[i]||(S[i]={}),S[i][t]||(S[i][t]={}),(!S[i][t][r]||!S[i][t][r].flipped!=!this.flipped)&&(a=(l.x+t%l.x)%l.x,u=(l.y+r%l.y)%l.y,h=this.getTileBounds(i,t,r),c=P.getTileBounds(i,a,u,!0),d=P.tileExists(i,a,u),m=P.getTileUrl(i,a,u),v=P.getTilePostData(i,a,u),this.loadTilesWithAjax?(y=P.getTileAjaxHeaders(i,a,u),e.isPlainObject(this.ajaxHeaders)&&(y=e.extend({},this.ajaxHeaders,y))):y=null,_=P.getContext2D?P.getContext2D(i,a,u):void 0,E=new e.Tile(i,t,r,h,d,m,_,this.loadTilesWithAjax,y,c,v,P.getTileHashKey(i,a,u,m,y,v)),this.getFlip()?a===0&&(E.isRightMost=!0):a===l.x-1&&(E.isRightMost=!0),u===l.y-1&&(E.isBottomMost=!0),E.flipped=this.flipped,S[i][t][r]=E),E=S[i][t][r],E.lastTouchTime=s,E},_loadTile:function(t,r){var i=this;t.loading=!0,this._imageLoader.addJob({src:t.getUrl(),tile:t,source:this.source,postData:t.postData,loadWithAjax:t.loadWithAjax,ajaxHeaders:t.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(s,l,a){i._onTileLoad(t,r,s,l,a)},abort:function(){t.loading=!1}})},_onTileLoad:function(t,r,i,s,l){if(i)t.exists=!0;else{e.console.error("Tile %s failed to load: %s - error: %s",t,t.getUrl(),s),this.viewer.raiseEvent("tile-load-failed",{tile:t,tiledImage:this,time:r,message:s,tileRequest:l}),t.loading=!1,t.exists=!1;return}if(r<this.lastResetTime){e.console.warn("Ignoring tile %s loaded before reset: %s",t,t.getUrl()),t.loading=!1;return}var a=this,u=function(){var h=a.source,c=h.getClosestLevel();a._setTileLoaded(t,i,c,l)};u()},_setTileLoaded:function(t,r,i,s){var l=0,a=!1,u=this;function h(){return a&&e.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),l++,c}function c(){l--,l===0&&(t.loading=!1,t.loaded=!0,t.hasTransparency=u.source.hasTransparency(t.context2D,t.getUrl(),t.ajaxHeaders,t.postData),t.context2D||u._tileCache.cacheTile({data:r,tile:t,cutoff:i,tiledImage:u}),u.viewer.raiseEvent("tile-ready",{tile:t,tiledImage:u,tileRequest:s}),u._needsDraw=!0)}var d=h();this.viewer.raiseEvent("tile-loaded",{tile:t,tiledImage:this,tileRequest:s,get image(){return e.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),r},data:r,getCompletionCallback:h}),a=!0,d()},_compareTiles:function(t,r,i){return t?(t.push(r),this._sortTiles(t),t.length>i&&t.pop(),t):[r]},_sortTiles:function(t){t.sort(function(r,i){return r===null?1:i===null?-1:r.visibility===i.visibility?r.squaredDistance-i.squaredDistance:i.visibility-r.visibility})},_providesCoverage:function(t,r,i,s){var l,a,u,h;if(!t[r])return!1;if(i===void 0||s===void 0){l=t[r];for(u in l)if(Object.prototype.hasOwnProperty.call(l,u)){a=l[u];for(h in a)if(Object.prototype.hasOwnProperty.call(a,h)&&!a[h])return!1}return!0}return t[r][i]===void 0||t[r][i][s]===void 0||t[r][i][s]===!0},_isCovered:function(t,r,i,s){return i===void 0||s===void 0?this._providesCoverage(t,r+1):this._providesCoverage(t,r+1,2*i,2*s)&&this._providesCoverage(t,r+1,2*i,2*s+1)&&this._providesCoverage(t,r+1,2*i+1,2*s)&&this._providesCoverage(t,r+1,2*i+1,2*s+1)},_setCoverage:function(t,r,i,s,l){if(!t[r]){e.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",r);return}t[r][i]||(t[r][i]={}),t[r][i][s]=l},_resetCoverage:function(t,r){t[r]={}}})})(o),(function(e){var t=function(i){e.console.assert(i,"[TileCache.cacheTile] options is required"),e.console.assert(i.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(i.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=i.tile,this.tiledImage=i.tiledImage},r=function(i){e.console.assert(i,"[ImageRecord] options is required"),e.console.assert(i.data,"[ImageRecord] options.data is required"),this._tiles=[],i.create.apply(null,[this,i.data,i.ownerTile]),this._destroyImplementation=i.destroy.bind(null,this),this.getImage=i.getImage.bind(null,this),this.getData=i.getData.bind(null,this),this.getRenderedContext=i.getRenderedContext.bind(null,this)};r.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(i){e.console.assert(i,"[ImageRecord.addTile] tile is required"),this._tiles.push(i)},removeTile:function(i){for(var s=0;s<this._tiles.length;s++)if(this._tiles[s]===i){this._tiles.splice(s,1);return}e.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",i)},getTileCount:function(){return this._tiles.length}},e.TileCache=function(i){i=i||{},this._maxImageCacheCount=i.maxImageCacheCount||e.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},e.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(i){e.console.assert(i,"[TileCache.cacheTile] options is required"),e.console.assert(i.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(i.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),e.console.assert(i.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var s=i.cutoff||0,l=this._tilesLoaded.length,a=this._imagesLoaded[i.tile.cacheKey];if(a||(i.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."),i.data=i.image),e.console.assert(i.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),a=this._imagesLoaded[i.tile.cacheKey]=new r({data:i.data,ownerTile:i.tile,create:i.tiledImage.source.createTileCache,destroy:i.tiledImage.source.destroyTileCache,getImage:i.tiledImage.source.getTileCacheDataAsImage,getData:i.tiledImage.source.getTileCacheData,getRenderedContext:i.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),a.addTile(i.tile),i.tile.cacheImageRecord=a,this._imagesLoadedCount>this._maxImageCacheCount){for(var u=null,h=-1,c=null,d,m,v,y,_,E,S=this._tilesLoaded.length-1;S>=0;S--)if(E=this._tilesLoaded[S],d=E.tile,!(d.level<=s||d.beingDrawn)){if(!u){u=d,h=S,c=E;continue}y=d.lastTouchTime,m=u.lastTouchTime,_=d.level,v=u.level,(y<m||y===m&&_>v)&&(u=d,h=S,c=E)}u&&h>=0&&(this._unloadTile(c),l=h)}this._tilesLoaded[l]=new t({tile:i.tile,tiledImage:i.tiledImage})},clearTilesFor:function(i){e.console.assert(i,"[TileCache.clearTilesFor] tiledImage is required");for(var s,l=0;l<this._tilesLoaded.length;++l)s=this._tilesLoaded[l],s.tiledImage===i&&(this._unloadTile(s),this._tilesLoaded.splice(l,1),l--)},getImageRecord:function(i){return e.console.assert(i,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[i]},_unloadTile:function(i){e.console.assert(i,"[TileCache._unloadTile] tileRecord is required");var s=i.tile,l=i.tiledImage;let a=s.getCanvasContext&&s.getCanvasContext();s.unload(),s.cacheImageRecord=null;var u=this._imagesLoaded[s.cacheKey];u&&(u.removeTile(s),u.getTileCount()||(u.destroy(),delete this._imagesLoaded[s.cacheKey],this._imagesLoadedCount--,a&&(a.canvas.width=0,a.canvas.height=0,l.viewer.raiseEvent("image-unloaded",{context2D:a,tile:s}))),l.viewer.raiseEvent("tile-unloaded",{tile:s,tiledImage:l}))}}})(o),(function(e){e.World=function(t){var r=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(i){r._autoRefigureSizes?r._figureSizes():r._needsSizesFigured=!0},this._figureSizes()},e.extend(e.World.prototype,e.EventSource.prototype,{addItem:function(t,r){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"),r=r||{},r.index!==void 0){var i=Math.max(0,Math.min(this._items.length,r.index));this._items.splice(i,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,r){e.console.assert(t,"[World.setItemIndex] item is required"),e.console.assert(r!==void 0,"[World.setItemIndex] index is required");var i=this.getIndexOfItem(t);if(r>=this._items.length)throw new Error("Index bigger than number of layers.");r===i||i===-1||(this._items.splice(i,1),this._items.splice(r,0,t),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:t,previousIndex:i,newIndex:r}))},removeItem:function(t){e.console.assert(t,"[World.removeItem] item is required");var r=e.indexOf(this._items,t);r!==-1&&(t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy(),this._items.splice(r,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(t))},removeAll:function(){this.viewer._cancelPendingImages();var t,r;for(r=0;r<this._items.length;r++)t=this._items[r],t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy();var i=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,r=0;r<i.length;r++)t=i[r],this._raiseRemoveItem(t)},resetItems:function(){for(var t=0;t<this._items.length;t++)this._items[t].reset()},update:function(t){for(var r=!1,i=0;i<this._items.length;i++)r=this._items[i].update(t)||r;return r},draw:function(){this.viewer.drawer.draw(this._items),this._needsDraw=!1,this._items.forEach(t=>{this._needsDraw=t.setDrawn()||this._needsDraw})},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 r=t.immediately||!1,i=t.layout||e.DEFAULT_SETTINGS.collectionLayout,s=t.rows||e.DEFAULT_SETTINGS.collectionRows,l=t.columns||e.DEFAULT_SETTINGS.collectionColumns,a=t.tileSize||e.DEFAULT_SETTINGS.collectionTileSize,u=t.tileMargin||e.DEFAULT_SETTINGS.collectionTileMargin,h=a+u,c;!t.rows&&l?c=l:c=Math.ceil(this._items.length/s);var d=0,m=0,v,y,_,E,S;this.setAutoRefigureSizes(!1);for(var P=0;P<this._items.length;P++)P&&P%c===0&&(i==="horizontal"?(m+=h,d=0):(d+=h,m=0)),v=this._items[P],y=v.getBounds(),y.width>y.height?_=a:_=a*(y.width/y.height),E=_*(y.height/y.width),S=new e.Point(d+(a-_)/2,m+(a-E)/2),v.setPosition(S,r),v.setWidth(_,r),i==="horizontal"?d+=h:m+=h;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var t=this._homeBounds?this._homeBounds.clone():null,r=this._contentSize?this._contentSize.clone():null,i=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 s=this._items[0],l=s.getBounds();this._contentFactor=s.getContentSize().x/l.width;for(var a=s.getClippedBounds().getBoundingBox(),u=a.x,h=a.y,c=a.x+a.width,d=a.y+a.height,m=1;m<this._items.length;m++)s=this._items[m],l=s.getBounds(),this._contentFactor=Math.max(this._contentFactor,s.getContentSize().x/l.width),a=s.getClippedBounds().getBoundingBox(),u=Math.min(u,a.x),h=Math.min(h,a.y),c=Math.max(c,a.x+a.width),d=Math.max(d,a.y+a.height);this._homeBounds=new e.Rect(u,h,c-u,d-h),this._contentSize=new e.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==i||!this._homeBounds.equals(t)||!this._contentSize.equals(r))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(t){this.raiseEvent("remove-item",{item:t})}})})(o)})(Si)),Si.exports}var Hn=Dl();const Al=Nn({__proto__:null,default:Rl(Hn)},[Hn])})();
|
|
200
|
+
`;let o=this._gl,u=this.constructor.initShaderProgram(o,i,n);o.useProgram(u),this._secondPass={shaderProgram:u,aOutputPosition:o.getAttribLocation(u,"a_output_position"),aTexturePosition:o.getAttribLocation(u,"a_texture_position"),uMatrix:o.getUniformLocation(u,"u_matrix"),uImage:o.getUniformLocation(u,"u_image"),uOpacityMultiplier:o.getUniformLocation(u,"u_opacity_multiplier"),bufferOutputPosition:o.createBuffer(),bufferTexturePosition:o.createBuffer()},o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),o.bufferData(o.ARRAY_BUFFER,this._unitQuad,o.STATIC_DRAW),o.enableVertexAttribArray(this._secondPass.aOutputPosition),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),o.bufferData(o.ARRAY_BUFFER,this._unitQuad,o.DYNAMIC_DRAW),o.enableVertexAttribArray(this._secondPass.aTexturePosition);let l=e.Mat3.makeScaling(2,2).multiply(e.Mat3.makeTranslation(-.5,-.5));o.uniformMatrix3fv(this._secondPass.uMatrix,!1,l.values)}_resizeRenderer(){let i=this._gl,n=this._renderingCanvas.width,o=this._renderingCanvas.height;i.viewport(0,0,n,o),i.deleteTexture(this._renderToTexture),this._renderToTexture=i.createTexture(),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this._renderToTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,o,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this._textureFilter()),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindFramebuffer(i.FRAMEBUFFER,this._glFrameBuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this._renderToTexture,0)}_setupCanvases(){let i=this;this._outputCanvas=this.canvas,this._outputContext=this._outputCanvas.getContext("2d"),this._renderingCanvas=document.createElement("canvas"),this._clippingCanvas=document.createElement("canvas"),this._clippingContext=this._clippingCanvas.getContext("2d"),this._renderingCanvas.width=this._clippingCanvas.width=this._outputCanvas.width,this._renderingCanvas.height=this._clippingCanvas.height=this._outputCanvas.height,this._gl=this._renderingCanvas.getContext("webgl"),this._resizeHandler=function(){i._outputCanvas!==i.viewer.drawer.canvas&&(i._outputCanvas.style.width=i.viewer.drawer.canvas.clientWidth+"px",i._outputCanvas.style.height=i.viewer.drawer.canvas.clientHeight+"px");let n=i._calculateCanvasSize();(i._outputCanvas.width!==n.x||i._outputCanvas.height!==n.y)&&(i._outputCanvas.width=n.x,i._outputCanvas.height=n.y),i._renderingCanvas.style.width=i._outputCanvas.clientWidth+"px",i._renderingCanvas.style.height=i._outputCanvas.clientHeight+"px",i._renderingCanvas.width=i._clippingCanvas.width=i._outputCanvas.width,i._renderingCanvas.height=i._clippingCanvas.height=i._outputCanvas.height,i._resizeRenderer()},this.viewer.addHandler("resize",this._resizeHandler)}_makeQuadVertexBuffer(i,n,o,u){return new Float32Array([i,u,n,u,i,o,i,o,n,u,n,o])}_tileReadyHandler(i){let n=i.tile,o=i.tiledImage;if(o.isTainted())return;let u=n.getCanvasContext(),l=u&&u.canvas;if(!l||e.isCanvasTainted(l)){o.isTainted()||(o.setTainted(!0),e.console.warn("WebGL cannot be used to draw this TiledImage because it has tainted data. Does crossOriginPolicy need to be set?"),this._raiseDrawerErrorEvent(o,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(l)){let a=this._gl,h=a.createTexture(),c,d=o.source.tileOverlap,v,m;if(n.sourceBounds?(v=Math.min(n.sourceBounds.width,l.width)/l.width,m=Math.min(n.sourceBounds.height,l.height)/l.height):(v=1,m=1),d>0){let y=this._calculateOverlapFraction(n,o),E=(n.x===0?0:y.x)*v,S=(n.y===0?0:y.y)*m,P=(n.isRightMost?1:1-y.x)*v,B=(n.isBottomMost?1:1-y.y)*m;c=this._makeQuadVertexBuffer(E,P,S,B)}else v===1&&m===1?c=this._unitQuad:c=this._makeQuadVertexBuffer(0,v,0,m);let _={texture:h,position:c};this._TextureMap.set(l,_),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,h),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this._textureFilter()),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,this._textureFilter()),this._uploadImageData(u)}}_calculateOverlapFraction(i,n){let o=n.source.tileOverlap,u=i.sourceBounds.width,l=i.sourceBounds.height,a=(i.x===0?0:o)+(i.isRightMost?0:o),h=(i.y===0?0:o)+(i.isBottomMost?0:o),c=o/(u+a),d=o/(l+h);return{x:c,y:d}}_unloadTextures(){Array.from(this._TextureMap.keys()).forEach(i=>{this._cleanupImageData(i)})}_uploadImageData(i){let n=this._gl,o=i.canvas;try{if(!o)throw i;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,o)}catch(u){e.console.error("Error uploading image data to WebGL",u)}}_imageUnloadedHandler(i){let n=i.context2D.canvas;this._cleanupImageData(n)}_cleanupImageData(i){let n=this._TextureMap.get(i);this._TextureMap.delete(i),n&&this._gl.deleteTexture(n.texture)}_setClip(){}_renderToClippingCanvas(i){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const n=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(n.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-n.x,0)}if(i._clip){let n=[{x:i._clip.x,y:i._clip.y},{x:i._clip.x+i._clip.width,y:i._clip.y},{x:i._clip.x+i._clip.width,y:i._clip.y+i._clip.height},{x:i._clip.x,y:i._clip.y+i._clip.height}].map(o=>{let u=i.imageToViewportCoordinates(o.x,o.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(u)});this._clippingContext.beginPath(),n.forEach((o,u)=>{this._clippingContext[u===0?"moveTo":"lineTo"](o.x,o.y)}),this._clippingContext.clip(),this._setClip()}if(i._croppingPolygons){let n=i._croppingPolygons.map(o=>o.map(u=>{let l=i.imageToViewportCoordinates(u.x,u.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(l)}));this._clippingContext.beginPath(),n.forEach(o=>{o.forEach((u,l)=>{this._clippingContext[l===0?"moveTo":"lineTo"](u.x,u.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const n=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(n.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-n.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(i){var n=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:n}),n=!1),i.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:i.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(i._getRotationPoint(!0),!0),saveContext:n})}_offsetForRotation(i){var n=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),o=this._outputContext;o.save(),o.translate(n.x,n.y),o.rotate(Math.PI/180*i.degrees),o.translate(-n.x,-n.y)}_flip(i){i=i||{};var n=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),o=this._outputContext;o.translate(n.x,0),o.scale(-1,1),o.translate(-n.x,0)}_drawDebugInfo(i,n,o){for(var u=i.length-1;u>=0;u--){var l=i[u].tile;try{this._drawDebugInfoOnTile(l,i.length,u,n,o)}catch(a){e.console.error(a)}}}_drawDebugInfoOnTile(i,n,o,u,l){var a=this.viewer.world.getIndexOfItem(u)%this.debugGridColor.length,h=this.context;h.save(),h.lineWidth=2*e.pixelDensityRatio,h.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",h.strokeStyle=this.debugGridColor[a],h.fillStyle=this.debugGridColor[a],this._setRotations(u),l&&this._flip({point:i.position.plus(i.size.divide(2))}),h.strokeRect(i.position.x*e.pixelDensityRatio,i.position.y*e.pixelDensityRatio,i.size.x*e.pixelDensityRatio,i.size.y*e.pixelDensityRatio);var c=(i.position.x+i.size.x/2)*e.pixelDensityRatio,d=(i.position.y+i.size.y/2)*e.pixelDensityRatio;h.translate(c,d);const v=this.viewport.getRotation(!0);h.rotate(Math.PI/180*-v),h.translate(-c,-d),i.x===0&&i.y===0&&(h.fillText("Zoom: "+this.viewport.getZoom(),i.position.x*e.pixelDensityRatio,(i.position.y-30)*e.pixelDensityRatio),h.fillText("Pan: "+this.viewport.getBounds().toString(),i.position.x*e.pixelDensityRatio,(i.position.y-20)*e.pixelDensityRatio)),h.fillText("Level: "+i.level,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+20)*e.pixelDensityRatio),h.fillText("Column: "+i.x,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+30)*e.pixelDensityRatio),h.fillText("Row: "+i.y,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+40)*e.pixelDensityRatio),h.fillText("Order: "+o+" of "+n,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+50)*e.pixelDensityRatio),h.fillText("Size: "+i.size.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+60)*e.pixelDensityRatio),h.fillText("Position: "+i.position.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),u.getRotation(!0)%360!==0&&this._restoreRotationChanges(),h.restore()}_drawPlaceholder(i){const n=i.getBounds(!0),o=this.viewportToDrawerRectangle(i.getBounds(!0)),u=this._outputContext;let l;typeof i.placeholderFillStyle=="function"?l=i.placeholderFillStyle(i,u):l=i.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),u.fillStyle=l,u.translate(o.x,o.y),u.rotate(Math.PI/180*n.degrees),u.translate(-o.x,-o.y),u.fillRect(o.x,o.y,o.width,o.height),this._restoreRotationChanges()}_getCanvasCenter(){return new e.Point(this.canvas.width/2,this.canvas.height/2)}_restoreRotationChanges(){var i=this._outputContext;i.restore()}static initShaderProgram(i,n,o){function u(c,d,v){const m=c.createShader(d);return c.shaderSource(m,v),c.compileShader(m),c.getShaderParameter(m,c.COMPILE_STATUS)?m:(e.console.error(`An error occurred compiling the shaders: ${c.getShaderInfoLog(m)}`),c.deleteShader(m),null)}const l=u(i,i.VERTEX_SHADER,n),a=u(i,i.FRAGMENT_SHADER,o),h=i.createProgram();return i.attachShader(h,l),i.attachShader(h,a),i.linkProgram(h),i.getProgramParameter(h,i.LINK_STATUS)?h:(e.console.error(`Unable to initialize the shader program: ${i.getProgramInfoLog(h)}`),null)}}})(s),(function(e){e.Viewport=function(t){var i=arguments;i.length&&i[0]instanceof e.Point&&(t={containerSize:i[0],contentSize:i[1],config:i[2]}),t.config&&(e.extend(!0,t,t.config),delete t.config),this._margins=e.extend({left:0,top:0,right:0,bottom:0},t.margins||{}),delete t.margins,t.initialDegrees=t.degrees,delete t.degrees,e.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:e.DEFAULT_SETTINGS.springStiffness,animationTime:e.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:e.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:e.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:e.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:e.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:e.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:e.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:e.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:e.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:e.DEFAULT_SETTINGS.degrees,flipped:e.DEFAULT_SETTINGS.flipped,homeFillsViewer:e.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:e.DEFAULT_SETTINGS.silenceMultiImageWarnings},t),this._updateContainerInnerSize(),this.centerSpringX=new e.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.centerSpringY=new e.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.zoomSpring=new e.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.degreesSpring=new e.Spring({initial:t.initialDegrees,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value,this._setContentBounds(new e.Rect(0,0,1,1),1),this.goHome(!0),this.update()},e.Viewport.prototype={get degrees(){return e.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead."),this.getRotation()},set degrees(t){e.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead."),this.rotateTo(t)},resetContentSize:function(t){return e.console.assert(t,"[Viewport.resetContentSize] contentSize is required"),e.console.assert(t instanceof e.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"),e.console.assert(t.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),e.console.assert(t.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this._setContentBounds(new e.Rect(0,0,1,t.y/t.x),t.x),this},setHomeBounds:function(t,i){e.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(t,i)},_setContentBounds:function(t,i){e.console.assert(t,"[Viewport._setContentBounds] bounds is required"),e.console.assert(t instanceof e.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect"),e.console.assert(t.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0"),e.console.assert(t.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0"),this._contentBoundsNoRotate=t.clone(),this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(i),this._contentBounds=t.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(i),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:i,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var 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(),n=i/this.getAspectRatio();return new e.Rect(t.x-i/2,t.y-n/2,i,n)},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),n=1/this.getZoom(t),o=n/this.getAspectRatio();return new e.Rect(i.x-n/2,i.y-o/2,n,o)},getBoundsWithMargins:function(t){return this.getBoundsNoRotateWithMargins(t).rotate(-this.getRotation(t),this.getCenter(t))},getBoundsNoRotateWithMargins:function(t){var i=this.getBoundsNoRotate(t),n=this._containerInnerSize.x*this.getZoom(t);return i.x-=this._margins.left/n,i.y-=this._margins.top/n,i.width+=(this._margins.left+this._margins.right)/n,i.height+=(this._margins.top+this._margins.bottom)/n,i},getCenter:function(t){var i=new e.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),n=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),o,u,l,a,h,c,d,v;return t?i:this.zoomPoint?(o=this.pixelFromPoint(this.zoomPoint,!0),u=this.getZoom(),l=1/u,a=l/this.getAspectRatio(),h=new e.Rect(i.x-l/2,i.y-a/2,l,a),c=this._pixelFromPoint(this.zoomPoint,h),d=c.minus(o).rotate(-this.getRotation(!0)),v=d.divide(this._containerInnerSize.x*u),n.plus(v)):n},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(),n=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),o=!1,u=!1;if(!this.wrapHorizontal){var l=i.x+i.width,a=n.x+n.width,h,c,d;i.width>n.width?h=this.visibilityRatio*n.width:h=this.visibilityRatio*i.width,c=n.x-l+h,d=a-i.x-h,h>n.width?(i.x+=(c+d)/2,o=!0):d<0?(i.x+=d,o=!0):c>0&&(i.x+=c,o=!0)}if(!this.wrapVertical){var v=i.y+i.height,m=n.y+n.height,_,y,E;i.height>n.height?_=this.visibilityRatio*n.height:_=this.visibilityRatio*i.height,y=n.y-v+_,E=m-i.y-_,_>n.height?(i.y+=(y+E)/2,u=!0):E<0?(i.y+=E,u=!0):y>0&&(i.y+=y,u=!0)}var S=o||u,P=S?this.viewerElementToViewportRectangle(i):t.clone();return P.xConstrained=o,P.yConstrained=u,P.constraintApplied=S,P},_raiseConstraintsEvent:function(t){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:t})},applyConstraints:function(t){var i=this.getZoom(),n=this._applyZoomConstraints(i);i!==n&&this.zoomTo(n,this.zoomPoint,t);var o=this.getConstrainedBounds(!1);return o.constraintApplied&&(this.fitBounds(o,t),this._raiseConstraintsEvent(t)),this},ensureVisible:function(t){return this.applyConstraints(t)},_fitBounds:function(t,i){i=i||{};var n=i.immediately||!1,o=i.constraints||!1,u=this.getAspectRatio(),l=t.getCenter(),a=new e.Rect(t.x,t.y,t.width,t.height,t.degrees+this.getRotation()).getBoundingBox();a.getAspectRatio()>=u?a.height=a.width/u:a.width=a.height*u,a.x=l.x-a.width/2,a.y=l.y-a.height/2;var h=1/a.width;if(n)return this.panTo(l,!0),this.zoomTo(h,null,!0),o&&this.applyConstraints(!0),this;var c=this.getCenter(!0),d=this.getZoom(!0);this.panTo(c,!0),this.zoomTo(d,null,!0);var v=this.getBounds(),m=this.getZoom();if(m===0||Math.abs(h/m-1)<1e-8)return this.zoomTo(h,null,!0),this.panTo(l,n),o&&this.applyConstraints(!1),this;if(o){this.panTo(l,!1),h=this._applyZoomConstraints(h),this.zoomTo(h,null,!1);var _=this.getConstrainedBounds();this.panTo(c,!0),this.zoomTo(d,null,!0),this.fitBounds(_)}else{var y=a.rotate(-this.getRotation()),E=y.getTopLeft().times(h).minus(v.getTopLeft().times(m)).divide(h-m);this.zoomTo(h,E,n)}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,n;return i=this.getBounds(t),n=this._applyBoundaryConstraints(i),n},panBy:function(t,i){var n=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(n.plus(t),i)},panTo:function(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,n){return this.zoomTo(this.zoomSpring.target.value*t,i,n)},zoomTo:function(t,i,n){var o=this;return this.zoomPoint=i instanceof e.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null,n?this._adjustCenterSpringsForZoomPoint(function(){o.zoomSpring.resetTo(t)}):this.zoomSpring.springTo(t),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:t,refPoint:i,immediately:n}),this},setRotation:function(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,n){return this.rotateTo(t,i,n)},rotateTo:function(t,i,n){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===t&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=i instanceof e.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null,n)if(this.rotationPivot){var o=t-this._oldDegrees;if(!o)return this.rotationPivot=null,this;this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var u=e.positiveModulo(this.degreesSpring.current.value,360),l=e.positiveModulo(t,360),a=l-u;a>180?l-=360:a<-180&&(l+=360);var h=u-l;this.degreesSpring.resetTo(t+h),this.degreesSpring.springTo(t)}return this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor()),this.viewer.forceRedraw(),this.viewer.raiseEvent("rotate",{degrees:t,immediately:!!n,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(t,i,n){return this.rotateTo(this.degreesSpring.target.value+t,i,n)},resize:function(t,i){var n=this.getBoundsNoRotate(),o=n,u;this.containerSize.x=t.x,this.containerSize.y=t.y,this._updateContainerInnerSize(),i&&(u=t.x/this.containerSize.x,o.width=n.width*u,o.height=o.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:t,maintain:i});var l=this.fitBounds(o,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:t,maintain:i}),l},_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;this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value;var n=i||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return n},_rotateAboutPivot:function(t){var i=t===!0,n=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(n.x),this.centerSpringY.shiftBy(n.y),i?this.degreesSpring.update():this.degreesSpring.resetTo(t);var o=this.degreesSpring.current.value-this._oldDegrees,u=n.rotate(o*-1).times(-1);this.centerSpringX.shiftBy(u.x),this.centerSpringY.shiftBy(u.y)},_adjustCenterSpringsForZoomPoint:function(t){if(this.zoomPoint){var i=this.pixelFromPoint(this.zoomPoint,!0);t();var n=this.pixelFromPoint(this.zoomPoint,!0),o=n.minus(i),u=this.deltaPointsFromPixels(o,!0);this.centerSpringX.shiftBy(u.x),this.centerSpringY.shiftBy(u.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 n=this.getBoundsNoRotate(i);return t.minus(new e.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/n.width).plus(n.getTopLeft())},pointFromPixel:function(t,i){return this.pointFromPixelNoRotate(t,i).rotate(-this.getRotation(i),this.getCenter(i))},_viewportToImageDelta:function(t,i){var n=this._contentBoundsNoRotate.width;return new e.Point(t*this._contentSizeNoRotate.x/n,i*this._contentSizeNoRotate.x/n)},viewportToImageCoordinates:function(t,i){if(t instanceof e.Point)return this.viewportToImageCoordinates(t.x,t.y);if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(n===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageCoordinates(t,i,!0)}}return this._viewportToImageDelta(t-this._contentBoundsNoRotate.x,i-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(t,i){var n=this._contentBoundsNoRotate.width;return new e.Point(t/this._contentSizeNoRotate.x*n,i/this._contentSizeNoRotate.x*n)},imageToViewportCoordinates:function(t,i){if(t instanceof e.Point)return this.imageToViewportCoordinates(t.x,t.y);if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(n===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportCoordinates(t,i,!0)}}var u=this._imageToViewportDelta(t,i);return u.x+=this._contentBoundsNoRotate.x,u.y+=this._contentBoundsNoRotate.y,u},imageToViewportRectangle:function(t,i,n,o){var u=t;if(u instanceof e.Rect||(u=new e.Rect(t,i,n,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(l===1){var a=this.viewer.world.getItemAt(0);return a.imageToViewportRectangle(t,i,n,o,!0)}}var h=this.imageToViewportCoordinates(u.x,u.y),c=this._imageToViewportDelta(u.width,u.height);return new e.Rect(h.x,h.y,c.x,c.y,u.degrees)},viewportToImageRectangle:function(t,i,n,o){var u=t;if(u instanceof e.Rect||(u=new e.Rect(t,i,n,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(l===1){var a=this.viewer.world.getItemAt(0);return a.viewportToImageRectangle(t,i,n,o,!0)}}var h=this.viewportToImageCoordinates(u.x,u.y),c=this._viewportToImageDelta(u.width,u.height);return new e.Rect(h.x,h.y,c.x,c.y,u.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 n=this.viewer.world.getItemAt(0);return n.viewportToImageZoom(t)}}var o=this._contentSizeNoRotate.x,u=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,a=u/o*l;return t*a},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. Instead, use [TiledImage.imageToViewportZoom] for the specific image of interest");else if(i===1){var n=this.viewer.world.getItemAt(0);return n.imageToViewportZoom(t)}}var o=this._contentSizeNoRotate.x,u=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,a=o/u/l;return t*a},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)},getMaxZoomPixelRatio:function(){return this.maxZoomPixelRatio},setMaxZoomPixelRatio:function(t,i=!0,n=!1){e.console.assert(!isNaN(t),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(t)&&(this.maxZoomPixelRatio=t,i&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(n))}}})(s),(function(e){e.TiledImage=function(t){this._initialized=!1,e.console.assert(t.tileCache,"[TiledImage] options.tileCache is required"),e.console.assert(t.drawer,"[TiledImage] options.drawer is required"),e.console.assert(t.viewer,"[TiledImage] options.viewer is required"),e.console.assert(t.imageLoader,"[TiledImage] options.imageLoader is required"),e.console.assert(t.source,"[TiledImage] options.source is required"),e.console.assert(!t.clip||t.clip instanceof e.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),e.EventSource.call(this),this._tileCache=t.tileCache,delete t.tileCache,this._drawer=t.drawer,delete t.drawer,this._imageLoader=t.imageLoader,delete t.imageLoader,t.clip instanceof e.Rect&&(this._clip=t.clip.clone()),delete t.clip;var i=t.x||0;delete t.x;var n=t.y||0;delete t.y,this.normHeight=t.source.dimensions.y/t.source.dimensions.x,this.contentAspectX=t.source.dimensions.x/t.source.dimensions.y;var o=1;t.width?(o=t.width,delete t.width,t.height&&(e.console.error("specifying both width and height to a tiledImage is not supported"),delete t.height)):t.height&&(o=t.height/this.normHeight,delete t.height);var u=t.fitBounds;delete t.fitBounds;var l=t.fitBoundsPlacement||s.Placement.CENTER;delete t.fitBoundsPlacement;var a=t.degrees||0;delete t.degrees;var h=t.ajaxHeaders;delete t.ajaxHeaders,e.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_needsDraw:!0,_needsUpdate:!0,_hasOpaqueTile:!1,_tilesLoading:0,_tilesToDraw:[],_lastDrawn:[],_isBlending:!1,_wasBlending:!1,_isTainted:!1,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,maxTilesPerFrame:e.DEFAULT_SETTINGS.maxTilesPerFrame},t),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new e.Spring({initial:i,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new e.Spring({initial:n,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new e.Spring({initial:o,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new e.Spring({initial:a,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),u&&this.fitBounds(u,l,!0),this._ownAjaxHeaders={},this.setAjaxHeaders(h,!1),this._initialized=!0},e.extend(e.TiledImage.prototype,e.EventSource.prototype,{needsDraw:function(){return this._needsDraw},redraw:function(){this._needsDraw=!0},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(t){t!==this._fullyLoaded&&(this._fullyLoaded=t,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=e.now(),this._needsDraw=!0},update:function(t){let i=this._xSpring.update(),n=this._ySpring.update(),o=this._scaleSpring.update(),u=this._degreesSpring.update(),l=i||n||o||u||this._needsUpdate;if(l||t||!this._fullyLoaded){let a=this._updateLevelsForViewport();this._setFullyLoaded(a)}return this._needsUpdate=!1,l?(this._updateForScale(),this._raiseBoundsChange(),this._needsDraw=!0,!0):!1},setDrawn:function(){return this._needsDraw=this._isBlending||this._wasBlending,this._needsDraw},setTainted(t){this._isTainted=t},isTainted(){return this._isTainted},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy(this.viewer)},getBounds:function(t){return this.getBoundsNoRotate(t).rotate(this.getRotation(t),this._getRotationPoint(t))},getBoundsNoRotate:function(t){return t?new e.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new e.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return e.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(t){var i=this.getBoundsNoRotate(t);if(this._clip){var n=t?this._worldWidthCurrent:this._worldWidthTarget,o=n/this.source.dimensions.x,u=this._clip.times(o);i=new e.Rect(i.x+u.x,i.y+u.y,u.width,u.height)}return i.rotate(this.getRotation(t),this._getRotationPoint(t))},getTileBounds:function(t,i,n){var o=this.source.getNumTiles(t),u=(o.x+i%o.x)%o.x,l=(o.y+n%o.y)%o.y,a=this.source.getTileBounds(t,u,l);return this.getFlip()&&(a.x=Math.max(0,1-a.x-a.width)),a.x+=(i-u)/o.x,a.y+=this._worldHeightCurrent/this._worldWidthCurrent*((n-l)/o.y),a},getContentSize:function(){return new e.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var t=this.imageToWindowCoordinates(new e.Point(0,0)),i=this.imageToWindowCoordinates(this.getContentSize());return new e.Point(i.x-t.x,i.y-t.y)},_viewportToImageDelta:function(t,i,n){var o=n?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t*(this.source.dimensions.x/o),i*(this.source.dimensions.y*this.contentAspectX/o))},viewportToImageCoordinates:function(t,i,n){var o;return t instanceof e.Point?(n=i,o=t):o=new e.Point(t,i),o=o.rotate(-this.getRotation(n),this._getRotationPoint(n)),n?this._viewportToImageDelta(o.x-this._xSpring.current.value,o.y-this._ySpring.current.value):this._viewportToImageDelta(o.x-this._xSpring.target.value,o.y-this._ySpring.target.value)},_imageToViewportDelta:function(t,i,n){var o=n?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t/this.source.dimensions.x*o,i/this.source.dimensions.y/this.contentAspectX*o)},imageToViewportCoordinates:function(t,i,n){t instanceof e.Point&&(n=i,i=t.y,t=t.x);var o=this._imageToViewportDelta(t,i,n);return n?(o.x+=this._xSpring.current.value,o.y+=this._ySpring.current.value):(o.x+=this._xSpring.target.value,o.y+=this._ySpring.target.value),o.rotate(this.getRotation(n),this._getRotationPoint(n))},imageToViewportRectangle:function(t,i,n,o,u){var l=t;l instanceof e.Rect?u=i:l=new e.Rect(t,i,n,o);var a=this.imageToViewportCoordinates(l.getTopLeft(),u),h=this._imageToViewportDelta(l.width,l.height,u);return new e.Rect(a.x,a.y,h.x,h.y,l.degrees+this.getRotation(u))},viewportToImageRectangle:function(t,i,n,o,u){var l=t;t instanceof e.Rect?u=i:l=new e.Rect(t,i,n,o);var a=this.viewportToImageCoordinates(l.getTopLeft(),u),h=this._viewportToImageDelta(l.width,l.height,u);return new e.Rect(a.x,a.y,h.x,h.y,l.degrees-this.getRotation(u))},viewerElementToImageCoordinates:function(t){var i=this.viewport.pointFromPixel(t,!0);return this.viewportToImageCoordinates(i)},imageToViewerElementCoordinates:function(t){var i=this.imageToViewportCoordinates(t);return this.viewport.pixelFromPoint(i,!0)},windowToImageCoordinates:function(t){var i=t.minus(s.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(i)},imageToWindowCoordinates:function(t){var i=this.imageToViewerElementCoordinates(t);return i.plus(s.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(t){var i=this._scaleSpring.current.value;return t=t.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new e.Rect((t.x-this._xSpring.current.value)/i,(t.y-this._ySpring.current.value)/i,t.width/i,t.height/i,t.degrees)},viewportToImageZoom:function(t){var i=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return i*t},imageToViewportZoom:function(t){var i=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return t/i},setPosition:function(t,i){var n=this._xSpring.target.value===t.x&&this._ySpring.target.value===t.y;if(i){if(n&&this._xSpring.current.value===t.x&&this._ySpring.current.value===t.y)return;this._xSpring.resetTo(t.x),this._ySpring.resetTo(t.y),this._needsDraw=!0,this._needsUpdate=!0}else{if(n)return;this._xSpring.springTo(t.x),this._ySpring.springTo(t.y),this._needsDraw=!0,this._needsUpdate=!0}n||this._raiseBoundsChange()},setWidth:function(t,i){this._setScale(t,i)},setHeight:function(t,i){this._setScale(t/this.normHeight,i)},setCroppingPolygons:function(t){var i=function(o){return o instanceof e.Point||typeof o.x=="number"&&typeof o.y=="number"},n=function(o){return o.map(function(u){try{if(i(u))return{x:u.x,y:u.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!e.isArray(t))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=t.map(function(o){return n(o)}),this._needsDraw=!0}catch(o){e.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),e.console.error(o),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(t,i,n){i=i||e.Placement.CENTER;var o=e.Placement.properties[i],u=this.contentAspectX,l=0,a=0,h=1,c=1;if(this._clip&&(u=this._clip.getAspectRatio(),h=this._clip.width/this.source.dimensions.x,c=this._clip.height/this.source.dimensions.y,t.getAspectRatio()>u?(l=this._clip.x/this._clip.height*t.height,a=this._clip.y/this._clip.height*t.height):(l=this._clip.x/this._clip.width*t.width,a=this._clip.y/this._clip.width*t.width)),t.getAspectRatio()>u){var d=t.height/c,v=0;o.isHorizontallyCentered?v=(t.width-t.height*u)/2:o.isRight&&(v=t.width-t.height*u),this.setPosition(new e.Point(t.x-l+v,t.y-a),n),this.setHeight(d,n)}else{var m=t.width/h,_=0;o.isVerticallyCentered?_=(t.height-t.width/u)/2:o.isBottom&&(_=t.height-t.width/u),this.setPosition(new e.Point(t.x-l,t.y-a+_),n),this.setWidth(m,n)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(t){e.console.assert(!t||t instanceof e.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),t instanceof e.Rect?this._clip=t.clone():this._clip=null,this._needsUpdate=!0,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return this.flipped},setFlip:function(t){this.flipped=t},get flipped(){return this._flipped},set flipped(t){let i=this._flipped!==!!t;this._flipped=!!t,i&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(t){let i=this._wrapHorizontal!==!!t;this._wrapHorizontal=!!t,this._initialized&&i&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(t){let i=this._wrapVertical!==!!t;this._wrapVertical=!!t,this._initialized&&i&&(this.update(!0),this._needsDraw=!0)},get debugMode(){return this._debugMode},set debugMode(t){this._debugMode=!!t,this._needsDraw=!0},getOpacity:function(){return this.opacity},setOpacity:function(t){this.opacity=t},get opacity(){return this._opacity},set opacity(t){t!==this.opacity&&(this._opacity=t,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(t){this._preload=!!t,this._needsDraw=!0},getRotation:function(t){return t?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(t,i){this._degreesSpring.target.value===t&&this._degreesSpring.isAtTargetValue()||(i?this._degreesSpring.resetTo(t):this._degreesSpring.springTo(t),this._needsDraw=!0,this._needsUpdate=!0,this._raiseBoundsChange())},getDrawArea:function(){if(this._opacity===0&&!this._preload)return!1;var t=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var i=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));t=t.intersection(i)}return t},getTilesToDraw:function(){let t=this._tilesToDraw.flat();return this._updateTilesInViewport(t),t=this._tilesToDraw.flat(),t.forEach(i=>{i.tile.beingDrawn=!0}),this._lastDrawn=t,t},_getRotationPoint:function(t){return this.getBoundsNoRotate(t).getCenter()},get compositeOperation(){return this._compositeOperation},set compositeOperation(t){t!==this._compositeOperation&&(this._compositeOperation=t,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this._compositeOperation}))},getCompositeOperation:function(){return this._compositeOperation},setCompositeOperation:function(t){this.compositeOperation=t},setAjaxHeaders:function(t,i){if(t===null&&(t={}),!e.isPlainObject(t)){console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}this._ownAjaxHeaders=t,this._updateAjaxHeaders(i)},_updateAjaxHeaders:function(t){if(t===void 0&&(t=!0),e.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=e.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders,t){var i,n,o,u;for(var l in this.tilesMatrix){i=this.source.getNumTiles(l);for(var a in this.tilesMatrix[l]){n=(i.x+a%i.x)%i.x;for(var h in this.tilesMatrix[l][a])if(o=(i.y+h%i.y)%i.y,u=this.tilesMatrix[l][a][h],u.loadWithAjax=this.loadTilesWithAjax,u.loadWithAjax){var c=this.source.getTileAjaxHeaders(l,n,o);u.ajaxHeaders=e.extend({},this.ajaxHeaders,c)}else u.ajaxHeaders=null}}for(var d=0;d<this._imageLoader.jobQueue.length;d++){var v=this._imageLoader.jobQueue[d];v.loadWithAjax=v.tile.loadWithAjax,v.ajaxHeaders=v.tile.loadWithAjax?v.tile.ajaxHeaders:null}}},_setScale:function(t,i){var n=this._scaleSpring.target.value===t;if(i){if(n&&this._scaleSpring.current.value===t)return;this._scaleSpring.resetTo(t),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}else{if(n)return;this._scaleSpring.springTo(t),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}n||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 t=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),i=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,n=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(i/this.minPixelRatio)/Math.log(2))));return n=Math.max(n,this.source.minLevel||0),t=Math.min(t,n),{lowestLevel:t,highestLevel:n}},_updateLevelsForViewport:function(){var t=this._getLevelsInterval(),i=t.lowestLevel,n=t.highestLevel,o=[],u=this.getDrawArea(),l=e.now();if(this._lastDrawn.forEach(O=>{O.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!u)return this._needsDraw=!1,this._fullyLoaded;var a=new Array(n-i+1);for(let O=0,M=n;M>=i;M--,O++)a[O]=M;for(let O=n+1;O<=this.source.maxLevel;O++){var h=this.tilesMatrix[O]&&this.tilesMatrix[O][0]&&this.tilesMatrix[O][0][0];if(h&&h.isBottomMost&&h.isRightMost&&h.loaded){a.push(O);break}}let c=!1;for(let O=0;O<a.length;O++){let M=a[O];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!0).x*this._scaleSpring.current.value;if(O===a.length-1||d>=this.minPixelRatio)c=!0;else if(!c)continue;var v=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!1).x*this._scaleSpring.current.value,m=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,_=this.immediateRender?1:m,y=Math.min(1,(d-.5)/.5),E=_/Math.abs(_-v),S=this._updateLevel(M,y,E,u,l,o);o=S.bestTiles;var P=S.updatedTiles.filter(L=>L.loaded),B=(function(L,W,Y){return function(Q){return{tile:Q,level:L,levelOpacity:W,currentTime:Y}}})(M,y,l);if(this._tilesToDraw[M]=P.map(B),this._providesCoverage(this.coverage,M))break}return o&&o.length>0?(o.forEach(function(O){O&&!O.context2D&&this._loadTile(O,l)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(t){let i=e.now(),n=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let o=t.length?t[0].level:0;if(!this.getDrawArea())return;function u(a){let h=a.tile;if(h&&h.loaded){let c=n._blendTile(h,h.x,h.y,a.level,a.levelOpacity,i,o);n._isBlending=n._isBlending||c,n._needsDraw=n._needsDraw||c||n._wasBlending}}let l=0;for(let a=0;a<t.length;a++){let h=t[a];u(h),this._providesCoverage(this.coverage,h.level)&&(l=Math.max(l,h.level))}if(l>0)for(let a in this._tilesToDraw)a<l&&delete this._tilesToDraw[a]},_blendTile:function(t,i,n,o,u,l,a){let h=1e3*this.blendTime,c,d;return t.blendStart||(t.blendStart=l),c=l-t.blendStart,d=h?Math.min(1,c/h):1,o===a&&(d=1,c=h),this.alwaysBlend&&(d*=u),t.opacity=d,d===1&&(this._setCoverage(this.coverage,o,i,n,!0),this._hasOpaqueTile=!0),c<h},_updateLevel:function(t,i,n,o,u,l){var a=o.getBoundingBox().getTopLeft(),h=o.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:t,opacity:i,visibility:n,drawArea:o,topleft:a,bottomright:h,currenttime:u,best:l}),this._resetCoverage(this.coverage,t),this._resetCoverage(this.loadingCoverage,t);var c=this._getCornerTiles(t,a,h),d=c.topLeft,v=c.bottomRight,m=this.source.getNumTiles(t),_=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(v.x+=1,this.wrapHorizontal||(v.x=Math.min(v.x,m.x-1)));for(var y=Math.max(0,(v.x-d.x)*(v.y-d.y)),E=new Array(y),S=0,P=d.x;P<=v.x;P++)for(var B=d.y;B<=v.y;B++){var O;if(this.getFlip()){var M=(m.x+P%m.x)%m.x;O=P+m.x-M-M-1}else O=P;if(o.intersection(this.getTileBounds(t,O,B))!==null){var L=this._updateTile(O,B,t,n,_,m,u,l);l=L.bestTiles,E[S]=L.tile,S+=1}}return{bestTiles:l,updatedTiles:E}},_positionTile:function(t,i,n,o,u){var l=t.bounds.getTopLeft();l.x*=this._scaleSpring.current.value,l.y*=this._scaleSpring.current.value,l.x+=this._xSpring.current.value,l.y+=this._ySpring.current.value;var a=t.bounds.getSize();a.x*=this._scaleSpring.current.value,a.y*=this._scaleSpring.current.value,t.positionedBounds.x=l.x,t.positionedBounds.y=l.y,t.positionedBounds.width=a.x,t.positionedBounds.height=a.y;var h=n.pixelFromPointNoRotate(l,!0),c=n.pixelFromPointNoRotate(l,!1),d=n.deltaPixelsFromPointsNoRotate(a,!0),v=n.deltaPixelsFromPointsNoRotate(a,!1),m=c.plus(v.divide(2)),_=o.squaredDistanceTo(m);this.viewer.drawer.minimumOverlapRequired(this)&&(i||(d=d.plus(new e.Point(1,1))),t.isRightMost&&this.wrapHorizontal&&(d.x+=.75),t.isBottomMost&&this.wrapVertical&&(d.y+=.75)),t.position=h,t.size=d,t.squaredDistance=_,t.visibility=u},_updateTile:function(t,i,n,o,u,l,a,h){var c=this._getTile(t,i,n,a,l);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:c}),this._setCoverage(this.coverage,n,t,i,!1);var d=c.loaded||c.loading||this._isCovered(this.loadingCoverage,n,t,i);if(this._setCoverage(this.loadingCoverage,n,t,i,d),!c.exists)return{bestTiles:h,tile:c};if(c.loaded&&c.opacity===1&&this._setCoverage(this.coverage,n,t,i,!0),this._positionTile(c,this.source.tileOverlap,this.viewport,u,o),!c.loaded)if(c.context2D)this._setTileLoaded(c);else{var v=this._tileCache.getImageRecord(c.cacheKey);v&&this._setTileLoaded(c,v.getData())}return c.loading?this._tilesLoading++:d||(h=this._compareTiles(h,c,this.maxTilesPerFrame)),{bestTiles:h,tile:c}},_getCornerTiles:function(t,i,n){var o,u;this.wrapHorizontal?(o=e.positiveModulo(i.x,1),u=e.positiveModulo(n.x,1)):(o=Math.max(0,i.x),u=Math.min(1,n.x));var l,a,h=1/this.source.aspectRatio;this.wrapVertical?(l=e.positiveModulo(i.y,h),a=e.positiveModulo(n.y,h)):(l=Math.max(0,i.y),a=Math.min(h,n.y));var c=this.source.getTileAtPoint(t,new e.Point(o,l)),d=this.source.getTileAtPoint(t,new e.Point(u,a)),v=this.source.getNumTiles(t);return this.wrapHorizontal&&(c.x+=v.x*Math.floor(i.x),d.x+=v.x*Math.floor(n.x)),this.wrapVertical&&(c.y+=v.y*Math.floor(i.y/h),d.y+=v.y*Math.floor(n.y/h)),{topLeft:c,bottomRight:d}},_getTile:function(t,i,n,o,u){var l,a,h,c,d,v,m,_,y,E,S=this.tilesMatrix,P=this.source;return S[n]||(S[n]={}),S[n][t]||(S[n][t]={}),(!S[n][t][i]||!S[n][t][i].flipped!=!this.flipped)&&(l=(u.x+t%u.x)%u.x,a=(u.y+i%u.y)%u.y,h=this.getTileBounds(n,t,i),c=P.getTileBounds(n,l,a,!0),d=P.tileExists(n,l,a),v=P.getTileUrl(n,l,a),m=P.getTilePostData(n,l,a),this.loadTilesWithAjax?(_=P.getTileAjaxHeaders(n,l,a),e.isPlainObject(this.ajaxHeaders)&&(_=e.extend({},this.ajaxHeaders,_))):_=null,y=P.getContext2D?P.getContext2D(n,l,a):void 0,E=new e.Tile(n,t,i,h,d,v,y,this.loadTilesWithAjax,_,c,m,P.getTileHashKey(n,l,a,v,_,m)),this.getFlip()?l===0&&(E.isRightMost=!0):l===u.x-1&&(E.isRightMost=!0),a===u.y-1&&(E.isBottomMost=!0),E.flipped=this.flipped,S[n][t][i]=E),E=S[n][t][i],E.lastTouchTime=o,E},_loadTile:function(t,i){var n=this;t.loading=!0,this._imageLoader.addJob({src:t.getUrl(),tile:t,source:this.source,postData:t.postData,loadWithAjax:t.loadWithAjax,ajaxHeaders:t.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(o,u,l){n._onTileLoad(t,i,o,u,l)},abort:function(){t.loading=!1}})},_onTileLoad:function(t,i,n,o,u){if(n)t.exists=!0;else{e.console.error("Tile %s failed to load: %s - error: %s",t,t.getUrl(),o),this.viewer.raiseEvent("tile-load-failed",{tile:t,tiledImage:this,time:i,message:o,tileRequest:u}),t.loading=!1,t.exists=!1;return}if(i<this.lastResetTime){e.console.warn("Ignoring tile %s loaded before reset: %s",t,t.getUrl()),t.loading=!1;return}var l=this,a=function(){var h=l.source,c=h.getClosestLevel();l._setTileLoaded(t,n,c,u)};a()},_setTileLoaded:function(t,i,n,o){var u=0,l=!1,a=this;function h(){return l&&e.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),u++,c}function c(){u--,u===0&&(t.loading=!1,t.loaded=!0,t.hasTransparency=a.source.hasTransparency(t.context2D,t.getUrl(),t.ajaxHeaders,t.postData),t.context2D||a._tileCache.cacheTile({data:i,tile:t,cutoff:n,tiledImage:a}),a.viewer.raiseEvent("tile-ready",{tile:t,tiledImage:a,tileRequest:o}),a._needsDraw=!0)}var d=h();this.viewer.raiseEvent("tile-loaded",{tile:t,tiledImage:this,tileRequest:o,get image(){return e.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),i},data:i,getCompletionCallback:h}),l=!0,d()},_compareTiles:function(t,i,n){return t?(t.push(i),this._sortTiles(t),t.length>n&&t.pop(),t):[i]},_sortTiles:function(t){t.sort(function(i,n){return i===null?1:n===null?-1:i.visibility===n.visibility?i.squaredDistance-n.squaredDistance:n.visibility-i.visibility})},_providesCoverage:function(t,i,n,o){var u,l,a,h;if(!t[i])return!1;if(n===void 0||o===void 0){u=t[i];for(a in u)if(Object.prototype.hasOwnProperty.call(u,a)){l=u[a];for(h in l)if(Object.prototype.hasOwnProperty.call(l,h)&&!l[h])return!1}return!0}return t[i][n]===void 0||t[i][n][o]===void 0||t[i][n][o]===!0},_isCovered:function(t,i,n,o){return n===void 0||o===void 0?this._providesCoverage(t,i+1):this._providesCoverage(t,i+1,2*n,2*o)&&this._providesCoverage(t,i+1,2*n,2*o+1)&&this._providesCoverage(t,i+1,2*n+1,2*o)&&this._providesCoverage(t,i+1,2*n+1,2*o+1)},_setCoverage:function(t,i,n,o,u){if(!t[i]){e.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",i);return}t[i][n]||(t[i][n]={}),t[i][n][o]=u},_resetCoverage:function(t,i){t[i]={}}})})(s),(function(e){var t=function(n){e.console.assert(n,"[TileCache.cacheTile] options is required"),e.console.assert(n.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(n.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=n.tile,this.tiledImage=n.tiledImage},i=function(n){e.console.assert(n,"[ImageRecord] options is required"),e.console.assert(n.data,"[ImageRecord] options.data is required"),this._tiles=[],n.create.apply(null,[this,n.data,n.ownerTile]),this._destroyImplementation=n.destroy.bind(null,this),this.getImage=n.getImage.bind(null,this),this.getData=n.getData.bind(null,this),this.getRenderedContext=n.getRenderedContext.bind(null,this)};i.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(n){e.console.assert(n,"[ImageRecord.addTile] tile is required"),this._tiles.push(n)},removeTile:function(n){for(var o=0;o<this._tiles.length;o++)if(this._tiles[o]===n){this._tiles.splice(o,1);return}e.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",n)},getTileCount:function(){return this._tiles.length}},e.TileCache=function(n){n=n||{},this._maxImageCacheCount=n.maxImageCacheCount||e.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},e.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(n){e.console.assert(n,"[TileCache.cacheTile] options is required"),e.console.assert(n.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(n.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),e.console.assert(n.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var o=n.cutoff||0,u=this._tilesLoaded.length,l=this._imagesLoaded[n.tile.cacheKey];if(l||(n.data||(e.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future."),n.data=n.image),e.console.assert(n.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),l=this._imagesLoaded[n.tile.cacheKey]=new i({data:n.data,ownerTile:n.tile,create:n.tiledImage.source.createTileCache,destroy:n.tiledImage.source.destroyTileCache,getImage:n.tiledImage.source.getTileCacheDataAsImage,getData:n.tiledImage.source.getTileCacheData,getRenderedContext:n.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),l.addTile(n.tile),n.tile.cacheImageRecord=l,this._imagesLoadedCount>this._maxImageCacheCount){for(var a=null,h=-1,c=null,d,v,m,_,y,E,S=this._tilesLoaded.length-1;S>=0;S--)if(E=this._tilesLoaded[S],d=E.tile,!(d.level<=o||d.beingDrawn)){if(!a){a=d,h=S,c=E;continue}_=d.lastTouchTime,v=a.lastTouchTime,y=d.level,m=a.level,(_<v||_===v&&y>m)&&(a=d,h=S,c=E)}a&&h>=0&&(this._unloadTile(c),u=h)}this._tilesLoaded[u]=new t({tile:n.tile,tiledImage:n.tiledImage})},clearTilesFor:function(n){e.console.assert(n,"[TileCache.clearTilesFor] tiledImage is required");for(var o,u=0;u<this._tilesLoaded.length;++u)o=this._tilesLoaded[u],o.tiledImage===n&&(this._unloadTile(o),this._tilesLoaded.splice(u,1),u--)},getImageRecord:function(n){return e.console.assert(n,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[n]},_unloadTile:function(n){e.console.assert(n,"[TileCache._unloadTile] tileRecord is required");var o=n.tile,u=n.tiledImage;let l=o.getCanvasContext&&o.getCanvasContext();o.unload(),o.cacheImageRecord=null;var a=this._imagesLoaded[o.cacheKey];a&&(a.removeTile(o),a.getTileCount()||(a.destroy(),delete this._imagesLoaded[o.cacheKey],this._imagesLoadedCount--,l&&(l.canvas.width=0,l.canvas.height=0,u.viewer.raiseEvent("image-unloaded",{context2D:l,tile:o}))),u.viewer.raiseEvent("tile-unloaded",{tile:o,tiledImage:u}))}}})(s),(function(e){e.World=function(t){var i=this;e.console.assert(t.viewer,"[World] options.viewer is required"),e.EventSource.call(this),this.viewer=t.viewer,this._items=[],this._needsDraw=!1,this._autoRefigureSizes=!0,this._needsSizesFigured=!1,this._delegatedFigureSizes=function(n){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 n=Math.max(0,Math.min(this._items.length,i.index));this._items.splice(n,0,t)}else this._items.push(t);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0,this._needsDraw=!0,t.addHandler("bounds-change",this._delegatedFigureSizes),t.addHandler("clip-change",this._delegatedFigureSizes),this.raiseEvent("add-item",{item:t})},getItemAt:function(t){return e.console.assert(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 n=this.getIndexOfItem(t);if(i>=this._items.length)throw new Error("Index bigger than number of layers.");i===n||n===-1||(this._items.splice(n,1),this._items.splice(i,0,t),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:t,previousIndex:n,newIndex:i}))},removeItem:function(t){e.console.assert(t,"[World.removeItem] item is required");var i=e.indexOf(this._items,t);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 n=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,i=0;i<n.length;i++)t=n[i],this._raiseRemoveItem(t)},resetItems:function(){for(var t=0;t<this._items.length;t++)this._items[t].reset()},update:function(t){for(var i=!1,n=0;n<this._items.length;n++)i=this._items[n].update(t)||i;return i},draw:function(){this.viewer.drawer.draw(this._items),this._needsDraw=!1,this._items.forEach(t=>{this._needsDraw=t.setDrawn()||this._needsDraw})},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,n=t.layout||e.DEFAULT_SETTINGS.collectionLayout,o=t.rows||e.DEFAULT_SETTINGS.collectionRows,u=t.columns||e.DEFAULT_SETTINGS.collectionColumns,l=t.tileSize||e.DEFAULT_SETTINGS.collectionTileSize,a=t.tileMargin||e.DEFAULT_SETTINGS.collectionTileMargin,h=l+a,c;!t.rows&&u?c=u:c=Math.ceil(this._items.length/o);var d=0,v=0,m,_,y,E,S;this.setAutoRefigureSizes(!1);for(var P=0;P<this._items.length;P++)P&&P%c===0&&(n==="horizontal"?(v+=h,d=0):(d+=h,v=0)),m=this._items[P],_=m.getBounds(),_.width>_.height?y=l:y=l*(_.width/_.height),E=y*(_.height/_.width),S=new e.Point(d+(l-y)/2,v+(l-E)/2),m.setPosition(S,i),m.setWidth(y,i),n==="horizontal"?d+=h:v+=h;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var t=this._homeBounds?this._homeBounds.clone():null,i=this._contentSize?this._contentSize.clone():null,n=this._contentFactor||0;if(!this._items.length)this._homeBounds=new e.Rect(0,0,1,1),this._contentSize=new e.Point(1,1),this._contentFactor=1;else{var o=this._items[0],u=o.getBounds();this._contentFactor=o.getContentSize().x/u.width;for(var l=o.getClippedBounds().getBoundingBox(),a=l.x,h=l.y,c=l.x+l.width,d=l.y+l.height,v=1;v<this._items.length;v++)o=this._items[v],u=o.getBounds(),this._contentFactor=Math.max(this._contentFactor,o.getContentSize().x/u.width),l=o.getClippedBounds().getBoundingBox(),a=Math.min(a,l.x),h=Math.min(h,l.y),c=Math.max(c,l.x+l.width),d=Math.max(d,l.y+l.height);this._homeBounds=new e.Rect(a,h,c-a,d-h),this._contentSize=new e.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==n||!this._homeBounds.equals(t)||!this._contentSize.equals(i))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(t){this.raiseEvent("remove-item",{item:t})}})})(s)})(en)),en.exports}var Mr=Rl();const Dl=Object.freeze(Object.defineProperty({__proto__:null,o:Pl({__proto__:null,default:Sl(Mr)},[Mr])},Symbol.toStringTag,{value:"Module"}))})();
|