triiiceratops 0.1.0
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/README.md +78 -0
- package/dist/favicon.ico +0 -0
- package/dist/src/lib/components/AnnotationOverlay.svelte.d.ts +1 -0
- package/dist/src/lib/components/CanvasNavigation.svelte.d.ts +1 -0
- package/dist/src/lib/components/FloatingMenu.svelte.d.ts +1 -0
- package/dist/src/lib/components/MetadataDialog.svelte.d.ts +1 -0
- package/dist/src/lib/components/OSDViewer.svelte.d.ts +1 -0
- package/dist/src/lib/components/SearchPanel.svelte.d.ts +1 -0
- package/dist/src/lib/components/ThumbnailGallery.svelte.d.ts +1 -0
- package/dist/src/lib/components/TriiiceratopsViewer.svelte.d.ts +1 -0
- package/dist/src/lib/custom-element.d.ts +0 -0
- package/dist/src/lib/index.d.ts +3 -0
- package/dist/src/lib/paraglide/messages/en.d.ts +1 -0
- package/dist/src/lib/paraglide/messages.d.ts +3 -0
- package/dist/src/lib/paraglide/runtime.d.ts +52 -0
- package/dist/src/lib/state/manifests.svelte.d.ts +18 -0
- package/dist/src/lib/state/viewer.svelte.d.ts +40 -0
- package/dist/src/lib/utils/annotationAdapter.d.ts +9 -0
- package/dist/triiiceratops-element.css +1 -0
- package/dist/triiiceratops-element.iife.js +1227 -0
- package/dist/triiiceratops-element.js +51795 -0
- package/dist/triiiceratops.js +1498 -0
- package/package.json +72 -0
|
@@ -0,0 +1,1227 @@
|
|
|
1
|
+
var CO=Object.defineProperty;var w_=vt=>{throw TypeError(vt)};var PO=(vt,yt,Ht)=>yt in vt?CO(vt,yt,{enumerable:!0,configurable:!0,writable:!0,value:Ht}):vt[yt]=Ht;var Ut=(vt,yt,Ht)=>PO(vt,typeof yt!="symbol"?yt+"":yt,Ht),ff=(vt,yt,Ht)=>yt.has(vt)||w_("Cannot "+Ht);var Z=(vt,yt,Ht)=>(ff(vt,yt,"read from private field"),Ht?Ht.call(vt):yt.get(vt)),Ie=(vt,yt,Ht)=>yt.has(vt)?w_("Cannot add the same private member more than once"):yt instanceof WeakSet?yt.add(vt):yt.set(vt,Ht),Ve=(vt,yt,Ht,Po)=>(ff(vt,yt,"write to private field"),Po?Po.call(vt,Ht):yt.set(vt,Ht),Ht),mt=(vt,yt,Ht)=>(ff(vt,yt,"access private method"),Ht);(function(){"use strict";var v_,xo,wo,_s,xs,Sa,Eo,To,Vt,pf,As,gf,E_,T_,$i,Fi,Ra,Br,ws,kr,er,Ai,Ur,nn,Ln,Es,Nn,Ts,Fn,Xh,kt,b_,A_,mf,Zh,qh,vf,_r,Hr,Bi,bs,Ca,Pa,Yh,sn,tr,Ia,Ma,Da,Oa,La,Na,Fa,Ba,ka,Ua,Ha,Ga,Va,za,ja,Wa,Xa,Ya;typeof window<"u"&&((v_=window.__svelte??(window.__svelte={})).v??(v_.v=new Set)).add("5");const yt=1,Ht=2,Po=4,I_=8,M_=16,Af=1,D_=2,Sf="[",$a="[!",tu="]",Bn={},Qt=Symbol(),O_="http://www.w3.org/1999/xhtml",L_="@attach",iu=!1;var ru=Array.isArray,N_=Array.prototype.indexOf,el=Array.from,tl=Object.keys,il=Object.defineProperty,Ss=Object.getOwnPropertyDescriptor,Rf=Object.getOwnPropertyDescriptors,F_=Object.prototype,B_=Array.prototype,nu=Object.getPrototypeOf,Cf=Object.isExtensible;function k_(r){return r()}function su(r){for(var e=0;e<r.length;e++)r[e]()}function Pf(){var r,e,t=new Promise((i,n)=>{r=i,e=n});return{promise:t,resolve:r,reject:e}}const Jt=2,ou=4,rl=8,If=1<<24,Vr=16,zr=32,on=64,nl=128,ir=512,ri=1024,vi=2048,jr=4096,Si=8192,Wr=16384,sl=32768,kn=65536,Mf=1<<17,Df=1<<18,Un=1<<19,Of=1<<20,Xr=1<<25,Hn=32768,au=1<<21,lu=1<<22,an=1<<23,ln=Symbol("$state"),U_=Symbol("legacy props"),H_=Symbol(""),Rs=new class extends Error{constructor(){super(...arguments);Ut(this,"name","StaleReactionError");Ut(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}},ol=3,Gn=8;function Lf(r){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function G_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function V_(r){throw new Error("https://svelte.dev/e/effect_in_teardown")}function z_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function j_(r){throw new Error("https://svelte.dev/e/effect_orphan")}function W_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function X_(){throw new Error("https://svelte.dev/e/hydration_failed")}function Y_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Z_(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function q_(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function K_(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function Io(r){console.warn("https://svelte.dev/e/hydration_mismatch")}function Q_(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function J_(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let Xe=!1;function rr(r){Xe=r}let Ze;function ni(r){if(r===null)throw Io(),Bn;return Ze=r}function Vn(){return ni(sr(Ze))}function ue(r){if(Xe){if(sr(Ze)!==null)throw Io(),Bn;Ze=r}}function yi(r=1){if(Xe){for(var e=r,t=Ze;e--;)t=sr(t);Ze=t}}function al(r=!0){for(var e=0,t=Ze;;){if(t.nodeType===Gn){var i=t.data;if(i===tu){if(e===0)return t;e-=1}else(i===Sf||i===$a)&&(e+=1)}var n=sr(t);r&&t.remove(),t=n}}function Nf(r){if(!r||r.nodeType!==Gn)throw Io(),Bn;return r.data}function Ff(r){return r===this.v}function $_(r,e){return r!=r?e==e:r!==e||r!==null&&typeof r=="object"||typeof r=="function"}function Bf(r){return!$_(r,this.v)}let Mo=!1,e1=!1;function t1(){Mo=!0}let dt=null;function Cs(r){dt=r}function Ps(r){return hu().get(r)}function i1(r,e){return hu().set(r,e),e}function r1(r){return hu().has(r)}function wt(r,e=!1,t){dt={p:dt,i:!1,c:null,e:null,s:r,x:null,l:Mo&&!e?{s:null,u:null,$:[]}:null}}function Et(r){var e=dt,t=e.e;if(t!==null){e.e=null;for(var i of t)ap(i)}return r!==void 0&&(e.x=r),e.i=!0,dt=e.p,r??{}}function Is(){return!Mo||dt!==null&&dt.l===null}function hu(r){return dt===null&&Lf(),dt.c??(dt.c=new Map(n1(dt)||void 0))}function n1(r){let e=r.p;for(;e!==null;){const t=e.c;if(t!==null)return t;e=e.p}return null}let zn=[];function kf(){var r=zn;zn=[],su(r)}function hn(r){if(zn.length===0&&!Do){var e=zn;queueMicrotask(()=>{e===zn&&kf()})}zn.push(r)}function s1(){for(;zn.length>0;)kf()}function Uf(r){var e=st;if(e===null)return tt.f|=an,r;if((e.f&sl)===0){if((e.f&nl)===0)throw r;e.b.error(r)}else Ms(r,e)}function Ms(r,e){for(;e!==null;){if((e.f&nl)!==0)try{e.b.error(r);return}catch(t){r=t}e=e.parent}throw r}const ll=new Set;let Qe=null,hl=null,Ot=null,Hi=[],ul=null,uu=!1,Do=!1;const Wh=class Wh{constructor(){Ie(this,Vt);Ut(this,"committed",!1);Ut(this,"current",new Map);Ut(this,"previous",new Map);Ie(this,xo,new Set);Ie(this,wo,new Set);Ie(this,_s,0);Ie(this,xs,0);Ie(this,Sa,null);Ie(this,Eo,[]);Ie(this,To,[]);Ut(this,"skipped_effects",new Set);Ut(this,"is_fork",!1)}is_deferred(){return this.is_fork||Z(this,xs)>0}process(e){var i;Hi=[],hl=null,this.apply();var t={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const n of e)mt(this,Vt,pf).call(this,n,t);this.is_fork||mt(this,Vt,E_).call(this),this.is_deferred()?(mt(this,Vt,As).call(this,t.effects),mt(this,Vt,As).call(this,t.render_effects),mt(this,Vt,As).call(this,t.block_effects)):(hl=this,Qe=null,Gf(t.render_effects),Gf(t.effects),hl=null,(i=Z(this,Sa))==null||i.resolve()),Ot=null}capture(e,t){this.previous.has(e)||this.previous.set(e,t),(e.f&an)===0&&(this.current.set(e,e.v),Ot==null||Ot.set(e,e.v))}activate(){Qe=this,this.apply()}deactivate(){Qe===this&&(Qe=null,Ot=null)}flush(){if(this.activate(),Hi.length>0){if(Hf(),Qe!==null&&Qe!==this)return}else Z(this,_s)===0&&this.process([]);this.deactivate()}discard(){for(const e of Z(this,wo))e(this);Z(this,wo).clear()}increment(e){Ve(this,_s,Z(this,_s)+1),e&&Ve(this,xs,Z(this,xs)+1)}decrement(e){Ve(this,_s,Z(this,_s)-1),e&&Ve(this,xs,Z(this,xs)-1),this.revive()}revive(){for(const e of Z(this,Eo))oi(e,vi),jn(e);for(const e of Z(this,To))oi(e,jr),jn(e);Ve(this,Eo,[]),Ve(this,To,[]),this.flush()}oncommit(e){Z(this,xo).add(e)}ondiscard(e){Z(this,wo).add(e)}settled(){return(Z(this,Sa)??Ve(this,Sa,Pf())).promise}static ensure(){if(Qe===null){const e=Qe=new Wh;ll.add(Qe),Do||Wh.enqueue(()=>{Qe===e&&e.flush()})}return Qe}static enqueue(e){hn(e)}apply(){}};xo=new WeakMap,wo=new WeakMap,_s=new WeakMap,xs=new WeakMap,Sa=new WeakMap,Eo=new WeakMap,To=new WeakMap,Vt=new WeakSet,pf=function(e,t){var u;e.f^=ri;for(var i=e.first;i!==null;){var n=i.f,s=(n&(zr|on))!==0,o=s&&(n&ri)!==0,a=o||(n&Si)!==0||this.skipped_effects.has(i);if((i.f&nl)!==0&&((u=i.b)!=null&&u.is_pending())&&(t={parent:t,effect:i,effects:[],render_effects:[],block_effects:[]}),!a&&i.fn!==null){s?i.f^=ri:(n&ou)!==0?t.effects.push(i):ko(i)&&((i.f&Vr)!==0&&t.block_effects.push(i),Uo(i));var l=i.first;if(l!==null){i=l;continue}}var h=i.parent;for(i=i.next;i===null&&h!==null;)h===t.effect&&(mt(this,Vt,As).call(this,t.effects),mt(this,Vt,As).call(this,t.render_effects),mt(this,Vt,As).call(this,t.block_effects),t=t.parent),i=h.next,h=h.parent}},As=function(e){for(const t of e)((t.f&vi)!==0?Z(this,Eo):Z(this,To)).push(t),mt(this,Vt,gf).call(this,t.deps),oi(t,ri)},gf=function(e){if(e!==null)for(const t of e)(t.f&Jt)===0||(t.f&Hn)===0||(t.f^=Hn,mt(this,Vt,gf).call(this,t.deps))},E_=function(){if(Z(this,xs)===0){for(const e of Z(this,xo))e();Z(this,xo).clear()}Z(this,_s)===0&&mt(this,Vt,T_).call(this)},T_=function(){var s;if(ll.size>1){this.previous.clear();var e=Ot,t=!0,i={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const o of ll){if(o===this){t=!1;continue}const a=[];for(const[h,u]of this.current){if(o.current.has(h))if(t&&u!==o.current.get(h))o.current.set(h,u);else continue;a.push(h)}if(a.length===0)continue;const l=[...o.current.keys()].filter(h=>!this.current.has(h));if(l.length>0){var n=Hi;Hi=[];const h=new Set,u=new Map;for(const c of a)Vf(c,l,h,u);if(Hi.length>0){Qe=o,o.apply();for(const c of Hi)mt(s=o,Vt,pf).call(s,c,i);o.deactivate()}Hi=n}}Qe=null,Ot=e}this.committed=!0,ll.delete(this)};let wr=Wh;function cu(r){var e=Do;Do=!0;try{for(var t;;){if(s1(),Hi.length===0&&(Qe==null||Qe.flush(),Hi.length===0))return ul=null,t;Hf()}}finally{Do=e}}function Hf(){var r=Yn;uu=!0;var e=null;try{var t=0;for(pl(!0);Hi.length>0;){var i=wr.ensure();if(t++>1e3){var n,s;o1()}i.process(Hi),un.clear()}}finally{uu=!1,pl(r),ul=null}}function o1(){try{W_()}catch(r){Ms(r,ul)}}let nr=null;function Gf(r){var e=r.length;if(e!==0){for(var t=0;t<e;){var i=r[t++];if((i.f&(Wr|Si))===0&&ko(i)&&(nr=new Set,Uo(i),i.deps===null&&i.first===null&&i.nodes===null&&(i.teardown===null&&i.ac===null?dp(i):i.fn=null),(nr==null?void 0:nr.size)>0)){un.clear();for(const n of nr){if((n.f&(Wr|Si))!==0)continue;const s=[n];let o=n.parent;for(;o!==null;)nr.has(o)&&(nr.delete(o),s.push(o)),o=o.parent;for(let a=s.length-1;a>=0;a--){const l=s[a];(l.f&(Wr|Si))===0&&Uo(l)}}nr.clear()}}nr=null}}function Vf(r,e,t,i){if(!t.has(r)&&(t.add(r),r.reactions!==null))for(const n of r.reactions){const s=n.f;(s&Jt)!==0?Vf(n,e,t,i):(s&(lu|Vr))!==0&&(s&vi)===0&&zf(n,e,i)&&(oi(n,vi),jn(n))}}function zf(r,e,t){const i=t.get(r);if(i!==void 0)return i;if(r.deps!==null)for(const n of r.deps){if(e.includes(n))return!0;if((n.f&Jt)!==0&&zf(n,e,t))return t.set(n,!0),!0}return t.set(r,!1),!1}function jn(r){for(var e=ul=r;e.parent!==null;){e=e.parent;var t=e.f;if(uu&&e===st&&(t&Vr)!==0&&(t&Df)===0)return;if((t&(on|zr))!==0){if((t&ri)===0)return;e.f^=ri}}Hi.push(e)}function a1(r){let e=0,t=Wn(0),i;return()=>{No()&&(P(t),fl(()=>(e===0&&(i=Ho(()=>r(()=>Lo(t)))),e+=1,()=>{hn(()=>{e-=1,e===0&&(i==null||i(),i=void 0,Lo(t))})})))}}var l1=kn|Un|nl;function h1(r,e,t){new u1(r,e,t)}class u1{constructor(e,t,i){Ie(this,kt);Ut(this,"parent");Ie(this,$i,!1);Ie(this,Fi);Ie(this,Ra,Xe?Ze:null);Ie(this,Br);Ie(this,ws);Ie(this,kr);Ie(this,er,null);Ie(this,Ai,null);Ie(this,Ur,null);Ie(this,nn,null);Ie(this,Ln,null);Ie(this,Es,0);Ie(this,Nn,0);Ie(this,Ts,!1);Ie(this,Fn,null);Ie(this,Xh,a1(()=>(Ve(this,Fn,Wn(Z(this,Es))),()=>{Ve(this,Fn,null)})));Ve(this,Fi,e),Ve(this,Br,t),Ve(this,ws,i),this.parent=st.b,Ve(this,$i,!!Z(this,Br).pending),Ve(this,kr,Fo(()=>{if(st.b=this,Xe){const s=Z(this,Ra);Vn(),s.nodeType===Gn&&s.data===$a?mt(this,kt,A_).call(this):mt(this,kt,b_).call(this)}else{var n=mt(this,kt,mf).call(this);try{Ve(this,er,wi(()=>i(n)))}catch(s){this.error(s)}Z(this,Nn)>0?mt(this,kt,qh).call(this):Ve(this,$i,!1)}return()=>{var s;(s=Z(this,Ln))==null||s.remove()}},l1)),Xe&&Ve(this,Fi,Ze)}is_pending(){return Z(this,$i)||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!Z(this,Br).pending}update_pending_count(e){mt(this,kt,vf).call(this,e),Ve(this,Es,Z(this,Es)+e),Z(this,Fn)&&Ds(Z(this,Fn),Z(this,Es))}get_effect_pending(){return Z(this,Xh).call(this),P(Z(this,Fn))}error(e){var t=Z(this,Br).onerror;let i=Z(this,Br).failed;if(Z(this,Ts)||!t&&!i)throw e;Z(this,er)&&(zt(Z(this,er)),Ve(this,er,null)),Z(this,Ai)&&(zt(Z(this,Ai)),Ve(this,Ai,null)),Z(this,Ur)&&(zt(Z(this,Ur)),Ve(this,Ur,null)),Xe&&(ni(Z(this,Ra)),yi(),ni(al()));var n=!1,s=!1;const o=()=>{if(n){J_();return}n=!0,s&&K_(),wr.ensure(),Ve(this,Es,0),Z(this,Ur)!==null&&Xn(Z(this,Ur),()=>{Ve(this,Ur,null)}),Ve(this,$i,this.has_pending_snippet()),Ve(this,er,mt(this,kt,Zh).call(this,()=>(Ve(this,Ts,!1),wi(()=>Z(this,ws).call(this,Z(this,Fi)))))),Z(this,Nn)>0?mt(this,kt,qh).call(this):Ve(this,$i,!1)};var a=tt;try{Ei(null),s=!0,t==null||t(e,o),s=!1}catch(l){Ms(l,Z(this,kr)&&Z(this,kr).parent)}finally{Ei(a)}i&&hn(()=>{Ve(this,Ur,mt(this,kt,Zh).call(this,()=>{wr.ensure(),Ve(this,Ts,!0);try{return wi(()=>{i(Z(this,Fi),()=>e,()=>o)})}catch(l){return Ms(l,Z(this,kr).parent),null}finally{Ve(this,Ts,!1)}}))})}}$i=new WeakMap,Fi=new WeakMap,Ra=new WeakMap,Br=new WeakMap,ws=new WeakMap,kr=new WeakMap,er=new WeakMap,Ai=new WeakMap,Ur=new WeakMap,nn=new WeakMap,Ln=new WeakMap,Es=new WeakMap,Nn=new WeakMap,Ts=new WeakMap,Fn=new WeakMap,Xh=new WeakMap,kt=new WeakSet,b_=function(){try{Ve(this,er,wi(()=>Z(this,ws).call(this,Z(this,Fi))))}catch(e){this.error(e)}Ve(this,$i,!1)},A_=function(){const e=Z(this,Br).pending;e&&(Ve(this,Ai,wi(()=>e(Z(this,Fi)))),wr.enqueue(()=>{var t=mt(this,kt,mf).call(this);Ve(this,er,mt(this,kt,Zh).call(this,()=>(wr.ensure(),wi(()=>Z(this,ws).call(this,t))))),Z(this,Nn)>0?mt(this,kt,qh).call(this):(Xn(Z(this,Ai),()=>{Ve(this,Ai,null)}),Ve(this,$i,!1))}))},mf=function(){var e=Z(this,Fi);return Z(this,$i)&&(Ve(this,Ln,xi()),Z(this,Fi).before(Z(this,Ln)),e=Z(this,Ln)),e},Zh=function(e){var t=st,i=tt,n=dt;Tr(Z(this,kr)),Ei(Z(this,kr)),Cs(Z(this,kr).ctx);try{return e()}catch(s){return Uf(s),null}finally{Tr(t),Ei(i),Cs(n)}},qh=function(){const e=Z(this,Br).pending;Z(this,er)!==null&&(Ve(this,nn,document.createDocumentFragment()),Z(this,nn).append(Z(this,Ln)),gp(Z(this,er),Z(this,nn))),Z(this,Ai)===null&&Ve(this,Ai,wi(()=>e(Z(this,Fi))))},vf=function(e){var t;if(!this.has_pending_snippet()){this.parent&&mt(t=this.parent,kt,vf).call(t,e);return}Ve(this,Nn,Z(this,Nn)+e),Z(this,Nn)===0&&(Ve(this,$i,!1),Z(this,Ai)&&Xn(Z(this,Ai),()=>{Ve(this,Ai,null)}),Z(this,nn)&&(Z(this,Fi).before(Z(this,nn)),Ve(this,nn,null)))};function jf(r,e,t,i){const n=Is()?Oo:Wf;if(t.length===0&&r.length===0){i(e.map(n));return}var s=Qe,o=st,a=c1();function l(){Promise.all(t.map(h=>d1(h))).then(h=>{a();try{i([...e.map(n),...h])}catch(u){(o.f&Wr)===0&&Ms(u,o)}s==null||s.deactivate(),cl()}).catch(h=>{Ms(h,o)})}r.length>0?Promise.all(r).then(()=>{a();try{return l()}finally{s==null||s.deactivate(),cl()}}):l()}function c1(){var r=st,e=tt,t=dt,i=Qe;return function(s=!0){Tr(r),Ei(e),Cs(t),s&&(i==null||i.activate())}}function cl(){Tr(null),Ei(null),Cs(null)}function Oo(r){var e=Jt|vi,t=tt!==null&&(tt.f&Jt)!==0?tt:null;return st!==null&&(st.f|=Un),{ctx:dt,deps:null,effects:null,equals:Ff,f:e,fn:r,reactions:null,rv:0,v:Qt,wv:0,parent:t??st,ac:null}}function d1(r,e){let t=st;t===null&&G_();var i=t.b,n=void 0,s=Wn(Qt),o=!tt,a=new Map;return E1(()=>{var d;var l=Pf();n=l.promise;try{Promise.resolve(r()).then(l.resolve,l.reject).then(()=>{h===Qe&&h.committed&&h.deactivate(),cl()})}catch(f){l.reject(f),cl()}var h=Qe;if(o){var u=!i.is_pending();i.update_pending_count(1),h.increment(u),(d=a.get(h))==null||d.reject(Rs),a.delete(h),a.set(h,l)}const c=(f,g=void 0)=>{if(h.activate(),g)g!==Rs&&(s.f|=an,Ds(s,g));else{(s.f&an)!==0&&(s.f^=an),Ds(s,f);for(const[p,m]of a){if(a.delete(p),p===h)break;m.reject(Rs)}}o&&(i.update_pending_count(-1),h.decrement(u))};l.promise.then(c,f=>c(null,f||"unknown"))}),gu(()=>{for(const l of a.values())l.reject(Rs)}),new Promise(l=>{function h(u){function c(){u===n?l(s):h(n)}u.then(c,c)}h(n)})}function me(r){const e=Oo(r);return vp(e),e}function Wf(r){const e=Oo(r);return e.equals=Bf,e}function Xf(r){var e=r.effects;if(e!==null){r.effects=null;for(var t=0;t<e.length;t+=1)zt(e[t])}}function f1(r){for(var e=r.parent;e!==null;){if((e.f&Jt)===0)return(e.f&Wr)===0?e:null;e=e.parent}return null}function du(r){var e,t=st;Tr(f1(r));try{r.f&=~Hn,Xf(r),e=Ep(r)}finally{Tr(t)}return e}function Yf(r){var e=du(r);if(r.equals(e)||(Qe!=null&&Qe.is_fork||(r.v=e),r.wv=xp()),!Zn)if(Ot!==null)(No()||Qe!=null&&Qe.is_fork)&&Ot.set(r,e);else{var t=(r.f&ir)===0?jr:ri;oi(r,t)}}let fu=new Set;const un=new Map;let Zf=!1;function Wn(r,e){var t={f:0,v:r,reactions:null,equals:Ff,rv:0,wv:0};return t}function qe(r,e){const t=Wn(r);return vp(t),t}function qf(r,e=!1,t=!0){var n;const i=Wn(r);return e||(i.equals=Bf),Mo&&t&&dt!==null&&dt.l!==null&&((n=dt.l).s??(n.s=[])).push(i),i}function Me(r,e,t=!1){tt!==null&&(!Er||(tt.f&Mf)!==0)&&Is()&&(tt.f&(Jt|Vr|lu|Mf))!==0&&!(di!=null&&di.includes(r))&&q_();let i=t?_i(e):e;return Ds(r,i)}function Ds(r,e){if(!r.equals(e)){var t=r.v;Zn?un.set(r,e):un.set(r,t),r.v=e;var i=wr.ensure();i.capture(r,t),(r.f&Jt)!==0&&((r.f&vi)!==0&&du(r),oi(r,(r.f&ir)!==0?ri:jr)),r.wv=xp(),Kf(r,vi),Is()&&st!==null&&(st.f&ri)!==0&&(st.f&(zr|on))===0&&(Vi===null?b1([r]):Vi.push(r)),!i.is_fork&&fu.size>0&&!Zf&&p1()}return e}function p1(){Zf=!1;var r=Yn;pl(!0);const e=Array.from(fu);try{for(const t of e)(t.f&ri)!==0&&oi(t,jr),ko(t)&&Uo(t)}finally{pl(r)}fu.clear()}function Lo(r){Me(r,r.v+1)}function Kf(r,e){var t=r.reactions;if(t!==null)for(var i=Is(),n=t.length,s=0;s<n;s++){var o=t[s],a=o.f;if(!(!i&&o===st)){var l=(a&vi)===0;if(l&&oi(o,e),(a&Jt)!==0){var h=o;Ot==null||Ot.delete(h),(a&Hn)===0&&(a&ir&&(o.f|=Hn),Kf(h,jr))}else l&&((a&Vr)!==0&&nr!==null&&nr.add(o),jn(o))}}}function _i(r){if(typeof r!="object"||r===null||ln in r)return r;const e=nu(r);if(e!==F_&&e!==B_)return r;var t=new Map,i=ru(r),n=qe(0),s=qn,o=a=>{if(qn===s)return a();var l=tt,h=qn;Ei(null),_p(s);var u=a();return Ei(l),_p(h),u};return i&&t.set("length",qe(r.length)),new Proxy(r,{defineProperty(a,l,h){(!("value"in h)||h.configurable===!1||h.enumerable===!1||h.writable===!1)&&Y_();var u=t.get(l);return u===void 0?u=o(()=>{var c=qe(h.value);return t.set(l,c),c}):Me(u,h.value,!0),!0},deleteProperty(a,l){var h=t.get(l);if(h===void 0){if(l in a){const u=o(()=>qe(Qt));t.set(l,u),Lo(n)}}else Me(h,Qt),Lo(n);return!0},get(a,l,h){var f;if(l===ln)return r;var u=t.get(l),c=l in a;if(u===void 0&&(!c||(f=Ss(a,l))!=null&&f.writable)&&(u=o(()=>{var g=_i(c?a[l]:Qt),p=qe(g);return p}),t.set(l,u)),u!==void 0){var d=P(u);return d===Qt?void 0:d}return Reflect.get(a,l,h)},getOwnPropertyDescriptor(a,l){var h=Reflect.getOwnPropertyDescriptor(a,l);if(h&&"value"in h){var u=t.get(l);u&&(h.value=P(u))}else if(h===void 0){var c=t.get(l),d=c==null?void 0:c.v;if(c!==void 0&&d!==Qt)return{enumerable:!0,configurable:!0,value:d,writable:!0}}return h},has(a,l){var d;if(l===ln)return!0;var h=t.get(l),u=h!==void 0&&h.v!==Qt||Reflect.has(a,l);if(h!==void 0||st!==null&&(!u||(d=Ss(a,l))!=null&&d.writable)){h===void 0&&(h=o(()=>{var f=u?_i(a[l]):Qt,g=qe(f);return g}),t.set(l,h));var c=P(h);if(c===Qt)return!1}return u},set(a,l,h,u){var _;var c=t.get(l),d=l in a;if(i&&l==="length")for(var f=h;f<c.v;f+=1){var g=t.get(f+"");g!==void 0?Me(g,Qt):f in a&&(g=o(()=>qe(Qt)),t.set(f+"",g))}if(c===void 0)(!d||(_=Ss(a,l))!=null&&_.writable)&&(c=o(()=>qe(void 0)),Me(c,_i(h)),t.set(l,c));else{d=c.v!==Qt;var p=o(()=>_i(h));Me(c,p)}var m=Reflect.getOwnPropertyDescriptor(a,l);if(m!=null&&m.set&&m.set.call(u,h),!d){if(i&&typeof l=="string"){var v=t.get("length"),y=Number(l);Number.isInteger(y)&&y>=v.v&&Me(v,y+1)}Lo(n)}return!0},ownKeys(a){P(n);var l=Reflect.ownKeys(a).filter(c=>{var d=t.get(c);return d===void 0||d.v!==Qt});for(var[h,u]of t)u.v!==Qt&&!(h in a)&&l.push(h);return l},setPrototypeOf(){Z_()}})}function Qf(r){try{if(r!==null&&typeof r=="object"&&ln in r)return r[ln]}catch{}return r}function g1(r,e){return Object.is(Qf(r),Qf(e))}var Jf,$f,ep,tp;function pu(){if(Jf===void 0){Jf=window,$f=/Firefox/.test(navigator.userAgent);var r=Element.prototype,e=Node.prototype,t=Text.prototype;ep=Ss(e,"firstChild").get,tp=Ss(e,"nextSibling").get,Cf(r)&&(r.__click=void 0,r.__className=void 0,r.__attributes=null,r.__style=void 0,r.__e=void 0),Cf(t)&&(t.__t=void 0)}}function xi(r=""){return document.createTextNode(r)}function si(r){return ep.call(r)}function sr(r){return tp.call(r)}function ce(r,e){if(!Xe)return si(r);var t=si(Ze);if(t===null)t=Ze.appendChild(xi());else if(e&&t.nodeType!==ol){var i=xi();return t==null||t.before(i),ni(i),i}return ni(t),t}function oe(r,e=!1){if(!Xe){var t=si(r);return t instanceof Comment&&t.data===""?sr(t):t}if(e&&(Ze==null?void 0:Ze.nodeType)!==ol){var i=xi();return Ze==null||Ze.before(i),ni(i),i}return Ze}function we(r,e=1,t=!1){let i=Xe?Ze:r;for(var n;e--;)n=i,i=sr(i);if(!Xe)return i;if(t&&(i==null?void 0:i.nodeType)!==ol){var s=xi();return i===null?n==null||n.after(s):i.before(s),ni(s),s}return ni(i),i}function ip(r){r.textContent=""}function rp(){return!1}function m1(r,e){if(e){const t=document.body;r.autofocus=!0,hn(()=>{document.activeElement===t&&r.focus()})}}let np=!1;function sp(){np||(np=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{var e;if(!r.defaultPrevented)for(const t of r.target.elements)(e=t.__on_r)==null||e.call(t)})},{capture:!0}))}function dl(r){var e=tt,t=st;Ei(null),Tr(null);try{return r()}finally{Ei(e),Tr(t)}}function v1(r,e,t,i=t){r.addEventListener(e,()=>dl(t));const n=r.__on_r;n?r.__on_r=()=>{n(),i(!0)}:r.__on_r=()=>i(!0),sp()}function op(r){st===null&&(tt===null&&j_(),z_()),Zn&&V_()}function y1(r,e){var t=e.last;t===null?e.last=e.first=r:(t.next=r,r.prev=t,e.last=r)}function Gi(r,e,t){var i=st;i!==null&&(i.f&Si)!==0&&(r|=Si);var n={ctx:dt,deps:null,nodes:null,f:r|vi|ir,first:null,fn:e,last:null,next:null,parent:i,b:i&&i.b,prev:null,teardown:null,wv:0,ac:null};if(t)try{Uo(n),n.f|=sl}catch(a){throw zt(n),a}else e!==null&&jn(n);var s=n;if(t&&s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&(s.f&Un)===0&&(s=s.first,(r&Vr)!==0&&(r&kn)!==0&&s!==null&&(s.f|=kn)),s!==null&&(s.parent=i,i!==null&&y1(s,i),tt!==null&&(tt.f&Jt)!==0&&(r&on)===0)){var o=tt;(o.effects??(o.effects=[])).push(s)}return n}function No(){return tt!==null&&!Er}function gu(r){const e=Gi(rl,null,!1);return oi(e,ri),e.teardown=r,e}function Ri(r){op();var e=st.f,t=!tt&&(e&zr)!==0&&(e&sl)===0;if(t){var i=dt;(i.e??(i.e=[])).push(r)}else return ap(r)}function ap(r){return Gi(ou|Of,r,!1)}function _1(r){return op(),Gi(rl|Of,r,!0)}function x1(r){wr.ensure();const e=Gi(on|Un,r,!0);return()=>{zt(e)}}function w1(r){wr.ensure();const e=Gi(on|Un,r,!0);return(t={})=>new Promise(i=>{t.outro?Xn(e,()=>{zt(e),i(void 0)}):(zt(e),i(void 0))})}function mu(r){return Gi(ou,r,!1)}function E1(r){return Gi(lu|Un,r,!0)}function fl(r,e=0){return Gi(rl|e,r,!0)}function Lt(r,e=[],t=[],i=[]){jf(i,e,t,n=>{Gi(rl,()=>r(...n.map(P)),!0)})}function Fo(r,e=0){var t=Gi(Vr|e,r,!0);return t}function lp(r,e=0){var t=Gi(If|e,r,!0);return t}function wi(r){return Gi(zr|Un,r,!0)}function hp(r){var e=r.teardown;if(e!==null){const t=Zn,i=tt;mp(!0),Ei(null);try{e.call(null)}finally{mp(t),Ei(i)}}}function up(r,e=!1){var t=r.first;for(r.first=r.last=null;t!==null;){const n=t.ac;n!==null&&dl(()=>{n.abort(Rs)});var i=t.next;(t.f&on)!==0?t.parent=null:zt(t,e),t=i}}function T1(r){for(var e=r.first;e!==null;){var t=e.next;(e.f&zr)===0&&zt(e),e=t}}function zt(r,e=!0){var t=!1;(e||(r.f&Df)!==0)&&r.nodes!==null&&r.nodes.end!==null&&(cp(r.nodes.start,r.nodes.end),t=!0),up(r,e&&!t),gl(r,0),oi(r,Wr);var i=r.nodes&&r.nodes.t;if(i!==null)for(const s of i)s.stop();hp(r);var n=r.parent;n!==null&&n.first!==null&&dp(r),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes=r.ac=null}function cp(r,e){for(;r!==null;){var t=r===e?null:sr(r);r.remove(),r=t}}function dp(r){var e=r.parent,t=r.prev,i=r.next;t!==null&&(t.next=i),i!==null&&(i.prev=t),e!==null&&(e.first===r&&(e.first=i),e.last===r&&(e.last=t))}function Xn(r,e,t=!0){var i=[];fp(r,i,!0);var n=()=>{t&&zt(r),e&&e()},s=i.length;if(s>0){var o=()=>--s||n();for(var a of i)a.out(o)}else n()}function fp(r,e,t){if((r.f&Si)===0){r.f^=Si;var i=r.nodes&&r.nodes.t;if(i!==null)for(const a of i)(a.is_global||t)&&e.push(a);for(var n=r.first;n!==null;){var s=n.next,o=(n.f&kn)!==0||(n.f&zr)!==0&&(r.f&Vr)!==0;fp(n,e,o?t:!1),n=s}}}function vu(r){pp(r,!0)}function pp(r,e){if((r.f&Si)!==0){r.f^=Si,(r.f&ri)===0&&(oi(r,vi),jn(r));for(var t=r.first;t!==null;){var i=t.next,n=(t.f&kn)!==0||(t.f&zr)!==0;pp(t,n?e:!1),t=i}var s=r.nodes&&r.nodes.t;if(s!==null)for(const o of s)(o.is_global||e)&&o.in()}}function gp(r,e){if(r.nodes)for(var t=r.nodes.start,i=r.nodes.end;t!==null;){var n=t===i?null:sr(t);e.append(t),t=n}}let Yn=!1;function pl(r){Yn=r}let Zn=!1;function mp(r){Zn=r}let tt=null,Er=!1;function Ei(r){tt=r}let st=null;function Tr(r){st=r}let di=null;function vp(r){tt!==null&&(di===null?di=[r]:di.push(r))}let fi=null,Ci=0,Vi=null;function b1(r){Vi=r}let yp=1,Bo=0,qn=Bo;function _p(r){qn=r}function xp(){return++yp}function ko(r){var e=r.f;if((e&vi)!==0)return!0;if(e&Jt&&(r.f&=~Hn),(e&jr)!==0){var t=r.deps;if(t!==null)for(var i=t.length,n=0;n<i;n++){var s=t[n];if(ko(s)&&Yf(s),s.wv>r.wv)return!0}(e&ir)!==0&&Ot===null&&oi(r,ri)}return!1}function wp(r,e,t=!0){var i=r.reactions;if(i!==null&&!(di!=null&&di.includes(r)))for(var n=0;n<i.length;n++){var s=i[n];(s.f&Jt)!==0?wp(s,e,!1):e===s&&(t?oi(s,vi):(s.f&ri)!==0&&oi(s,jr),jn(s))}}function Ep(r){var g;var e=fi,t=Ci,i=Vi,n=tt,s=di,o=dt,a=Er,l=qn,h=r.f;fi=null,Ci=0,Vi=null,tt=(h&(zr|on))===0?r:null,di=null,Cs(r.ctx),Er=!1,qn=++Bo,r.ac!==null&&(dl(()=>{r.ac.abort(Rs)}),r.ac=null);try{r.f|=au;var u=r.fn,c=u(),d=r.deps;if(fi!==null){var f;if(gl(r,Ci),d!==null&&Ci>0)for(d.length=Ci+fi.length,f=0;f<fi.length;f++)d[Ci+f]=fi[f];else r.deps=d=fi;if(No()&&(r.f&ir)!==0)for(f=Ci;f<d.length;f++)((g=d[f]).reactions??(g.reactions=[])).push(r)}else d!==null&&Ci<d.length&&(gl(r,Ci),d.length=Ci);if(Is()&&Vi!==null&&!Er&&d!==null&&(r.f&(Jt|jr|vi))===0)for(f=0;f<Vi.length;f++)wp(Vi[f],r);return n!==null&&n!==r&&(Bo++,Vi!==null&&(i===null?i=Vi:i.push(...Vi))),(r.f&an)!==0&&(r.f^=an),c}catch(p){return Uf(p)}finally{r.f^=au,fi=e,Ci=t,Vi=i,tt=n,di=s,Cs(o),Er=a,qn=l}}function A1(r,e){let t=e.reactions;if(t!==null){var i=N_.call(t,r);if(i!==-1){var n=t.length-1;n===0?t=e.reactions=null:(t[i]=t[n],t.pop())}}t===null&&(e.f&Jt)!==0&&(fi===null||!fi.includes(e))&&(oi(e,jr),(e.f&ir)!==0&&(e.f^=ir,e.f&=~Hn),Xf(e),gl(e,0))}function gl(r,e){var t=r.deps;if(t!==null)for(var i=e;i<t.length;i++)A1(r,t[i])}function Uo(r){var e=r.f;if((e&Wr)===0){oi(r,ri);var t=st,i=Yn;st=r,Yn=!0;try{(e&(Vr|If))!==0?T1(r):up(r),hp(r);var n=Ep(r);r.teardown=typeof n=="function"?n:null,r.wv=yp;var s;iu&&e1&&(r.f&vi)!==0&&r.deps}finally{Yn=i,st=t}}}async function S1(){await Promise.resolve(),cu()}function P(r){var e=r.f,t=(e&Jt)!==0;if(tt!==null&&!Er){var i=st!==null&&(st.f&Wr)!==0;if(!i&&!(di!=null&&di.includes(r))){var n=tt.deps;if((tt.f&au)!==0)r.rv<Bo&&(r.rv=Bo,fi===null&&n!==null&&n[Ci]===r?Ci++:fi===null?fi=[r]:fi.includes(r)||fi.push(r));else{(tt.deps??(tt.deps=[])).push(r);var s=r.reactions;s===null?r.reactions=[tt]:s.includes(tt)||s.push(tt)}}}if(Zn){if(un.has(r))return un.get(r);if(t){var o=r,a=o.v;return((o.f&ri)===0&&o.reactions!==null||bp(o))&&(a=du(o)),un.set(o,a),a}}else t&&(!(Ot!=null&&Ot.has(r))||Qe!=null&&Qe.is_fork&&!No())&&(o=r,ko(o)&&Yf(o),Yn&&No()&&(o.f&ir)===0&&Tp(o));if(Ot!=null&&Ot.has(r))return Ot.get(r);if((r.f&an)!==0)throw r.v;return r.v}function Tp(r){if(r.deps!==null){r.f^=ir;for(const e of r.deps)(e.reactions??(e.reactions=[])).push(r),(e.f&Jt)!==0&&(e.f&ir)===0&&Tp(e)}}function bp(r){if(r.v===Qt)return!0;if(r.deps===null)return!1;for(const e of r.deps)if(un.has(e)||(e.f&Jt)!==0&&bp(e))return!0;return!1}function Ho(r){var e=Er;try{return Er=!0,r()}finally{Er=e}}const R1=-7169;function oi(r,e){r.f=r.f&R1|e}function C1(r){if(!(typeof r!="object"||!r||r instanceof EventTarget)){if(ln in r)yu(r);else if(!Array.isArray(r))for(let e in r){const t=r[e];typeof t=="object"&&t&&ln in t&&yu(t)}}}function yu(r,e=new Set){if(typeof r=="object"&&r!==null&&!(r instanceof EventTarget)&&!e.has(r)){e.add(r),r instanceof Date&&r.getTime();for(let i in r)try{yu(r[i],e)}catch{}const t=nu(r);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){const i=Rf(t);for(let n in i){const s=i[n].get;if(s)try{s.call(r)}catch{}}}}}const Ap=new Set,_u=new Set;function Sp(r,e,t,i={}){function n(s){if(i.capture||Go.call(e,s),!s.cancelBubble)return dl(()=>t==null?void 0:t.call(this,s))}return r.startsWith("pointer")||r.startsWith("touch")||r==="wheel"?hn(()=>{e.addEventListener(r,n,i)}):e.addEventListener(r,n,i),n}function cn(r,e,t,i,n){var s={capture:i,passive:n},o=Sp(r,e,t,s);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&gu(()=>{e.removeEventListener(r,o,s)})}function Kn(r){for(var e=0;e<r.length;e++)Ap.add(r[e]);for(var t of _u)t(r)}let Rp=null;function Go(r){var m;var e=this,t=e.ownerDocument,i=r.type,n=((m=r.composedPath)==null?void 0:m.call(r))||[],s=n[0]||r.target;Rp=r;var o=0,a=Rp===r&&r.__root;if(a){var l=n.indexOf(a);if(l!==-1&&(e===document||e===window)){r.__root=e;return}var h=n.indexOf(e);if(h===-1)return;l<=h&&(o=l)}if(s=n[o]||r.target,s!==e){il(r,"currentTarget",{configurable:!0,get(){return s||t}});var u=tt,c=st;Ei(null),Tr(null);try{for(var d,f=[];s!==null;){var g=s.assignedSlot||s.parentNode||s.host||null;try{var p=s["__"+i];p!=null&&(!s.disabled||r.target===s)&&p.call(s,r)}catch(v){d?f.push(v):d=v}if(r.cancelBubble||g===e||g===null)break;s=g}if(d){for(let v of f)queueMicrotask(()=>{throw v});throw d}}finally{r.__root=e,delete r.currentTarget,Ei(u),Tr(c)}}}function xu(r){var e=document.createElement("template");return e.innerHTML=r.replaceAll("<!>","<!---->"),e.content}function Pi(r,e){var t=st;t.nodes===null&&(t.nodes={start:r,end:e,a:null,t:null})}function rt(r,e){var t=(e&Af)!==0,i=(e&D_)!==0,n,s=!r.startsWith("<!>");return()=>{if(Xe)return Pi(Ze,null),Ze;n===void 0&&(n=xu(s?r:"<!>"+r),t||(n=si(n)));var o=i||$f?document.importNode(n,!0):n.cloneNode(!0);if(t){var a=si(o),l=o.lastChild;Pi(a,l)}else Pi(o,o);return o}}function P1(r,e,t="svg"){var i=!r.startsWith("<!>"),n=(e&Af)!==0,s=`<${t}>${i?r:"<!>"+r}</${t}>`,o;return()=>{if(Xe)return Pi(Ze,null),Ze;if(!o){var a=xu(s),l=si(a);if(n)for(o=document.createDocumentFragment();si(l);)o.appendChild(si(l));else o=si(l)}var h=o.cloneNode(!0);if(n){var u=si(h),c=h.lastChild;Pi(u,c)}else Pi(h,h);return h}}function le(r,e){return P1(r,e,"svg")}function Ti(r=""){if(!Xe){var e=xi(r+"");return Pi(e,e),e}var t=Ze;return t.nodeType!==ol&&(t.before(t=xi()),ni(t)),Pi(t,t),t}function de(){if(Xe)return Pi(Ze,null),Ze;var r=document.createDocumentFragment(),e=document.createComment(""),t=xi();return r.append(e,t),Pi(e,t),r}function U(r,e){if(Xe){var t=st;((t.f&sl)===0||t.nodes.end===null)&&(t.nodes.end=Ze),Vn();return}r!==null&&r.before(e)}function I1(r){return r.endsWith("capture")&&r!=="gotpointercapture"&&r!=="lostpointercapture"}const M1=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function D1(r){return M1.includes(r)}const O1={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 L1(r){return r=r.toLowerCase(),O1[r]??r}const N1=["touchstart","touchmove"];function F1(r){return N1.includes(r)}function ai(r,e){var t=e==null?"":typeof e=="object"?e+"":e;t!==(r.__t??(r.__t=r.nodeValue))&&(r.__t=t,r.nodeValue=t+"")}function Cp(r,e){return Pp(r,e)}function B1(r,e){pu(),e.intro=e.intro??!1;const t=e.target,i=Xe,n=Ze;try{for(var s=si(t);s&&(s.nodeType!==Gn||s.data!==Sf);)s=sr(s);if(!s)throw Bn;rr(!0),ni(s);const o=Pp(r,{...e,anchor:s});return rr(!1),o}catch(o){if(o instanceof Error&&o.message.split(`
|
|
2
|
+
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw o;return o!==Bn&&console.warn("Failed to hydrate: ",o),e.recover===!1&&X_(),pu(),ip(t),rr(!1),Cp(r,e)}finally{rr(i),ni(n)}}const Os=new Map;function Pp(r,{target:e,anchor:t,props:i={},events:n,context:s,intro:o=!0}){pu();var a=new Set,l=c=>{for(var d=0;d<c.length;d++){var f=c[d];if(!a.has(f)){a.add(f);var g=F1(f);e.addEventListener(f,Go,{passive:g});var p=Os.get(f);p===void 0?(document.addEventListener(f,Go,{passive:g}),Os.set(f,1)):Os.set(f,p+1)}}};l(el(Ap)),_u.add(l);var h=void 0,u=w1(()=>{var c=t??e.appendChild(xi());return h1(c,{pending:()=>{}},d=>{if(s){wt({});var f=dt;f.c=s}if(n&&(i.$$events=n),Xe&&Pi(d,null),h=r(d,i)||{},Xe&&(st.nodes.end=Ze,Ze===null||Ze.nodeType!==Gn||Ze.data!==tu))throw Io(),Bn;s&&Et()}),()=>{var g;for(var d of a){e.removeEventListener(d,Go);var f=Os.get(d);--f===0?(document.removeEventListener(d,Go),Os.delete(d)):Os.set(d,f)}_u.delete(l),c!==t&&((g=c.parentNode)==null||g.removeChild(c))}});return wu.set(h,u),h}let wu=new WeakMap;function k1(r,e){const t=wu.get(r);return t?(wu.delete(r),t(e)):Promise.resolve()}class Eu{constructor(e,t=!0){Ut(this,"anchor");Ie(this,_r,new Map);Ie(this,Hr,new Map);Ie(this,Bi,new Map);Ie(this,bs,new Set);Ie(this,Ca,!0);Ie(this,Pa,()=>{var e=Qe;if(Z(this,_r).has(e)){var t=Z(this,_r).get(e),i=Z(this,Hr).get(t);if(i)vu(i),Z(this,bs).delete(t);else{var n=Z(this,Bi).get(t);n&&(Z(this,Hr).set(t,n.effect),Z(this,Bi).delete(t),n.fragment.lastChild.remove(),this.anchor.before(n.fragment),i=n.effect)}for(const[s,o]of Z(this,_r)){if(Z(this,_r).delete(s),s===e)break;const a=Z(this,Bi).get(o);a&&(zt(a.effect),Z(this,Bi).delete(o))}for(const[s,o]of Z(this,Hr)){if(s===t||Z(this,bs).has(s))continue;const a=()=>{if(Array.from(Z(this,_r).values()).includes(s)){var h=document.createDocumentFragment();gp(o,h),h.append(xi()),Z(this,Bi).set(s,{effect:o,fragment:h})}else zt(o);Z(this,bs).delete(s),Z(this,Hr).delete(s)};Z(this,Ca)||!i?(Z(this,bs).add(s),Xn(o,a,!1)):a()}}});Ie(this,Yh,e=>{Z(this,_r).delete(e);const t=Array.from(Z(this,_r).values());for(const[i,n]of Z(this,Bi))t.includes(i)||(zt(n.effect),Z(this,Bi).delete(i))});this.anchor=e,Ve(this,Ca,t)}ensure(e,t){var i=Qe,n=rp();if(t&&!Z(this,Hr).has(e)&&!Z(this,Bi).has(e))if(n){var s=document.createDocumentFragment(),o=xi();s.append(o),Z(this,Bi).set(e,{effect:wi(()=>t(o)),fragment:s})}else Z(this,Hr).set(e,wi(()=>t(this.anchor)));if(Z(this,_r).set(i,e),n){for(const[a,l]of Z(this,Hr))a===e?i.skipped_effects.delete(l):i.skipped_effects.add(l);for(const[a,l]of Z(this,Bi))a===e?i.skipped_effects.delete(l.effect):i.skipped_effects.add(l.effect);i.oncommit(Z(this,Pa)),i.ondiscard(Z(this,Yh))}else Xe&&(this.anchor=Ze),Z(this,Pa).call(this)}}_r=new WeakMap,Hr=new WeakMap,Bi=new WeakMap,bs=new WeakMap,Ca=new WeakMap,Pa=new WeakMap,Yh=new WeakMap;function Ii(r,e,...t){var i=new Eu(r);Fo(()=>{const n=e()??null;i.ensure(n,n&&(s=>n(s,...t)))},kn)}function U1(r){dt===null&&Lf(),Mo&&dt.l!==null?H1(dt).m.push(r):Ri(()=>{const e=Ho(r);if(typeof e=="function")return e})}function H1(r){var e=r.l;return e.u??(e.u={a:[],b:[],m:[]})}function ie(r,e,t=!1){Xe&&Vn();var i=new Eu(r),n=t?kn:0;function s(o,a){if(Xe){const h=Nf(r)===$a;if(o===h){var l=al();ni(l),i.anchor=l,rr(!1),i.ensure(o,a),rr(!0);return}}i.ensure(o,a)}Fo(()=>{var o=!1;e((a,l=!0)=>{o=!0,s(l,a)}),o||s(!1,null)},n)}function G1(r,e,t){Xe&&Vn();var i=new Eu(r),n=!Is();Fo(()=>{var s=e();n&&s!==null&&typeof s=="object"&&(s={}),i.ensure(s,t)})}function ml(r,e){return e}function V1(r,e,t){for(var i=[],n=e.length,s,o=e.length,a=0;a<n;a++){let c=e[a];Xn(c,()=>{if(s){if(s.pending.delete(c),s.done.add(c),s.pending.size===0){var d=r.outrogroups;Tu(el(s.done)),d.delete(s),d.size===0&&(r.outrogroups=null)}}else o-=1},!1)}if(o===0){var l=i.length===0&&t!==null;if(l){var h=t,u=h.parentNode;ip(u),u.append(h),r.items.clear()}Tu(e,!l)}else s={pending:new Set(e),done:new Set},(r.outrogroups??(r.outrogroups=new Set)).add(s)}function Tu(r,e=!0){for(var t=0;t<r.length;t++)zt(r[t],e)}var Ip;function vl(r,e,t,i,n,s=null){var o=r,a=new Map,l=(e&Po)!==0;if(l){var h=r;o=Xe?ni(si(h)):h.appendChild(xi())}Xe&&Vn();var u=null,c=Wf(()=>{var v=t();return ru(v)?v:v==null?[]:el(v)}),d,f=!0;function g(){m.fallback=u,z1(m,d,o,e,i),u!==null&&(d.length===0?(u.f&Xr)===0?vu(u):(u.f^=Xr,Vo(u,null,o)):Xn(u,()=>{u=null}))}var p=Fo(()=>{d=P(c);var v=d.length;let y=!1;if(Xe){var _=Nf(o)===$a;_!==(v===0)&&(o=al(),ni(o),rr(!1),y=!0)}for(var w=new Set,A=Qe,F=rp(),C=0;C<v;C+=1){Xe&&Ze.nodeType===Gn&&Ze.data===tu&&(o=Ze,y=!0,rr(!1));var R=d[C],M=i(R,C),k=f?null:a.get(M);k?(k.v&&Ds(k.v,R),k.i&&Ds(k.i,C),F&&A.skipped_effects.delete(k.e)):(k=j1(a,f?o:Ip??(Ip=xi()),R,M,C,n,e,t),f||(k.e.f|=Xr),a.set(M,k)),w.add(M)}if(v===0&&s&&!u&&(f?u=wi(()=>s(o)):(u=wi(()=>s(Ip??(Ip=xi()))),u.f|=Xr)),Xe&&v>0&&ni(al()),!f)if(F){for(const[z,D]of a)w.has(z)||A.skipped_effects.add(D.e);A.oncommit(g),A.ondiscard(()=>{})}else g();y&&rr(!0),P(c)}),m={effect:p,items:a,outrogroups:null,fallback:u};f=!1,Xe&&(o=Ze)}function z1(r,e,t,i,n){var k,z,D,S,b,O,j,V,Y;var s=(i&I_)!==0,o=e.length,a=r.items,l=r.effect.first,h,u=null,c,d=[],f=[],g,p,m,v;if(s)for(v=0;v<o;v+=1)g=e[v],p=n(g,v),m=a.get(p).e,(m.f&Xr)===0&&((z=(k=m.nodes)==null?void 0:k.a)==null||z.measure(),(c??(c=new Set)).add(m));for(v=0;v<o;v+=1){if(g=e[v],p=n(g,v),m=a.get(p).e,r.outrogroups!==null)for(const G of r.outrogroups)G.pending.delete(m),G.done.delete(m);if((m.f&Xr)!==0)if(m.f^=Xr,m===l)Vo(m,null,t);else{var y=u?u.next:l;m===r.effect.last&&(r.effect.last=m.prev),m.prev&&(m.prev.next=m.next),m.next&&(m.next.prev=m.prev),dn(r,u,m),dn(r,m,y),Vo(m,y,t),u=m,d=[],f=[],l=u.next;continue}if((m.f&Si)!==0&&(vu(m),s&&((S=(D=m.nodes)==null?void 0:D.a)==null||S.unfix(),(c??(c=new Set)).delete(m))),m!==l){if(h!==void 0&&h.has(m)){if(d.length<f.length){var _=f[0],w;u=_.prev;var A=d[0],F=d[d.length-1];for(w=0;w<d.length;w+=1)Vo(d[w],_,t);for(w=0;w<f.length;w+=1)h.delete(f[w]);dn(r,A.prev,F.next),dn(r,u,A),dn(r,F,_),l=_,u=F,v-=1,d=[],f=[]}else h.delete(m),Vo(m,l,t),dn(r,m.prev,m.next),dn(r,m,u===null?r.effect.first:u.next),dn(r,u,m),u=m;continue}for(d=[],f=[];l!==null&&l!==m;)(h??(h=new Set)).add(l),f.push(l),l=l.next;if(l===null)continue}(m.f&Xr)===0&&d.push(m),u=m,l=m.next}if(r.outrogroups!==null){for(const G of r.outrogroups)G.pending.size===0&&(Tu(el(G.done)),(b=r.outrogroups)==null||b.delete(G));r.outrogroups.size===0&&(r.outrogroups=null)}if(l!==null||h!==void 0){var C=[];if(h!==void 0)for(m of h)(m.f&Si)===0&&C.push(m);for(;l!==null;)(l.f&Si)===0&&l!==r.fallback&&C.push(l),l=l.next;var R=C.length;if(R>0){var M=(i&Po)!==0&&o===0?t:null;if(s){for(v=0;v<R;v+=1)(j=(O=C[v].nodes)==null?void 0:O.a)==null||j.measure();for(v=0;v<R;v+=1)(Y=(V=C[v].nodes)==null?void 0:V.a)==null||Y.fix()}V1(r,C,M)}}s&&hn(()=>{var G,H;if(c!==void 0)for(m of c)(H=(G=m.nodes)==null?void 0:G.a)==null||H.apply()})}function j1(r,e,t,i,n,s,o,a){var l=(o&yt)!==0?(o&M_)===0?qf(t,!1,!1):Wn(t):null,h=(o&Ht)!==0?Wn(n):null;return{v:l,i:h,e:wi(()=>(s(e,l??t,h??n,a),()=>{r.delete(i)}))}}function Vo(r,e,t){if(r.nodes)for(var i=r.nodes.start,n=r.nodes.end,s=e&&(e.f&Xr)===0?e.nodes.start:t;i!==null;){var o=sr(i);if(s.before(i),i===n)return;i=o}}function dn(r,e,t){e===null?r.effect.first=t:e.next=t,t===null?r.effect.last=e:t.prev=e}function Qn(r,e,t=!1,i=!1,n=!1){var s=r,o="";Lt(()=>{var a=st;if(o===(o=e()??"")){Xe&&Vn();return}if(a.nodes!==null&&(cp(a.nodes.start,a.nodes.end),a.nodes=null),o!==""){if(Xe){Ze.data;for(var l=Vn(),h=l;l!==null&&(l.nodeType!==Gn||l.data!=="");)h=l,l=sr(l);if(l===null)throw Io(),Bn;Pi(Ze,h),s=ni(l);return}var u=o+"";t?u=`<svg>${u}</svg>`:i&&(u=`<math>${u}</math>`);var c=xu(u);if((t||i)&&(c=si(c)),Pi(si(c),c.lastChild),t||i)for(;si(c);)s.before(si(c));else s.before(c)}})}function W1(r,e){var t=void 0,i;lp(()=>{t!==(t=e())&&(i&&(zt(i),i=null),t&&(i=wi(()=>{mu(()=>t(r))})))})}function Mp(r){var e,t,i="";if(typeof r=="string"||typeof r=="number")i+=r;else if(typeof r=="object")if(Array.isArray(r)){var n=r.length;for(e=0;e<n;e++)r[e]&&(t=Mp(r[e]))&&(i&&(i+=" "),i+=t)}else for(t in r)r[t]&&(i&&(i+=" "),i+=t);return i}function X1(){for(var r,e,t=0,i="",n=arguments.length;t<n;t++)(r=arguments[t])&&(e=Mp(r))&&(i&&(i+=" "),i+=e);return i}function bu(r){return typeof r=="object"?X1(r):r??""}const Dp=[...`
|
|
3
|
+
\r\f \v\uFEFF`];function Y1(r,e,t){var i=r==null?"":""+r;if(t){for(var n in t)if(t[n])i=i?i+" "+n:n;else if(i.length)for(var s=n.length,o=0;(o=i.indexOf(n,o))>=0;){var a=o+s;(o===0||Dp.includes(i[o-1]))&&(a===i.length||Dp.includes(i[a]))?i=(o===0?"":i.substring(0,o))+i.substring(a+1):o=a}}return i===""?null:i}function Op(r,e=!1){var t=e?" !important;":";",i="";for(var n in r){var s=r[n];s!=null&&s!==""&&(i+=" "+n+": "+s+t)}return i}function Au(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function Z1(r,e){if(e){var t="",i,n;if(Array.isArray(e)?(i=e[0],n=e[1]):i=e,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var s=!1,o=0,a=!1,l=[];i&&l.push(...Object.keys(i).map(Au)),n&&l.push(...Object.keys(n).map(Au));var h=0,u=-1;const p=r.length;for(var c=0;c<p;c++){var d=r[c];if(a?d==="/"&&r[c-1]==="*"&&(a=!1):s?s===d&&(s=!1):d==="/"&&r[c+1]==="*"?a=!0:d==='"'||d==="'"?s=d:d==="("?o++:d===")"&&o--,!a&&s===!1&&o===0){if(d===":"&&u===-1)u=c;else if(d===";"||c===p-1){if(u!==-1){var f=Au(r.substring(h,u).trim());if(!l.includes(f)){d!==";"&&c++;var g=r.substring(h,c).trim();t+=" "+g+";"}}h=c+1,u=-1}}}}return i&&(t+=Op(i)),n&&(t+=Op(n,!0)),t=t.trim(),t===""?null:t}return r==null?null:String(r)}function Nt(r,e,t,i,n,s){var o=r.__className;if(Xe||o!==t||o===void 0){var a=Y1(t,i,s);(!Xe||a!==r.getAttribute("class"))&&(a==null?r.removeAttribute("class"):e?r.className=a:r.setAttribute("class",a)),r.__className=t}else if(s&&n!==s)for(var l in s){var h=!!s[l];(n==null||h!==!!n[l])&&r.classList.toggle(l,h)}return s}function Su(r,e={},t,i){for(var n in t){var s=t[n];e[n]!==s&&(t[n]==null?r.style.removeProperty(n):r.style.setProperty(n,s,i))}}function yl(r,e,t,i){var n=r.__style;if(Xe||n!==e){var s=Z1(e,i);(!Xe||s!==r.getAttribute("style"))&&(s==null?r.removeAttribute("style"):r.style.cssText=s),r.__style=e}else i&&(Array.isArray(i)?(Su(r,t==null?void 0:t[0],i[0]),Su(r,t==null?void 0:t[1],i[1],"important")):Su(r,t,i));return i}function Ru(r,e,t=!1){if(r.multiple){if(e==null)return;if(!ru(e))return Q_();for(var i of r.options)i.selected=e.includes(Lp(i));return}for(i of r.options){var n=Lp(i);if(g1(n,e)){i.selected=!0;return}}(!t||e!==void 0)&&(r.selectedIndex=-1)}function q1(r){var e=new MutationObserver(()=>{Ru(r,r.__value)});e.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),gu(()=>{e.disconnect()})}function Lp(r){return"__value"in r?r.__value:r.value}const zo=Symbol("class"),jo=Symbol("style"),Np=Symbol("is custom element"),Fp=Symbol("is html");function Bp(r){if(Xe){var e=!1,t=()=>{if(!e){if(e=!0,r.hasAttribute("value")){var i=r.value;Mi(r,"value",null),r.value=i}if(r.hasAttribute("checked")){var n=r.checked;Mi(r,"checked",null),r.checked=n}}};r.__on_r=t,hn(t),sp()}}function K1(r,e){e?r.hasAttribute("selected")||r.setAttribute("selected",""):r.removeAttribute("selected")}function Mi(r,e,t,i){var n=kp(r);Xe&&(n[e]=r.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&r.nodeName==="LINK")||n[e]!==(n[e]=t)&&(e==="loading"&&(r[H_]=t),t==null?r.removeAttribute(e):typeof t!="string"&&Hp(r).includes(e)?r[e]=t:r.setAttribute(e,t))}function Q1(r,e,t,i,n=!1,s=!1){if(Xe&&n&&r.tagName==="INPUT"){var o=r,a=o.type==="checkbox"?"defaultChecked":"defaultValue";a in t||Bp(o)}var l=kp(r),h=l[Np],u=!l[Fp];let c=Xe&&h;c&&rr(!1);var d=e||{},f=r.tagName==="OPTION";for(var g in e)g in t||(t[g]=null);t.class?t.class=bu(t.class):t[zo]&&(t.class=null),t[jo]&&(t.style??(t.style=null));var p=Hp(r);for(const F in t){let C=t[F];if(f&&F==="value"&&C==null){r.value=r.__value="",d[F]=C;continue}if(F==="class"){var m=r.namespaceURI==="http://www.w3.org/1999/xhtml";Nt(r,m,C,i,e==null?void 0:e[zo],t[zo]),d[F]=C,d[zo]=t[zo];continue}if(F==="style"){yl(r,C,e==null?void 0:e[jo],t[jo]),d[F]=C,d[jo]=t[jo];continue}var v=d[F];if(!(C===v&&!(C===void 0&&r.hasAttribute(F)))){d[F]=C;var y=F[0]+F[1];if(y!=="$$")if(y==="on"){const R={},M="$$"+F;let k=F.slice(2);var _=D1(k);if(I1(k)&&(k=k.slice(0,-7),R.capture=!0),!_&&v){if(C!=null)continue;r.removeEventListener(k,d[M],R),d[M]=null}if(C!=null)if(_)r[`__${k}`]=C,Kn([k]);else{let z=function(D){d[F].call(this,D)};d[M]=Sp(k,r,z,R)}else _&&(r[`__${k}`]=void 0)}else if(F==="style")Mi(r,F,C);else if(F==="autofocus")m1(r,!!C);else if(!h&&(F==="__value"||F==="value"&&C!=null))r.value=r.__value=C;else if(F==="selected"&&f)K1(r,C);else{var w=F;u||(w=L1(w));var A=w==="defaultValue"||w==="defaultChecked";if(C==null&&!h&&!A)if(l[F]=null,w==="value"||w==="checked"){let R=r;const M=e===void 0;if(w==="value"){let k=R.defaultValue;R.removeAttribute(w),R.defaultValue=k,R.value=R.__value=M?k:null}else{let k=R.defaultChecked;R.removeAttribute(w),R.defaultChecked=k,R.checked=M?k:!1}}else r.removeAttribute(F);else A||p.includes(w)&&(h||typeof C!="string")?(r[w]=C,w in l&&(l[w]=Qt)):typeof C!="function"&&Mi(r,w,C)}}}return c&&rr(!0),d}function Di(r,e,t=[],i=[],n=[],s,o=!1,a=!1){jf(n,t,i,l=>{var h=void 0,u={},c=r.nodeName==="SELECT",d=!1;if(lp(()=>{var g=e(...l.map(P)),p=Q1(r,h,g,s,o,a);d&&c&&"value"in g&&Ru(r,g.value);for(let v of Object.getOwnPropertySymbols(u))g[v]||zt(u[v]);for(let v of Object.getOwnPropertySymbols(g)){var m=g[v];v.description===L_&&(!h||m!==h[v])&&(u[v]&&zt(u[v]),u[v]=wi(()=>W1(r,()=>m))),p[v]=m}h=p}),c){var f=r;mu(()=>{Ru(f,h.value,!0),q1(f)})}d=!0})}function kp(r){return r.__attributes??(r.__attributes={[Np]:r.nodeName.includes("-"),[Fp]:r.namespaceURI===O_})}var Up=new Map;function Hp(r){var e=r.getAttribute("is")||r.nodeName,t=Up.get(e);if(t)return t;Up.set(e,t=[]);for(var i,n=r,s=Element.prototype;s!==n;){i=Rf(n);for(var o in i)i[o].set&&t.push(o);n=nu(n)}return t}function J1(r,e,t=e){var i=new WeakSet;v1(r,"input",async n=>{var s=n?r.defaultValue:r.value;if(s=Cu(r)?Pu(s):s,t(s),Qe!==null&&i.add(Qe),await S1(),s!==(s=e())){var o=r.selectionStart,a=r.selectionEnd,l=r.value.length;if(r.value=s??"",a!==null){var h=r.value.length;o===a&&a===l&&h>l?(r.selectionStart=h,r.selectionEnd=h):(r.selectionStart=o,r.selectionEnd=Math.min(a,h))}}}),(Xe&&r.defaultValue!==r.value||Ho(e)==null&&r.value)&&(t(Cu(r)?Pu(r.value):r.value),Qe!==null&&i.add(Qe)),fl(()=>{var n=e();if(r===document.activeElement){var s=hl??Qe;if(i.has(s))return}Cu(r)&&n===Pu(r.value)||r.type==="date"&&!n&&!r.value||n!==r.value&&(r.value=n??"")})}function Cu(r){var e=r.type;return e==="number"||e==="range"}function Pu(r){return r===""?null:+r}function Gp(r,e){return r===e||(r==null?void 0:r[ln])===e}function Vp(r={},e,t,i){return mu(()=>{var n,s;return fl(()=>{n=s,s=[],Ho(()=>{r!==t(...s)&&(e(r,...s),n&&Gp(t(...n),r)&&e(null,...n))})}),()=>{hn(()=>{s&&Gp(t(...s),r)&&e(null,...s)})}}),r}function $1(r=!1){const e=dt,t=e.l.u;if(!t)return;let i=()=>C1(e.s);if(r){let n=0,s={};const o=Oo(()=>{let a=!1;const l=e.s;for(const h in l)l[h]!==s[h]&&(s[h]=l[h],a=!0);return a&&n++,n});i=()=>P(o)}t.b.length&&_1(()=>{zp(e,i),su(t.b)}),Ri(()=>{const n=Ho(()=>t.m.map(k_));return()=>{for(const s of n)typeof s=="function"&&s()}}),t.a.length&&Ri(()=>{zp(e,i),su(t.a)})}function zp(r,e){if(r.l.s)for(const t of r.l.s)P(t);e()}const ex={get(r,e){if(!r.exclude.includes(e))return r.props[e]},set(r,e){return!1},getOwnPropertyDescriptor(r,e){if(!r.exclude.includes(e)&&e in r.props)return{enumerable:!0,configurable:!0,value:r.props[e]}},has(r,e){return r.exclude.includes(e)?!1:e in r.props},ownKeys(r){return Reflect.ownKeys(r.props).filter(e=>!r.exclude.includes(e))}};function Oi(r,e,t){return new Proxy({props:r,exclude:e},ex)}function tx(r,e,t,i){var n=i,s=!0,o=()=>(s&&(s=!1,n=i),n),a;a=r[e],a===void 0&&i!==void 0&&(a=o());var l;l=()=>{var d=r[e];return d===void 0?o():(s=!0,d)};var h=!1,u=Oo(()=>(h=!1,l())),c=st;return(function(d,f){if(arguments.length>0){const g=f?P(u):d;return Me(u,g),h=!0,n!==void 0&&(n=g),d}return Zn&&h||(c.f&Wr)!==0?u.v:P(u)})}function ix(r){return new rx(r)}class rx{constructor(e){Ie(this,sn);Ie(this,tr);var s;var t=new Map,i=(o,a)=>{var l=qf(a,!1,!1);return t.set(o,l),l};const n=new Proxy({...e.props||{},$$events:{}},{get(o,a){return P(t.get(a)??i(a,Reflect.get(o,a)))},has(o,a){return a===U_?!0:(P(t.get(a)??i(a,Reflect.get(o,a))),Reflect.has(o,a))},set(o,a,l){return Me(t.get(a)??i(a,l),l),Reflect.set(o,a,l)}});Ve(this,tr,(e.hydrate?B1:Cp)(e.component,{target:e.target,anchor:e.anchor,props:n,context:e.context,intro:e.intro??!1,recover:e.recover})),(!((s=e==null?void 0:e.props)!=null&&s.$$host)||e.sync===!1)&&cu(),Ve(this,sn,n.$$events);for(const o of Object.keys(Z(this,tr)))o==="$set"||o==="$destroy"||o==="$on"||il(this,o,{get(){return Z(this,tr)[o]},set(a){Z(this,tr)[o]=a},enumerable:!0});Z(this,tr).$set=o=>{Object.assign(n,o)},Z(this,tr).$destroy=()=>{k1(Z(this,tr))}}$set(e){Z(this,tr).$set(e)}$on(e,t){Z(this,sn)[e]=Z(this,sn)[e]||[];const i=(...n)=>t.call(this,...n);return Z(this,sn)[e].push(i),()=>{Z(this,sn)[e]=Z(this,sn)[e].filter(n=>n!==i)}}$destroy(){Z(this,tr).$destroy()}}sn=new WeakMap,tr=new WeakMap;let jp;typeof HTMLElement=="function"&&(jp=class extends HTMLElement{constructor(e,t,i){super();Ut(this,"$$ctor");Ut(this,"$$s");Ut(this,"$$c");Ut(this,"$$cn",!1);Ut(this,"$$d",{});Ut(this,"$$r",!1);Ut(this,"$$p_d",{});Ut(this,"$$l",{});Ut(this,"$$l_u",new Map);Ut(this,"$$me");this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const n=this.$$c.$on(e,t);this.$$l_u.set(t,n)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const n=this.$$l_u.get(t);n&&(n(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(n){return s=>{const o=document.createElement("slot");n!=="default"&&(o.name=n),U(s,o)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nx(this);for(const n of this.$$s)n in i&&(n==="default"&&!this.$$d.children?(this.$$d.children=e(n),t.default=!0):t[n]=e(n));for(const n of this.attributes){const s=this.$$g_p(n.name);s in this.$$d||(this.$$d[s]=_l(s,n.value,this.$$p_d,"toProp"))}for(const n in this.$$p_d)!(n in this.$$d)&&this[n]!==void 0&&(this.$$d[n]=this[n],delete this[n]);this.$$c=ix({component:this.$$ctor,target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=x1(()=>{fl(()=>{var n;this.$$r=!0;for(const s of tl(this.$$c)){if(!((n=this.$$p_d[s])!=null&&n.reflect))continue;this.$$d[s]=this.$$c[s];const o=_l(s,this.$$d[s],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,o)}this.$$r=!1})});for(const n in this.$$l)for(const s of this.$$l[n]){const o=this.$$c.$on(n,s);this.$$l_u.set(s,o)}this.$$l={}}}attributeChangedCallback(e,t,i){var n;this.$$r||(e=this.$$g_p(e),this.$$d[e]=_l(e,i,this.$$p_d,"toProp"),(n=this.$$c)==null||n.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return tl(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function _l(r,e,t,i){var s;const n=(s=t[r])==null?void 0:s.type;if(e=n==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(n){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(n){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function nx(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}function sx(r,e,t,i,n,s){let o=class extends jp{constructor(){super(r,t,n),this.$$p_d=e}static get observedAttributes(){return tl(e).map(a=>(e[a].attribute||a).toLowerCase())}};return tl(e).forEach(a=>{il(o.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(l){var c;l=_l(a,l,e),this.$$d[a]=l;var h=this.$$c;if(h){var u=(c=Ss(h,a))==null?void 0:c.get;u?h[a]=l:h.$set({[a]:l})}}})}),i.forEach(a=>{il(o.prototype,a,{get(){var l;return(l=this.$$c)==null?void 0:l[a]}})}),r.element=o,o}var Wp=(function(){function r(e){this.__jsonld=e,this.context=this.getProperty("context"),this.id=this.getProperty("id")}return r.prototype.getProperty=function(e){var t=null;return this.__jsonld&&(t=this.__jsonld[e],t||(t=this.__jsonld["@"+e])),t},r})(),xl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Iu(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function ox(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var e=r.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}var Tt={},Xp;function ax(){if(Xp)return Tt;Xp=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.ViewingHint=Tt.ViewingDirection=Tt.ServiceType=Tt.ServiceProfile=Tt.RenderingFormat=Tt.MediaType=Tt.IIIFResourceType=Tt.ExternalResourceType=Tt.Behavior=Tt.AnnotationMotivation=void 0;var r;(function(u){u.BOOKMARKING="oa:bookmarking",u.CLASSIFYING="oa:classifying",u.COMMENTING="oa:commenting",u.DESCRIBING="oa:describing",u.EDITING="oa:editing",u.HIGHLIGHTING="oa:highlighting",u.IDENTIFYING="oa:identifying",u.LINKING="oa:linking",u.MODERATING="oa:moderating",u.PAINTING="sc:painting",u.QUESTIONING="oa:questioning",u.REPLYING="oa:replying",u.TAGGING="oa:tagging",u.TRANSCRIBING="oad:transcribing"})(r||(Tt.AnnotationMotivation=r={}));var e;(function(u){u.AUTO_ADVANCE="auto-advance",u.CONTINUOUS="continuous",u.FACING_PAGES="facing-pages",u.HIDDEN="hidden",u.INDIVIDUALS="individuals",u.MULTI_PART="multi-part",u.NO_NAV="no-nav",u.NON_PAGED="non-paged",u.PAGED="paged",u.REPEAT="repeat",u.SEQUENCE="sequence",u.THUMBNAIL_NAV="thumbnail-nav",u.TOGETHER="together",u.UNORDERED="unordered"})(e||(Tt.Behavior=e={}));var t;(function(u){u.CANVAS="canvas",u.CHOICE="choice",u.OA_CHOICE="oa:choice",u.CONTENT_AS_TEXT="contentastext",u.DATASET="dataset",u.DOCUMENT="document",u.IMAGE="image",u.MODEL="model",u.MOVING_IMAGE="movingimage",u.PDF="pdf",u.PHYSICAL_OBJECT="physicalobject",u.SOUND="sound",u.TEXT="text",u.TEXTUALBODY="textualbody",u.VIDEO="video"})(t||(Tt.ExternalResourceType=t={}));var i;(function(u){u.ANNOTATION="annotation",u.ANNOTATION_COLLECTION="annotationcollection",u.ANNOTATION_PAGE="annotationpage",u.CANVAS="canvas",u.COLLECTION="collection",u.MANIFEST="manifest",u.RANGE="range",u.SEQUENCE="sequence"})(i||(Tt.IIIFResourceType=i={}));var n;(function(u){u.APNG="image/apng",u.AUDIO_MP4="audio/mp4",u.AUDIO_OGG="audio/ogg",u.AVIF="audio/avif",u.CORTO="application/corto",u.DICOM="application/dicom",u.DRACO="application/draco",u.EPUB="application/epub+zip",u.GIF="image/gif",u.GIRDER="image/vnd.kitware.girder",u.GLB="model/gltf-binary",u.GLTF="model/gltf+json",u.IIIF_PRESENTATION_2='application/ld+json;profile="http://iiif.io/api/presentation/2/context.json"',u.IIIF_PRESENTATION_3='application/ld+json;profile="http://iiif.io/api/presentation/3/context.json"',u.JPG="image/jpeg",u.M3U8="application/vnd.apple.mpegurl",u.MP3="audio/mp3",u.MPEG="audio/mpeg",u.MPEG_DASH="application/dash+xml",u.OBJ="model/obj",u.OPF="application/oebps-package+xml",u.PDF="application/pdf",u.PLY="application/ply",u.PNG="image/png",u.SVG="image/svg+xml",u.THREEJS="application/vnd.threejs+json",u.USDZ="model/vnd.usd+zip",u.VIDEO_MP4="video/mp4",u.VIDEO_OGG="video/ogg",u.WAV="audio/wav",u.WEBM="video/webm",u.WEBP="image/webp"})(n||(Tt.MediaType=n={}));var s;(function(u){u.DOC="application/msword",u.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",u.ODT="application/vnd.oasis.opendocument.text",u.PDF="application/pdf"})(s||(Tt.RenderingFormat=s={}));var o;(function(u){u.IMAGE_0_COMPLIANCE_LEVEL_0="http://library.stanford.edu/iiif/image-api/compliance.html#level0",u.IMAGE_0_COMPLIANCE_LEVEL_1="http://library.stanford.edu/iiif/image-api/compliance.html#level1",u.IMAGE_0_COMPLIANCE_LEVEL_2="http://library.stanford.edu/iiif/image-api/compliance.html#level2",u.IMAGE_0_CONFORMANCE_LEVEL_0="http://library.stanford.edu/iiif/image-api/conformance.html#level0",u.IMAGE_0_CONFORMANCE_LEVEL_1="http://library.stanford.edu/iiif/image-api/conformance.html#level1",u.IMAGE_0_CONFORMANCE_LEVEL_2="http://library.stanford.edu/iiif/image-api/conformance.html#level2",u.IMAGE_1_COMPLIANCE_LEVEL_0="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0",u.IMAGE_1_COMPLIANCE_LEVEL_1="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1",u.IMAGE_1_COMPLIANCE_LEVEL_2="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2",u.IMAGE_1_CONFORMANCE_LEVEL_0="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0",u.IMAGE_1_CONFORMANCE_LEVEL_1="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1",u.IMAGE_1_CONFORMANCE_LEVEL_2="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2",u.IMAGE_1_LEVEL_0="http://iiif.io/api/image/1/level0.json",u.IMAGE_1_PROFILE_LEVEL_0="http://iiif.io/api/image/1/profiles/level0.json",u.IMAGE_1_LEVEL_1="http://iiif.io/api/image/1/level1.json",u.IMAGE_1_PROFILE_LEVEL_1="http://iiif.io/api/image/1/profiles/level1.json",u.IMAGE_1_LEVEL_2="http://iiif.io/api/image/1/level2.json",u.IMAGE_1_PROFILE_LEVEL_2="http://iiif.io/api/image/1/profiles/level2.json",u.IMAGE_2_LEVEL_0="http://iiif.io/api/image/2/level0.json",u.IMAGE_2_PROFILE_LEVEL_0="http://iiif.io/api/image/2/profiles/level0.json",u.IMAGE_2_LEVEL_1="http://iiif.io/api/image/2/level1.json",u.IMAGE_2_PROFILE_LEVEL_1="http://iiif.io/api/image/2/profiles/level1.json",u.IMAGE_2_LEVEL_2="http://iiif.io/api/image/2/level2.json",u.IMAGE_2_PROFILE_LEVEL_2="http://iiif.io/api/image/2/profiles/level2.json",u.AUTH_0_CLICK_THROUGH="http://iiif.io/api/auth/0/login/clickthrough",u.AUTH_0_LOGIN="http://iiif.io/api/auth/0/login",u.AUTH_0_LOGOUT="http://iiif.io/api/auth/0/logout",u.AUTH_0_RESTRICTED="http://iiif.io/api/auth/0/login/restricted",u.AUTH_0_TOKEN="http://iiif.io/api/auth/0/token",u.AUTH_1_CLICK_THROUGH="http://iiif.io/api/auth/1/clickthrough",u.AUTH_1_EXTERNAL="http://iiif.io/api/auth/1/external",u.AUTH_1_KIOSK="http://iiif.io/api/auth/1/kiosk",u.AUTH_1_LOGIN="http://iiif.io/api/auth/1/login",u.AUTH_1_LOGOUT="http://iiif.io/api/auth/1/logout",u.AUTH_1_PROBE="http://iiif.io/api/auth/1/probe",u.AUTH_1_TOKEN="http://iiif.io/api/auth/1/token",u.SEARCH_0="http://iiif.io/api/search/0/search",u.SEARCH_0_AUTO_COMPLETE="http://iiif.io/api/search/0/autocomplete",u.SEARCH_1="http://iiif.io/api/search/1/search",u.SEARCH_1_AUTO_COMPLETE="http://iiif.io/api/search/1/autocomplete",u.SEARCH_2="http://iiif.io/api/search/2/search",u.SEARCH_2_AUTO_COMPLETE="http://iiif.io/api/search/2/autocomplete",u.TRACKING_EXTENSIONS="http://universalviewer.io/tracking-extensions-profile",u.UI_EXTENSIONS="http://universalviewer.io/ui-extensions-profile",u.PRINT_EXTENSIONS="http://universalviewer.io/print-extensions-profile",u.SHARE_EXTENSIONS="http://universalviewer.io/share-extensions-profile",u.DOWNLOAD_EXTENSIONS="http://universalviewer.io/download-extensions-profile",u.OTHER_MANIFESTATIONS="http://iiif.io/api/otherManifestations.json",u.IXIF="http://wellcomelibrary.org/ld/ixif/0/alpha.json"})(o||(Tt.ServiceProfile=o={}));var a;(function(u){u.IMAGE_SERVICE_2="ImageService2",u.IMAGE_SERVICE_3="ImageService3",u.SEARCH_SERVICE_2="SearchService2",u.AUTO_COMPLETE_SERVICE_2="AutoCompleteService2"})(a||(Tt.ServiceType=a={}));var l;(function(u){u.BOTTOM_TO_TOP="bottom-to-top",u.LEFT_TO_RIGHT="left-to-right",u.RIGHT_TO_LEFT="right-to-left",u.TOP_TO_BOTTOM="top-to-bottom"})(l||(Tt.ViewingDirection=l={}));var h;return(function(u){u.CONTINUOUS="continuous",u.INDIVIDUALS="individuals",u.NON_PAGED="non-paged",u.PAGED="paged",u.TOP="top"})(h||(Tt.ViewingHint=h={})),Tt}var fe=ax(),lx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Yr=(function(r){lx(e,r);function e(t,i){var n=r.call(this,t)||this;return n.options=i,n}return e.prototype.getIIIFResourceType=function(){return Ke.normaliseType(this.getProperty("type"))},e.prototype.getLabel=function(){var t=this.getProperty("label");return t?ji.parse(t,this.options.locale):new ji([],this.options.locale)},e.prototype.getDefaultLabel=function(){return this.getLabel().getValue(this.options.locale)},e.prototype.getMetadata=function(){var t=this.getProperty("metadata"),i=[];if(!t)return i;for(var n=0;n<t.length;n++){var s=t[n],o=new bl(this.options.locale);o.parse(s),i.push(o)}return i},e.prototype.getRendering=function(t){for(var i=this.getRenderings(),n=0;n<i.length;n++){var s=i[n];if(s.getFormat()===t)return s}return null},e.prototype.getRenderings=function(){var t;this.__jsonld?t=this.__jsonld.rendering:t=this.rendering;var i=[];if(!t)return i;Array.isArray(t)||(t=[t]);for(var n=0;n<t.length;n++){var s=t[n];i.push(new zx(s,this.options))}return i},e.prototype.getRequiredStatement=function(){var t=null,i=this.getProperty("requiredStatement");return i&&(t=new bl(this.options.locale),t.parse(i)),t},e.prototype.getService=function(t){return Ke.getService(this,t)},e.prototype.getServices=function(){return Ke.getServices(this)},e.prototype.getThumbnail=function(){var t=this.getProperty("thumbnail");return Array.isArray(t)&&(t=t[0]),t?new qx(t,this.options):null},e.prototype.isAnnotation=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.ANNOTATION},e.prototype.isCanvas=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.CANVAS},e.prototype.isCollection=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.COLLECTION},e.prototype.isManifest=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.MANIFEST},e.prototype.isRange=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.RANGE},e.prototype.isSequence=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.SEQUENCE},e})(Wp),hx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Mu=(function(r){hx(e,r);function e(t,i){return r.call(this,t,i)||this}return e.prototype.getFormat=function(){var t=this.getProperty("format");return t?t.toLowerCase():null},e.prototype.getResources=function(){var t=[];if(!this.__jsonld.resources)return t;for(var i=0;i<this.__jsonld.resources.length;i++){var n=this.__jsonld.resources[i],s=new wl(n,this.options);t.push(s)}return t},e.prototype.getType=function(){var t=this.getProperty("type");return t?Ke.normaliseType(t):null},e.prototype.getWidth=function(){return this.getProperty("width")},e.prototype.getHeight=function(){return this.getProperty("height")},e.prototype.getMaxWidth=function(){return this.getProperty("maxWidth")},e.prototype.getMaxHeight=function(){var t=this.getProperty("maxHeight");return t?null:this.getMaxWidth()},e})(Yr),ux=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Yp=(function(r){ux(e,r);function e(t,i){var n=r.call(this,t,i)||this;n.index=-1,n.isLoaded=!1;var s={defaultLabel:"-",locale:"en-GB",resource:n,pessimisticAccessControl:!1};return n.options=Object.assign(s,i),n}return e.prototype.getAttribution=function(){var t=this.getProperty("attribution");return t?ji.parse(t,this.options.locale):new ji([],this.options.locale)},e.prototype.getDescription=function(){var t=this.getProperty("description");return t===void 0&&(t=this.getProperty("summary")),t?ji.parse(t,this.options.locale):new ji([],this.options.locale)},e.prototype.getSummary=function(){var t=this.getProperty("summary");return t===void 0&&(t=this.getProperty("description")),t?ji.parse(t,this.options.locale):new ji([],this.options.locale)},e.prototype.getHomepage=function(){var t=this.getProperty("homepage");return t?typeof t=="string"?t:(Array.isArray(t)&&t.length&&(t=t[0]),t["@id"]||t.id):null},e.prototype.getIIIFResourceType=function(){return Ke.normaliseType(this.getProperty("type"))},e.prototype.getLogo=function(){var t=this.getProperty("logo");if(!t){var i=this.getProperty("provider");if(!i)return null;var n=i.find(function(s){return s.logo!==void 0});n&&n.logo!==void 0?t=n.logo:t=null}return t?typeof t=="string"?t:(Array.isArray(t)&&t.length&&(t=t[0]),t["@id"]||(t==null?void 0:t.id)):null},e.prototype.getLicense=function(){return Ke.getLocalisedValue(this.getProperty("license"),this.options.locale)},e.prototype.getRights=function(){var t=this.getProperty("rights");return t?typeof t=="string"?t:(Array.isArray(t)&&t.length&&(t=t[0]),t["@id"]||t.id):null},e.prototype.getNavDate=function(){return new Date(this.getProperty("navDate"))},e.prototype.getRelated=function(){return this.getProperty("related")},e.prototype.getSeeAlso=function(){return this.getProperty("seeAlso")},e.prototype.getTrackingLabel=function(){var t=this.getService(fe.ServiceProfile.TRACKING_EXTENSIONS);return t?t.getProperty("trackingLabel"):""},e.prototype.getDefaultTree=function(){return this.defaultTree=new ec("root"),this.defaultTree.data=this,this.defaultTree},e.prototype.getRequiredStatement=function(){var t=null,i=this.getProperty("requiredStatement");if(i)t=new bl(this.options.locale),t.parse(i);else{var n=this.getAttribution();n&&n.length&&(t=new bl(this.options.locale),t.value=n)}return t},e.prototype.isCollection=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.COLLECTION},e.prototype.isManifest=function(){return this.getIIIFResourceType()===fe.IIIFResourceType.MANIFEST},e.prototype.load=function(){var t=this;return new Promise(function(i){if(t.isLoaded)i(t);else{var n=t.options;n.navDate=t.getNavDate();var s=t.__jsonld.id;s||(s=t.__jsonld["@id"]),Ke.loadManifest(s).then(function(o){t.parentLabel=t.getLabel().getValue(n.locale);var a=vg.parse(o,n);t=Object.assign(t,a),t.index=n.index,i(t)})}})},e})(Yr),cx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),wl=(function(r){cx(e,r);function e(t,i){return r.call(this,t,i)||this}return e.prototype.getBody=function(){var t=[],i=this.getProperty("body");if(i)if(Array.isArray(i))for(var n=0;n<i.length;n++){var s=i[n];if(s.items)for(var o=0;o<s.items.length;o++){var a=s.items[o];t.push(new El(a,this.options))}else t.push(new El(s,this.options))}else if(i.items)for(var n=0;n<i.items.length;n++){var s=i.items[n];t.push(new El(s,this.options))}else t.push(new El(i,this.options));return t},e.prototype.getMotivation=function(){var t=this.getProperty("motivation");return t||null},e.prototype.getOn=function(){return this.getProperty("on")},e.prototype.getTarget=function(){return this.getProperty("target")},e.prototype.getResource=function(){return new Mu(this.getProperty("resource"),this.options)},e})(Yr),dx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),El=(function(r){dx(e,r);function e(t,i){return r.call(this,t,i)||this}return e.prototype.getFormat=function(){var t=this.getProperty("format");return t?Ke.getMediaType(t):null},e.prototype.getType=function(){var t=this.getProperty("type");return t?Ke.normaliseType(this.getProperty("type")):null},e.prototype.getValue=function(){return this.getProperty("value")},e.prototype.getLanguage=function(){return this.getProperty("language")},e.prototype.getWidth=function(){return this.getProperty("width")},e.prototype.getHeight=function(){return this.getProperty("height")},e})(Yr),fx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),px=(function(r){fx(e,r);function e(t,i,n){var s=r.call(this,i)||this;return s.label=t,s.options=n,s}return e.prototype.getIIIFResourceType=function(){return Ke.normaliseType(this.getProperty("type"))},e.prototype.getLabel=function(){return this.label},e.prototype.getResources=function(){var t=this,i=this.getProperty("resources");return i.map(function(n){return new wl(n,t.options)})},e.prototype.load=function(){var t=this;return new Promise(function(i,n){if(t.isLoaded)i(t);else{var s=t.__jsonld.id;s||(s=t.__jsonld["@id"]),Ke.loadManifest(s).then(function(o){t.__jsonld=o,t.context=t.getProperty("context"),t.id=t.getProperty("id"),t.isLoaded=!0,i(t)}).catch(n)}})},e})(Wp),gx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Zp=(function(r){gx(e,r);function e(t,i){return r.call(this,t,i)||this}return e.prototype.getItems=function(){return this.getProperty("items")},e.prototype.getAnnotations=function(){var t=[],i=this.getProperty("items");if(!i||!Array.isArray(i))return t;for(var n=0;n<i.length;n++){var s=new wl(i[n],this.options);t.push(s)}return t},e})(Yr),Du,qp;function mx(){if(qp)return Du;qp=1;function r(e,t){for(var i=-1,n=t.length,s=e.length;++i<n;)e[s+i]=t[i];return e}return Du=r,Du}var Ou,Kp;function vx(){if(Kp)return Ou;Kp=1;var r=typeof xl=="object"&&xl&&xl.Object===Object&&xl;return Ou=r,Ou}var Lu,Qp;function yx(){if(Qp)return Lu;Qp=1;var r=vx(),e=typeof self=="object"&&self&&self.Object===Object&&self,t=r||e||Function("return this")();return Lu=t,Lu}var Nu,Jp;function Fu(){if(Jp)return Nu;Jp=1;var r=yx(),e=r.Symbol;return Nu=e,Nu}var Bu,$p;function _x(){if($p)return Bu;$p=1;var r=Fu(),e=Object.prototype,t=e.hasOwnProperty,i=e.toString,n=r?r.toStringTag:void 0;function s(o){var a=t.call(o,n),l=o[n];try{o[n]=void 0;var h=!0}catch{}var u=i.call(o);return h&&(a?o[n]=l:delete o[n]),u}return Bu=s,Bu}var ku,eg;function xx(){if(eg)return ku;eg=1;var r=Object.prototype,e=r.toString;function t(i){return e.call(i)}return ku=t,ku}var Uu,tg;function wx(){if(tg)return Uu;tg=1;var r=Fu(),e=_x(),t=xx(),i="[object Null]",n="[object Undefined]",s=r?r.toStringTag:void 0;function o(a){return a==null?a===void 0?n:i:s&&s in Object(a)?e(a):t(a)}return Uu=o,Uu}var Hu,ig;function rg(){if(ig)return Hu;ig=1;function r(e){return e!=null&&typeof e=="object"}return Hu=r,Hu}var Gu,ng;function Ex(){if(ng)return Gu;ng=1;var r=wx(),e=rg(),t="[object Arguments]";function i(n){return e(n)&&r(n)==t}return Gu=i,Gu}var Vu,sg;function Tx(){if(sg)return Vu;sg=1;var r=Ex(),e=rg(),t=Object.prototype,i=t.hasOwnProperty,n=t.propertyIsEnumerable,s=r((function(){return arguments})())?r:function(o){return e(o)&&i.call(o,"callee")&&!n.call(o,"callee")};return Vu=s,Vu}var zu,og;function bx(){if(og)return zu;og=1;var r=Array.isArray;return zu=r,zu}var ju,ag;function Ax(){if(ag)return ju;ag=1;var r=Fu(),e=Tx(),t=bx(),i=r?r.isConcatSpreadable:void 0;function n(s){return t(s)||e(s)||!!(i&&s&&s[i])}return ju=n,ju}var Wu,lg;function hg(){if(lg)return Wu;lg=1;var r=mx(),e=Ax();function t(i,n,s,o,a){var l=-1,h=i.length;for(s||(s=e),a||(a=[]);++l<h;){var u=i[l];n>0&&s(u)?n>1?t(u,n-1,s,o,a):r(a,u):o||(a[a.length]=u)}return a}return Wu=t,Wu}var Xu,ug;function Sx(){if(ug)return Xu;ug=1;var r=hg();function e(t){var i=t==null?0:t.length;return i?r(t,1):[]}return Xu=e,Xu}var Rx=Sx();const Yu=Iu(Rx);var Zu,cg;function Cx(){if(cg)return Zu;cg=1;var r=hg(),e=1/0;function t(i){var n=i==null?0:i.length;return n?r(i,e):[]}return Zu=t,Zu}var Px=Cx();const dg=Iu(Px);var Ix=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Tl=(function(r){Ix(e,r);function e(t,i){return r.call(this,t,i)||this}return e.prototype.getCanonicalImageUri=function(t){var i=null,n="full",s=0,o="default",a=t,l=a+",";if(this.externalResource&&this.externalResource.data&&this.externalResource.data["@id"])i=this.externalResource.data["@id"],a||(a=this.externalResource.data.width),this.externalResource.data["@context"]&&(this.externalResource.data["@context"].indexOf("/1.0/context.json")>-1||this.externalResource.data["@context"].indexOf("/1.1/context.json")>-1||this.externalResource.data["@context"].indexOf("/1/context.json")>-1)&&(o="native");else{var h=void 0;if(h=this.getImages(),h&&h.length){var u=h[0],c=u.getResource(),d=c.getServices();a||(a=c.getWidth());var f=d?d.find(function(y){return Ke.isImageProfile(y.getProfile())||Ke.isImageServiceType(y.getIIIFResourceType())}):null;if(f)i=f.id,o=Ke.getImageQuality(f.getProfile());else if(a===c.getWidth())return c.id}if(h=this.getContent(),h&&h.length){var u=h[0],g=u.getBody(),p=g[0],d=p.getServices();a||(a=p.getWidth());var f=d?d.find(function(A){return Ke.isImageServiceType(A.getIIIFResourceType())}):null;if(f)i=f.id,o=Ke.getImageQuality(f.getProfile());else if(a===p.getWidth())return p.id}if(!i){var m=this.getProperty("thumbnail");if(m){if(typeof m=="string")return m;if(m["@id"])return m["@id"];if(m.length)return m[0].id}}}i&&i.endsWith("/")&&(i=i.substr(0,i.length-1));var v=[i,n,l,s,o+".jpg"].join("/");return v},e.prototype.getMaxDimensions=function(){var t=null,i;return this.externalResource&&this.externalResource.data&&this.externalResource.data.profile&&(i=this.externalResource.data.profile,Array.isArray(i)&&(i=i.filter(function(n){var s;return(s=n.maxWidth)!==null&&s!==void 0?s:n.maxwidth})[0],i&&(t=new Xx(i.maxWidth,i.maxHeight?i.maxHeight:i.maxWidth)))),t},e.prototype.getContent=function(){var t=[],i=this.__jsonld.items||this.__jsonld.content;if(!i)return t;var n=null;if(i.length&&(n=new Zp(i[0],this.options)),!n)return t;for(var s=n.getAnnotations(),o=0;o<s.length;o++){var a=s[o];t.push(a)}return t},e.prototype.getAnnotations=function(){var t=[],i=this.__jsonld.annotations;if(!i||!Array.isArray(i))return t;for(var n=0;n<i.length;n++){var s=new Zp(i[n],this.options);t.push(s)}return t},e.prototype.getDuration=function(){return this.getProperty("duration")},e.prototype.getImages=function(){var t=[];if(!this.__jsonld.images)return t;for(var i=0;i<this.__jsonld.images.length;i++){var n=this.__jsonld.images[i],s=new wl(n,this.options);t.push(s)}return t},e.prototype.getIndex=function(){return this.getProperty("index")},e.prototype.getOtherContent=function(){var t=this,i=Array.isArray(this.getProperty("otherContent"))?this.getProperty("otherContent"):[this.getProperty("otherContent")],n=function(o,a){return typeof o!="string"?!1:o.toLowerCase()===o.toLowerCase()},s=i.filter(function(o){return o&&n(o["@type"])}).map(function(o,a){return new px(o.label||"Annotation list ".concat(a),o,t.options)}).map(function(o){return o.load()});return Promise.all(s)},e.prototype.getWidth=function(){return this.getProperty("width")},e.prototype.getHeight=function(){return this.getProperty("height")},e.prototype.getViewingHint=function(){var t=this.getProperty("viewingHint");return Array.isArray(t)&&(t=t[0]),t||null},Object.defineProperty(e.prototype,"imageResources",{get:function(){var t=this,i=dg([this.getImages().map(function(n){return n.getResource()}),this.getContent().map(function(n){return n.getBody()})]);return Yu(i.map(function(n){switch(n.getProperty("type").toLowerCase()){case fe.ExternalResourceType.CHOICE:case fe.ExternalResourceType.OA_CHOICE:return new e({images:Yu([n.getProperty("default"),n.getProperty("item")]).map(function(s){return{resource:s}})},t.options).getImages().map(function(s){return s.getResource()});default:return n}}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resourceAnnotations",{get:function(){return dg([this.getImages(),this.getContent()])},enumerable:!1,configurable:!0}),e.prototype.resourceAnnotation=function(t){return this.resourceAnnotations.find(function(i){return i.getResource().id===t||Yu(new Array(i.getBody())).some(function(n){return n.id===t})})},e.prototype.onFragment=function(t){var i=this.resourceAnnotation(t);if(i){var n=i.getProperty("on"),s=i.getProperty("target");if(!(!n||!s)){var o=(n||s).match(/xywh=(.*)$/);if(o)return o[1].split(",").map(function(a){return parseInt(a,10)})}}},Object.defineProperty(e.prototype,"iiifImageResources",{get:function(){return this.imageResources.filter(function(t){return t&&t.getServices()[0]&&t.getServices()[0].id})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageServiceIds",{get:function(){return this.iiifImageResources.map(function(t){return t.getServices()[0].id})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this.getWidth()/this.getHeight()},enumerable:!1,configurable:!0}),e})(Mu),Mx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Dx=(function(r){Mx(e,r);function e(t,i){var n=r.call(this,t,i)||this;return n.items=[],n._collections=null,n._manifests=null,t.__collection=n,n}return e.prototype.getCollections=function(){return this._collections?this._collections:this._collections=this.items.filter(function(t){return t.isCollection()})},e.prototype.getManifests=function(){return this._manifests?this._manifests:this._manifests=this.items.filter(function(t){return t.isManifest()})},e.prototype.getCollectionByIndex=function(t){for(var i=this.getCollections(),n,s=0;s<i.length;s++){var o=i[s];o.index===t&&(n=o)}if(n)return n.options.index=t,n.load();throw new Error("Collection index not found")},e.prototype.getManifestByIndex=function(t){for(var i=this.getManifests(),n,s=0;s<i.length;s++){var o=i[s];o.index===t&&(n=o)}if(n)return n.options.index=t,n.load();throw new Error("Manifest index not found")},e.prototype.getTotalCollections=function(){return this.getCollections().length},e.prototype.getTotalManifests=function(){return this.getManifests().length},e.prototype.getTotalItems=function(){return this.items.length},e.prototype.getViewingDirection=function(){return this.getProperty("viewingDirection")?this.getProperty("viewingDirection"):fe.ViewingDirection.LEFT_TO_RIGHT},e.prototype.getBehavior=function(){var t=this.getProperty("behavior");return Array.isArray(t)&&(t=t[0]),t||null},e.prototype.getViewingHint=function(){var t=this.getProperty("viewingHint");return Array.isArray(t)&&(t=t[0]),t||null},e.prototype.getDefaultTree=function(){return r.prototype.getDefaultTree.call(this),this.defaultTree.data.type=Ke.normaliseType(br.COLLECTION),this._parseManifests(this),this._parseCollections(this),Ke.generateTreeNodeIds(this.defaultTree),this.defaultTree},e.prototype._parseManifests=function(t){if(t.getManifests()&&t.getManifests().length)for(var i=0;i<t.getManifests().length;i++){var n=t.getManifests()[i],s=n.getDefaultTree();s.label=n.parentLabel||n.getLabel().getValue(this.options.locale)||"manifest "+(i+1),s.navDate=n.getNavDate(),s.data.id=n.id,s.data.type=Ke.normaliseType(br.MANIFEST),t.defaultTree.addNode(s)}},e.prototype._parseCollections=function(t){if(t.getCollections()&&t.getCollections().length)for(var i=0;i<t.getCollections().length;i++){var n=t.getCollections()[i],s=n.getDefaultTree();s.label=n.parentLabel||n.getLabel().getValue(this.options.locale)||"collection "+(i+1),s.navDate=n.getNavDate(),s.data.id=n.id,s.data.type=Ke.normaliseType(br.COLLECTION),t.defaultTree.addNode(s)}},e})(Yp),qu=(function(){function r(e,t){this.start=e,this.end=t}return r.prototype.getLength=function(){return this.end-this.start},r})(),bl=(function(){function r(e){this.defaultLocale=e}return r.prototype.parse=function(e){this.resource=e,this.label=ji.parse(this.resource.label,this.defaultLocale),this.value=ji.parse(this.resource.value,this.defaultLocale)},r.prototype.getLabel=function(e){return this.label===null?null:(Array.isArray(e)&&!e.length&&(e=void 0),this.label.getValue(e||this.defaultLocale))},r.prototype.setLabel=function(e){this.label===null&&(this.label=new ji([])),this.label.setValue(e,this.defaultLocale)},r.prototype.getValue=function(e,t){return t===void 0&&(t="<br/>"),this.value===null?null:(Array.isArray(e)&&!e.length&&(e=void 0),this.value.getValue(e||this.defaultLocale,t))},r.prototype.getValues=function(e){return this.value===null?[]:(Array.isArray(e)&&!e.length&&(e=void 0),this.value.getValues(e||this.defaultLocale))},r.prototype.setValue=function(e){this.value===null&&(this.value=new ji([])),this.value.setValue(e,this.defaultLocale)},r})(),Ox=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})();(function(r){Ox(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getValue=function(t,i){return t.getValue(i,"<br/>")},e.getValues=function(t,i){return t.getValues(i)},e})(Array);var Se={},fg;function Lx(){return fg||(fg=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.CONTINUE=100,Se.SWITCHING_PROTOCOLS=101,Se.PROCESSING=102,Se.OK=200,Se.CREATED=201,Se.ACCEPTED=202,Se.NON_AUTHORITATIVE_INFORMATION=203,Se.NO_CONTENT=204,Se.RESET_CONTENT=205,Se.PARTIAL_CONTENT=206,Se.MULTI_STATUS=207,Se.MULTIPLE_CHOICES=300,Se.MOVED_PERMANENTLY=301,Se.MOVED_TEMPORARILY=302,Se.SEE_OTHER=303,Se.NOT_MODIFIED=304,Se.USE_PROXY=305,Se.TEMPORARY_REDIRECT=307,Se.BAD_REQUEST=400,Se.UNAUTHORIZED=401,Se.PAYMENT_REQUIRED=402,Se.FORBIDDEN=403,Se.NOT_FOUND=404,Se.METHOD_NOT_ALLOWED=405,Se.NOT_ACCEPTABLE=406,Se.PROXY_AUTHENTICATION_REQUIRED=407,Se.REQUEST_TIME_OUT=408,Se.CONFLICT=409,Se.GONE=410,Se.LENGTH_REQUIRED=411,Se.PRECONDITION_FAILED=412,Se.REQUEST_ENTITY_TOO_LARGE=413,Se.REQUEST_URI_TOO_LARGE=414,Se.UNSUPPORTED_MEDIA_TYPE=415,Se.REQUESTED_RANGE_NOT_SATISFIABLE=416,Se.EXPECTATION_FAILED=417,Se.IM_A_TEAPOT=418,Se.UNPROCESSABLE_ENTITY=422,Se.LOCKED=423,Se.FAILED_DEPENDENCY=424,Se.UNORDERED_COLLECTION=425,Se.UPGRADE_REQUIRED=426,Se.PRECONDITION_REQUIRED=428,Se.TOO_MANY_REQUESTS=429,Se.REQUEST_HEADER_FIELDS_TOO_LARGE=431,Se.INTERNAL_SERVER_ERROR=500,Se.NOT_IMPLEMENTED=501,Se.BAD_GATEWAY=502,Se.SERVICE_UNAVAILABLE=503,Se.GATEWAY_TIME_OUT=504,Se.HTTP_VERSION_NOT_SUPPORTED=505,Se.VARIANT_ALSO_NEGOTIATES=506,Se.INSUFFICIENT_STORAGE=507,Se.BANDWIDTH_LIMIT_EXCEEDED=509,Se.NOT_EXTENDED=510,Se.NETWORK_AUTHENTICATION_REQUIRED=511),Se}var zi=Lx();function Nx(r,e){return e=e||{},new Promise(function(t,i){var n=new XMLHttpRequest,s=[],o=[],a={},l=function(){return{ok:(n.status/100|0)==2,statusText:n.statusText,status:n.status,url:n.responseURL,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([n.response]))},clone:l,headers:{keys:function(){return s},entries:function(){return o},get:function(u){return a[u.toLowerCase()]},has:function(u){return u.toLowerCase()in a}}}};for(var h in n.open(e.method||"get",r,!0),n.onload=function(){n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(u,c,d){s.push(c=c.toLowerCase()),o.push([c,d]),a[c]=a[c]?a[c]+","+d:d}),t(l())},n.onerror=i,n.withCredentials=e.credentials=="include",e.headers)n.setRequestHeader(h,e.headers[h]);n.send(e.body||null)})}const pg=ox(Object.freeze(Object.defineProperty({__proto__:null,default:Nx},Symbol.toStringTag,{value:"Module"})));var Ku,gg;function Fx(){return gg||(gg=1,Ku=self.fetch||(self.fetch=pg.default||pg)),Ku}Fx();var Qu=function(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{h(i.next(u))}catch(c){o(c)}}function l(u){try{h(i.throw(u))}catch(c){o(c)}}function h(u){u.done?s(u.value):n(u.value).then(a,l)}h((i=i.apply(r,e||[])).next())})},Ju=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(u){return l([h,u])}}function l(h){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(t=0)),t;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(u){h=[6,u],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}},Ke=(function(){function r(){}return r.getMediaType=function(e){return e=e.toLowerCase(),e=e.split(";")[0],e.trim()},r.getImageQuality=function(e){return e===fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_1||e===fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_2||e===fe.ServiceProfile.IMAGE_1_COMPLIANCE_LEVEL_1||e===fe.ServiceProfile.IMAGE_1_COMPLIANCE_LEVEL_2||e===fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_1||e===fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_2||e===fe.ServiceProfile.IMAGE_1_CONFORMANCE_LEVEL_1||e===fe.ServiceProfile.IMAGE_1_CONFORMANCE_LEVEL_2||e===fe.ServiceProfile.IMAGE_1_LEVEL_1||e===fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_1||e===fe.ServiceProfile.IMAGE_1_LEVEL_2||e===fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_2?"native":"default"},r.getInexactLocale=function(e){return e.indexOf("-")!==-1?e.substr(0,e.indexOf("-")):e},r.getLocalisedValue=function(e,t){if(!Array.isArray(e))return e;for(var i=0;i<e.length;i++){var n=e[i],s=n["@language"];if(t===s)return n["@value"]}for(var o=t.substr(0,t.indexOf("-")),i=0;i<e.length;i++){var a=e[i],l=a["@language"];if(l===o)return a["@value"]}return null},r.generateTreeNodeIds=function(e,t){t===void 0&&(t=0);var i;e.parentNode?i=e.parentNode.id+"-"+t:i="0",e.id=i;for(var n=0;n<e.nodes.length;n++){var s=e.nodes[n];r.generateTreeNodeIds(s,n)}},r.normaliseType=function(e){if(e=(e||"").toLowerCase(),e.indexOf(":")!==-1){var t=e.split(":");return t[1]}return e},r.normaliseUrl=function(e){return e=e.substr(e.indexOf("://")),e.indexOf("#")!==-1&&(e=e.split("#")[0]),e},r.normalisedUrlsMatch=function(e,t){return r.normaliseUrl(e)===r.normaliseUrl(t)},r.isImageProfile=function(e){return!!(r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_COMPLIANCE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_COMPLIANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_CONFORMANCE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_CONFORMANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_PROFILE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_PROFILE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_PROFILE_LEVEL_2))},r.isImageServiceType=function(e){return e!==null&&e.toLowerCase()===fe.ServiceType.IMAGE_SERVICE_2.toLowerCase()||e===fe.ServiceType.IMAGE_SERVICE_3.toLowerCase()},r.isLevel0ImageProfile=function(e){return!!(r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_COMPLIANCE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_CONFORMANCE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_LEVEL_0)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_PROFILE_LEVEL_0))},r.isLevel1ImageProfile=function(e){return!!(r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_COMPLIANCE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_CONFORMANCE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_LEVEL_1)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_PROFILE_LEVEL_1))},r.isLevel2ImageProfile=function(e){return!!(r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_COMPLIANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_0_CONFORMANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_CONFORMANCE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_1_PROFILE_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_LEVEL_2)||r.normalisedUrlsMatch(e,fe.ServiceProfile.IMAGE_2_PROFILE_LEVEL_2))},r.parseManifest=function(e,t){return vg.parse(e,t)},r.checkStatus=function(e){if(e.ok)return e;var t=new Error(e.statusText);return t.response=e,Promise.reject(t)},r.loadManifest=function(e){return new Promise(function(t,i){fetch(e).then(r.checkStatus).then(function(n){return n.json()}).then(function(n){t(n)}).catch(function(n){i()})})},r.loadExternalResourcesAuth1=function(e,t,i,n,s,o,a,l){return new Promise(function(h,u){var c=e.map(function(d){return r.loadExternalResourceAuth1(d,t,i,n,s,o,a,l)});Promise.all(c).then(function(){h(e)}).catch(function(d){u(d)})})},r.loadExternalResourceAuth1=function(e,t,i,n,s,o,a,l){return Qu(this,void 0,void 0,function(){var h;return Ju(this,function(u){switch(u.label){case 0:return[4,n(e)];case 1:return h=u.sent(),h?[4,e.getData(h)]:[3,6];case 2:return u.sent(),e.status!==zi.OK?[3,3]:[2,e];case 3:return[4,r.doAuthChain(e,t,i,s,o,a,l)];case 4:u.sent(),u.label=5;case 5:if(e.status===zi.OK||e.status===zi.MOVED_TEMPORARILY)return[2,e];throw r.createAuthorizationFailedError();case 6:return[4,e.getData()];case 7:return u.sent(),e.status===zi.MOVED_TEMPORARILY||e.status===zi.UNAUTHORIZED?[4,r.doAuthChain(e,t,i,s,o,a,l)]:[3,9];case 8:u.sent(),u.label=9;case 9:if(e.status===zi.OK||e.status===zi.MOVED_TEMPORARILY)return[2,e];throw r.createAuthorizationFailedError()}})})},r.doAuthChain=function(e,t,i,n,s,o,a){return Qu(this,void 0,void 0,function(){var l,h,u,c,d,f,g,p,p;return Ju(this,function(m){switch(m.label){case 0:return e.isAccessControlled()?(l=e.externalService,l&&(l.options=e.options),h=e.kioskService,h&&(h.options=e.options),u=e.clickThroughService,u&&(u.options=e.options),c=e.loginService,c&&(c.options=e.options),!e.isResponseHandled&&e.status===zi.MOVED_TEMPORARILY?[4,o(e)]:[3,2]):[2,e];case 1:return m.sent(),[2,e];case 2:return d=null,f=null,d=l,d?(f=d,[4,r.attemptResourceWithToken(e,i,d)]):[3,4];case 3:return m.sent(),[2,e];case 4:return d=h,d?(f=d,g=t(d),g?[4,n(g)]:[3,7]):[3,7];case 5:return m.sent(),[4,r.attemptResourceWithToken(e,i,d)];case 6:return m.sent(),[2,e];case 7:return d=u,d?(f=d,[4,s(e,d)]):[3,11];case 8:return p=m.sent(),p?[4,n(p)]:[3,11];case 9:return m.sent(),[4,r.attemptResourceWithToken(e,i,d)];case 10:return m.sent(),[2,e];case 11:return d=c,d?(f=d,[4,s(e,d)]):[3,15];case 12:return p=m.sent(),p?[4,n(p)]:[3,15];case 13:return m.sent(),[4,r.attemptResourceWithToken(e,i,d)];case 14:return m.sent(),[2,e];case 15:return f&&a(e,f),[2]}})})},r.attemptResourceWithToken=function(e,t,i){return Qu(this,void 0,void 0,function(){var n,s;return Ju(this,function(o){switch(o.label){case 0:return n=i.getService(fe.ServiceProfile.AUTH_1_TOKEN),n?[4,t(e,n)]:[3,3];case 1:return s=o.sent(),s&&s.accessToken?[4,e.getData(s)]:[3,3];case 2:return o.sent(),[2,e];case 3:return[2]}})})},r.loadExternalResourcesAuth09=function(e,t,i,n,s,o,a,l,h,u){return new Promise(function(c,d){var f=e.map(function(g){return r.loadExternalResourceAuth09(g,t,i,n,s,o,a,l,h,u)});Promise.all(f).then(function(){c(e)}).catch(function(g){d(g)})})},r.loadExternalResourceAuth09=function(e,t,i,n,s,o,a,l,h,u){return new Promise(function(c,d){u&&u.pessimisticAccessControl?e.getData().then(function(){e.isAccessControlled()?e.clickThroughService?(c(i(e)),c(n(e))):s(e).then(function(){o(e,!0).then(function(f){e.getData(f).then(function(){c(h(e))}).catch(function(g){d(r.createInternalServerError(g))})}).catch(function(f){d(r.createInternalServerError(f))})}).catch(function(f){d(r.createInternalServerError(f))}):c(e)}).catch(function(f){d(r.createInternalServerError(f))}):l(e,t).then(function(f){f?e.getData(f).then(function(){e.status===zi.OK?c(h(e)):r.authorize(e,t,i,n,s,o,a,l).then(function(){c(h(e))}).catch(function(g){d(r.createAuthorizationFailedError())})}).catch(function(g){d(r.createAuthorizationFailedError())}):r.authorize(e,t,i,n,s,o,a,l).then(function(){c(h(e))}).catch(function(g){d(r.createAuthorizationFailedError())})}).catch(function(f){d(r.createAuthorizationFailedError())})})},r.createError=function(e,t){var i=new Error;return i.message=t,i.name=String(e),i},r.createAuthorizationFailedError=function(){return r.createError(Wo.AUTHORIZATION_FAILED,"Authorization failed")},r.createRestrictedError=function(){return r.createError(Wo.RESTRICTED,"Restricted")},r.createInternalServerError=function(e){return r.createError(Wo.INTERNAL_SERVER_ERROR,e)},r.authorize=function(e,t,i,n,s,o,a,l){return new Promise(function(h,u){e.getData().then(function(){e.isAccessControlled()?l(e,t).then(function(c){c?e.getData(c).then(function(){e.status===zi.OK?h(e):r.showAuthInteraction(e,t,i,n,s,o,a,h,u)}).catch(function(d){u(r.createInternalServerError(d))}):o(e,!1).then(function(d){d?a(e,d,t).then(function(){e.getData(d).then(function(){e.status===zi.OK?h(e):r.showAuthInteraction(e,t,i,n,s,o,a,h,u)}).catch(function(f){u(r.createInternalServerError(f))})}).catch(function(f){u(r.createInternalServerError(f))}):r.showAuthInteraction(e,t,i,n,s,o,a,h,u)})}).catch(function(c){u(r.createInternalServerError(c))}):h(e)})})},r.showAuthInteraction=function(e,t,i,n,s,o,a,l,h){e.status===zi.MOVED_TEMPORARILY&&!e.isResponseHandled?l(e):e.clickThroughService&&!e.isResponseHandled?i(e).then(function(){o(e,!0).then(function(u){a(e,u,t).then(function(){e.getData(u).then(function(){l(e)}).catch(function(c){h(r.createInternalServerError(c))})}).catch(function(c){h(r.createInternalServerError(c))})}).catch(function(u){h(r.createInternalServerError(u))})}):s(e).then(function(){o(e,!0).then(function(u){a(e,u,t).then(function(){e.getData(u).then(function(){l(e)}).catch(function(c){h(r.createInternalServerError(c))})}).catch(function(c){h(r.createInternalServerError(c))})}).catch(function(u){h(r.createInternalServerError(u))})})},r.getService=function(e,t){for(var i=this.getServices(e),n=0;n<i.length;n++){var s=i[n];if(s.getProfile()===t)return s}return null},r.getResourceById=function(e,t){return r.traverseAndFind(e.__jsonld,"@id",t)},r.traverseAndFind=function(e,t,i){if(e.hasOwnProperty(t)&&e[t]===i)return e;for(var n=0;n<Object.keys(e).length;n++)if(typeof e[Object.keys(e)[n]]=="object"){var s=r.traverseAndFind(e[Object.keys(e)[n]],t,i);if(s!=null)return s}},r.getServices=function(e,t){var i=t===void 0?{}:t,n=i.onlyService,s=n===void 0?!1:n,o=i.onlyServices,a=o===void 0?!1:o,l=i.skipParentResources,h=l===void 0?!1:l,u=[];!h&&e&&e.options&&e.options.resource&&e.options.resource!==e&&u.push.apply(u,r.getServices(e.options.resource,{onlyServices:!0}));var c=a?[]:(e.__jsonld||e).service||[];if(Array.isArray(c)||(c=[c]),s||c.push.apply(c,(e.__jsonld||e).services||[]),c.length===0)return u;for(var d=0;d<c.length;d++){var f=c[d];if(typeof f=="string"){var g=this.getResourceById(e.options.resource,f);g&&u.push(new yg(g.__jsonld||g,e.options))}else u.push(new yg(f,e.options))}return u},r.getTemporalComponent=function(e){var t=/t=([^&]+)/g.exec(e),i=null;return t&&t[1]&&(i=t[1].split(",")),i},r})(),Bx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Ls=(function(){function r(e,t,i){i===void 0&&(i="none"),Array.isArray(e)&&e.length===1?this._value=e[0]:this._value=e,(t==="none"||t==="@none")&&(t=void 0),this._locale=t,this._defaultLocale=i}return r.parseV2Value=function(e,t){return typeof e=="string"?new r(e,void 0,t):e["@value"]?new r(e["@value"],e["@language"],t):null},Object.defineProperty(r.prototype,"value",{get:function(){return Array.isArray(this._value)?this._value.join("<br/>"):this._value},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"locale",{get:function(){return this._locale===void 0?this._defaultLocale:this._locale},enumerable:!1,configurable:!0}),r.prototype.addValue=function(e){Array.isArray(this._value)||(this._value=[this._value]),Array.isArray(e)?this._value=this._value.concat(e):this._value.push(e)},r})(),ji=(function(r){Bx(e,r);function e(t,i){t===void 0&&(t=[]);var n=r.apply(this,t)||this;return n.__proto__=e.prototype,n._defaultLocale=i,n}return e.parse=function(t,i){if(!t)return new e([],i);if(Array.isArray(t)){var n=t.map(function(o){return Ls.parseV2Value(o,i)}).filter(function(o){return o!==null}),s=n.reduce(function(o,a){var l=a._locale;return l||(l="none"),o[l]?o[l].addValue(a._value):o[l]=a,o},{});return new e(Object.values(s),i)}else{if(typeof t=="string")return new e([new Ls(t,void 0,i)],i);if(t["@language"]){var n=Ls.parseV2Value(t);return new e(n!==null?[n]:[],i)}else if(t["@value"]){var n=Ls.parseV2Value(t);return new e(n!==null?[n]:[],i)}else return new e(Object.keys(t).map(function(o){var a=t[o];if(!Array.isArray(a))throw new Error("A IIIF v3 localized property value must have an array as the value for a given language.");return new Ls(a,o,i)}),i)}},e.prototype.getSuitableLocale=function(t){for(var i=Array.from(this.values()).map(function(f){return f._locale}).filter(function(f){return f!==void 0}),n=function(f){var g=i.find(function(p){return p===f});if(g)return{value:g}},s=0,o=t;s<o.length;s++){var a=o[s],l=n(a);if(typeof l=="object")return l.value}for(var h=function(f){var g=i.find(function(p){return Ke.getInexactLocale(p)===Ke.getInexactLocale(f)});if(g)return{value:g}},u=0,c=t;u<c.length;u++){var a=c[u],d=h(a);if(typeof d=="object")return d.value}},e.prototype.setValue=function(t,i){var n=void 0;if(!i)n=this.find(function(o){return o._locale===void 0});else{var s=this.getSuitableLocale([i]);s&&(n=this.find(function(o){return o._locale===s}))}n?n._value=t:this.push(new Ls(t,i,this._defaultLocale))},e.prototype.getValue=function(t,i){var n=this.getValues(t);return n.length===0?null:i?n.join(i):n[0]},e.prototype.getValues=function(t){if(!this.length)return[];var i;if(t?Array.isArray(t)?i=t:i=[t]:i=[],this.length===1&&this[0]._locale===void 0){var n=this[0]._value;return Array.isArray(n)?n:[n]}var s=this.getSuitableLocale(i);if(s){var n=this.find(function(h){return h._locale===s})._value;return Array.isArray(n)?n:[n]}var o=!this.find(function(l){return l._locale===void 0});if(o){var n=this[0]._value;return Array.isArray(n)?n:[n]}var a=this.find(function(l){return l._locale===void 0});return a?Array.isArray(a._value)?a._value:[a._value]:[]},e})(Array),kx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Ux=(function(r){kx(e,r);function e(t,i){var n=r.call(this,t,i)||this;if(n.index=0,n._allRanges=null,n.items=[],n._topRanges=[],n.__jsonld.structures&&n.__jsonld.structures.length)for(var s=n._getTopRanges(),o=0;o<s.length;o++){var a=s[o];n._parseRanges(a,String(o))}return n}return e.prototype.getPosterCanvas=function(){var t=this.getProperty("posterCanvas");return t&&(t=new Tl(t,this.options)),t},e.prototype.getAccompanyingCanvas=function(){var t=this.getProperty("accompanyingCanvas");return t&&(t=new Tl(t,this.options)),t},e.prototype.getBehavior=function(){var t=this.getProperty("behavior");return Array.isArray(t)&&(t=t[0]),t||null},e.prototype.getDefaultTree=function(){if(r.prototype.getDefaultTree.call(this),this.defaultTree.data.type=Ke.normaliseType(br.MANIFEST),!this.isLoaded)return this.defaultTree;var t=this.getTopRanges();return t.length&&t[0].getTree(this.defaultTree),Ke.generateTreeNodeIds(this.defaultTree),this.defaultTree},e.prototype._getTopRanges=function(){var t=[];if(this.__jsonld.structures&&this.__jsonld.structures.length){for(var i=0;i<this.__jsonld.structures.length;i++){var n=this.__jsonld.structures[i];n.viewingHint===fe.ViewingHint.TOP&&t.push(n)}if(!t.length){var s={};s.ranges=this.__jsonld.structures,t.push(s)}}return t},e.prototype.getTopRanges=function(){return this._topRanges},e.prototype._getRangeById=function(t){if(this.__jsonld.structures&&this.__jsonld.structures.length)for(var i=0;i<this.__jsonld.structures.length;i++){var n=this.__jsonld.structures[i];if(n["@id"]===t||n.id===t)return n}return null},e.prototype._parseRanges=function(t,i,n){var s=null;if(typeof t=="string"&&(s=t,t=this._getRangeById(s)),!t){console.warn("Range:",s,"does not exist");return}var o=new Gx(t,this.options);o.parentRange=n,o.path=i,n?n.items.push(o):this._topRanges.push(o);var a=t.items||t.members;if(a)for(var l=0;l<a.length;l++){var h=a[l];if(h["@type"]&&h["@type"].toLowerCase()==="sc:range"||h.type&&h.type.toLowerCase()==="range")this._parseRanges(h,i+"/"+l,o);else if(h["@type"]&&h["@type"].toLowerCase()==="sc:canvas"||h.type&&h.type.toLowerCase()==="canvas"){o.canvases||(o.canvases=[]);var u=h.id||h["@id"];o.canvases.push(u)}}else if(t.ranges)for(var l=0;l<t.ranges.length;l++)this._parseRanges(t.ranges[l],i+"/"+l,o)},e.prototype.getAllRanges=function(){if(this._allRanges!=null)return this._allRanges;this._allRanges=[];for(var t=this.getTopRanges(),i=function(o){var a=t[o];a.id&&n._allRanges.push(a);var l=function(u,c){u.add(c);var d=c.getRanges();return d.length?d.reduce(l,u):u},h=Array.from(a.getRanges().reduce(l,new Set));n._allRanges=n._allRanges.concat(h)},n=this,s=0;s<t.length;s++)i(s);return this._allRanges},e.prototype.getRangeById=function(t){for(var i=this.getAllRanges(),n=0;n<i.length;n++){var s=i[n];if(s.id===t)return s}return null},e.prototype.getRangeByPath=function(t){for(var i=this.getAllRanges(),n=0;n<i.length;n++){var s=i[n];if(s.path===t)return s}return null},e.prototype.getSequences=function(){if(this.items.length)return this.items;var t=this.__jsonld.mediaSequences||this.__jsonld.sequences;if(t)for(var i=0;i<t.length;i++){var n=t[i],s=new mg(n,this.options);this.items.push(s)}else if(this.__jsonld.items){var s=new mg(this.__jsonld.items,this.options);this.items.push(s)}return this.items},e.prototype.getSequenceByIndex=function(t){return this.getSequences()[t]},e.prototype.getTotalSequences=function(){return this.getSequences().length},e.prototype.getManifestType=function(){var t=this.getService(fe.ServiceProfile.UI_EXTENSIONS);return t?t.getProperty("manifestType"):$u.EMPTY},e.prototype.isMultiSequence=function(){return this.getTotalSequences()>1},e.prototype.isPagingEnabled=function(){var t=this.getViewingHint();if(t)return t===fe.ViewingHint.PAGED;var i=this.getBehavior();return i?i===fe.Behavior.PAGED:!1},e.prototype.getViewingDirection=function(){return this.getProperty("viewingDirection")},e.prototype.getViewingHint=function(){var t=this.getProperty("viewingHint");return Array.isArray(t)&&(t=t[0]),t||null},e})(Yp),$u;(function(r){r.EMPTY="",r.MANUSCRIPT="manuscript",r.MONOGRAPH="monograph"})($u||($u={}));var Hx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Gx=(function(r){Hx(e,r);function e(t,i){var n=r.call(this,t,i)||this;return n._ranges=null,n.canvases=null,n.items=[],n}return e.prototype.getCanvasIds=function(){return this.__jsonld.canvases?this.__jsonld.canvases:this.canvases?this.canvases:[]},e.prototype.getDuration=function(){if(this.canvases&&this.canvases.length){for(var t=[],i=[],n=0,s=this.canvases;n<s.length;n++){var o=s[n];if(o){var a=o.match(/(.*)#t=([0-9.]+),?([0-9.]+)?/)||[void 0,o],l=a[1],h=a[2],u=a[3];l&&(t.push(parseFloat(h)),i.push(parseFloat(u)))}}if(t.length&&i.length)return new qu(Math.min.apply(Math,t),Math.max.apply(Math,i))}else{for(var c=this.getRanges(),t=[],i=[],d=0,f=c;d<f.length;d++){var g=f[d],p=g.getDuration();p&&(t.push(p.start),i.push(p.end))}if(t.length&&i.length)return new qu(Math.min.apply(Math,t),Math.max.apply(Math,i))}var m,v;if(this.canvases&&this.canvases.length)for(var y=0;y<this.canvases.length;y++){var o=this.canvases[y],_=Ke.getTemporalComponent(o);_&&_.length>1&&(y===0&&(m=Number(_[0])),y===this.canvases.length-1&&(v=Number(_[1])))}else for(var c=this.getRanges(),y=0;y<c.length;y++){var g=c[y],p=g.getDuration();p&&(y===0&&(m=p.start),y===c.length-1&&(v=p.end))}if(m!==void 0&&v!==void 0)return new qu(m,v)},e.prototype.getRanges=function(){return this._ranges?this._ranges:this._ranges=this.items.filter(function(t){return t.isRange()})},e.prototype.getBehavior=function(){var t=this.getProperty("behavior");return Array.isArray(t)&&(t=t[0]),t||null},e.prototype.getViewingDirection=function(){return this.getProperty("viewingDirection")},e.prototype.getViewingHint=function(){var t=this.getProperty("viewingHint");return Array.isArray(t)&&(t=t[0]),t||null},e.prototype.getTree=function(t){t.data=this,this.treeNode=t;var i=this.getRanges();if(i&&i.length)for(var n=0;n<i.length;n++){var s=i[n],o=new ec;t.addNode(o),this._parseTreeNode(o,s)}return Ke.generateTreeNodeIds(t),t},e.prototype.spansTime=function(t){var i=this.getDuration();return!!(i&&t>=i.start&&t<=i.end)},e.prototype._parseTreeNode=function(t,i){t.label=i.getLabel().getValue(this.options.locale),t.data=i,t.data.type=Ke.normaliseType(br.RANGE),i.treeNode=t;var n=i.getRanges();if(n&&n.length)for(var s=0;s<n.length;s++){var o=n[s],a=o.getBehavior();if(a!==fe.Behavior.NO_NAV){var l=new ec;t.addNode(l),this._parseTreeNode(l,o)}}},e})(Yr),Vx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),zx=(function(r){Vx(e,r);function e(t,i){return r.call(this,t,i)||this}return e.prototype.getFormat=function(){return this.getProperty("format")},e})(Yr),jx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),mg=(function(r){jx(e,r);function e(t,i){var n=r.call(this,t,i)||this;return n.items=[],n._thumbnails=null,n}return e.prototype.getCanvases=function(){if(this.items.length)return this.items;var t=this.__jsonld.canvases||this.__jsonld.elements;if(t)for(var i=0;i<t.length;i++){var n=t[i],s=new Tl(n,this.options);s.index=i,this.items.push(s)}else if(this.__jsonld)for(var i=0;i<this.__jsonld.length;i++){var n=this.__jsonld[i],s=new Tl(n,this.options);s.index=i,this.items.push(s)}return this.items},e.prototype.getCanvasById=function(t){for(var i=0;i<this.getTotalCanvases();i++){var n=this.getCanvasByIndex(i),s=Ke.normaliseUrl(n.id);if(Ke.normaliseUrl(t)===s)return n}return null},e.prototype.getCanvasByIndex=function(t){return this.getCanvases()[t]},e.prototype.getCanvasIndexById=function(t){for(var i=0;i<this.getTotalCanvases();i++){var n=this.getCanvasByIndex(i);if(n.id===t)return i}return null},e.prototype.getCanvasIndexByLabel=function(t,i){t=t.trim(),isNaN(t)||(t=parseInt(t,10).toString(),i&&(t+="r"));for(var n=/(\d*)\D+(\d*)/,s,o,a,l,h,u=0;u<this.getTotalCanvases();u++){var c=this.getCanvasByIndex(u);if(c.getLabel().getValue(this.options.locale)===t)return u;if(s=n.exec(t),!!s&&(l=s[1],h=s[2],!!h&&(a="^"+l+"\\D+"+h+"$",o=new RegExp(a),o.test(c.getLabel().toString()))))return u}return-1},e.prototype.getLastCanvasLabel=function(t){for(var i=this.getTotalCanvases()-1;i>=0;i--){var n=this.getCanvasByIndex(i),s=n.getLabel().getValue(this.options.locale);if(t){var o=/^[a-zA-Z0-9]*$/;if(o.test(s))return s}else if(s)return s}return this.options.defaultLabel},e.prototype.getLastPageIndex=function(){return this.getTotalCanvases()-1},e.prototype.getNextPageIndex=function(t,i){var n;if(i){var s=this.getPagedIndices(t),o=this.getViewingDirection();o&&o===fe.ViewingDirection.RIGHT_TO_LEFT?n=s[0]+1:n=s[s.length-1]+1}else n=t+1;return n>this.getLastPageIndex()?-1:n},e.prototype.getPagedIndices=function(t,i){var n=[];if(!i)n.push(t);else{this.isFirstCanvas(t)||this.isLastCanvas(t)?n=[t]:t%2?n=[t,t+1]:n=[t-1,t];var s=this.getViewingDirection();s&&s===fe.ViewingDirection.RIGHT_TO_LEFT&&(n=n.reverse())}return n},e.prototype.getPrevPageIndex=function(t,i){var n;if(i){var s=this.getPagedIndices(t),o=this.getViewingDirection();o&&o===fe.ViewingDirection.RIGHT_TO_LEFT?n=s[s.length-1]-1:n=s[0]-1}else n=t-1;return n},e.prototype.getStartCanvasIndex=function(){var t=this.getStartCanvas();if(t)for(var i=0;i<this.getTotalCanvases();i++){var n=this.getCanvasByIndex(i);if(n.id===t)return i}return 0},e.prototype.getThumbs=function(t,i){for(var n=[],s=this.getTotalCanvases(),o=0;o<s;o++){var a=this.getCanvasByIndex(o),l=new Yx(t,a);n.push(l)}return n},e.prototype.getThumbnails=function(){if(this._thumbnails!=null)return this._thumbnails;this._thumbnails=[];for(var t=this.getCanvases(),i=0;i<t.length;i++){var n=t[i].getThumbnail();n&&this._thumbnails.push(n)}return this._thumbnails},e.prototype.getStartCanvas=function(){return this.getProperty("startCanvas")},e.prototype.getTotalCanvases=function(){return this.getCanvases().length},e.prototype.getViewingDirection=function(){return this.getProperty("viewingDirection")?this.getProperty("viewingDirection"):this.options.resource.getViewingDirection?this.options.resource.getViewingDirection():null},e.prototype.getViewingHint=function(){var t=this.getProperty("viewingHint");return Array.isArray(t)&&(t=t[0]),t||null},e.prototype.isCanvasIndexOutOfRange=function(t){return t>this.getTotalCanvases()-1},e.prototype.isFirstCanvas=function(t){return t===0},e.prototype.isLastCanvas=function(t){return t===this.getTotalCanvases()-1},e.prototype.isMultiCanvas=function(){return this.getTotalCanvases()>1},e.prototype.isPagingEnabled=function(){var t=this.getViewingHint();return t?t===fe.ViewingHint.PAGED:!1},e.prototype.isTotalCanvasesEven=function(){return this.getTotalCanvases()%2===0},e})(Yr),vg=(function(){function r(){}return r.parse=function(e,t){return typeof e=="string"&&(e=JSON.parse(e)),this.parseJson(e,t)},r.parseJson=function(e,t){var i;if(t&&t.navDate&&!isNaN(t.navDate.getTime())&&(e.navDate=t.navDate.toString()),e["@type"])switch(e["@type"]){case"sc:Collection":i=this.parseCollection(e,t);break;case"sc:Manifest":i=this.parseManifest(e,t);break;default:return null}else switch(e.type){case"Collection":i=this.parseCollection(e,t);break;case"Manifest":i=this.parseManifest(e,t);break;default:return null}return i.isLoaded=!0,i},r.parseCollection=function(e,t){var i=new Dx(e,t);return t?(i.index=t.index||0,t.resource&&(i.parentCollection=t.resource.parentCollection)):i.index=0,this.parseCollections(i,t),this.parseManifests(i,t),this.parseItems(i,t),i},r.parseCollections=function(e,t){var i;if(e.__jsonld.collections?i=e.__jsonld.collections:e.__jsonld.items&&(i=e.__jsonld.items.filter(function(o){return o.type.toLowerCase()==="collection"})),i)for(var n=0;n<i.length;n++){t&&(t.index=n);var s=this.parseCollection(i[n],t);s.index=n,s.parentCollection=e,e.items.push(s)}},r.parseManifest=function(e,t){var i=new Ux(e,t);return i},r.parseManifests=function(e,t){var i;if(e.__jsonld.manifests?i=e.__jsonld.manifests:e.__jsonld.items&&(i=e.__jsonld.items.filter(function(o){return o.type.toLowerCase()==="manifest"})),i)for(var n=0;n<i.length;n++){var s=this.parseManifest(i[n],t);s.index=n,s.parentCollection=e,e.items.push(s)}},r.parseItem=function(e,t){if(e["@type"]){if(e["@type"].toLowerCase()==="sc:manifest")return this.parseManifest(e,t);if(e["@type"].toLowerCase()==="sc:collection")return this.parseCollection(e,t)}else if(e.type){if(e.type.toLowerCase()==="manifest")return this.parseManifest(e,t);if(e.type.toLowerCase()==="collection")return this.parseCollection(e,t)}return null},r.parseItems=function(e,t){var i=e.__jsonld.members||e.__jsonld.items;if(i)for(var n=function(l){t&&(t.index=l);var h=s.parseItem(i[l],t);if(!h)return{value:void 0};if(e.items.filter(function(u){return u.id===h.id})[0])return"continue";h.index=l,h.parentCollection=e,e.items.push(h)},s=this,o=0;o<i.length;o++){var a=n(o);if(typeof a=="object")return a.value}},r})(),Wx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),yg=(function(r){Wx(e,r);function e(t,i){return r.call(this,t,i)||this}return e.prototype.getProfile=function(){var t=this.getProperty("profile");return t||(t=this.getProperty("dcterms:conformsTo")),Array.isArray(t)?t[0]:t},e.prototype.getConfirmLabel=function(){return Ke.getLocalisedValue(this.getProperty("confirmLabel"),this.options.locale)},e.prototype.getDescription=function(){return Ke.getLocalisedValue(this.getProperty("description"),this.options.locale)},e.prototype.getFailureDescription=function(){return Ke.getLocalisedValue(this.getProperty("failureDescription"),this.options.locale)},e.prototype.getFailureHeader=function(){return Ke.getLocalisedValue(this.getProperty("failureHeader"),this.options.locale)},e.prototype.getHeader=function(){return Ke.getLocalisedValue(this.getProperty("header"),this.options.locale)},e.prototype.getServiceLabel=function(){return Ke.getLocalisedValue(this.getProperty("label"),this.options.locale)},e.prototype.getInfoUri=function(){var t=this.id;return t.endsWith("/")||(t+="/"),t+="info.json",t},e})(Yr),Xx=(function(){function r(e,t){this.width=e,this.height=t}return r})(),Wo;(function(r){r[r.AUTHORIZATION_FAILED=1]="AUTHORIZATION_FAILED",r[r.FORBIDDEN=2]="FORBIDDEN",r[r.INTERNAL_SERVER_ERROR=3]="INTERNAL_SERVER_ERROR",r[r.RESTRICTED=4]="RESTRICTED"})(Wo||(Wo={}));var Yx=(function(){function r(e,t){this.data=t,this.index=t.index,this.width=e;var i=t.getHeight()/t.getWidth();i?this.height=Math.floor(this.width*i):this.height=e,this.uri=t.getCanonicalImageUri(e),this.label=t.getLabel().getValue(),this.viewingHint=t.getViewingHint()}return r})(),Zx=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),qx=(function(r){Zx(e,r);function e(t,i){return r.call(this,t,i)||this}return e})(Mu),ec=(function(){function r(e,t){this.label=e,this.data=t||{},this.nodes=[]}return r.prototype.addNode=function(e){this.nodes.push(e),e.parentNode=this},r.prototype.isCollection=function(){return this.data.type===Ke.normaliseType(br.COLLECTION)},r.prototype.isManifest=function(){return this.data.type===Ke.normaliseType(br.MANIFEST)},r.prototype.isRange=function(){return this.data.type===Ke.normaliseType(br.RANGE)},r})(),br;(function(r){r.COLLECTION="collection",r.MANIFEST="manifest",r.RANGE="range"})(br||(br={}));var Kx=function(r,e){return Ke.parseManifest(r,e)};class Qx{constructor(){Ie(this,Ia,qe(_i({})))}get manifests(){return P(Z(this,Ia))}set manifests(e){Me(Z(this,Ia),e,!0)}async fetchManifest(e){if(!this.manifests[e]){this.manifests[e]={isFetching:!0};try{const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const i=await t.json(),n=Kx(i);this.manifests[e]={json:i,manifesto:n,isFetching:!1}}catch(t){this.manifests[e]={error:t.message,isFetching:!1}}}}getManifest(e){const t=this.manifests[e];return t==null?void 0:t.manifesto}async fetchAnnotationList(e){if(!this.manifests[e])try{const t=await fetch(e);if(t.ok){const i=await t.json();this.manifests[e]={json:i}}else console.error(`Failed to fetch annotation list: ${e}`)}catch(t){console.error(`Error fetching annotation list: ${e}`,t)}}getCanvases(e){const t=this.getManifest(e);if(!t)return[];const i=t.getSequences();return!i||!i.length?[]:i[0].getCanvases()}getAnnotations(e,t){const i=this.getManifest(e);return i?i.getSequences()[0].getCanvasById(t)?this.manualGetAnnotations(e,t):[]:[]}manualGetAnnotations(e,t){const i=this.getManifest(e);if(!i)return[];const n=i.getSequences()[0].getCanvasById(t);if(!n)return[];const s=n.__jsonld;let o=[];const a=l=>l.resources||l.items||[];return s.otherContent&&s.otherContent.forEach(l=>{const h=l["@id"]||l.id;if(h&&!l.resources){const u=this.manifests[h];if(u){if(u.json){const c=a(u.json);o.push(...c)}}else this.fetchAnnotationList(h)}else l.resources&&o.push(...l.resources)}),s.annotations&&s.annotations.forEach(l=>{const h=l.id||l["@id"];if(h&&!l.items){const u=this.manifests[h];if(u){if(u.json){const c=a(u.json);o.push(...c)}}else this.fetchAnnotationList(h)}else l.items&&o.push(...l.items)}),o}}Ia=new WeakMap;const Ns=new Qx;class Jx{constructor(e){Ie(this,Ma,qe(null));Ie(this,Da,qe(null));Ie(this,Oa,qe(!1));Ie(this,La,qe(!1));Ie(this,Na,qe(!1));Ie(this,Fa,qe(!1));Ie(this,Ba,qe(!1));Ie(this,ka,qe(!1));Ie(this,Ua,qe("none"));Ie(this,Ha,qe(_i(new Set)));Ie(this,Ga,qe(_i({})));Ie(this,Va,qe(!1));Ie(this,za,qe(""));Ie(this,ja,qe(_i([])));Ie(this,Wa,qe(!1));Ie(this,Xa,qe(!1));Ie(this,Ya,qe(_i([])));this.manifestId=e||null,this.manifestId&&Ns.fetchManifest(this.manifestId)}get manifestId(){return P(Z(this,Ma))}set manifestId(e){Me(Z(this,Ma),e,!0)}get canvasId(){return P(Z(this,Da))}set canvasId(e){Me(Z(this,Da),e,!0)}get showAnnotations(){return P(Z(this,Oa))}set showAnnotations(e){Me(Z(this,Oa),e,!0)}get showThumbnailGallery(){return P(Z(this,La))}set showThumbnailGallery(e){Me(Z(this,La),e,!0)}get isGalleryDockedBottom(){return P(Z(this,Na))}set isGalleryDockedBottom(e){Me(Z(this,Na),e,!0)}get isGalleryDockedRight(){return P(Z(this,Fa))}set isGalleryDockedRight(e){Me(Z(this,Fa),e,!0)}get isFullScreen(){return P(Z(this,Ba))}set isFullScreen(e){Me(Z(this,Ba),e,!0)}get showMetadataDialog(){return P(Z(this,ka))}set showMetadataDialog(e){Me(Z(this,ka),e,!0)}get dockSide(){return P(Z(this,Ua))}set dockSide(e){Me(Z(this,Ua),e,!0)}get visibleAnnotationIds(){return P(Z(this,Ha))}set visibleAnnotationIds(e){Me(Z(this,Ha),e,!0)}get createdAnnotations(){return P(Z(this,Ga))}set createdAnnotations(e){Me(Z(this,Ga),e,!0)}get isCreatingAnnotation(){return P(Z(this,Va))}set isCreatingAnnotation(e){Me(Z(this,Va),e,!0)}get manifest(){return this.manifestId?Ns.getManifest(this.manifestId):null}get canvases(){if(!this.manifestId)return[];const e=Ns.getCanvases(this.manifestId);return e.length>0&&!this.canvasId&&setTimeout(()=>{!this.canvasId&&e.length>0&&(this.canvasId=e[0].id)},0),e}get currentCanvasIndex(){return this.canvasId?this.canvases.findIndex(e=>e.id===this.canvasId):this.canvases.length>0?0:-1}get hasNext(){return this.currentCanvasIndex<this.canvases.length-1}get hasPrevious(){return this.currentCanvasIndex>0}nextCanvas(){if(this.hasNext){const e=this.currentCanvasIndex+1,t=this.canvases[e];this.canvasId=t.id}}previousCanvas(){if(this.hasPrevious){const e=this.currentCanvasIndex-1,t=this.canvases[e];this.canvasId=t.id}}setManifest(e){this.manifestId=e,this.canvasId=null,Ns.fetchManifest(e)}setCanvas(e){this.canvasId=e,this.loadAnnotationsFromStorage(e)}toggleCreationMode(e){typeof e=="boolean"?this.isCreatingAnnotation=e:this.isCreatingAnnotation=!this.isCreatingAnnotation}loadAnnotationsFromStorage(e){if(typeof localStorage>"u")return;const t=`triiiceratops-annotations-${e}`,i=localStorage.getItem(t);if(i)try{const n=JSON.parse(i);Array.isArray(n)&&(this.createdAnnotations[e]=n)}catch(n){console.error("Failed to parse stored annotations",n)}}addAnnotation(e,t){if(t&&(this.createdAnnotations[t]||(this.createdAnnotations[t]=[]),this.createdAnnotations[t]=[...this.createdAnnotations[t],e],typeof localStorage<"u")){const i=`triiiceratops-annotations-${t}`;localStorage.setItem(i,JSON.stringify(this.createdAnnotations[t]))}}toggleAnnotations(){this.showAnnotations=!this.showAnnotations}toggleThumbnailGallery(){this.showThumbnailGallery=!this.showThumbnailGallery}toggleFullScreen(){if(document.fullscreenElement)document.exitFullscreen();else{const e=document.getElementById("triiiceratops-viewer");e&&e.requestFullscreen().catch(t=>{console.warn("Fullscreen request failed",t)})}}toggleMetadataDialog(){this.showMetadataDialog=!this.showMetadataDialog}get searchQuery(){return P(Z(this,za))}set searchQuery(e){Me(Z(this,za),e,!0)}get searchResults(){return P(Z(this,ja))}set searchResults(e){Me(Z(this,ja),e,!0)}get isSearching(){return P(Z(this,Wa))}set isSearching(e){Me(Z(this,Wa),e,!0)}get showSearchPanel(){return P(Z(this,Xa))}set showSearchPanel(e){Me(Z(this,Xa),e,!0)}toggleSearchPanel(){this.showSearchPanel=!this.showSearchPanel,this.showSearchPanel||(this.searchAnnotations=[])}get searchAnnotations(){return P(Z(this,Ya))}set searchAnnotations(e){Me(Z(this,Ya),e,!0)}get currentCanvasSearchAnnotations(){return this.canvasId?this.searchAnnotations.filter(e=>e.canvasId===this.canvasId):[]}async search(e){var t,i;if(e.trim()){this.isSearching=!0,this.searchQuery=e,this.searchResults=[];try{const n=this.manifest;if(!n)throw new Error("No manifest loaded");let s=n.getService("http://iiif.io/api/search/1/search")||n.getService("http://iiif.io/api/search/0/search");if(s||n.__jsonld&&n.__jsonld.service&&(s=(Array.isArray(n.__jsonld.service)?n.__jsonld.service:[n.__jsonld.service]).find(g=>g.profile==="http://iiif.io/api/search/1/search"||g.profile==="http://iiif.io/api/search/0/search")),!s){console.warn("No IIIF search service found in manifest"),this.isSearching=!1;return}const a=`${s.id||s["@id"]}?q=${encodeURIComponent(e)}`,l=await fetch(a);if(!l.ok)throw new Error("Search request failed");const h=await l.json(),u=h.resources||[],c=[],d=f=>{const g=typeof f=="string"?f:f["@id"]||f.id;if(!g)return null;const p=g.split("#xywh=");if(p.length<2)return null;const m=p[1].split(",").map(Number);return m.length===4?m:null};if(h.hits)for(const f of h.hits){const g=f.annotations||[];for(const p of g){const m=u.find(v=>v["@id"]===p||v.id===p);if(m&&m.on){const v=typeof m.on=="string"?m.on:m.on["@id"]||m.on.id,y=v.split("#")[0],_=d(v),w=this.canvases.findIndex(A=>A.id===y);if(w>=0){const A=this.canvases[w];let F="Canvas "+(w+1);try{if(A.getLabel){const C=A.getLabel();Array.isArray(C)&&C.length>0?F=C[0].value:typeof C=="string"&&(F=C)}else A.label&&(typeof A.label=="string"?F=A.label:Array.isArray(A.label)&&(F=(t=A.label[0])==null?void 0:t.value))}catch{}c.push({type:"hit",before:f.before,match:f.match,after:f.after,canvasIndex:w,canvasLabel:String(F),bounds:_})}}}}else if(u.length>0)for(const f of u){const g=typeof f.on=="string"?f.on:f.on["@id"]||f.on.id,p=g.split("#")[0],m=d(g),v=this.canvases.findIndex(y=>y.id===p);if(v>=0){const y=this.canvases[v];let _="Canvas "+(v+1);try{if(y.getLabel){const w=y.getLabel();Array.isArray(w)&&w.length>0?_=w[0].value:typeof w=="string"&&(_=w)}else y.label&&(typeof y.label=="string"?_=y.label:Array.isArray(y.label)&&(_=(i=y.label[0])==null?void 0:i.value))}catch{}c.push({type:"resource",match:f.resource&&f.resource.chars?f.resource.chars:f.chars||"",canvasIndex:v,canvasLabel:String(_),bounds:m})}}this.searchResults=c,this.searchAnnotations=c.filter(f=>f.bounds).map((f,g)=>{const p=this.canvases[f.canvasIndex],m=`${p.id}#xywh=${f.bounds.join(",")}`;return{"@id":`urn:search-hit:${g}`,"@type":"oa:Annotation",motivation:"sc:painting",on:m,canvasId:p.id,resource:{"@type":"cnt:ContentAsText",chars:f.match},isSearchHit:!0}})}catch(n){console.error("Search error:",n)}finally{this.isSearching=!1}}}}Ma=new WeakMap,Da=new WeakMap,Oa=new WeakMap,La=new WeakMap,Na=new WeakMap,Fa=new WeakMap,Ba=new WeakMap,ka=new WeakMap,Ua=new WeakMap,Ha=new WeakMap,Ga=new WeakMap,Va=new WeakMap,za=new WeakMap,ja=new WeakMap,Wa=new WeakMap,Xa=new WeakMap,Ya=new WeakMap;const Fs="triiiceratops:viewerState";var Al={exports:{}},$x=Al.exports,_g;function ew(){return _g||(_g=1,(function(r){//! openseadragon 5.0.1
|
|
4
|
+
//! Built on 2024-12-09
|
|
5
|
+
//! Git commit: v5.0.1-0-480de92d
|
|
6
|
+
//! http://openseadragon.github.io
|
|
7
|
+
//! License: http://openseadragon.github.io/license/
|
|
8
|
+
function e(t){return new e.Viewer(t)}(function(t){t.version={versionStr:"5.0.1",major:parseInt("5",10),minor:parseInt("0",10),revision:parseInt("1",10)};var i={"[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"},n=Object.prototype.toString,s=Object.prototype.hasOwnProperty;t.isFunction=function(o){return t.type(o)==="function"},t.isArray=Array.isArray||function(o){return t.type(o)==="array"},t.isWindow=function(o){return o&&typeof o=="object"&&"setInterval"in o},t.type=function(o){return o==null?String(o):i[n.call(o)]||"object"},t.isPlainObject=function(o){if(!o||e.type(o)!=="object"||o.nodeType||t.isWindow(o)||o.constructor&&!s.call(o,"constructor")&&!s.call(o.constructor.prototype,"isPrototypeOf"))return!1;var a;for(var l in o)a=l;return a===void 0||s.call(o,a)},t.isEmptyObject=function(o){for(var a in o)return!1;return!0},t.freezeObject=function(o){return Object.freeze?t.freezeObject=Object.freeze:t.freezeObject=function(a){return a},t.freezeObject(o)},t.supportsCanvas=(function(){var o=document.createElement("canvas");return!!(t.isFunction(o.getContext)&&o.getContext("2d"))})(),t.isCanvasTainted=function(o){var a=!1;try{o.getContext("2d").getImageData(0,0,1,1)}catch{a=!0}return a},t.supportsAddEventListener=(function(){return!!(document.documentElement.addEventListener&&document.addEventListener)})(),t.supportsRemoveEventListener=(function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)})(),t.supportsEventListenerOptions=(function(){var o=0;if(t.supportsAddEventListener)try{var a={get capture(){return o++,!1},get once(){return o++,!1},get passive(){return o++,!1}};window.addEventListener("test",null,a),window.removeEventListener("test",null,a)}catch{o=0}return o>=3})(),t.getCurrentPixelDensityRatio=function(){if(t.supportsCanvas){var o=document.createElement("canvas").getContext("2d"),a=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;return Math.max(a,1)/l}else return 1},t.pixelDensityRatio=t.getCurrentPixelDensityRatio()})(e),(function(t){t.extend=function(){var l,h,u,c,d,f,g=arguments[0]||{},p=arguments.length,m=!1,v=1;for(typeof g=="boolean"&&(m=g,g=arguments[1]||{},v=2),typeof g!="object"&&!e.isFunction(g)&&(g={}),p===v&&(g=this,--v);v<p;v++)if(l=arguments[v],l!==null||l!==void 0)for(h in l){var y=Object.getOwnPropertyDescriptor(l,h);if(y!==void 0){if(y.get||y.set){Object.defineProperty(g,h,y);continue}c=y.value}else{t.console.warn('Could not copy inherited property "'+h+'".');continue}g!==c&&(m&&c&&(e.isPlainObject(c)||(d=e.isArray(c)))?(u=g[h],d?(d=!1,f=u&&e.isArray(u)?u:[]):f=u&&e.isPlainObject(u)?u:{},g[h]=e.extend(m,f,c)):c!==void 0&&(g[h]=c))}return g};var i=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};t.extend(t,{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:i(),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,h){return function(){var u=arguments;return u===void 0&&(u=[]),h.apply(l,u)}},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 t._viewers.get(this.getElement(l))},getElement:function(l){return typeof l=="string"&&(l=document.getElementById(l)),l},getElementPosition:function(l){var h=new t.Point,u,c;for(l=t.getElement(l),u=t.getElementStyle(l).position==="fixed",c=a(l,u);c;)h.x+=l.offsetLeft,h.y+=l.offsetTop,u&&(h=h.plus(t.getPageScroll())),l=c,u=t.getElementStyle(l).position==="fixed",c=a(l,u);return h},getElementOffset:function(l){l=t.getElement(l);var h=l&&l.ownerDocument,u,c,d={top:0,left:0};return h?(u=h.documentElement,typeof l.getBoundingClientRect<"u"&&(d=l.getBoundingClientRect()),c=h===h.window?h:h.nodeType===9?h.defaultView||h.parentWindow:!1,new t.Point(d.left+(c.pageXOffset||u.scrollLeft)-(u.clientLeft||0),d.top+(c.pageYOffset||u.scrollTop)-(u.clientTop||0))):new t.Point},getElementSize:function(l){return l=t.getElement(l),new t.Point(l.clientWidth,l.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(l){return l=t.getElement(l),l.currentStyle}:function(l){return l=t.getElement(l),window.getComputedStyle(l,"")},getCssPropertyWithVendorPrefix:function(l){var h={};return t.getCssPropertyWithVendorPrefix=function(u){if(h[u]!==void 0)return h[u];var c=document.createElement("div").style,d=null;if(c[u]!==void 0)d=u;else for(var f=["Webkit","Moz","MS","O","webkit","moz","ms","o"],g=t.capitalizeFirstLetter(u),p=0;p<f.length;p++){var m=f[p]+g;if(c[m]!==void 0){d=m;break}}return h[u]=d,d},t.getCssPropertyWithVendorPrefix(l)},capitalizeFirstLetter:function(l){return l.charAt(0).toUpperCase()+l.slice(1)},positiveModulo:function(l,h){var u=l%h;return u<0&&(u+=h),u},pointInElement:function(l,h){l=t.getElement(l);var u=t.getElementOffset(l),c=t.getElementSize(l);return h.x>=u.x&&h.x<u.x+c.x&&h.y<u.y+c.y&&h.y>=u.y},getMousePosition:function(l){if(typeof l.pageX=="number")t.getMousePosition=function(h){var u=new t.Point;return u.x=h.pageX,u.y=h.pageY,u};else if(typeof l.clientX=="number")t.getMousePosition=function(h){var u=new t.Point;return u.x=h.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,u.y=h.clientY+document.body.scrollTop+document.documentElement.scrollTop,u};else throw new Error("Unknown event mouse position, no known technique.");return t.getMousePosition(l)},getPageScroll:function(){var l=document.documentElement||{},h=document.body||{};if(typeof window.pageXOffset=="number")t.getPageScroll=function(){return new t.Point(window.pageXOffset,window.pageYOffset)};else if(h.scrollLeft||h.scrollTop)t.getPageScroll=function(){return new t.Point(document.body.scrollLeft,document.body.scrollTop)};else if(l.scrollLeft||l.scrollTop)t.getPageScroll=function(){return new t.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)};else return new t.Point(0,0);return t.getPageScroll()},setPageScroll:function(l){if(typeof window.scrollTo<"u")t.setPageScroll=function(c){window.scrollTo(c.x,c.y)};else{var h=t.getPageScroll();if(h.x===l.x&&h.y===l.y)return;document.body.scrollLeft=l.x,document.body.scrollTop=l.y;var u=t.getPageScroll();if(u.x!==h.x&&u.y!==h.y){t.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,u=t.getPageScroll(),u.x!==h.x&&u.y!==h.y){t.setPageScroll=function(c){document.documentElement.scrollLeft=c.x,document.documentElement.scrollTop=c.y};return}t.setPageScroll=function(c){}}t.setPageScroll(l)},getWindowSize:function(){var l=document.documentElement||{},h=document.body||{};if(typeof window.innerWidth=="number")t.getWindowSize=function(){return new t.Point(window.innerWidth,window.innerHeight)};else if(l.clientWidth||l.clientHeight)t.getWindowSize=function(){return new t.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(h.clientWidth||h.clientHeight)t.getWindowSize=function(){return new t.Point(document.body.clientWidth,document.body.clientHeight)};else throw new Error("Unknown window size, no known technique.");return t.getWindowSize()},makeCenteredNode:function(l){l=t.getElement(l);var h=[t.makeNeutralElement("div"),t.makeNeutralElement("div"),t.makeNeutralElement("div")];return t.extend(h[0].style,{display:"table",height:"100%",width:"100%"}),t.extend(h[1].style,{display:"table-row"}),t.extend(h[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),h[0].appendChild(h[1]),h[1].appendChild(h[2]),h[2].appendChild(l),h[0]},makeNeutralElement:function(l){var h=document.createElement(l),u=h.style;return u.background="transparent none",u.border="none",u.margin="0px",u.padding="0px",u.position="static",h},now:function(){return Date.now?t.now=Date.now:t.now=function(){return new Date().getTime()},t.now()},makeTransparentImage:function(l){var h=t.makeNeutralElement("img");return h.src=l,h},setElementOpacity:function(l,h,u){var c,d;l=t.getElement(l),u&&!t.Browser.alpha&&(h=Math.round(h)),t.Browser.opacity?l.style.opacity=h<1?h:"":h<1?(c=Math.round(100*h),d="alpha(opacity="+c+")",l.style.filter=d):l.style.filter=""},setElementTouchActionNone:function(l){l=t.getElement(l),typeof l.style.touchAction<"u"?l.style.touchAction="none":typeof l.style.msTouchAction<"u"&&(l.style.msTouchAction="none")},setElementPointerEvents:function(l,h){l=t.getElement(l),typeof l.style<"u"&&typeof l.style.pointerEvents<"u"&&(l.style.pointerEvents=h)},setElementPointerEventsNone:function(l){t.setElementPointerEvents(l,"none")},addClass:function(l,h){l=t.getElement(l),l.className?(" "+l.className+" ").indexOf(" "+h+" ")===-1&&(l.className+=" "+h):l.className=h},indexOf:function(l,h,u){return Array.prototype.indexOf?this.indexOf=function(c,d,f){return c.indexOf(d,f)}:this.indexOf=function(c,d,f){var g,p=f||0,m;if(!c)throw new TypeError;if(m=c.length,m===0||p>=m)return-1;for(p<0&&(p=m-Math.abs(p)),g=p;g<m;g++)if(c[g]===d)return g;return-1},this.indexOf(l,h,u)},removeClass:function(l,h){var u,c=[],d;for(l=t.getElement(l),u=l.className.split(/\s+/),d=0;d<u.length;d++)u[d]&&u[d]!==h&&c.push(u[d]);l.className=c.join(" ")},normalizeEventListenerOptions:function(l){var h;return typeof l<"u"?typeof l=="boolean"?h=t.supportsEventListenerOptions?{capture:l}:l:h=t.supportsEventListenerOptions?l:typeof l.capture<"u"?l.capture:!1:h=t.supportsEventListenerOptions?{capture:!1}:!1,h},addEvent:(function(){if(t.supportsAddEventListener)return function(l,h,u,c){c=t.normalizeEventListenerOptions(c),l=t.getElement(l),l.addEventListener(h,u,c)};if(document.documentElement.attachEvent&&document.attachEvent)return function(l,h,u){l=t.getElement(l),l.attachEvent("on"+h,u)};throw new Error("No known event model.")})(),removeEvent:(function(){if(t.supportsRemoveEventListener)return function(l,h,u,c){c=t.normalizeEventListenerOptions(c),l=t.getElement(l),l.removeEventListener(h,u,c)};if(document.documentElement.detachEvent&&document.detachEvent)return function(l,h,u){l=t.getElement(l),l.detachEvent("on"+h,u)};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,h){console.error("The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.");var u=[],c;for(c=2;c<arguments.length;c++)u.push(arguments[c]);return function(){var d=u.concat([]),f;for(f=0;f<arguments.length;f++)d.push(arguments[f]);return h.apply(l,d)}},getUrlParameter:function(l){var h=o[l];return h||null},getUrlProtocol:function(l){var h=l.match(/^([a-z]+:)\/\//i);return h===null?window.location.protocol:h[1].toLowerCase()},createAjaxRequest:function(){if(window.XMLHttpRequest)return t.createAjaxRequest=function(){return new XMLHttpRequest},new XMLHttpRequest;throw new Error("Browser doesn't support XMLHttpRequest.")},makeAjaxRequest:function(l,h,u){var c,d,f,g;t.isPlainObject(l)&&(h=l.success,u=l.error,c=l.withCredentials,d=l.headers,f=l.responseType||null,g=l.postData||null,l=l.url);var p=t.getUrlProtocol(l),m=t.createAjaxRequest();if(!t.isFunction(h))throw new Error("makeAjaxRequest requires a success callback");m.onreadystatechange=function(){m.readyState===4&&(m.onreadystatechange=function(){},m.status>=200&&m.status<300||m.status===0&&p!=="http:"&&p!=="https:"?h(m):t.isFunction(u)?u(m):t.console.error("AJAX request returned %d: %s",m.status,l))};var v=g?"POST":"GET";try{if(m.open(v,l,!0),f&&(m.responseType=f),d)for(var y in d)Object.prototype.hasOwnProperty.call(d,y)&&d[y]&&m.setRequestHeader(y,d[y]);c&&(m.withCredentials=!0),m.send(g)}catch(_){t.console.error("%s while making AJAX request: %s",_.name,_.message),m.onreadystatechange=function(){},t.isFunction(u)&&u(m,_)}return m},jsonp:function(l){var h,u=l.url,c=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=l.callbackName||"openseadragon"+t.now(),f=window[d],g="$1"+d+"$2",p=l.param||"callback",m=l.callback;u=u.replace(/(=)\?(&|$)|\?\?/i,g),u+=(/\?/.test(u)?"&":"?")+p+"="+d,window[d]=function(v){if(f)window[d]=f;else try{delete window[d]}catch{}m&&t.isFunction(m)&&m(v)},h=document.createElement("script"),(l.async!==void 0||l.async!==!1)&&(h.async="async"),l.scriptCharset&&(h.charset=l.scriptCharset),h.src=u,h.onload=h.onreadystatechange=function(v,y){(y||!h.readyState||/loaded|complete/.test(h.readyState))&&(h.onload=h.onreadystatechange=null,c&&h.parentNode&&c.removeChild(h),h=void 0)},c.insertBefore(h,c.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(l){if(window.DOMParser)t.parseXml=function(h){var u=null,c;return c=new DOMParser,u=c.parseFromString(h,"text/xml"),u};else throw new Error("Browser doesn't support XML DOM.");return t.parseXml(l)},parseJSON:function(l){return t.parseJSON=window.JSON.parse,t.parseJSON(l)},imageFormatSupported:function(l){return l=l||"",!!s[l.toLowerCase()]},setImageFormatsSupported:function(l){t.extend(s,l)}});var n=function(l){};t.console=window.console||{log:n,debug:n,info:n,warn:n,error:n,assert:n},t.Browser={vendor:t.BROWSERS.UNKNOWN,version:0,alpha:!0};var s={avif:!0,bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0},o={};(function(){var l=navigator.appVersion,h=navigator.userAgent,u;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(h.substring(h.indexOf("MSIE")+5,h.indexOf(";",h.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(h.indexOf("Edge")>=0?(t.Browser.vendor=t.BROWSERS.EDGE,t.Browser.version=parseFloat(h.substring(h.indexOf("Edge")+5))):h.indexOf("Edg")>=0?(t.Browser.vendor=t.BROWSERS.CHROMEEDGE,t.Browser.version=parseFloat(h.substring(h.indexOf("Edg")+4))):h.indexOf("Firefox")>=0?(t.Browser.vendor=t.BROWSERS.FIREFOX,t.Browser.version=parseFloat(h.substring(h.indexOf("Firefox")+8))):h.indexOf("Safari")>=0?(t.Browser.vendor=h.indexOf("Chrome")>=0?t.BROWSERS.CHROME:t.BROWSERS.SAFARI,t.Browser.version=parseFloat(h.substring(h.substring(0,h.indexOf("Safari")).lastIndexOf("/")+1,h.indexOf("Safari")))):(u=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),u.exec(h)!==null&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(RegExp.$1))));break;case"Opera":t.Browser.vendor=t.BROWSERS.OPERA,t.Browser.version=parseFloat(l);break}var c=window.location.search.substring(1),d=c.split("&"),f,g,p;for(p=0;p<d.length;p++)if(f=d[p],g=f.indexOf("="),g>0){var m=f.substring(0,g),v=f.substring(g+1);try{o[m]=decodeURIComponent(v)}catch{t.console.error("Ignoring malformed URL parameter: %s=%s",m,v)}}t.Browser.alpha=!(t.Browser.vendor===t.BROWSERS.CHROME&&t.Browser.version<2),t.Browser.opacity=!0,t.Browser.vendor===t.BROWSERS.IE&&t.console.error("Internet Explorer is not supported by OpenSeadragon")})(),(function(l){var h=l.requestAnimationFrame||l.mozRequestAnimationFrame||l.webkitRequestAnimationFrame||l.msRequestAnimationFrame,u=l.cancelAnimationFrame||l.mozCancelAnimationFrame||l.webkitCancelAnimationFrame||l.msCancelAnimationFrame;if(h&&u)t.requestAnimationFrame=function(){return h.apply(l,arguments)},t.cancelAnimationFrame=function(){return u.apply(l,arguments)};else{var c=[],d=[],f=0,g;t.requestAnimationFrame=function(p){return c.push([++f,p]),g||(g=setInterval(function(){if(c.length){var m=t.now(),v=d;for(d=c,c=v;d.length;)d.shift()[1](m)}else clearInterval(g),g=void 0},1e3/50)),f},t.cancelAnimationFrame=function(p){var m,v;for(m=0,v=c.length;m<v;m+=1)if(c[m][0]===p){c.splice(m,1);return}for(m=0,v=d.length;m<v;m+=1)if(d[m][0]===p){d.splice(m,1);return}}}})(window);function a(l,h){return h&&l!==document.body?document.body:l.offsetParent}})(e),(function(t,i){r.exports?r.exports=i():t.OpenSeadragon=i()})($x,function(){return e}),(function(t){class i{constructor(s){s||(s=[0,0,0,0,0,0,0,0,0]),this.values=s}static makeIdentity(){return new i([1,0,0,0,1,0,0,0,1])}static makeTranslation(s,o){return new i([1,0,0,0,1,0,s,o,1])}static makeRotation(s){var o=Math.cos(s),a=Math.sin(s);return new i([o,-a,0,a,o,0,0,0,1])}static makeScaling(s,o){return new i([s,0,0,0,o,0,0,0,1])}multiply(s){let o=this.values,a=s.values;var l=o[0],h=o[1],u=o[2],c=o[3],d=o[4],f=o[5],g=o[6],p=o[7],m=o[8],v=a[0],y=a[1],_=a[2],w=a[3],A=a[4],F=a[5],C=a[6],R=a[7],M=a[8];return new i([v*l+y*c+_*g,v*h+y*d+_*p,v*u+y*f+_*m,w*l+A*c+F*g,w*h+A*d+F*p,w*u+A*f+F*m,C*l+R*c+M*g,C*h+R*d+M*p,C*u+R*f+M*m])}}t.Mat3=i})(e),(function(t){var i={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.fullscreenElement},i.requestFullScreen=function(n){return n.requestFullscreen().catch(function(s){t.console.error("Fullscreen request failed: ",s)})},i.exitFullScreen=function(){document.exitFullscreen().catch(function(n){t.console.error("Error while exiting fullscreen: ",n)})},i.fullScreenEventName="fullscreenchange",i.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.msFullscreenElement},i.requestFullScreen=function(n){return n.msRequestFullscreen()},i.exitFullScreen=function(){document.msExitFullscreen()},i.fullScreenEventName="MSFullscreenChange",i.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitFullscreenElement},i.requestFullScreen=function(n){return n.webkitRequestFullscreen()},i.exitFullScreen=function(){document.webkitExitFullscreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},i.requestFullScreen=function(n){return n.webkitRequestFullScreen()},i.exitFullScreen=function(){document.webkitCancelFullScreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.mozFullScreenElement},i.requestFullScreen=function(n){return n.mozRequestFullScreen()},i.exitFullScreen=function(){document.mozCancelFullScreen()},i.fullScreenEventName="mozfullscreenchange",i.fullScreenErrorEventName="mozfullscreenerror"),i.isFullScreen=function(){return i.getFullScreenElement()!==null},i.cancelFullScreen=function(){t.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),i.exitFullScreen()},t.extend(t,i)})(e),(function(t){t.EventSource=function(){this.events={},this._rejectedEventList={}},t.EventSource.prototype={addOnceHandler:function(i,n,s,o,a){var l=this;o=o||1;var h=0,u=function(c){return h++,h===o&&l.removeHandler(i,u),n(c)};return this.addHandler(i,u,s,a)},addHandler:function(i,n,s,o){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,i))return t.console.error(`Error adding handler for ${i}. ${this._rejectedEventList[i]}`),!1;var a=this.events[i];if(a||(this.events[i]=a=[]),n&&t.isFunction(n)){var l=a.length,h={handler:n,userData:s||null,priority:o||0};for(a[l]=h;l>0&&a[l-1].priority<a[l].priority;)a[l]=a[l-1],a[l-1]=h,l--}return!0},removeHandler:function(i,n){var s=this.events[i],o=[],a;if(s&&t.isArray(s)){for(a=0;a<s.length;a++)s[a].handler!==n&&o.push(s[a]);this.events[i]=o}},numberOfHandlers:function(i){var n=this.events[i];return n?n.length:0},removeAllHandlers:function(i){if(i)this.events[i]=[];else for(var n in this.events)this.events[n]=[]},getHandler:function(i){var n=this.events[i];return!n||!n.length?null:(n=n.length===1?[n[0]]:Array.apply(null,n),function(s,o){var a,l=n.length;for(a=0;a<l;a++)n[a]&&(o.eventSource=s,o.userData=n[a].userData,n[a].handler(o))})},raiseEvent:function(i,n){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,i))return t.console.error(`Error adding handler for ${i}. ${this._rejectedEventList[i]}`),!1;var s=this.getHandler(i);return s&&s(this,n||{}),!0},rejectEventHandler(i,n=""){this._rejectedEventList[i]=n},allowEventHandler(i){delete this._rejectedEventList[i]}}})(e),(function(t){var i={};t.MouseTracker=function(T){var E=arguments;t.isPlainObject(T)||(T={element:E[0],clickTimeThreshold:E[1],clickDistThreshold:E[2]}),this.hash=Math.random(),this.element=t.getElement(T.element),this.clickTimeThreshold=T.clickTimeThreshold||t.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=T.clickDistThreshold||t.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=T.dblClickTimeThreshold||t.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=T.dblClickDistThreshold||t.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=T.userData||null,this.stopDelay=T.stopDelay||50,this.preProcessEventHandler=T.preProcessEventHandler||null,this.contextMenuHandler=T.contextMenuHandler||null,this.enterHandler=T.enterHandler||null,this.leaveHandler=T.leaveHandler||null,this.exitHandler=T.exitHandler||null,this.overHandler=T.overHandler||null,this.outHandler=T.outHandler||null,this.pressHandler=T.pressHandler||null,this.nonPrimaryPressHandler=T.nonPrimaryPressHandler||null,this.releaseHandler=T.releaseHandler||null,this.nonPrimaryReleaseHandler=T.nonPrimaryReleaseHandler||null,this.moveHandler=T.moveHandler||null,this.scrollHandler=T.scrollHandler||null,this.clickHandler=T.clickHandler||null,this.dblClickHandler=T.dblClickHandler||null,this.dragHandler=T.dragHandler||null,this.dragEndHandler=T.dragEndHandler||null,this.pinchHandler=T.pinchHandler||null,this.stopHandler=T.stopHandler||null,this.keyDownHandler=T.keyDownHandler||null,this.keyUpHandler=T.keyUpHandler||null,this.keyHandler=T.keyHandler||null,this.focusHandler=T.focusHandler||null,this.blurHandler=T.blurHandler||null;var N=this;i[this.hash]={click:function(B){_(N,B)},dblclick:function(B){w(N,B)},keydown:function(B){A(N,B)},keyup:function(B){F(N,B)},keypress:function(B){C(N,B)},focus:function(B){R(N,B)},blur:function(B){M(N,B)},contextmenu:function(B){k(N,B)},wheel:function(B){z(N,B)},mousewheel:function(B){D(N,B)},DOMMouseScroll:function(B){D(N,B)},MozMousePixelScroll:function(B){D(N,B)},losecapture:function(B){b(N,B)},mouseenter:function(B){Q(N,B)},mouseleave:function(B){W(N,B)},mouseover:function(B){$(N,B)},mouseout:function(B){ne(N,B)},mousedown:function(B){_e(N,B)},mouseup:function(B){pe(N,B)},mousemove:function(B){Be(N,B)},touchstart:function(B){O(N,B)},touchend:function(B){j(N,B)},touchmove:function(B){V(N,B)},touchcancel:function(B){Y(N,B)},gesturestart:function(B){G(N,B)},gesturechange:function(B){H(N,B)},gotpointercapture:function(B){X(N,B)},lostpointercapture:function(B){K(N,B)},pointerenter:function(B){Q(N,B)},pointerleave:function(B){W(N,B)},pointerover:function(B){$(N,B)},pointerout:function(B){ne(N,B)},pointerdown:function(B){_e(N,B)},pointerup:function(B){pe(N,B)},pointermove:function(B){Be(N,B)},pointercancel:function(B){$e(N,B)},pointerupcaptured:function(B){Ce(N,B)},pointermovecaptured:function(B){ke(N,B)},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,t.MouseTracker.havePointerEvents&&t.setElementPointerEvents(this.element,"auto"),this.exitHandler&&t.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead."),T.startDisabled||this.setTracking(!0)},t.MouseTracker.prototype={destroy:function(){l(this),this.element=null,i[this.hash]=null,delete i[this.hash]},isTracking:function(){return i[this.hash].tracking},setTracking:function(T){return T?a(this):l(this),this},getActivePointersListByType:function(T){var E=i[this.hash],N,B=E?E.activePointersLists.length:0,te;for(N=0;N<B;N++)if(E.activePointersLists[N].type===T)return E.activePointersLists[N];return te=new t.MouseTracker.GesturePointList(T),E&&E.activePointersLists.push(te),te},getActivePointerCount:function(){var T=i[this.hash],E,N=T.activePointersLists.length,B=0;for(E=0;E<N;E++)B+=T.activePointersLists[E].getLength();return B},preProcessEventHandler:function(){},contextMenuHandler:function(){},enterHandler:function(){},leaveHandler:function(){},exitHandler:function(){},overHandler:function(){},outHandler:function(){},pressHandler:function(){},nonPrimaryPressHandler:function(){},releaseHandler:function(){},nonPrimaryReleaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyDownHandler:function(){},keyUpHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}};var n=(function(){try{return window.self!==window.top}catch{return!0}})();function s(T){try{return T.addEventListener&&T.removeEventListener}catch{return!1}}t.MouseTracker.gesturePointVelocityTracker=(function(){var T=[],E=0,N=0,B=function(ct,Fe){return ct.hash.toString()+Fe.type+Fe.id.toString()},te=function(){var ct,Fe=T.length,ki,Kt,bo=t.now(),y_,__,x_;for(y_=bo-N,N=bo,ct=0;ct<Fe;ct++)ki=T[ct],Kt=ki.gPoint,Kt.direction=Math.atan2(Kt.currentPos.y-ki.lastPos.y,Kt.currentPos.x-ki.lastPos.x),__=ki.lastPos.distanceTo(Kt.currentPos),ki.lastPos=Kt.currentPos,x_=1e3*__/(y_+1),Kt.speed=.75*x_+.25*Kt.speed},ae=function(ct,Fe){var ki=B(ct,Fe);T.push({guid:ki,gPoint:Fe,lastPos:Fe.currentPos}),T.length===1&&(N=t.now(),E=window.setInterval(te,50))},Oe=function(ct,Fe){var ki=B(ct,Fe),Kt,bo=T.length;for(Kt=0;Kt<bo;Kt++)if(T[Kt].guid===ki){T.splice(Kt,1),bo--,bo===0&&window.clearInterval(E);break}};return{addPoint:ae,removePoint:Oe}})(),t.MouseTracker.captureElement=document,t.MouseTracker.wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll",t.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",t.MouseTracker.wheelEventName],t.MouseTracker.wheelEventName==="DOMMouseScroll"&&t.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(t.MouseTracker.havePointerEvents=!0,t.MouseTracker.subscribeEvents.push("pointerenter","pointerleave","pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),t.MouseTracker.havePointerCapture=(function(){var T=document.createElement("div");return t.isFunction(T.setPointerCapture)&&t.isFunction(T.releasePointerCapture)})(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("gotpointercapture","lostpointercapture")):(t.MouseTracker.havePointerEvents=!1,t.MouseTracker.subscribeEvents.push("mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","mousemove"),t.MouseTracker.mousePointerId="legacy-mouse",t.MouseTracker.havePointerCapture=(function(){var T=document.createElement("div");return t.isFunction(T.setCapture)&&t.isFunction(T.releaseCapture)})(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("losecapture"),"ontouchstart"in window&&t.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ongesturestart"in window&&t.MouseTracker.subscribeEvents.push("gesturestart","gesturechange")),t.MouseTracker.GesturePointList=function(T){this._gPoints=[],this.type=T,this.buttons=0,this.contacts=0,this.clicks=0,this.captureCount=0},t.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(T){return this._gPoints.push(T)},removeById:function(T){var E,N=this._gPoints.length;for(E=0;E<N;E++)if(this._gPoints[E].id===T){this._gPoints.splice(E,1);break}return this._gPoints.length},getByIndex:function(T){return T<this._gPoints.length?this._gPoints[T]:null},getById:function(T){var E,N=this._gPoints.length;for(E=0;E<N;E++)if(this._gPoints[E].id===T)return this._gPoints[E];return null},getPrimary:function(T){var E,N=this._gPoints.length;for(E=0;E<N;E++)if(this._gPoints[E].isPrimary)return this._gPoints[E];return null},addContact:function(){++this.contacts,this.contacts>1&&(this.type==="mouse"||this.type==="pen")&&(t.console.warn("GesturePointList.addContact() Implausible contacts value"),this.contacts=1)},removeContact:function(){--this.contacts,this.contacts<0&&(this.contacts=0)}};function o(T){var E=i[T.hash],N,B,te,ae,Oe,ct=E.activePointersLists.length;for(N=0;N<ct;N++)if(te=E.activePointersLists[N],te.getLength()>0){for(Oe=[],ae=te.asArray(),B=0;B<ae.length;B++)Oe.push(ae[B]);for(B=0;B<Oe.length;B++)Pt(T,te,Oe[B])}for(N=0;N<ct;N++)E.activePointersLists.pop();E.sentDragEvent=!1}function a(T){var E=i[T.hash],N,B;if(!E.tracking){for(B=0;B<t.MouseTracker.subscribeEvents.length;B++)N=t.MouseTracker.subscribeEvents[B],t.addEvent(T.element,N,E[N],N===t.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);o(T),E.tracking=!0}}function l(T){var E=i[T.hash],N,B;if(E.tracking){for(B=0;B<t.MouseTracker.subscribeEvents.length;B++)N=t.MouseTracker.subscribeEvents[B],t.removeEvent(T.element,N,E[N],!1);o(T),E.tracking=!1}}function h(T,E){var N=i[T.hash];if(E==="pointerevent")return{upName:"pointerup",upHandler:N.pointerupcaptured,moveName:"pointermove",moveHandler:N.pointermovecaptured};if(E==="mouse")return{upName:"pointerup",upHandler:N.pointerupcaptured,moveName:"pointermove",moveHandler:N.pointermovecaptured};if(E==="touch")return{upName:"touchend",upHandler:N.touchendcaptured,moveName:"touchmove",moveHandler:N.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function u(T,E){var N;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents)try{T.element.setPointerCapture(E.id)}catch{t.console.warn("setPointerCapture() called on invalid pointer ID");return}else T.element.setCapture(!0);else N=h(T,t.MouseTracker.havePointerEvents?"pointerevent":E.type),n&&s(window.top)&&t.addEvent(window.top,N.upName,N.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,N.upName,N.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,N.moveName,N.moveHandler,!0);q(T,E,!0)}function c(T,E){var N,B,te;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents){if(B=T.getActivePointersListByType(E.type),te=B.getById(E.id),!te||!te.captured)return;try{T.element.releasePointerCapture(E.id)}catch{}}else T.element.releaseCapture();else N=h(T,t.MouseTracker.havePointerEvents?"pointerevent":E.type),n&&s(window.top)&&t.removeEvent(window.top,N.upName,N.upHandler,!0),t.removeEvent(t.MouseTracker.captureElement,N.moveName,N.moveHandler,!0),t.removeEvent(t.MouseTracker.captureElement,N.upName,N.upHandler,!0);q(T,E,!1)}function d(T){return t.MouseTracker.havePointerEvents?T.pointerId:t.MouseTracker.mousePointerId}function f(T){return t.MouseTracker.havePointerEvents&&T.pointerType?T.pointerType:"mouse"}function g(T){return t.MouseTracker.havePointerEvents?T.isPrimary:!0}function p(T){return t.getMousePosition(T)}function m(T,E){return v(p(T),E)}function v(T,E){var N=t.getElementOffset(E);return T.minus(N)}function y(T,E){return new t.Point((T.x+E.x)/2,(T.y+E.y)/2)}function _(T,E){var N={originalEvent:E,eventType:"click",pointerType:"mouse",isEmulated:!1};L(T,N),N.preventDefault&&!N.defaultPrevented&&t.cancelEvent(E),N.stopPropagation&&t.stopEvent(E)}function w(T,E){var N={originalEvent:E,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};L(T,N),N.preventDefault&&!N.defaultPrevented&&t.cancelEvent(E),N.stopPropagation&&t.stopEvent(E)}function A(T,E){var N=null,B={originalEvent:E,eventType:"keydown",pointerType:"",isEmulated:!1};L(T,B),T.keyDownHandler&&!B.preventGesture&&!B.defaultPrevented&&(N={eventSource:T,keyCode:E.keyCode?E.keyCode:E.charCode,ctrl:E.ctrlKey,shift:E.shiftKey,alt:E.altKey,meta:E.metaKey,originalEvent:E,preventDefault:B.preventDefault||B.defaultPrevented,userData:T.userData},T.keyDownHandler(N)),(N&&N.preventDefault||B.preventDefault&&!B.defaultPrevented)&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E)}function F(T,E){var N=null,B={originalEvent:E,eventType:"keyup",pointerType:"",isEmulated:!1};L(T,B),T.keyUpHandler&&!B.preventGesture&&!B.defaultPrevented&&(N={eventSource:T,keyCode:E.keyCode?E.keyCode:E.charCode,ctrl:E.ctrlKey,shift:E.shiftKey,alt:E.altKey,meta:E.metaKey,originalEvent:E,preventDefault:B.preventDefault||B.defaultPrevented,userData:T.userData},T.keyUpHandler(N)),(N&&N.preventDefault||B.preventDefault&&!B.defaultPrevented)&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E)}function C(T,E){var N=null,B={originalEvent:E,eventType:"keypress",pointerType:"",isEmulated:!1};L(T,B),T.keyHandler&&!B.preventGesture&&!B.defaultPrevented&&(N={eventSource:T,keyCode:E.keyCode?E.keyCode:E.charCode,ctrl:E.ctrlKey,shift:E.shiftKey,alt:E.altKey,meta:E.metaKey,originalEvent:E,preventDefault:B.preventDefault||B.defaultPrevented,userData:T.userData},T.keyHandler(N)),(N&&N.preventDefault||B.preventDefault&&!B.defaultPrevented)&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E)}function R(T,E){var N={originalEvent:E,eventType:"focus",pointerType:"",isEmulated:!1};L(T,N),T.focusHandler&&!N.preventGesture&&T.focusHandler({eventSource:T,originalEvent:E,userData:T.userData})}function M(T,E){var N={originalEvent:E,eventType:"blur",pointerType:"",isEmulated:!1};L(T,N),T.blurHandler&&!N.preventGesture&&T.blurHandler({eventSource:T,originalEvent:E,userData:T.userData})}function k(T,E){var N=null,B={originalEvent:E,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};L(T,B),T.contextMenuHandler&&!B.preventGesture&&!B.defaultPrevented&&(N={eventSource:T,position:v(p(E),T.element),originalEvent:B.originalEvent,preventDefault:B.preventDefault||B.defaultPrevented,userData:T.userData},T.contextMenuHandler(N)),(N&&N.preventDefault||B.preventDefault&&!B.defaultPrevented)&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E)}function z(T,E){S(T,E,E)}function D(T,E){var N={target:E.target||E.srcElement,type:"wheel",shiftKey:E.shiftKey||!1,clientX:E.clientX,clientY:E.clientY,pageX:E.pageX?E.pageX:E.clientX,pageY:E.pageY?E.pageY:E.clientY,deltaMode:E.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};t.MouseTracker.wheelEventName==="mousewheel"?N.deltaY=-E.wheelDelta/t.DEFAULT_SETTINGS.pixelsPerWheelLine:N.deltaY=E.detail,S(T,N,E)}function S(T,E,N){var B=0,te,ae=null;B=E.deltaY?E.deltaY<0?1:-1:0,te={originalEvent:E,eventType:"wheel",pointerType:"mouse",isEmulated:E!==N},L(T,te),T.scrollHandler&&!te.preventGesture&&!te.defaultPrevented&&(ae={eventSource:T,pointerType:"mouse",position:m(E,T.element),scroll:B,shift:E.shiftKey,isTouchEvent:!1,originalEvent:N,preventDefault:te.preventDefault||te.defaultPrevented,userData:T.userData},T.scrollHandler(ae)),te.stopPropagation&&t.stopEvent(N),(ae&&ae.preventDefault||te.preventDefault&&!te.defaultPrevented)&&t.cancelEvent(N)}function b(T,E){var N={id:t.MouseTracker.mousePointerId,type:"mouse"},B={originalEvent:E,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};L(T,B),E.target===T.element&&q(T,N,!1),B.stopPropagation&&t.stopEvent(E)}function O(T,E){var N,B,te=E.changedTouches.length,ae,Oe=T.getActivePointersListByType("touch");N=t.now(),Oe.getLength()>E.touches.length-te&&t.console.warn("Tracked touch contact count doesn't match event.touches.length");var ct={originalEvent:E,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(L(T,ct),B=0;B<te;B++)ae={id:E.changedTouches[B].identifier,type:"touch",isPrimary:Oe.getLength()===0,currentPos:p(E.changedTouches[B]),currentTime:N},ee(T,ct,ae),Ue(T,ct,ae,0),q(T,ae,!0);ct.preventDefault&&!ct.defaultPrevented&&t.cancelEvent(E),ct.stopPropagation&&t.stopEvent(E)}function j(T,E){var N,B,te=E.changedTouches.length,ae;N=t.now();var Oe={originalEvent:E,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(L(T,Oe),B=0;B<te;B++)ae={id:E.changedTouches[B].identifier,type:"touch",currentPos:p(E.changedTouches[B]),currentTime:N},it(T,Oe,ae,0),q(T,ae,!1),J(T,Oe,ae);Oe.preventDefault&&!Oe.defaultPrevented&&t.cancelEvent(E),Oe.stopPropagation&&t.stopEvent(E)}function V(T,E){var N,B,te=E.changedTouches.length,ae;N=t.now();var Oe={originalEvent:E,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(L(T,Oe),B=0;B<te;B++)ae={id:E.changedTouches[B].identifier,type:"touch",currentPos:p(E.changedTouches[B]),currentTime:N},gt(T,Oe,ae);Oe.preventDefault&&!Oe.defaultPrevented&&t.cancelEvent(E),Oe.stopPropagation&&t.stopEvent(E)}function Y(T,E){var N=E.changedTouches.length,B,te,ae={originalEvent:E,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(L(T,ae),B=0;B<N;B++)te={id:E.changedTouches[B].identifier,type:"touch"},je(T,ae,te);ae.stopPropagation&&t.stopEvent(E)}function G(T,E){return t.eventIsCanceled(E)||E.preventDefault(),!1}function H(T,E){return t.eventIsCanceled(E)||E.preventDefault(),!1}function X(T,E){var N={originalEvent:E,eventType:"gotpointercapture",pointerType:f(E),isEmulated:!1};L(T,N),E.target===T.element&&q(T,{id:E.pointerId,type:f(E)},!0),N.stopPropagation&&t.stopEvent(E)}function K(T,E){var N={originalEvent:E,eventType:"lostpointercapture",pointerType:f(E),isEmulated:!1};L(T,N),E.target===T.element&&q(T,{id:E.pointerId,type:f(E)},!1),N.stopPropagation&&t.stopEvent(E)}function Q(T,E){var N={id:d(E),type:f(E),isPrimary:g(E),currentPos:p(E),currentTime:t.now()},B={originalEvent:E,eventType:"pointerenter",pointerType:N.type,isEmulated:!1};L(T,B),ee(T,B,N)}function W(T,E){var N={id:d(E),type:f(E),isPrimary:g(E),currentPos:p(E),currentTime:t.now()},B={originalEvent:E,eventType:"pointerleave",pointerType:N.type,isEmulated:!1};L(T,B),J(T,B,N)}function $(T,E){var N={id:d(E),type:f(E),isPrimary:g(E),currentPos:p(E),currentTime:t.now()},B={originalEvent:E,eventType:"pointerover",pointerType:N.type,isEmulated:!1};L(T,B),xe(T,B,N),B.preventDefault&&!B.defaultPrevented&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E)}function ne(T,E){var N={id:d(E),type:f(E),isPrimary:g(E),currentPos:p(E),currentTime:t.now()},B={originalEvent:E,eventType:"pointerout",pointerType:N.type,isEmulated:!1};L(T,B),re(T,B,N),B.preventDefault&&!B.defaultPrevented&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E)}function _e(T,E){var N={id:d(E),type:f(E),isPrimary:g(E),currentPos:p(E),currentTime:t.now()},B=t.MouseTracker.havePointerEvents&&N.type==="touch",te={originalEvent:E,eventType:"pointerdown",pointerType:N.type,isEmulated:!1};L(T,te),Ue(T,te,N,E.button),te.preventDefault&&!te.defaultPrevented&&t.cancelEvent(E),te.stopPropagation&&t.stopEvent(E),te.shouldCapture&&(B?q(T,N,!0):u(T,N))}function pe(T,E){Pe(T,E)}function Ce(T,E){var N=T.getActivePointersListByType(f(E));N.getById(E.pointerId)&&Pe(T,E),t.stopEvent(E)}function Pe(T,E){var N;N={id:d(E),type:f(E),isPrimary:g(E),currentPos:p(E),currentTime:t.now()};var B={originalEvent:E,eventType:"pointerup",pointerType:N.type,isEmulated:!1};L(T,B),it(T,B,N,E.button),B.preventDefault&&!B.defaultPrevented&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E),B.shouldReleaseCapture&&(E.target===T.element?c(T,N):q(T,N,!1))}function Be(T,E){Ge(T,E)}function ke(T,E){var N=T.getActivePointersListByType(f(E));N.getById(E.pointerId)&&Ge(T,E),t.stopEvent(E)}function Ge(T,E){var N={id:d(E),type:f(E),isPrimary:g(E),currentPos:p(E),currentTime:t.now()},B={originalEvent:E,eventType:"pointermove",pointerType:N.type,isEmulated:!1};L(T,B),gt(T,B,N),B.preventDefault&&!B.defaultPrevented&&t.cancelEvent(E),B.stopPropagation&&t.stopEvent(E)}function $e(T,E){var N={id:E.pointerId,type:f(E)},B={originalEvent:E,eventType:"pointercancel",pointerType:N.type,isEmulated:!1};L(T,B),je(T,B,N),B.stopPropagation&&t.stopEvent(E)}function ft(T,E){return E.speed=0,E.direction=0,E.contactPos=E.currentPos,E.contactTime=E.currentTime,E.lastPos=E.currentPos,E.lastTime=E.currentTime,T.add(E)}function Pt(T,E,N){var B,te=E.getById(N.id);return te?(te.captured&&(t.console.warn("stopTrackingPointer() called on captured pointer"),c(T,te)),E.removeContact(),B=E.removeById(N.id)):B=E.getLength(),B}function x(T,E){switch(E.eventType){case"pointermove":E.isStoppable=!0,E.isCancelable=!0,E.preventDefault=!1,E.preventGesture=!T.hasGestureHandlers,E.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":E.isStoppable=!0,E.isCancelable=!0,E.preventDefault=!1,E.preventGesture=!1,E.stopPropagation=!1;break;case"pointerdown":E.isStoppable=!0,E.isCancelable=!0,E.preventDefault=!1,E.preventGesture=!T.hasGestureHandlers,E.stopPropagation=!1;break;case"pointerup":E.isStoppable=!0,E.isCancelable=!0,E.preventDefault=!1,E.preventGesture=!T.hasGestureHandlers,E.stopPropagation=!1;break;case"wheel":E.isStoppable=!0,E.isCancelable=!0,E.preventDefault=!1,E.preventGesture=!T.hasScrollHandler,E.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":E.isStoppable=!0,E.isCancelable=!1,E.preventDefault=!1,E.preventGesture=!1,E.stopPropagation=!1;break;case"click":E.isStoppable=!0,E.isCancelable=!0,E.preventDefault=!!T.clickHandler,E.preventGesture=!1,E.stopPropagation=!1;break;case"dblclick":E.isStoppable=!0,E.isCancelable=!0,E.preventDefault=!!T.dblClickHandler,E.preventGesture=!1,E.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:E.isStoppable=!1,E.isCancelable=!1,E.preventDefault=!1,E.preventGesture=!1,E.stopPropagation=!1;break}}function L(T,E){E.eventSource=T,E.eventPhase=E.originalEvent&&typeof E.originalEvent.eventPhase<"u"?E.originalEvent.eventPhase:0,E.defaultPrevented=t.eventIsCanceled(E.originalEvent),E.shouldCapture=!1,E.shouldReleaseCapture=!1,E.userData=T.userData,x(T,E),T.preProcessEventHandler&&T.preProcessEventHandler(E)}function q(T,E,N){var B=T.getActivePointersListByType(E.type),te=B.getById(E.id);te?N&&!te.captured?(te.captured=!0,B.captureCount++):!N&&te.captured&&(te.captured=!1,B.captureCount--,B.captureCount<0&&(B.captureCount=0,t.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):t.console.warn("updatePointerCaptured() called on untracked pointer")}function ee(T,E,N){var B=T.getActivePointersListByType(N.type),te;te=B.getById(N.id),te?(te.insideElement=!0,te.lastPos=te.currentPos,te.lastTime=te.currentTime,te.currentPos=N.currentPos,te.currentTime=N.currentTime,N=te):(N.captured=!1,N.insideElementPressed=!1,N.insideElement=!0,ft(B,N)),T.enterHandler&&T.enterHandler({eventSource:T,pointerType:N.type,position:v(N.currentPos,T.element),buttons:B.buttons,pointers:T.getActivePointerCount(),insideElementPressed:N.insideElementPressed,buttonDownAny:B.buttons!==0,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData})}function J(T,E,N){var B=T.getActivePointersListByType(N.type),te,ae;te=B.getById(N.id),te?(te.captured?(te.insideElement=!1,te.lastPos=te.currentPos,te.lastTime=te.currentTime,te.currentPos=N.currentPos,te.currentTime=N.currentTime):Pt(T,B,te),N=te):(N.captured=!1,N.insideElementPressed=!1),(T.leaveHandler||T.exitHandler)&&(ae={eventSource:T,pointerType:N.type,position:N.currentPos&&v(N.currentPos,T.element),buttons:B.buttons,pointers:T.getActivePointerCount(),insideElementPressed:N.insideElementPressed,buttonDownAny:B.buttons!==0,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData},T.leaveHandler&&T.leaveHandler(ae),T.exitHandler&&T.exitHandler(ae))}function xe(T,E,N){var B,te;B=T.getActivePointersListByType(N.type),te=B.getById(N.id),te?N=te:(N.captured=!1,N.insideElementPressed=!1),T.overHandler&&T.overHandler({eventSource:T,pointerType:N.type,position:v(N.currentPos,T.element),buttons:B.buttons,pointers:T.getActivePointerCount(),insideElementPressed:N.insideElementPressed,buttonDownAny:B.buttons!==0,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData})}function re(T,E,N){var B,te;B=T.getActivePointersListByType(N.type),te=B.getById(N.id),te?N=te:(N.captured=!1,N.insideElementPressed=!1),T.outHandler&&T.outHandler({eventSource:T,pointerType:N.type,position:N.currentPos&&v(N.currentPos,T.element),buttons:B.buttons,pointers:T.getActivePointerCount(),insideElementPressed:N.insideElementPressed,buttonDownAny:B.buttons!==0,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData})}function Ue(T,E,N,B){var te=i[T.hash],ae=T.getActivePointersListByType(N.type),Oe;if(typeof E.originalEvent.buttons<"u"?ae.buttons=E.originalEvent.buttons:B===0?ae.buttons|=1:B===1?ae.buttons|=4:B===2?ae.buttons|=2:B===3?ae.buttons|=8:B===4?ae.buttons|=16:B===5&&(ae.buttons|=32),B!==0){E.shouldCapture=!1,E.shouldReleaseCapture=!1,T.nonPrimaryPressHandler&&!E.preventGesture&&!E.defaultPrevented&&(E.preventDefault=!0,T.nonPrimaryPressHandler({eventSource:T,pointerType:N.type,position:v(N.currentPos,T.element),button:B,buttons:ae.buttons,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData}));return}Oe=ae.getById(N.id),Oe?(Oe.insideElementPressed=!0,Oe.insideElement=!0,Oe.originalTarget=E.originalEvent.target,Oe.contactPos=N.currentPos,Oe.contactTime=N.currentTime,Oe.lastPos=Oe.currentPos,Oe.lastTime=Oe.currentTime,Oe.currentPos=N.currentPos,Oe.currentTime=N.currentTime,N=Oe):(N.captured=!1,N.insideElementPressed=!0,N.insideElement=!0,N.originalTarget=E.originalEvent.target,ft(ae,N)),ae.addContact(),!E.preventGesture&&!E.defaultPrevented?(E.shouldCapture=!0,E.shouldReleaseCapture=!1,E.preventDefault=!0,(T.dragHandler||T.dragEndHandler||T.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.addPoint(T,N),ae.contacts===1?T.pressHandler&&!E.preventGesture&&T.pressHandler({eventSource:T,pointerType:N.type,position:v(N.contactPos,T.element),buttons:ae.buttons,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData}):ae.contacts===2&&T.pinchHandler&&N.type==="touch"&&(te.pinchGPoints=ae.asArray(),te.lastPinchDist=te.currentPinchDist=te.pinchGPoints[0].currentPos.distanceTo(te.pinchGPoints[1].currentPos),te.lastPinchCenter=te.currentPinchCenter=y(te.pinchGPoints[0].currentPos,te.pinchGPoints[1].currentPos))):(E.shouldCapture=!1,E.shouldReleaseCapture=!1)}function it(T,E,N,B){var te=i[T.hash],ae=T.getActivePointersListByType(N.type),Oe,ct,Fe,ki=!1,Kt;if(typeof E.originalEvent.buttons<"u"?ae.buttons=E.originalEvent.buttons:B===0?ae.buttons^=-2:B===1?ae.buttons^=-5:B===2?ae.buttons^=-3:B===3?ae.buttons^=-9:B===4?ae.buttons^=-17:B===5&&(ae.buttons^=-33),E.shouldCapture=!1,B!==0){E.shouldReleaseCapture=!1,T.nonPrimaryReleaseHandler&&!E.preventGesture&&!E.defaultPrevented&&(E.preventDefault=!0,T.nonPrimaryReleaseHandler({eventSource:T,pointerType:N.type,position:v(N.currentPos,T.element),button:B,buttons:ae.buttons,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData}));return}Fe=ae.getById(N.id),Fe?(ae.removeContact(),Fe.captured&&(ki=!0),Fe.lastPos=Fe.currentPos,Fe.lastTime=Fe.currentTime,Fe.currentPos=N.currentPos,Fe.currentTime=N.currentTime,Fe.insideElement||Pt(T,ae,Fe),Oe=Fe.currentPos,ct=Fe.currentTime):(N.captured=!1,N.insideElementPressed=!1,N.insideElement=!0,ft(ae,N),Fe=N),!E.preventGesture&&!E.defaultPrevented&&(ki?(E.shouldReleaseCapture=!0,E.preventDefault=!0,(T.dragHandler||T.dragEndHandler||T.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.removePoint(T,Fe),ae.contacts===0?(T.releaseHandler&&Oe&&T.releaseHandler({eventSource:T,pointerType:Fe.type,position:v(Oe,T.element),buttons:ae.buttons,insideElementPressed:Fe.insideElementPressed,insideElementReleased:Fe.insideElement,isTouchEvent:Fe.type==="touch",originalEvent:E.originalEvent,userData:T.userData}),T.dragEndHandler&&te.sentDragEvent&&T.dragEndHandler({eventSource:T,pointerType:Fe.type,position:v(Fe.currentPos,T.element),speed:Fe.speed,direction:Fe.direction,shift:E.originalEvent.shiftKey,isTouchEvent:Fe.type==="touch",originalEvent:E.originalEvent,userData:T.userData}),te.sentDragEvent=!1,(T.clickHandler||T.dblClickHandler)&&Fe.insideElement&&(Kt=ct-Fe.contactTime<=T.clickTimeThreshold&&Fe.contactPos.distanceTo(Oe)<=T.clickDistThreshold,T.clickHandler&&T.clickHandler({eventSource:T,pointerType:Fe.type,position:v(Fe.currentPos,T.element),quick:Kt,shift:E.originalEvent.shiftKey,isTouchEvent:Fe.type==="touch",originalEvent:E.originalEvent,originalTarget:Fe.originalTarget,userData:T.userData}),T.dblClickHandler&&Kt&&(ae.clicks++,ae.clicks===1?(te.lastClickPos=Oe,te.dblClickTimeOut=setTimeout(function(){ae.clicks=0},T.dblClickTimeThreshold)):ae.clicks===2&&(clearTimeout(te.dblClickTimeOut),ae.clicks=0,te.lastClickPos.distanceTo(Oe)<=T.dblClickDistThreshold&&T.dblClickHandler({eventSource:T,pointerType:Fe.type,position:v(Fe.currentPos,T.element),shift:E.originalEvent.shiftKey,isTouchEvent:Fe.type==="touch",originalEvent:E.originalEvent,userData:T.userData}),te.lastClickPos=null)))):ae.contacts===2&&T.pinchHandler&&Fe.type==="touch"&&(te.pinchGPoints=ae.asArray(),te.lastPinchDist=te.currentPinchDist=te.pinchGPoints[0].currentPos.distanceTo(te.pinchGPoints[1].currentPos),te.lastPinchCenter=te.currentPinchCenter=y(te.pinchGPoints[0].currentPos,te.pinchGPoints[1].currentPos))):(E.shouldReleaseCapture=!1,T.releaseHandler&&Oe&&(T.releaseHandler({eventSource:T,pointerType:Fe.type,position:v(Oe,T.element),buttons:ae.buttons,insideElementPressed:Fe.insideElementPressed,insideElementReleased:Fe.insideElement,isTouchEvent:Fe.type==="touch",originalEvent:E.originalEvent,userData:T.userData}),E.preventDefault=!0)))}function gt(T,E,N){var B=i[T.hash],te=T.getActivePointersListByType(N.type),ae,Oe,ct;if(typeof E.originalEvent.buttons<"u"&&(te.buttons=E.originalEvent.buttons),ae=te.getById(N.id),ae)ae.lastPos=ae.currentPos,ae.lastTime=ae.currentTime,ae.currentPos=N.currentPos,ae.currentTime=N.currentTime;else return;E.shouldCapture=!1,E.shouldReleaseCapture=!1,T.stopHandler&&N.type==="mouse"&&(clearTimeout(T.stopTimeOut),T.stopTimeOut=setTimeout(function(){Dt(T,E.originalEvent,N.type)},T.stopDelay)),te.contacts===0?T.moveHandler&&T.moveHandler({eventSource:T,pointerType:N.type,position:v(N.currentPos,T.element),buttons:te.buttons,isTouchEvent:N.type==="touch",originalEvent:E.originalEvent,userData:T.userData}):te.contacts===1?(T.moveHandler&&(ae=te.asArray()[0],T.moveHandler({eventSource:T,pointerType:ae.type,position:v(ae.currentPos,T.element),buttons:te.buttons,isTouchEvent:ae.type==="touch",originalEvent:E.originalEvent,userData:T.userData})),T.dragHandler&&!E.preventGesture&&!E.defaultPrevented&&(ae=te.asArray()[0],ct=ae.currentPos.minus(ae.lastPos),T.dragHandler({eventSource:T,pointerType:ae.type,position:v(ae.currentPos,T.element),buttons:te.buttons,delta:ct,speed:ae.speed,direction:ae.direction,shift:E.originalEvent.shiftKey,isTouchEvent:ae.type==="touch",originalEvent:E.originalEvent,userData:T.userData}),E.preventDefault=!0,B.sentDragEvent=!0)):te.contacts===2&&(T.moveHandler&&(Oe=te.asArray(),T.moveHandler({eventSource:T,pointerType:Oe[0].type,position:v(y(Oe[0].currentPos,Oe[1].currentPos),T.element),buttons:te.buttons,isTouchEvent:Oe[0].type==="touch",originalEvent:E.originalEvent,userData:T.userData})),T.pinchHandler&&N.type==="touch"&&!E.preventGesture&&!E.defaultPrevented&&(ct=B.pinchGPoints[0].currentPos.distanceTo(B.pinchGPoints[1].currentPos),ct!==B.currentPinchDist&&(B.lastPinchDist=B.currentPinchDist,B.currentPinchDist=ct,B.lastPinchCenter=B.currentPinchCenter,B.currentPinchCenter=y(B.pinchGPoints[0].currentPos,B.pinchGPoints[1].currentPos),T.pinchHandler({eventSource:T,pointerType:"touch",gesturePoints:B.pinchGPoints,lastCenter:v(B.lastPinchCenter,T.element),center:v(B.currentPinchCenter,T.element),lastDistance:B.lastPinchDist,distance:B.currentPinchDist,shift:E.originalEvent.shiftKey,originalEvent:E.originalEvent,userData:T.userData}),E.preventDefault=!0)))}function je(T,E,N){var B=T.getActivePointersListByType(N.type),te;te=B.getById(N.id),te&&Pt(T,B,te)}function Dt(T,E,N){T.stopHandler&&T.stopHandler({eventSource:T,pointerType:N,position:m(E,T.element),buttons:T.getActivePointersListByType(N).buttons,isTouchEvent:N==="touch",originalEvent:E,userData:T.userData})}})(e),(function(t){t.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},t.Control=function(i,n,s){var o=i.parentNode;typeof n=="number"&&(t.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"),n={anchor:n}),n.attachToViewer=typeof n.attachToViewer>"u"?!0:n.attachToViewer,this.autoFade=typeof n.autoFade>"u"?!0:n.autoFade,this.element=i,this.anchor=n.anchor,this.container=s,this.anchor===t.ControlAnchor.ABSOLUTE?(this.wrapper=t.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof n.top=="number"?n.top+"px":n.top,this.wrapper.style.left=typeof n.left=="number"?n.left+"px":n.left,this.wrapper.style.height=typeof n.height=="number"?n.height+"px":n.height,this.wrapper.style.width=typeof n.width=="number"?n.width+"px":n.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=t.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor===t.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),n.attachToViewer?this.anchor===t.ControlAnchor.TOP_RIGHT||this.anchor===t.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):o.appendChild(this.wrapper)},t.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.anchor!==t.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return this.wrapper.style.display!=="none"},setVisible:function(i){this.wrapper.style.display=i?this.anchor===t.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(i){t.setElementOpacity(this.wrapper,i,!0)}}})(e),(function(t){t.ControlDock=function(n){var s=["topleft","topright","bottomright","bottomleft"],o,a;for(t.extend(!0,this,{id:"controldock-"+t.now()+"-"+Math.floor(Math.random()*1e6),container:t.makeNeutralElement("div"),controls:[]},n),this.container.onsubmit=function(){return!1},this.element&&(this.element=t.getElement(this.element),this.element.appendChild(this.container),t.getElementStyle(this.element).position==="static"&&(this.element.style.position="relative"),this.container.style.width="100%",this.container.style.height="100%"),a=0;a<s.length;a++)o=s[a],this.controls[o]=t.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)},t.ControlDock.prototype={addControl:function(n,s){n=t.getElement(n);var o=null;if(!(i(this,n)>=0)){switch(s.anchor){case t.ControlAnchor.TOP_RIGHT:o=this.controls.topright,n.style.position="relative",n.style.paddingRight="0px",n.style.paddingTop="0px";break;case t.ControlAnchor.BOTTOM_RIGHT:o=this.controls.bottomright,n.style.position="relative",n.style.paddingRight="0px",n.style.paddingBottom="0px";break;case t.ControlAnchor.BOTTOM_LEFT:o=this.controls.bottomleft,n.style.position="relative",n.style.paddingLeft="0px",n.style.paddingBottom="0px";break;case t.ControlAnchor.TOP_LEFT:o=this.controls.topleft,n.style.position="relative",n.style.paddingLeft="0px",n.style.paddingTop="0px";break;case t.ControlAnchor.ABSOLUTE:o=this.container,n.style.margin="0px",n.style.padding="0px";break;default:case t.ControlAnchor.NONE:o=this.container,n.style.margin="0px",n.style.padding="0px";break}this.controls.push(new t.Control(n,s,o)),n.style.display="inline-block"}},removeControl:function(n){n=t.getElement(n);var s=i(this,n);return s>=0&&(this.controls[s].destroy(),this.controls.splice(s,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var n;for(n=this.controls.length-1;n>=0;n--)if(this.controls[n].isVisible())return!0;return!1},setControlsEnabled:function(n){var s;for(s=this.controls.length-1;s>=0;s--)this.controls[s].setVisible(n);return this}};function i(n,s){var o=n.controls,a;for(a=o.length-1;a>=0;a--)if(o[a].element===s)return a;return-1}})(e),(function(t){t.Placement=t.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}}})})(e),(function(t){var i={},n=1;t.Viewer=function(x){var L=arguments,q=this,ee;t.isPlainObject(x)||(x={id:L[0],xmlPath:L.length>1?L[1]:void 0,prefixUrl:L.length>2?L[2]:void 0,controls:L.length>3?L[3]:void 0,overlays:L.length>4?L[4]:void 0}),x.config&&(t.extend(!0,x,x.config),delete x.config);let J=["useCanvas"];if(x.drawerOptions=Object.assign({},J.reduce((re,Ue)=>(re[Ue]=x[Ue],delete x[Ue],re),{}),x.drawerOptions),t.extend(!0,this,{id:x.id,hash:x.hash||n++,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},t.DEFAULT_SETTINGS,x),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");typeof i[this.hash]<"u"&&t.console.warn("Hash "+this.hash+" has already been used."),i[this.hash]={fsBoundsDelta:new t.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=t.now(),t.EventSource.call(this),this.addHandler("open-failed",function(re){var Ue=t.getString("Errors.OpenFailed",re.eventSource,re.message);q._showMessage(Ue)}),t.ControlDock.call(this,x),this.xmlPath&&(this.tileSources=[this.xmlPath]),this.element=this.element||document.getElementById(this.id),this.canvas=t.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",(function(re){re.width="100%",re.height="100%",re.overflow="hidden",re.position="absolute",re.top="0px",re.left="0px"})(this.canvas.style),t.setElementTouchActionNone(this.canvas),x.tabIndex!==""&&(this.canvas.tabIndex=x.tabIndex===void 0?0:x.tabIndex),this.container.className="openseadragon-container",(function(re){re.width="100%",re.height="100%",re.position="relative",re.overflow="hidden",re.left="0px",re.top="0px",re.textAlign="left"})(this.container.style),t.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 t.MouseTracker({userData:"Viewer.innerTracker",element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,contextMenuHandler:t.delegate(this,m),keyDownHandler:t.delegate(this,v),keyHandler:t.delegate(this,y),clickHandler:t.delegate(this,_),dblClickHandler:t.delegate(this,w),dragHandler:t.delegate(this,A),dragEndHandler:t.delegate(this,F),enterHandler:t.delegate(this,C),leaveHandler:t.delegate(this,R),pressHandler:t.delegate(this,M),releaseHandler:t.delegate(this,k),nonPrimaryPressHandler:t.delegate(this,z),nonPrimaryReleaseHandler:t.delegate(this,D),scrollHandler:t.delegate(this,j),pinchHandler:t.delegate(this,S),focusHandler:t.delegate(this,b),blurHandler:t.delegate(this,O)}),this.outerTracker=new t.MouseTracker({userData:"Viewer.outerTracker",element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:t.delegate(this,V),leaveHandler:t.delegate(this,Y)}),this.toolbar&&(this.toolbar=new t.ControlDock({element:this.toolbar})),this.bindStandardControls(),i[this.hash].prevContainerSize=s(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){i[q.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new t.World({viewer:this}),this.world.addHandler("add-item",function(re){q.source=q.world.getItemAt(0).source,i[q.hash].forceRedraw=!0,q._updateRequestId||(q._updateRequestId=h(q,G))}),this.world.addHandler("remove-item",function(re){q.world.getItemCount()?q.source=q.world.getItemAt(0).source:q.source=null,i[q.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(re){q.viewport&&q.viewport._setContentBounds(q.world.getHomeBounds(),q.world.getContentFactor())}),this.world.addHandler("item-index-change",function(re){q.source=q.world.getItemAt(0).source}),this.viewport=new t.Viewport({containerSize:i[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 t.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:x.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay}),this.tileCache=new t.TileCache({maxImageCacheCount:this.maxImageCacheCount}),Object.prototype.hasOwnProperty.call(this.drawerOptions,"useCanvas")&&(t.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)'),this.drawerOptions.useCanvas||(this.drawer=t.HTMLDrawer),delete this.drawerOptions.useCanvas);let xe=Array.isArray(this.drawer)?this.drawer:[this.drawer];xe.length===0&&(xe=[t.DEFAULT_SETTINGS.drawer].flat(),t.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const re of xe)if(this.requestDrawer(re,{mainDrawer:!0,redrawImmediately:!1}))break;if(!this.drawer)throw t.console.error("No drawer could be created!"),"Error with creating the selected drawer(s)";for(this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),this.overlaysContainer=t.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(ee=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(ee,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(ee=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(ee,1),this.buttonGroup.element.removeChild(this.rotateRight.element))),this._addUpdatePixelDensityRatioEvent(),this.showNavigator&&(this.navigator=new t.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),ee=0;ee<this.customControls.length;ee++)this.addControl(this.customControls[ee].id,{anchor:this.customControls[ee].anchor});t.requestAnimationFrame(function(){c(q)}),t._viewers.set(this.element,this)},t.extend(t.Viewer.prototype,t.EventSource.prototype,t.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},openDzi:function(x){return t.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(x)},openTileSource:function(x){return t.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(x)},get buttons(){return t.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(x,L){var q=this;if(this.close(),!x)return this;if(this.sequenceMode&&t.isArray(x))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof L<"u"&&!isNaN(L)&&(this.initialPage=L),this.tileSources=x,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(t.isArray(x)||(x=[x]),!x.length)return this;this._opening=!0;for(var ee=x.length,J=0,xe=0,re,Ue=function(){if(J+xe===ee)if(J){(q._firstOpen||!q.preserveViewport)&&(q.viewport.goHome(!0),q.viewport.update()),q._firstOpen=!1;var je=x[0];if(je.tileSource&&(je=je.tileSource),q.overlays&&!q.preserveOverlays)for(var Dt=0;Dt<q.overlays.length;Dt++)q.currentOverlays[Dt]=a(q,q.overlays[Dt]);q._drawOverlays(),q._opening=!1,q.raiseEvent("open",{source:je})}else q._opening=!1,q.raiseEvent("open-failed",re)},it=function(je){(!t.isPlainObject(je)||!je.tileSource)&&(je={tileSource:je}),je.index!==void 0&&(t.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete je.index),je.collectionImmediately===void 0&&(je.collectionImmediately=!0);var Dt=je.success;je.success=function(E){if(J++,je.tileSource.overlays)for(var N=0;N<je.tileSource.overlays.length;N++)q.addOverlay(je.tileSource.overlays[N]);Dt&&Dt(E),Ue()};var T=je.error;je.error=function(E){xe++,re||(re=E),T&&T(E),Ue()},q.addTiledImage(je)},gt=0;gt<x.length;gt++)it(x[gt]);return this},close:function(){return i[this.hash]?(this._opening=!1,this.navigator&&this.navigator.close(),this.preserveOverlays||(this.clearOverlays(),this.overlaysContainer.innerHTML=""),i[this.hash].animating=!1,this.world.removeAll(),this.imageLoader.clear(),this.raiseEvent("close"),this):this},destroy:function(){if(i[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&&(t.cancelAnimationFrame(this._updateRequestId),this._updateRequestId=null),this.drawer&&this.drawer.destroy(),this.navigator&&(this.navigator.destroy(),i[this.navigator.hash]=null,delete i[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(),i[this.hash]=null,delete i[this.hash],this.canvas=null,this.container=null,t._viewers.delete(this.element),this.element=null,this.raiseEvent("destroy"),this.removeAllHandlers()}},requestDrawer(x,L){const q={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};L=t.extend(!0,q,L);const ee=L.mainDrawer,J=L.redrawImmediately,xe=L.drawerOptions,re=this.drawer;let Ue=null;if(x&&x.prototype instanceof t.DrawerBase?(Ue=x,x="custom"):typeof x=="string"&&(Ue=t.determineDrawer(x)),Ue||t.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),Ue&&Ue.isSupported()){re&&ee&&re.destroy();const it=new Ue({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:xe||this.drawerOptions[x]});return ee&&(this.drawer=it,J&&this.forceRedraw()),it}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(x){return this.innerTracker.setTracking(x),this.outerTracker.setTracking(x),this.raiseEvent("mouse-enabled",{enabled:x}),this},areControlsEnabled:function(){var x=this.controls.length,L;for(L=0;L<this.controls.length;L++)x=x&&this.controls[L].isVisible();return x},setControlsEnabled:function(x){return x?f(this):c(this),this.raiseEvent("controls-enabled",{enabled:x}),this},setDebugMode:function(x){for(var L=0;L<this.world.getItemCount();L++)this.world.getItemAt(L).debugMode=x;this.debugMode=x,this.forceRedraw()},setAjaxHeaders:function(x,L){if(x===null&&(x={}),!t.isPlainObject(x)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(L===void 0&&(L=!0),this.ajaxHeaders=x,L){for(var q=0;q<this.world.getItemCount();q++)this.world.getItemAt(q)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var ee in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[ee].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(x){this.buttonGroup.addButton(x)},isFullPage:function(){return i[this.hash]&&i[this.hash].fullPage},setFullPage:function(x){var L=document.body,q=L.style,ee=document.documentElement.style,J=this,xe,re;if(x===this.isFullPage())return this;var Ue={fullPage:x,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",Ue),Ue.preventDefaultAction)return this;if(x&&this.element){for(this.elementSize=t.getElementSize(this.element),this.pageScroll=t.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=q.margin,this.docMargin=ee.margin,q.margin="0",ee.margin="0",this.bodyPadding=q.padding,this.docPadding=ee.padding,q.padding="0",ee.padding="0",this.bodyWidth=q.width,this.docWidth=ee.width,q.width="100%",ee.width="100%",this.bodyHeight=q.height,this.docHeight=ee.height,q.height="100%",ee.height="100%",this.bodyDisplay=q.display,q.display="block",this.previousBody=[],i[this.hash].prevElementParent=this.element.parentNode,i[this.hash].prevNextSibling=this.element.nextSibling,i[this.hash].prevElementWidth=this.element.style.width,i[this.hash].prevElementHeight=this.element.style.height,xe=L.childNodes.length,re=0;re<xe;re++)this.previousBody.push(L.childNodes[0]),L.removeChild(L.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,L.appendChild(this.toolbar.element),t.addClass(this.toolbar.element,"fullpage")),t.addClass(this.element,"fullpage"),L.appendChild(this.element),this.element.style.height="100vh",this.element.style.width="100vw",this.toolbar&&this.toolbar.element&&(this.element.style.height=t.getElementSize(this.element).y-t.getElementSize(this.toolbar.element).y+"px"),i[this.hash].fullPage=!0,t.delegate(this,V)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,q.margin=this.bodyMargin,ee.margin=this.docMargin,q.padding=this.bodyPadding,ee.padding=this.docPadding,q.width=this.bodyWidth,ee.width=this.docWidth,q.height=this.bodyHeight,ee.height=this.docHeight,q.display=this.bodyDisplay,L.removeChild(this.element),xe=this.previousBody.length,re=0;re<xe;re++)L.appendChild(this.previousBody.shift());t.removeClass(this.element,"fullpage"),i[this.hash].prevElementParent.insertBefore(this.element,i[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(L.removeChild(this.toolbar.element),t.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=i[this.hash].prevElementWidth,this.element.style.height=i[this.hash].prevElementHeight;var it=0,gt=function(){t.setPageScroll(J.pageScroll);var je=t.getPageScroll();it++,it<10&&(je.x!==J.pageScroll.x||je.y!==J.pageScroll.y)&&t.requestAnimationFrame(gt)};t.requestAnimationFrame(gt),i[this.hash].fullPage=!1,t.delegate(this,Y)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:x}),this},setFullScreen:function(x){var L=this;if(!t.supportsFullScreen)return this.setFullPage(x);if(t.isFullScreen()===x)return this;var q={fullScreen:x,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",q),q.preventDefaultAction)return this;if(x){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 ee=function(){var J=t.isFullScreen();J||(t.removeEvent(document,t.fullScreenEventName,ee),t.removeEvent(document,t.fullScreenErrorEventName,ee),L.setFullPage(!1),L.isFullPage()&&(L.element.style.width=L.fullPageStyleWidth,L.element.style.height=L.fullPageStyleHeight)),L.navigator&&L.viewport&&setTimeout(function(){L.navigator.update(L.viewport)}),L.raiseEvent("full-screen",{fullScreen:J})};t.addEvent(document,t.fullScreenEventName,ee),t.addEvent(document,t.fullScreenErrorEventName,ee),t.requestFullScreen(document.body)}else t.exitFullScreen();return this},isVisible:function(){return this.container.style.visibility!=="hidden"},isFullScreen:function(){return t.isFullScreen()&&this.isFullPage()},setVisible:function(x){return this.container.style.visibility=x?"":"hidden",this.raiseEvent("visible",{visible:x}),this},addTiledImage:function(x){t.console.assert(x,"[Viewer.addTiledImage] options is required"),t.console.assert(x.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),t.console.assert(!x.replace||x.index>-1&&x.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var L=this;x.replace&&(x.replaceItem=L.world.getItemAt(x.index)),this._hideMessage(),x.placeholderFillStyle===void 0&&(x.placeholderFillStyle=this.placeholderFillStyle),x.opacity===void 0&&(x.opacity=this.opacity),x.preload===void 0&&(x.preload=this.preload),x.compositeOperation===void 0&&(x.compositeOperation=this.compositeOperation),x.crossOriginPolicy===void 0&&(x.crossOriginPolicy=x.tileSource.crossOriginPolicy!==void 0?x.tileSource.crossOriginPolicy:this.crossOriginPolicy),x.ajaxWithCredentials===void 0&&(x.ajaxWithCredentials=this.ajaxWithCredentials),x.loadTilesWithAjax===void 0&&(x.loadTilesWithAjax=this.loadTilesWithAjax),t.isPlainObject(x.ajaxHeaders)||(x.ajaxHeaders={});var q={options:x};function ee(re){for(var Ue=0;Ue<L._loadQueue.length;Ue++)if(L._loadQueue[Ue]===q){L._loadQueue.splice(Ue,1);break}L._loadQueue.length===0&&J(q),L.raiseEvent("add-item-failed",re),x.error&&x.error(re)}function J(re){L.collectionMode&&(L.world.arrange({immediately:re.options.collectionImmediately,rows:L.collectionRows,columns:L.collectionColumns,layout:L.collectionLayout,tileSize:L.collectionTileSize,tileMargin:L.collectionTileMargin}),L.world.setAutoRefigureSizes(!0))}if(t.isArray(x.tileSource)){setTimeout(function(){ee({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:x.tileSource,options:x})});return}this._loadQueue.push(q);function xe(){for(var re,Ue,it;L._loadQueue.length&&(re=L._loadQueue[0],!!re.tileSource);){if(L._loadQueue.splice(0,1),re.options.replace){var gt=L.world.getIndexOfItem(re.options.replaceItem);gt!==-1&&(re.options.index=gt),L.world.removeItem(re.options.replaceItem)}Ue=new t.TiledImage({viewer:L,source:re.tileSource,viewport:L.viewport,drawer:L.drawer,tileCache:L.tileCache,imageLoader:L.imageLoader,x:re.options.x,y:re.options.y,width:re.options.width,height:re.options.height,fitBounds:re.options.fitBounds,fitBoundsPlacement:re.options.fitBoundsPlacement,clip:re.options.clip,placeholderFillStyle:re.options.placeholderFillStyle,opacity:re.options.opacity,preload:re.options.preload,degrees:re.options.degrees,flipped:re.options.flipped,compositeOperation:re.options.compositeOperation,springStiffness:L.springStiffness,animationTime:L.animationTime,minZoomImageRatio:L.minZoomImageRatio,wrapHorizontal:L.wrapHorizontal,wrapVertical:L.wrapVertical,maxTilesPerFrame:L.maxTilesPerFrame,immediateRender:L.immediateRender,blendTime:L.blendTime,alwaysBlend:L.alwaysBlend,minPixelRatio:L.minPixelRatio,smoothTileEdgesMinZoom:L.smoothTileEdgesMinZoom,iOSDevice:L.iOSDevice,crossOriginPolicy:re.options.crossOriginPolicy,ajaxWithCredentials:re.options.ajaxWithCredentials,loadTilesWithAjax:re.options.loadTilesWithAjax,ajaxHeaders:re.options.ajaxHeaders,debugMode:L.debugMode,subPixelRoundingForTransparency:L.subPixelRoundingForTransparency}),L.collectionMode&&L.world.setAutoRefigureSizes(!1),L.navigator&&(it=t.extend({},re.options,{replace:!1,originalTiledImage:Ue,tileSource:re.tileSource}),L.navigator.addTiledImage(it)),L.world.addItem(Ue,{index:re.options.index}),L._loadQueue.length===0&&J(re),L.world.getItemCount()===1&&!L.preserveViewport&&L.viewport.goHome(!0),re.options.success&&re.options.success({item:Ue})}}o(this,x.tileSource,x,function(re){q.tileSource=re,xe()},function(re){re.options=x,ee(re),xe()})},addSimpleImage:function(x){t.console.assert(x,"[Viewer.addSimpleImage] options is required"),t.console.assert(x.url,"[Viewer.addSimpleImage] options.url is required");var L=t.extend({},x,{tileSource:{type:"image",url:x.url}});delete L.url,this.addTiledImage(L)},addLayer:function(x){var L=this;t.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var q=t.extend({},x,{success:function(ee){L.raiseEvent("add-layer",{options:x,drawer:ee.item})},error:function(ee){L.raiseEvent("add-layer-failed",ee)}});return this.addTiledImage(q),this},getLayerAtLevel:function(x){return t.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(x)},getLevelOfLayer:function(x){return t.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(x)},getLayersCount:function(){return t.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(x,L){return t.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(x,L)},removeLayer:function(x){return t.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(x)},forceRedraw:function(){return i[this.hash].forceRedraw=!0,this},forceResize:function(){i[this.hash].needsResize=!0,i[this.hash].forceResize=!0},bindSequenceControls:function(){var x=t.delegate(this,g),L=t.delegate(this,p),q=t.delegate(this,this.goToNextPage),ee=t.delegate(this,this.goToPreviousPage),J=this.navImages,xe=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(xe=!1),this.previousButton=new t.Button({element:this.previousButton?t.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.PreviousPage"),srcRest:Q(this.prefixUrl,J.previous.REST),srcGroup:Q(this.prefixUrl,J.previous.GROUP),srcHover:Q(this.prefixUrl,J.previous.HOVER),srcDown:Q(this.prefixUrl,J.previous.DOWN),onRelease:ee,onFocus:x,onBlur:L}),this.nextButton=new t.Button({element:this.nextButton?t.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.NextPage"),srcRest:Q(this.prefixUrl,J.next.REST),srcGroup:Q(this.prefixUrl,J.next.GROUP),srcHover:Q(this.prefixUrl,J.next.HOVER),srcDown:Q(this.prefixUrl,J.next.DOWN),onRelease:q,onFocus:x,onBlur:L}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),xe&&(this.paging=new t.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:t.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||t.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var x=t.delegate(this,W),L=t.delegate(this,ne),q=t.delegate(this,Ce),ee=t.delegate(this,$),J=t.delegate(this,Pe),xe=t.delegate(this,ke),re=t.delegate(this,Ge),Ue=t.delegate(this,$e),it=t.delegate(this,ft),gt=t.delegate(this,Pt),je=t.delegate(this,g),Dt=t.delegate(this,p),T=this.navImages,E=[],N=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(N=!1),this.showZoomControl&&(E.push(this.zoomInButton=new t.Button({element:this.zoomInButton?t.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomIn"),srcRest:Q(this.prefixUrl,T.zoomIn.REST),srcGroup:Q(this.prefixUrl,T.zoomIn.GROUP),srcHover:Q(this.prefixUrl,T.zoomIn.HOVER),srcDown:Q(this.prefixUrl,T.zoomIn.DOWN),onPress:x,onRelease:L,onClick:q,onEnter:x,onExit:L,onFocus:je,onBlur:Dt})),E.push(this.zoomOutButton=new t.Button({element:this.zoomOutButton?t.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomOut"),srcRest:Q(this.prefixUrl,T.zoomOut.REST),srcGroup:Q(this.prefixUrl,T.zoomOut.GROUP),srcHover:Q(this.prefixUrl,T.zoomOut.HOVER),srcDown:Q(this.prefixUrl,T.zoomOut.DOWN),onPress:ee,onRelease:L,onClick:J,onEnter:ee,onExit:L,onFocus:je,onBlur:Dt}))),this.showHomeControl&&E.push(this.homeButton=new t.Button({element:this.homeButton?t.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Home"),srcRest:Q(this.prefixUrl,T.home.REST),srcGroup:Q(this.prefixUrl,T.home.GROUP),srcHover:Q(this.prefixUrl,T.home.HOVER),srcDown:Q(this.prefixUrl,T.home.DOWN),onRelease:xe,onFocus:je,onBlur:Dt})),this.showFullPageControl&&E.push(this.fullPageButton=new t.Button({element:this.fullPageButton?t.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.FullPage"),srcRest:Q(this.prefixUrl,T.fullpage.REST),srcGroup:Q(this.prefixUrl,T.fullpage.GROUP),srcHover:Q(this.prefixUrl,T.fullpage.HOVER),srcDown:Q(this.prefixUrl,T.fullpage.DOWN),onRelease:re,onFocus:je,onBlur:Dt})),this.showRotationControl&&(E.push(this.rotateLeftButton=new t.Button({element:this.rotateLeftButton?t.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateLeft"),srcRest:Q(this.prefixUrl,T.rotateleft.REST),srcGroup:Q(this.prefixUrl,T.rotateleft.GROUP),srcHover:Q(this.prefixUrl,T.rotateleft.HOVER),srcDown:Q(this.prefixUrl,T.rotateleft.DOWN),onRelease:Ue,onFocus:je,onBlur:Dt})),E.push(this.rotateRightButton=new t.Button({element:this.rotateRightButton?t.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateRight"),srcRest:Q(this.prefixUrl,T.rotateright.REST),srcGroup:Q(this.prefixUrl,T.rotateright.GROUP),srcHover:Q(this.prefixUrl,T.rotateright.HOVER),srcDown:Q(this.prefixUrl,T.rotateright.DOWN),onRelease:it,onFocus:je,onBlur:Dt}))),this.showFlipControl&&E.push(this.flipButton=new t.Button({element:this.flipButton?t.getElement(this.flipButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Flip"),srcRest:Q(this.prefixUrl,T.flip.REST),srcGroup:Q(this.prefixUrl,T.flip.GROUP),srcHover:Q(this.prefixUrl,T.flip.HOVER),srcDown:Q(this.prefixUrl,T.flip.DOWN),onRelease:gt,onFocus:je,onBlur:Dt})),N?(this.buttonGroup=new t.ButtonGroup({buttons:E,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",t.delegate(this,Be)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT})):this.customButtons=E),this},currentPage:function(){return this._sequenceIndex},goToPage:function(x){return this.tileSources&&x>=0&&x<this.tileSources.length&&(this._sequenceIndex=x,this._updateSequenceButtons(x),this.open(this.tileSources[x]),this.referenceStrip&&this.referenceStrip.setFocus(x),this.raiseEvent("page",{page:x})),this},addOverlay:function(x,L,q,ee){var J;if(t.isPlainObject(x)?J=x:J={element:x,location:L,placement:q,onDraw:ee},x=t.getElement(J.element),l(this.currentOverlays,x)>=0)return this;var xe=a(this,J);return this.currentOverlays.push(xe),xe.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:x,location:J.location,placement:J.placement}),this},updateOverlay:function(x,L,q){var ee;return x=t.getElement(x),ee=l(this.currentOverlays,x),ee>=0&&(this.currentOverlays[ee].update(L,q),i[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:x,location:L,placement:q})),this},removeOverlay:function(x){var L;return x=t.getElement(x),L=l(this.currentOverlays,x),L>=0&&(this.currentOverlays[L].destroy(),this.currentOverlays.splice(L,1),i[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:x})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return i[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},getOverlayById:function(x){var L;return x=t.getElement(x),L=l(this.currentOverlays,x),L>=0?this.currentOverlays[L]:null},_updateSequenceButtons:function(x){this.nextButton&&(!this.tileSources||this.tileSources.length-1===x?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(x>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(x){this._hideMessage();var L=t.makeNeutralElement("div");L.appendChild(document.createTextNode(x)),this.messageDiv=t.makeCenteredNode(L),t.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var x=this.messageDiv;x&&(x.parentNode.removeChild(x),delete this.messageDiv)},gestureSettingsByDeviceType:function(x){switch(x){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var x,L=this.currentOverlays.length;for(x=0;x<L;x++)this.currentOverlays[x].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 t.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 t.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')},_addUpdatePixelDensityRatioEvent:function(){this._updatePixelDensityRatioBind=this._updatePixelDensityRatio.bind(this),t.addEvent(window,"resize",this._updatePixelDensityRatioBind)},_removeUpdatePixelDensityRatioEvent:function(){t.removeEvent(window,"resize",this._updatePixelDensityRatioBind)},_updatePixelDensityRatio:function(){var x=t.pixelDensityRatio,L=t.getCurrentPixelDensityRatio();x!==L&&(t.pixelDensityRatio=L,this.forceResize())},goToPreviousPage:function(){var x=this._sequenceIndex-1;this.navPrevNextWrap&&x<0&&(x+=this.tileSources.length),this.goToPage(x)},goToNextPage:function(){var x=this._sequenceIndex+1;this.navPrevNextWrap&&x>=this.tileSources.length&&(x=0),this.goToPage(x)},isAnimating:function(){return i[this.hash].animating}});function s(x){return x=t.getElement(x),new t.Point(x.clientWidth===0?1:x.clientWidth,x.clientHeight===0?1:x.clientHeight)}function o(x,L,q,ee,J){var xe=x;if(t.type(L)==="string"){if(L.match(/^\s*<.*>\s*$/))L=t.parseXml(L);else if(L.match(/^\s*[{[].*[}\]]\s*$/))try{var re=t.parseJSON(L);L=re}catch{}}function Ue(it,gt){it.ready?ee(it):(it.addHandler("ready",function(){ee(it)}),it.addHandler("open-failed",function(je){J({message:je.message,source:gt})}))}setTimeout(function(){if(t.type(L)==="string")L=new t.TileSource({url:L,crossOriginPolicy:q.crossOriginPolicy!==void 0?q.crossOriginPolicy:x.crossOriginPolicy,ajaxWithCredentials:x.ajaxWithCredentials,ajaxHeaders:q.ajaxHeaders?q.ajaxHeaders:x.ajaxHeaders,splitHashDataForPost:x.splitHashDataForPost,success:function(Dt){ee(Dt.tileSource)}}),L.addHandler("open-failed",function(Dt){J(Dt)});else if(t.isPlainObject(L)||L.nodeType)if(L.crossOriginPolicy===void 0&&(q.crossOriginPolicy!==void 0||x.crossOriginPolicy!==void 0)&&(L.crossOriginPolicy=q.crossOriginPolicy!==void 0?q.crossOriginPolicy:x.crossOriginPolicy),L.ajaxWithCredentials===void 0&&(L.ajaxWithCredentials=x.ajaxWithCredentials),t.isFunction(L.getTileUrl)){var it=new t.TileSource(L);it.getTileUrl=L.getTileUrl,ee(it)}else{var gt=t.TileSource.determineType(xe,L);if(!gt){J({message:"Unable to load TileSource",source:L});return}var je=gt.prototype.configure.apply(xe,[L]);Ue(new gt(je),L)}else Ue(L,L)})}function a(x,L){if(L instanceof t.Overlay)return L;var q=null;if(L.element)q=t.getElement(L.element);else{var ee=L.id?L.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);q=t.getElement(L.id),q||(q=document.createElement("a"),q.href="#/overlay/"+ee),q.id=ee,t.addClass(q,L.className?L.className:"openseadragon-overlay")}var J=L.location,xe=L.width,re=L.height;if(!J){var Ue=L.x,it=L.y;if(L.px!==void 0){var gt=x.viewport.imageToViewportRectangle(new t.Rect(L.px,L.py,xe||0,re||0));Ue=gt.x,it=gt.y,xe=xe!==void 0?gt.width:void 0,re=re!==void 0?gt.height:void 0}J=new t.Point(Ue,it)}var je=L.placement;return je&&t.type(je)==="string"&&(je=t.Placement[L.placement.toUpperCase()]),new t.Overlay({element:q,location:J,placement:je,onDraw:L.onDraw,checkResize:L.checkResize,width:xe,height:re,rotationMode:L.rotationMode})}function l(x,L){var q;for(q=x.length-1;q>=0;q--)if(x[q].element===L)return q;return-1}function h(x,L){return t.requestAnimationFrame(function(){L(x)})}function u(x){t.requestAnimationFrame(function(){d(x)})}function c(x){x.autoHideControls&&(x.controlsShouldFade=!0,x.controlsFadeBeginTime=t.now()+x.controlsFadeDelay,window.setTimeout(function(){u(x)},x.controlsFadeDelay))}function d(x){var L,q,ee,J;if(x.controlsShouldFade){for(L=t.now(),q=L-x.controlsFadeBeginTime,ee=1-q/x.controlsFadeLength,ee=Math.min(1,ee),ee=Math.max(0,ee),J=x.controls.length-1;J>=0;J--)x.controls[J].autoFade&&x.controls[J].setOpacity(ee);ee>0&&u(x)}}function f(x){var L;for(x.controlsShouldFade=!1,L=x.controls.length-1;L>=0;L--)x.controls[L].setOpacity(1)}function g(){f(this)}function p(){c(this)}function m(x){var L={tracker:x.eventSource,position:x.position,originalEvent:x.originalEvent,preventDefault:x.preventDefault};this.raiseEvent("canvas-contextmenu",L),x.preventDefault=L.preventDefault}function v(x){var L={originalEvent:x.originalEvent,preventDefaultAction:!1,preventVerticalPan:x.preventVerticalPan||!this.panVertical,preventHorizontalPan:x.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",L),!L.preventDefaultAction&&!x.ctrl&&!x.alt&&!x.meta)switch(x.keyCode){case 38:L.preventVerticalPan||(x.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 40:L.preventVerticalPan||(x.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 37:L.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 39:L.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),x.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),x.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),x.preventDefault=!0;break;case 87:L.preventVerticalPan||(x.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-40))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 83:L.preventVerticalPan||(x.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,40))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 65:L.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-40,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 68:L.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(40,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 82:x.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(),x.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),x.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:x.preventDefault=!1;break}else x.preventDefault=!1}function y(x){var L={originalEvent:x.originalEvent};this.raiseEvent("canvas-key-press",L)}function _(x){var L,q=document.activeElement===this.canvas;q||this.canvas.focus(),this.viewport.flipped&&(x.position.x=this.viewport.getContainerSize().x-x.position.x);var ee={tracker:x.eventSource,position:x.position,quick:x.quick,shift:x.shift,originalEvent:x.originalEvent,originalTarget:x.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",ee),!ee.preventDefaultAction&&this.viewport&&x.quick&&(L=this.gestureSettingsByDeviceType(x.pointerType),L.clickToZoom===!0&&(this.viewport.zoomBy(x.shift?1/this.zoomPerClick:this.zoomPerClick,L.zoomToRefPoint?this.viewport.pointFromPixel(x.position,!0):null),this.viewport.applyConstraints()),L.dblClickDragToZoom&&(i[this.hash].draggingToZoom===!0?(i[this.hash].lastClickTime=null,i[this.hash].draggingToZoom=!1):i[this.hash].lastClickTime=t.now()))}function w(x){var L,q={tracker:x.eventSource,position:x.position,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",q),!q.preventDefaultAction&&this.viewport&&(L=this.gestureSettingsByDeviceType(x.pointerType),L.dblClickToZoom&&(this.viewport.zoomBy(x.shift?1/this.zoomPerClick:this.zoomPerClick,L.zoomToRefPoint?this.viewport.pointFromPixel(x.position,!0):null),this.viewport.applyConstraints()))}function A(x){var L,q={tracker:x.eventSource,pointerType:x.pointerType,position:x.position,delta:x.delta,speed:x.speed,direction:x.direction,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",q),L=this.gestureSettingsByDeviceType(x.pointerType),!q.preventDefaultAction&&this.viewport){if(L.dblClickDragToZoom&&i[this.hash].draggingToZoom){var ee=Math.pow(this.zoomPerDblClickDrag,x.delta.y/50);this.viewport.zoomBy(ee)}else if(L.dragToPan&&!i[this.hash].draggingToZoom){if(this.panHorizontal||(x.delta.x=0),this.panVertical||(x.delta.y=0),this.viewport.flipped&&(x.delta.x=-x.delta.x),this.constrainDuringPan){var J=this.viewport.deltaPointsFromPixels(x.delta.negate());this.viewport.centerSpringX.target.value+=J.x,this.viewport.centerSpringY.target.value+=J.y;var xe=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=J.x,this.viewport.centerSpringY.target.value-=J.y,xe.xConstrained&&(x.delta.x=0),xe.yConstrained&&(x.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(x.delta.negate()),L.flickEnabled&&!this.constrainDuringPan)}}}function F(x){var L,q={tracker:x.eventSource,pointerType:x.pointerType,position:x.position,speed:x.speed,direction:x.direction,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",q),L=this.gestureSettingsByDeviceType(x.pointerType),!q.preventDefaultAction&&this.viewport){if(!i[this.hash].draggingToZoom&&L.dragToPan&&L.flickEnabled&&x.speed>=L.flickMinSpeed){var ee=0;this.panHorizontal&&(ee=L.flickMomentum*x.speed*Math.cos(x.direction));var J=0;this.panVertical&&(J=L.flickMomentum*x.speed*Math.sin(x.direction));var xe=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),re=this.viewport.pointFromPixel(new t.Point(xe.x-ee,xe.y-J));this.viewport.panTo(re,!1)}this.viewport.applyConstraints()}L.dblClickDragToZoom&&i[this.hash].draggingToZoom===!0&&(i[this.hash].draggingToZoom=!1)}function C(x){this.raiseEvent("canvas-enter",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function R(x){this.raiseEvent("canvas-exit",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function M(x){var L;if(this.raiseEvent("canvas-press",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,insideElementPressed:x.insideElementPressed,insideElementReleased:x.insideElementReleased,originalEvent:x.originalEvent}),L=this.gestureSettingsByDeviceType(x.pointerType),L.dblClickDragToZoom){var q=i[this.hash].lastClickTime,ee=t.now();if(q===null)return;ee-q<this.dblClickTimeThreshold&&(i[this.hash].draggingToZoom=!0),i[this.hash].lastClickTime=null}}function k(x){this.raiseEvent("canvas-release",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,insideElementPressed:x.insideElementPressed,insideElementReleased:x.insideElementReleased,originalEvent:x.originalEvent})}function z(x){this.raiseEvent("canvas-nonprimary-press",{tracker:x.eventSource,position:x.position,pointerType:x.pointerType,button:x.button,buttons:x.buttons,originalEvent:x.originalEvent})}function D(x){this.raiseEvent("canvas-nonprimary-release",{tracker:x.eventSource,position:x.position,pointerType:x.pointerType,button:x.button,buttons:x.buttons,originalEvent:x.originalEvent})}function S(x){var L,q,ee,J,xe={tracker:x.eventSource,pointerType:x.pointerType,gesturePoints:x.gesturePoints,lastCenter:x.lastCenter,center:x.center,lastDistance:x.lastDistance,distance:x.distance,shift:x.shift,originalEvent:x.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",xe),this.viewport&&(L=this.gestureSettingsByDeviceType(x.pointerType),L.pinchToZoom&&(!xe.preventDefaultPanAction||!xe.preventDefaultZoomAction)&&(q=this.viewport.pointFromPixel(x.center,!0),L.zoomToRefPoint&&!xe.preventDefaultPanAction&&(ee=this.viewport.pointFromPixel(x.lastCenter,!0),J=ee.minus(q),this.panHorizontal||(J.x=0),this.panVertical||(J.y=0),this.viewport.panBy(J,!0)),xe.preventDefaultZoomAction||this.viewport.zoomBy(x.distance/x.lastDistance,q,!0),this.viewport.applyConstraints()),L.pinchRotate&&!xe.preventDefaultRotateAction)){var re=Math.atan2(x.gesturePoints[0].currentPos.y-x.gesturePoints[1].currentPos.y,x.gesturePoints[0].currentPos.x-x.gesturePoints[1].currentPos.x),Ue=Math.atan2(x.gesturePoints[0].lastPos.y-x.gesturePoints[1].lastPos.y,x.gesturePoints[0].lastPos.x-x.gesturePoints[1].lastPos.x);q=this.viewport.pointFromPixel(x.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(re-Ue)*(180/Math.PI),q,!0)}}function b(x){this.raiseEvent("canvas-focus",{tracker:x.eventSource,originalEvent:x.originalEvent})}function O(x){this.raiseEvent("canvas-blur",{tracker:x.eventSource,originalEvent:x.originalEvent})}function j(x){var L,q,ee,J,xe;J=t.now(),xe=J-this._lastScrollTime,xe>this.minScrollDeltaTime?(this._lastScrollTime=J,L={tracker:x.eventSource,position:x.position,scroll:x.scroll,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",L),!L.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(x.position.x=this.viewport.getContainerSize().x-x.position.x),q=this.gestureSettingsByDeviceType(x.pointerType),q.scrollToZoom&&(ee=Math.pow(this.zoomPerScroll,x.scroll),this.viewport.zoomBy(ee,q.zoomToRefPoint?this.viewport.pointFromPixel(x.position,!0):null),this.viewport.applyConstraints())),x.preventDefault=L.preventDefault):x.preventDefault=!0}function V(x){i[this.hash].mouseInside=!0,f(this),this.raiseEvent("container-enter",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function Y(x){x.pointers<1&&(i[this.hash].mouseInside=!1,i[this.hash].animating||c(this)),this.raiseEvent("container-exit",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function G(x){X(x),x.isOpen()?x._updateRequestId=h(x,G):x._updateRequestId=!1}function H(x,L){var q=x.viewport,ee=q.getZoom(),J=q.getCenter();q.resize(L,x.preserveImageSizeOnResize),q.panTo(J,!0);var xe;if(x.preserveImageSizeOnResize)xe=i[x.hash].prevContainerSize.x/L.x;else{var re=new t.Point(0,0),Ue=new t.Point(i[x.hash].prevContainerSize.x,i[x.hash].prevContainerSize.y).distanceTo(re),it=new t.Point(L.x,L.y).distanceTo(re);xe=it/Ue*i[x.hash].prevContainerSize.x/L.x}q.zoomTo(ee*xe,null,!0),i[x.hash].prevContainerSize=L,i[x.hash].forceRedraw=!0,i[x.hash].needsResize=!1,i[x.hash].forceResize=!1}function X(x){if(!(x._opening||!i[x.hash])){if(x.autoResize||i[x.hash].forceResize){var L;if(x._autoResizePolling){L=s(x.container);var q=i[x.hash].prevContainerSize;L.equals(q)||(i[x.hash].needsResize=!0)}i[x.hash].needsResize&&H(x,L||s(x.container))}var ee=x.viewport.update(),J=x.world.update(ee)||ee;ee&&x.raiseEvent("viewport-change"),x.referenceStrip&&(J=x.referenceStrip.update(x.viewport)||J);var xe=i[x.hash].animating;!xe&&J&&(x.raiseEvent("animation-start"),f(x));var re=xe&&!J;re&&(i[x.hash].animating=!1),(J||re||i[x.hash].forceRedraw||x.world.needsDraw())&&(K(x),x._drawOverlays(),x.navigator&&x.navigator.update(x.viewport),i[x.hash].forceRedraw=!1,J&&x.raiseEvent("animation")),re&&(x.raiseEvent("animation-finish"),i[x.hash].mouseInside||c(x)),i[x.hash].animating=J}}function K(x){x.imageLoader.clear(),x.world.draw(),x.raiseEvent("update-viewport",{})}function Q(x,L){return x?x+L:L}function W(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=this.zoomPerSecond,i[this.hash].zooming=!0,_e(this)}function $(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=1/this.zoomPerSecond,i[this.hash].zooming=!0,_e(this)}function ne(){i[this.hash].zooming=!1}function _e(x){t.requestAnimationFrame(t.delegate(x,pe))}function pe(){var x,L,q;i[this.hash].zooming&&this.viewport&&(x=t.now(),L=x-i[this.hash].lastZoomTime,q=Math.pow(i[this.hash].zoomFactor,L/1e3),this.viewport.zoomBy(q),this.viewport.applyConstraints(),i[this.hash].lastZoomTime=x,_e(this))}function Ce(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function Pe(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function Be(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function ke(){this.viewport&&this.viewport.goHome()}function Ge(){this.isFullPage()&&!t.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttonGroup&&this.buttonGroup.emulateLeave(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function $e(){if(this.viewport){var x=this.viewport.getRotation();this.viewport.flipped?x+=this.rotationIncrement:x-=this.rotationIncrement,this.viewport.setRotation(x)}}function ft(){if(this.viewport){var x=this.viewport.getRotation();this.viewport.flipped?x-=this.rotationIncrement:x+=this.rotationIncrement,this.viewport.setRotation(x)}}function Pt(){this.viewport.toggleFlip()}t.determineDrawer=function(x){for(let L in e){const q=e[L],ee=q.prototype;if(ee&&ee instanceof e.DrawerBase&&t.isFunction(ee.getType)&&ee.getType.call(q)===x)return q}return null}})(e),(function(t){t.Navigator=function(h){var u=h.viewer,c=this,d,f;h.element||h.id?(h.element?(h.id&&t.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),h.element.id?h.id=h.element.id:h.id="navigator-"+t.now(),this.element=h.element):this.element=document.getElementById(h.id),h.controlOptions={anchor:t.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(h.id="navigator-"+t.now(),this.element=t.makeNeutralElement("div"),h.controlOptions={anchor:t.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:h.autoFade},h.position&&(h.position==="BOTTOM_RIGHT"?h.controlOptions.anchor=t.ControlAnchor.BOTTOM_RIGHT:h.position==="BOTTOM_LEFT"?h.controlOptions.anchor=t.ControlAnchor.BOTTOM_LEFT:h.position==="TOP_RIGHT"?h.controlOptions.anchor=t.ControlAnchor.TOP_RIGHT:h.position==="TOP_LEFT"?h.controlOptions.anchor=t.ControlAnchor.TOP_LEFT:h.position==="ABSOLUTE"&&(h.controlOptions.anchor=t.ControlAnchor.ABSOLUTE,h.controlOptions.top=h.top,h.controlOptions.left=h.left,h.controlOptions.height=h.height,h.controlOptions.width=h.width))),this.element.id=h.id,this.element.className+=" navigator",h=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.navigatorSizeRatio},h,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:h.animationTime,autoResize:!1,minZoomImageRatio:1,background:h.background,opacity:h.opacity,borderColor:h.borderColor,displayRegionColor:h.displayRegionColor}),h.minPixelRatio=this.minPixelRatio=u.minPixelRatio,t.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new t.Point(1,1),this.totalBorderWidths=new t.Point(this.borderWidth*2,this.borderWidth*2).minus(this.fudge),h.controlOptions.anchor!==t.ControlAnchor.NONE&&(function(m,v){m.margin="0px",m.border=v+"px solid "+h.borderColor,m.padding="0px",m.background=h.background,m.opacity=h.opacity,m.overflow="hidden"})(this.element.style,this.borderWidth),this.displayRegion=t.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",(function(m,v){m.position="relative",m.top="0px",m.left="0px",m.fontSize="0px",m.overflow="hidden",m.border=v+"px solid "+h.displayRegionColor,m.margin="0px",m.padding="0px",m.background="transparent",m.float="left",m.cssFloat="left",m.zIndex=999999999,m.cursor="default",m.boxSizing="content-box"})(this.displayRegion.style,this.borderWidth),t.setElementPointerEventsNone(this.displayRegion),t.setElementTouchActionNone(this.displayRegion),this.displayRegionContainer=t.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",t.setElementPointerEventsNone(this.displayRegionContainer),t.setElementTouchActionNone(this.displayRegionContainer),u.addControl(this.element,h.controlOptions),this._resizeWithViewer=h.controlOptions.anchor!==t.ControlAnchor.ABSOLUTE&&h.controlOptions.anchor!==t.ControlAnchor.NONE,h.width&&h.height?(this.setWidth(h.width),this.setHeight(h.height)):this._resizeWithViewer&&(d=t.getElementSize(u.element),this.element.style.height=Math.round(d.y*h.sizeRatio)+"px",this.element.style.width=Math.round(d.x*h.sizeRatio)+"px",this.oldViewerSize=d,f=t.getElementSize(this.element),this.elementArea=f.x*f.y),this.oldContainerSize=new t.Point(0,0),t.Viewer.apply(this,[h]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function g(m,v){a(c.displayRegionContainer,m),a(c.displayRegion,-m),c.viewport.setRotation(m,v)}if(h.navigatorRotate){var p=h.viewer.viewport?h.viewer.viewport.getRotation():h.viewer.degrees||0;g(p,!0),h.viewer.addHandler("rotate",function(m){g(m.degrees,m.immediately)})}this.innerTracker.destroy(),this.innerTracker=new t.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:t.delegate(this,n),clickHandler:t.delegate(this,i),releaseHandler:t.delegate(this,s),scrollHandler:t.delegate(this,o),preProcessEventHandler:function(m){m.eventType==="wheel"&&(m.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",t.setElementPointerEventsNone(this.canvas),t.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){c.viewport&&c.viewport.goHome(!0)}),u.world.addHandler("item-index-change",function(m){window.setTimeout(function(){var v=c.world.getItemAt(m.previousIndex);c.world.setItemIndex(v,m.newIndex)},1)}),u.world.addHandler("remove-item",function(m){var v=m.item,y=c._getMatchingItem(v);y&&c.world.removeItem(y)}),this.update(u.viewport)},t.extend(t.Navigator.prototype,t.EventSource.prototype,t.Viewer.prototype,{updateSize:function(){if(this.viewport){var h=new t.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);h.equals(this.oldContainerSize)||(this.viewport.resize(h,!0),this.viewport.goHome(!0),this.oldContainerSize=h,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(h){this.width=h,this.element.style.width=typeof h=="number"?h+"px":h,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(h){this.height=h,this.element.style.height=typeof h=="number"?h+"px":h,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(h){return this.viewport.setFlip(h),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(h){l(this.canvas,h),l(this.element,h)},update:function(h){var u,c,d,f,g,p;if(h||(h=this.viewer.viewport),u=t.getElementSize(this.viewer.element),this._resizeWithViewer&&u.x&&u.y&&!u.equals(this.oldViewerSize)&&(this.oldViewerSize=u,this.maintainSizeRatio||!this.elementArea?(c=u.x*this.sizeRatio,d=u.y*this.sizeRatio):(c=Math.sqrt(this.elementArea*(u.x/u.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()),h&&this.viewport){if(f=h.getBoundsNoRotate(!0),g=this.viewport.pixelFromPointNoRotate(f.getTopLeft(),!1),p=this.viewport.pixelFromPointNoRotate(f.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var m=h.getRotation(!0);a(this.displayRegion,-m)}var v=this.displayRegion.style;v.display=this.world.getItemCount()?"block":"none",v.top=g.y.toFixed(2)+"px",v.left=g.x.toFixed(2)+"px";var y=p.x-g.x,_=p.y-g.y;v.width=Math.round(Math.max(y,0))+"px",v.height=Math.round(Math.max(_,0))+"px"}},addTiledImage:function(h){var u=this,c=h.originalTiledImage;delete h.original;var d=t.extend({},h,{success:function(f){var g=f.item;g._originalForNavigator=c,u._matchBounds(g,c,!0),u._matchOpacity(g,c),u._matchCompositeOperation(g,c);function p(){u._matchBounds(g,c)}function m(){u._matchOpacity(g,c)}function v(){u._matchCompositeOperation(g,c)}c.addHandler("bounds-change",p),c.addHandler("clip-change",p),c.addHandler("opacity-change",m),c.addHandler("composite-operation-change",v)}});return t.Viewer.prototype.addTiledImage.apply(this,[d])},destroy:function(){return t.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(h){for(var u=this.world.getItemCount(),c,d=0;d<u;d++)if(c=this.world.getItemAt(d),c._originalForNavigator===h)return c;return null},_matchBounds:function(h,u,c){var d=u.getBoundsNoRotate();h.setPosition(d.getTopLeft(),c),h.setWidth(d.width,c),h.setRotation(u.getRotation(),c),h.setClip(u.getClip()),h.setFlip(u.getFlip())},_matchOpacity:function(h,u){h.setOpacity(u.opacity)},_matchCompositeOperation:function(h,u){h.setCompositeOperation(u.compositeOperation)}});function i(h){var u={tracker:h.eventSource,position:h.position,quick:h.quick,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",u),!u.preventDefaultAction&&h.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(h.position.x=this.viewport.getContainerSize().x-h.position.x);var c=this.viewport.pointFromPixel(h.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 n(h){var u={tracker:h.eventSource,position:h.position,delta:h.delta,speed:h.speed,direction:h.direction,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",u),!u.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(h.delta.x=0),this.panVertical||(h.delta.y=0),this.viewer.viewport.flipped&&(h.delta.x=-h.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(h.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function s(h){h.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function o(h){var u={tracker:h.eventSource,position:h.position,scroll:h.scroll,shift:h.shift,originalEvent:h.originalEvent,preventDefault:h.preventDefault};this.viewer.raiseEvent("navigator-scroll",u),h.preventDefault=u.preventDefault}function a(h,u){l(h,"rotate("+u+"deg)")}function l(h,u){h.style.webkitTransform=u,h.style.mozTransform=u,h.style.msTransform=u,h.style.oTransform=u,h.style.transform=u}})(e),(function(t){var i={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"}};t.extend(t,{getString:function(n){var s=n.split("."),o=null,a=arguments,l=i,h;for(h=0;h<s.length-1;h++)l=l[s[h]]||{};return o=l[s[h]],typeof o!="string"&&(t.console.error("Untranslated source string:",n),o=""),o.replace(/\{\d+\}/g,function(u){var c=parseInt(u.match(/\d+/),10)+1;return c<a.length?a[c]:""})},setString:function(n,s){var o=n.split("."),a=i,l;for(l=0;l<o.length-1;l++)a[o[l]]||(a[o[l]]={}),a=a[o[l]];a[o[l]]=s}})})(e),(function(t){t.Point=function(i,n){this.x=typeof i=="number"?i:0,this.y=typeof n=="number"?n:0},t.Point.prototype={clone:function(){return new t.Point(this.x,this.y)},plus:function(i){return new t.Point(this.x+i.x,this.y+i.y)},minus:function(i){return new t.Point(this.x-i.x,this.y-i.y)},times:function(i){return new t.Point(this.x*i,this.y*i)},divide:function(i){return new t.Point(this.x/i,this.y/i)},negate:function(){return new t.Point(-this.x,-this.y)},distanceTo:function(i){return Math.sqrt(Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2))},squaredDistanceTo:function(i){return Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2)},apply:function(i){return new t.Point(i(this.x),i(this.y))},equals:function(i){return i instanceof t.Point&&this.x===i.x&&this.y===i.y},rotate:function(i,n){n=n||new t.Point(0,0);var s,o;if(i%90===0){var a=t.positiveModulo(i,360);switch(a){case 0:s=1,o=0;break;case 90:s=0,o=1;break;case 180:s=-1,o=0;break;case 270:s=0,o=-1;break}}else{var l=i*Math.PI/180;s=Math.cos(l),o=Math.sin(l)}var h=s*(this.x-n.x)-o*(this.y-n.y)+n.x,u=o*(this.x-n.x)+s*(this.y-n.y)+n.y;return new t.Point(h,u)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(e),(function(t){t.TileSource=function(n,s,o,a,l,h){var u=this,c=arguments,d,f;if(t.isPlainObject(n)?d=n:d={width:c[0],height:c[1],tileSize:c[2],tileOverlap:c[3],minLevel:c[4],maxLevel:c[5]},t.EventSource.call(this),t.extend(!0,this,d),!this.success){for(f=0;f<arguments.length;f++)if(t.isFunction(arguments[f])){this.success=arguments[f];break}}this.success&&this.addHandler("ready",function(g){u.success(g)}),t.type(arguments[0])==="string"&&(this.url=arguments[0]),this.url?(this.aspectRatio=1,this.dimensions=new t.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 t.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&&t.isFunction(this.success)&&this.success(this))},t.TileSource.prototype={getTileSize:function(n){return t.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(n){return this._tileWidth?this._tileWidth:this.getTileSize(n)},getTileHeight:function(n){return this._tileHeight?this._tileHeight:this.getTileSize(n)},setMaxLevel:function(n){this.maxLevel=n,this._memoizeLevelScale()},getLevelScale:function(n){return this._memoizeLevelScale(),this.getLevelScale(n)},_memoizeLevelScale:function(){var n={},s;for(s=0;s<=this.maxLevel;s++)n[s]=1/Math.pow(2,this.maxLevel-s);this.getLevelScale=function(o){return n[o]}},getNumTiles:function(n){var s=this.getLevelScale(n),o=Math.ceil(s*this.dimensions.x/this.getTileWidth(n)),a=Math.ceil(s*this.dimensions.y/this.getTileHeight(n));return new t.Point(o,a)},getPixelRatio:function(n){var s=this.dimensions.times(this.getLevelScale(n)),o=1/s.x*t.pixelDensityRatio,a=1/s.y*t.pixelDensityRatio;return new t.Point(o,a)},getClosestLevel:function(){var n,s;for(n=this.minLevel+1;n<=this.maxLevel&&(s=this.getNumTiles(n),!(s.x>1||s.y>1));n++);return n-1},getTileAtPoint:function(n,s){var o=s.x>=0&&s.x<=1&&s.y>=0&&s.y<=1/this.aspectRatio;t.console.assert(o,"[TileSource.getTileAtPoint] must be called with a valid point.");var a=this.dimensions.x*this.getLevelScale(n),l=s.x*a,h=s.y*a,u=Math.floor(l/this.getTileWidth(n)),c=Math.floor(h/this.getTileHeight(n));s.x>=1&&(u=this.getNumTiles(n).x-1);var d=1e-15;return s.y>=1/this.aspectRatio-d&&(c=this.getNumTiles(n).y-1),new t.Point(u,c)},getTileBounds:function(n,s,o,a){var l=this.dimensions.times(this.getLevelScale(n)),h=this.getTileWidth(n),u=this.getTileHeight(n),c=s===0?0:h*s-this.tileOverlap,d=o===0?0:u*o-this.tileOverlap,f=h+(s===0?1:2)*this.tileOverlap,g=u+(o===0?1:2)*this.tileOverlap,p=1/l.x;return f=Math.min(f,l.x-c),g=Math.min(g,l.y-d),a?new t.Rect(0,0,f,g):new t.Rect(c*p,d*p,f*p,g*p)},getImageInfo:function(n){var s=this,o,a,l,h,u,c,d;n&&(u=n.split("/"),c=u[u.length-1],d=c.lastIndexOf("."),d>-1&&(u[u.length-1]=c.slice(0,d)));var f=null;if(this.splitHashDataForPost){var g=n.indexOf("#");g!==-1&&(f=n.substring(g+1),n=n.substr(0,g))}a=function(p){typeof p=="string"&&(p=t.parseXml(p));var m=t.TileSource.determineType(s,p,n);if(!m){s.raiseEvent("open-failed",{message:"Unable to load TileSource",source:n});return}h=m.prototype.configure.apply(s,[p,n,f]),h.ajaxWithCredentials===void 0&&(h.ajaxWithCredentials=s.ajaxWithCredentials),l=new m(h),s.ready=!0,s.raiseEvent("ready",{tileSource:l})},n.match(/\.js$/)?(o=n.split("/").pop().replace(".js",""),t.jsonp({url:n,async:!1,callbackName:o,callback:a})):t.makeAjaxRequest({url:n,postData:f,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(p){var m=i(p);a(m)},error:function(p,m){var v;try{v="HTTP "+p.status+" attempting to load TileSource: "+n}catch{var y;typeof m>"u"||!m.toString?y="Unknown error":y=m.toString(),v=y+" attempting to load TileSource: "+n}t.console.error(v),s.raiseEvent("open-failed",{message:v,source:n,postData:f})}})},supports:function(n,s){return!1},configure:function(n,s,o){throw new Error("Method not implemented.")},getTileUrl:function(n,s,o){throw new Error("Method not implemented.")},getTilePostData:function(n,s,o){return null},getTileAjaxHeaders:function(n,s,o){return{}},getTileHashKey:function(n,s,o,a,l,h){function u(c){return l?c+"+"+JSON.stringify(l):c}return u(typeof a!="string"?n+"/"+s+"_"+o:a)},tileExists:function(n,s,o){var a=this.getNumTiles(n);return n>=this.minLevel&&n<=this.maxLevel&&s>=0&&o>=0&&s<a.x&&o<a.y},hasTransparency:function(n,s,o,a){return!!n||s.match(".png")},downloadTileStart:function(n){var s=n.userData,o=new Image;s.image=o,s.request=null;var a=function(l){if(!o){n.finish(null,s.request,"Image load failed: undefined Image instance.");return}o.onload=o.onerror=o.onabort=null,n.finish(l?null:o,s.request,l)};o.onload=function(){a()},o.onabort=o.onerror=function(){a("Image load aborted.")},n.loadWithAjax?s.request=t.makeAjaxRequest({url:n.src,withCredentials:n.ajaxWithCredentials,headers:n.ajaxHeaders,responseType:"arraybuffer",postData:n.postData,success:function(l){var h;try{h=new window.Blob([l.response])}catch(d){var u=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&u){var c=new u;c.append(l.response),h=c.getBlob()}}h.size===0?a("Empty image response."):o.src=(window.URL||window.webkitURL).createObjectURL(h)},error:function(l){a("Image load aborted - XHR error")}}):(n.crossOriginPolicy!==!1&&(o.crossOrigin=n.crossOriginPolicy),o.src=n.src)},downloadTileAbort:function(n){n.userData.request&&n.userData.request.abort();var s=n.userData.image;n.userData.image&&(s.onload=s.onerror=s.onabort=null)},createTileCache:function(n,s,o){n._data=s},destroyTileCache:function(n){n._data=null,n._renderedContext=null},getTileCacheData:function(n){return n._data},getTileCacheDataAsImage:function(n){return n._data},getTileCacheDataAsContext2D:function(n){if(!n._renderedContext){var s=document.createElement("canvas");s.width=n._data.width,s.height=n._data.height,n._renderedContext=s.getContext("2d"),n._renderedContext.drawImage(n._data,0,0),n._data=null}return n._renderedContext}},t.extend(!0,t.TileSource.prototype,t.EventSource.prototype);function i(n){var s=n.responseText,o=n.status,a,l;if(n){if(n.status!==200&&n.status!==0)throw o=n.status,a=o===404?"Not Found":n.statusText,new Error(t.getString("Errors.Status",o,a))}else throw new Error(t.getString("Errors.Security"));if(s.match(/^\s*<.*/))try{l=n.responseXML&&n.responseXML.documentElement?n.responseXML:t.parseXml(s)}catch{l=n.responseText}else if(s.match(/\s*[{[].*/))try{l=t.parseJSON(s)}catch{l=s}else l=s;return l}t.TileSource.determineType=function(n,s,o){var a;for(a in e)if(a.match(/.+TileSource$/)&&t.isFunction(e[a])&&t.isFunction(e[a].prototype.supports)&&e[a].prototype.supports.call(n,s,o))return e[a];return t.console.error("No TileSource was able to open %s %s",o,s),null}})(e),(function(t){t.DziTileSource=function(s,o,a,l,h,u,c,d,f){var g,p,m,v;if(t.isPlainObject(s)?v=s:v={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=v.tilesUrl,this.fileFormat=v.fileFormat,this.displayRects=v.displayRects,this.displayRects)for(g=this.displayRects.length-1;g>=0;g--)for(p=this.displayRects[g],m=p.minLevel;m<=p.maxLevel;m++)this._levelRects[m]||(this._levelRects[m]=[]),this._levelRects[m].push(p);t.TileSource.apply(this,[v])},t.extend(t.DziTileSource.prototype,t.TileSource.prototype,{supports:function(s,o){var a;return s.Image?a=s.Image.xmlns:s.documentElement&&(s.documentElement.localName==="Image"||s.documentElement.tagName==="Image")&&(a=s.documentElement.namespaceURI),a=(a||"").toLowerCase(),a.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||a.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(s,o,a){var l;return t.isPlainObject(s)?l=n(this,s):l=i(this,s),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(s,o,a){return[this.tilesUrl,s,"/",o,"_",a,".",this.fileFormat,this.queryParams].join("")},tileExists:function(s,o,a){var l=this._levelRects[s],h,u,c,d,f,g,p;if(this.minLevel&&s<this.minLevel||this.maxLevel&&s>this.maxLevel)return!1;if(!l||!l.length)return!0;for(p=l.length-1;p>=0;p--)if(h=l[p],!(s<h.minLevel||s>h.maxLevel)&&(u=this.getLevelScale(s),c=h.x*u,d=h.y*u,f=c+h.width*u,g=d+h.height*u,c=Math.floor(c/this._tileWidth),d=Math.floor(d/this._tileWidth),f=Math.ceil(f/this._tileWidth),g=Math.ceil(g/this._tileWidth),c<=o&&o<f&&d<=a&&a<g))return!0;return!1}});function i(s,o){if(!o||!o.documentElement)throw new Error(t.getString("Errors.Xml"));var a=o.documentElement,l=a.localName||a.tagName,h=o.documentElement.namespaceURI,u=null,c=[],d,f,g,p,m;if(l==="Image")try{if(p=a.getElementsByTagName("Size")[0],p===void 0&&(p=a.getElementsByTagNameNS(h,"Size")[0]),u={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:a.getAttribute("Url"),Format:a.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(a.getAttribute("Overlap"),10),TileSize:parseInt(a.getAttribute("TileSize"),10),Size:{Height:parseInt(p.getAttribute("Height"),10),Width:parseInt(p.getAttribute("Width"),10)}}},!t.imageFormatSupported(u.Image.Format))throw new Error(t.getString("Errors.ImageFormat",u.Image.Format.toUpperCase()));for(d=a.getElementsByTagName("DisplayRect"),d===void 0&&(d=a.getElementsByTagNameNS(h,"DisplayRect")[0]),m=0;m<d.length;m++)f=d[m],g=f.getElementsByTagName("Rect")[0],g===void 0&&(g=f.getElementsByTagNameNS(h,"Rect")[0]),c.push({Rect:{X:parseInt(g.getAttribute("X"),10),Y:parseInt(g.getAttribute("Y"),10),Width:parseInt(g.getAttribute("Width"),10),Height:parseInt(g.getAttribute("Height"),10),MinLevel:parseInt(f.getAttribute("MinLevel"),10),MaxLevel:parseInt(f.getAttribute("MaxLevel"),10)}});return c.length&&(u.Image.DisplayRect=c),n(s,u)}catch(_){throw _ instanceof Error?_:new Error(t.getString("Errors.Dzi"))}else{if(l==="Collection")throw new Error(t.getString("Errors.Dzc"));if(l==="Error"){var v=a.getElementsByTagName("Message")[0],y=v.firstChild.nodeValue;throw new Error(y)}}throw new Error(t.getString("Errors.Dzi"))}function n(s,o){var a=o.Image,l=a.Url,h=a.Format,u=a.Size,c=a.DisplayRect||[],d=parseInt(u.Width,10),f=parseInt(u.Height,10),g=parseInt(a.TileSize,10),p=parseInt(a.Overlap,10),m=[],v,y;for(y=0;y<c.length;y++)v=c[y].Rect,m.push(new t.DisplayRect(parseInt(v.X,10),parseInt(v.Y,10),parseInt(v.Width,10),parseInt(v.Height,10),parseInt(v.MinLevel,10),parseInt(v.MaxLevel,10)));return t.extend(!0,{width:d,height:f,tileSize:g,tileOverlap:p,minLevel:null,maxLevel:null,tilesUrl:l,fileFormat:h,displayRects:m},o)}})(e),(function(t){t.IIIFTileSource=function(a){if(t.extend(!0,this,a),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(a.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=a.version,this.tile_width&&this.tile_height)a.tileWidth=this.tile_width,a.tileHeight=this.tile_height;else if(this.tile_width)a.tileSize=this.tile_width;else if(this.tile_height)a.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)a.tileWidth=this.tiles[0].width,a.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 h=0;h<this.tiles[l].scaleFactors.length;h++){var u=this.tiles[l].scaleFactors[h];this.scale_factors.push(u),a.tileSizePerScaleFactor[u]={width:this.tiles[l].width,height:this.tiles[l].height||this.tiles[l].width}}}else if(i(a)){for(var c=Math.min(this.height,this.width),d=[256,512,1024],f=[],g=0;g<d.length;g++)d[g]<=c&&f.push(d[g]);f.length>0?a.tileSize=Math.max.apply(null,f):a.tileSize=c}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,a.levels=n(this),t.extend(!0,a,{width:a.levels[a.levels.length-1].width,height:a.levels[a.levels.length-1].height,tileSize:Math.max(a.height,a.width),tileOverlap:0,minLevel:0,maxLevel:a.levels.length-1}),this.levels=a.levels):t.console.error("Nothing in the info.json to construct image pyramids from");if(!a.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)a.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var p=Math.max.apply(null,this.scale_factors);a.maxLevel=Math.round(Math.log(p)*Math.LOG2E)}if(this.sizes){var m=this.sizes.length;(m===a.maxLevel||m===a.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((v,y)=>v.width-y.width),m===a.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}t.TileSource.apply(this,[a])},t.extend(t.IIIFTileSource.prototype,t.TileSource.prototype,{supports:function(a,l){return a.protocol&&a.protocol==="http://iiif.io/api/image"||a["@context"]&&(a["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||a["@context"]==="http://iiif.io/api/image/1/context.json")||a.profile&&a.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||a.identifier&&a.width&&a.height?!0:!!(a.documentElement&&a.documentElement.tagName==="info"&&a.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(a,l,h){if(t.isPlainObject(a)){if(!a["@context"])a["@context"]="http://iiif.io/api/image/1.0/context.json",a["@id"]=l.replace("/info.json",""),a.version=1;else{var c=a["@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":a.version=1;break;case"http://iiif.io/api/image/2/context.json":a.version=2;break;case"http://iiif.io/api/image/3/context.json":a.version=3;break;default:t.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(a.preferredFormats){for(var f=0;f<a.preferredFormats.length;f++)if(e.imageFormatSupported(a.preferredFormats[f])){a.tileFormat=a.preferredFormats[f];break}}return a}else{var u=s(a);return u["@context"]="http://iiif.io/api/image/1.0/context.json",u["@id"]=l.replace("/info.xml",""),u.version=1,u}},getTileWidth:function(a){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileWidth.call(this,a);var l=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].width:this._tileWidth},getTileHeight:function(a){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileHeight.call(this,a);var l=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].height:this._tileHeight},getLevelScale:function(a){if(this.emulateLegacyImagePyramid){var l=NaN;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(l=this.levels[a].width/this.levels[this.maxLevel].width),l}return t.TileSource.prototype.getLevelScale.call(this,a)},getNumTiles:function(a){if(this.emulateLegacyImagePyramid){var l=this.getLevelScale(a);return l?new t.Point(1,1):new t.Point(0,0)}if(this.levelSizes){var h=this.levelSizes[a],u=Math.ceil(h.width/this.getTileWidth(a)),c=Math.ceil(h.height/this.getTileHeight(a));return new t.Point(u,c)}else return t.TileSource.prototype.getNumTiles.call(this,a)},getTileAtPoint:function(a,l){if(this.emulateLegacyImagePyramid)return new t.Point(0,0);if(this.levelSizes){var h=l.x>=0&&l.x<=1&&l.y>=0&&l.y<=1/this.aspectRatio;t.console.assert(h,"[TileSource.getTileAtPoint] must be called with a valid point.");var u=this.levelSizes[a].width,c=l.x*u,d=l.y*u,f=Math.floor(c/this.getTileWidth(a)),g=Math.floor(d/this.getTileHeight(a));l.x>=1&&(f=this.getNumTiles(a).x-1);var p=1e-15;return l.y>=1/this.aspectRatio-p&&(g=this.getNumTiles(a).y-1),new t.Point(f,g)}return t.TileSource.prototype.getTileAtPoint.call(this,a,l)},getTileUrl:function(a,l,h){if(this.emulateLegacyImagePyramid){var u=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(u=this.levels[a].url),u}var c="0",d=Math.pow(.5,this.maxLevel-a),f,g,p,m,v,y,_,w,A,F,C,R,M,k,z,D;return this.levelSizes?(f=this.levelSizes[a].width,g=this.levelSizes[a].height):(f=Math.ceil(this.width*d),g=Math.ceil(this.height*d)),p=this.getTileWidth(a),m=this.getTileHeight(a),v=Math.round(p/d),y=Math.round(m/d),this.version===1?z="native."+this.tileFormat:z="default."+this.tileFormat,f<p&&g<m?(this.version===2&&f===this.width?R="full":this.version===3&&f===this.width&&g===this.height?R="max":this.version===3?R=f+","+g:R=f+",",_="full"):(w=l*v,A=h*y,F=Math.min(v,this.width-w),C=Math.min(y,this.height-A),l===0&&h===0&&F===this.width&&C===this.height?_="full":_=[w,A,F,C].join(","),M=Math.min(p,f-l*p),k=Math.min(m,g-h*m),this.version===2&&M===this.width?R="full":this.version===3&&M===this.width&&k===this.height?R="max":this.version===3?R=M+","+k:R=M+","),D=[this._id,_,R,c,z].join("/"),D},__testonly__:{canBeTiled:i,constructLevels:n}});function i(a){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"],h=Array.isArray(a.profile)?a.profile[0]:a.profile,u=l.indexOf(h)!==-1,c=!1;return a.version===2&&a.profile.length>1&&a.profile[1].supports&&(c=a.profile[1].supports.indexOf("sizeByW")!==-1),a.version===3&&a.extraFeatures&&(c=a.extraFeatures.indexOf("sizeByWh")!==-1),!u||c}function n(a){for(var l=[],h=0;h<a.sizes.length;h++)l.push({url:a._id+"/full/"+a.sizes[h].width+","+(a.version===3?a.sizes[h].height:"")+"/0/default."+a.tileFormat,width:a.sizes[h].width,height:a.sizes[h].height});return l.sort(function(u,c){return u.width-c.width})}function s(a){if(!a||!a.documentElement)throw new Error(t.getString("Errors.Xml"));var l=a.documentElement,h=l.tagName,u=null;if(h==="info")try{return u={},o(l,u),u}catch(c){throw c instanceof Error?c:new Error(t.getString("Errors.IIIF"))}throw new Error(t.getString("Errors.IIIF"))}function o(a,l,h){var u,c;if(a.nodeType===3&&h)c=a.nodeValue.trim(),c.match(/^\d*$/)&&(c=Number(c)),l[h]?(t.isArray(l[h])||(l[h]=[l[h]]),l[h].push(c)):l[h]=c;else if(a.nodeType===1)for(u=0;u<a.childNodes.length;u++)o(a.childNodes[u],l,a.nodeName)}})(e),(function(t){t.OsmTileSource=function(i,n,s,o,a){var l;t.isPlainObject(i)?l=i: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,t.TileSource.apply(this,[l])},t.extend(t.OsmTileSource.prototype,t.TileSource.prototype,{supports:function(i,n){return i.type&&i.type==="openstreetmaps"},configure:function(i,n,s){return i},getTileUrl:function(i,n,s){return this.tilesUrl+(i-8)+"/"+n+"/"+s+".png"}})})(e),(function(t){t.TmsTileSource=function(i,n,s,o,a){var l;t.isPlainObject(i)?l=i:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var h=Math.ceil(l.width/256)*256,u=Math.ceil(l.height/256)*256,c;h>u?c=h/256:c=u/256,l.maxLevel=Math.ceil(Math.log(c)/Math.log(2))-1,l.tileSize=256,l.width=h,l.height=u,t.TileSource.apply(this,[l])},t.extend(t.TmsTileSource.prototype,t.TileSource.prototype,{supports:function(i,n){return i.type&&i.type==="tiledmapservice"},configure:function(i,n,s){return i},getTileUrl:function(i,n,s){var o=this.getNumTiles(i).y-1;return this.tilesUrl+i+"/"+n+"/"+(o-s)+".png"}})})(e),(function(t){t.ZoomifyTileSource=function(i){typeof i.tileSize>"u"&&(i.tileSize=256),typeof i.fileFormat>"u"&&(i.fileFormat="jpg",this.fileFormat=i.fileFormat);var n={x:i.width,y:i.height};for(i.imageSizes=[{x:i.width,y:i.height}],i.gridSize=[this._getGridSize(i.width,i.height,i.tileSize)];parseInt(n.x,10)>i.tileSize||parseInt(n.y,10)>i.tileSize;)n.x=Math.floor(n.x/2),n.y=Math.floor(n.y/2),i.imageSizes.push({x:n.x,y:n.y}),i.gridSize.push(this._getGridSize(n.x,n.y,i.tileSize));i.imageSizes.reverse(),i.gridSize.reverse(),i.minLevel=0,i.maxLevel=i.gridSize.length-1,e.TileSource.apply(this,[i])},t.extend(t.ZoomifyTileSource.prototype,t.TileSource.prototype,{_getGridSize:function(i,n,s){return{x:Math.ceil(i/s),y:Math.ceil(n/s)}},_calculateAbsoluteTileNumber:function(i,n,s){for(var o=0,a={},l=0;l<i;l++)a=this.gridSize[l],o+=a.x*a.y;return a=this.gridSize[i],o+=a.x*s+n,o},supports:function(i,n){return i.type&&i.type==="zoomifytileservice"},configure:function(i,n,s){return i},getTileUrl:function(i,n,s){var o=0,a=this._calculateAbsoluteTileNumber(i,n,s);return o=Math.floor(a/256),this.tilesUrl+"TileGroup"+o+"/"+i+"-"+n+"-"+s+"."+this.fileFormat}})})(e),(function(t){t.LegacyTileSource=function(o){var a,l,h;t.isArray(o)&&(a={type:"legacy-image-pyramid",levels:o}),a.levels=i(a.levels),a.levels.length>0?(l=a.levels[a.levels.length-1].width,h=a.levels[a.levels.length-1].height):(l=0,h=0,t.console.error("No supported image formats found")),t.extend(!0,a,{width:l,height:h,tileSize:Math.max(h,l),tileOverlap:0,minLevel:0,maxLevel:a.levels.length>0?a.levels.length-1:0}),t.TileSource.apply(this,[a]),this.levels=a.levels},t.extend(t.LegacyTileSource.prototype,t.TileSource.prototype,{supports:function(o,a){return o.type&&o.type==="legacy-image-pyramid"||o.documentElement&&o.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(o,a,l){var h;return t.isPlainObject(o)?h=s(this,o):h=n(this,o),h},getLevelScale:function(o){var a=NaN;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(a=this.levels[o].width/this.levels[this.maxLevel].width),a},getNumTiles:function(o){var a=this.getLevelScale(o);return a?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(o,a,l){var h=null;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(h=this.levels[o].url),h}});function i(o){var a=[],l,h;for(h=0;h<o.length;h++)l=o[h],l.height&&l.width&&l.url?a.push({url:l.url,width:Number(l.width),height:Number(l.height)}):t.console.error("Unsupported image format: %s",l.url?l.url:"<no URL>");return a.sort(function(u,c){return u.height-c.height})}function n(o,a){if(!a||!a.documentElement)throw new Error(t.getString("Errors.Xml"));var l=a.documentElement,h=l.tagName,u=null,c=[],d,f;if(h==="image")try{for(u={type:l.getAttribute("type"),levels:[]},c=l.getElementsByTagName("level"),f=0;f<c.length;f++)d=c[f],u.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return s(o,u)}catch(g){throw g instanceof Error?g:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(h==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(h==="error")throw new Error("Error: "+a)}throw new Error("Unknown element "+h)}function s(o,a){return a.levels}})(e),(function(t){t.ImageTileSource=function(i){i=t.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1},i),t.TileSource.apply(this,[i])},t.extend(t.ImageTileSource.prototype,t.TileSource.prototype,{supports:function(i,n){return i.type&&i.type==="image"},configure:function(i,n,s){return i},getImageInfo:function(i){var n=this._image=new Image,s=this;this.crossOriginPolicy&&(n.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(n.useCredentials=this.ajaxWithCredentials),t.addEvent(n,"load",function(){s.width=n.naturalWidth,s.height=n.naturalHeight,s.aspectRatio=s.width/s.height,s.dimensions=new t.Point(s.width,s.height),s._tileWidth=s.width,s._tileHeight=s.height,s.tileOverlap=0,s.minLevel=0,s.levels=s._buildLevels(),s.maxLevel=s.levels.length-1,s.ready=!0,s.raiseEvent("ready",{tileSource:s})}),t.addEvent(n,"error",function(){s.raiseEvent("open-failed",{message:"Error loading image at "+i,source:i})}),n.src=i},getLevelScale:function(i){var n=NaN;return i>=this.minLevel&&i<=this.maxLevel&&(n=this.levels[i].width/this.levels[this.maxLevel].width),n},getNumTiles:function(i){var n=this.getLevelScale(i);return n?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(i,n,s){var o=null;return i>=this.minLevel&&i<=this.maxLevel&&(o=this.levels[i].url),o},getContext2D:function(i,n,s){var o=null;return i>=this.minLevel&&i<=this.maxLevel&&(o=this.levels[i].context2D),o},destroy:function(i){this._freeupCanvasMemory(i)},_buildLevels:function(){var i=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!t.supportsCanvas)return delete this._image,i;var n=this._image.naturalWidth,s=this._image.naturalHeight,o=document.createElement("canvas"),a=o.getContext("2d");if(o.width=n,o.height=s,a.drawImage(this._image,0,0,n,s),i[0].context2D=a,delete this._image,t.isCanvasTainted(o))return i;for(;n>=2&&s>=2;){n=Math.floor(n/2),s=Math.floor(s/2);var l=document.createElement("canvas"),h=l.getContext("2d");l.width=n,l.height=s,h.drawImage(o,0,0,n,s),i.splice(0,0,{context2D:h,width:n,height:s}),o=l,a=h}return i},_freeupCanvasMemory:function(i){for(var n=0;n<this.levels.length;n++)this.levels[n].context2D&&(this.levels[n].context2D.canvas.height=0,this.levels[n].context2D.canvas.width=0,i&&i.raiseEvent("image-unloaded",{context2D:this.levels[n].context2D}))}})})(e),(function(t){t.TileSourceCollection=function(i,n,s,o){t.console.error("TileSourceCollection is deprecated; use World instead")}})(e),(function(t){t.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},t.Button=function(h){var u=this;t.EventSource.call(this),t.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null,userData:null},h),this.element=h.element||t.makeNeutralElement("div"),h.element||(this.imgRest=t.makeTransparentImage(this.srcRest),this.imgGroup=t.makeTransparentImage(this.srcGroup),this.imgHover=t.makeTransparentImage(this.srcHover),this.imgDown=t.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,t.setElementPointerEventsNone(this.imgRest),t.setElementPointerEventsNone(this.imgGroup),t.setElementPointerEventsNone(this.imgHover),t.setElementPointerEventsNone(this.imgDown),this.element.style.position="relative",t.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=t.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 t.MouseTracker({userData:"Button.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(c){c.insideElementPressed?(a(u,t.ButtonState.DOWN),u.raiseEvent("enter",{originalEvent:c.originalEvent})):c.buttonDownAny||a(u,t.ButtonState.HOVER)},focusHandler:function(c){u.tracker.enterHandler(c),u.raiseEvent("focus",{originalEvent:c.originalEvent})},leaveHandler:function(c){l(u,t.ButtonState.GROUP),c.insideElementPressed&&u.raiseEvent("exit",{originalEvent:c.originalEvent})},blurHandler:function(c){u.tracker.leaveHandler(c),u.raiseEvent("blur",{originalEvent:c.originalEvent})},pressHandler:function(c){a(u,t.ButtonState.DOWN),u.raiseEvent("press",{originalEvent:c.originalEvent})},releaseHandler:function(c){c.insideElementPressed&&c.insideElementReleased?(l(u,t.ButtonState.HOVER),u.raiseEvent("release",{originalEvent:c.originalEvent})):c.insideElementPressed?l(u,t.ButtonState.GROUP):a(u,t.ButtonState.HOVER)},clickHandler:function(c){c.quick&&u.raiseEvent("click",{originalEvent:c.originalEvent})},keyHandler:function(c){c.keyCode===13?(u.raiseEvent("click",{originalEvent:c.originalEvent}),u.raiseEvent("release",{originalEvent:c.originalEvent}),c.preventDefault=!0):c.preventDefault=!1}}),l(this,t.ButtonState.REST)},t.extend(t.Button.prototype,t.EventSource.prototype,{notifyGroupEnter:function(){a(this,t.ButtonState.GROUP)},notifyGroupExit:function(){l(this,t.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,this.tracker.setTracking(!1),t.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,this.tracker.setTracking(!0),t.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 i(h){t.requestAnimationFrame(function(){n(h)})}function n(h){var u,c,d;h.shouldFade&&(u=t.now(),c=u-h.fadeBeginTime,d=1-c/h.fadeLength,d=Math.min(1,d),d=Math.max(0,d),h.imgGroup&&t.setElementOpacity(h.imgGroup,d,!0),d>0&&i(h))}function s(h){h.shouldFade=!0,h.fadeBeginTime=t.now()+h.fadeDelay,window.setTimeout(function(){i(h)},h.fadeDelay)}function o(h){h.shouldFade=!1,h.imgGroup&&t.setElementOpacity(h.imgGroup,1,!0)}function a(h,u){h.element.disabled||(u>=t.ButtonState.GROUP&&h.currentState===t.ButtonState.REST&&(o(h),h.currentState=t.ButtonState.GROUP),u>=t.ButtonState.HOVER&&h.currentState===t.ButtonState.GROUP&&(h.imgHover&&(h.imgHover.style.visibility=""),h.currentState=t.ButtonState.HOVER),u>=t.ButtonState.DOWN&&h.currentState===t.ButtonState.HOVER&&(h.imgDown&&(h.imgDown.style.visibility=""),h.currentState=t.ButtonState.DOWN))}function l(h,u){h.element.disabled||(u<=t.ButtonState.HOVER&&h.currentState===t.ButtonState.DOWN&&(h.imgDown&&(h.imgDown.style.visibility="hidden"),h.currentState=t.ButtonState.HOVER),u<=t.ButtonState.GROUP&&h.currentState===t.ButtonState.HOVER&&(h.imgHover&&(h.imgHover.style.visibility="hidden"),h.currentState=t.ButtonState.GROUP),u<=t.ButtonState.REST&&h.currentState===t.ButtonState.GROUP&&(s(h),h.currentState=t.ButtonState.REST))}})(e),(function(t){t.ButtonGroup=function(i){t.extend(!0,this,{buttons:[],clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},i);var n=this.buttons.concat([]),s=this,o;if(this.element=i.element||t.makeNeutralElement("div"),!i.group)for(this.element.style.display="inline-block",o=0;o<n.length;o++)this.element.appendChild(n[o].element);t.setElementTouchActionNone(this.element),this.tracker=new t.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(a){var l;for(l=0;l<s.buttons.length;l++)s.buttons[l].notifyGroupEnter()},leaveHandler:function(a){var l;if(!a.insideElementPressed)for(l=0;l<s.buttons.length;l++)s.buttons[l].notifyGroupExit()}})},t.ButtonGroup.prototype={addButton:function(i){this.buttons.push(i),this.element.appendChild(i.element)},emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){var i=this.buttons.pop();this.element.removeChild(i.element),i.destroy()}this.tracker.destroy(),this.element=null}}})(e),(function(t){t.Rect=function(i,n,s,o,a){this.x=typeof i=="number"?i:0,this.y=typeof n=="number"?n:0,this.width=typeof s=="number"?s:0,this.height=typeof o=="number"?o:0,this.degrees=typeof a=="number"?a:0,this.degrees=t.positiveModulo(this.degrees,360);var l,h;this.degrees>=270?(l=this.getTopRight(),this.x=l.x,this.y=l.y,h=this.height,this.height=this.width,this.width=h,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,h=this.height,this.height=this.width,this.width=h,this.degrees-=90)},t.Rect.fromSummits=function(i,n,s){var o=i.distanceTo(n),a=i.distanceTo(s),l=n.minus(i),h=Math.atan(l.y/l.x);return l.x<0?h+=Math.PI:l.y<0&&(h+=2*Math.PI),new t.Rect(i.x,i.y,o,a,h/Math.PI*180)},t.Rect.prototype={clone:function(){return new t.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new t.Point(this.x,this.y)},getBottomRight:function(){return new t.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new t.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new t.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new t.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new t.Point(this.width,this.height)},equals:function(i){return i instanceof t.Rect&&this.x===i.x&&this.y===i.y&&this.width===i.width&&this.height===i.height&&this.degrees===i.degrees},times:function(i){return new t.Rect(this.x*i,this.y*i,this.width*i,this.height*i,this.degrees)},translate:function(i){return new t.Rect(this.x+i.x,this.y+i.y,this.width,this.height,this.degrees)},union:function(i){var n=this.getBoundingBox(),s=i.getBoundingBox(),o=Math.min(n.x,s.x),a=Math.min(n.y,s.y),l=Math.max(n.x+n.width,s.x+s.width),h=Math.max(n.y+n.height,s.y+s.height);return new t.Rect(o,a,l-o,h-a)},intersection:function(i){var n=1e-10,s=[],o=this.getTopLeft();i.containsPoint(o,n)&&s.push(o);var a=this.getTopRight();i.containsPoint(a,n)&&s.push(a);var l=this.getBottomLeft();i.containsPoint(l,n)&&s.push(l);var h=this.getBottomRight();i.containsPoint(h,n)&&s.push(h);var u=i.getTopLeft();this.containsPoint(u,n)&&s.push(u);var c=i.getTopRight();this.containsPoint(c,n)&&s.push(c);var d=i.getBottomLeft();this.containsPoint(d,n)&&s.push(d);var f=i.getBottomRight();this.containsPoint(f,n)&&s.push(f);for(var g=this._getSegments(),p=i._getSegments(),m=0;m<g.length;m++)for(var v=g[m],y=0;y<p.length;y++){var _=p[y],w=A(v[0],v[1],_[0],_[1]);w&&s.push(w)}function A(D,S,b,O){var j=S.minus(D),V=O.minus(b),Y=-V.x*j.y+j.x*V.y;if(Y===0)return null;var G=(j.x*(D.y-b.y)-j.y*(D.x-b.x))/Y,H=(V.x*(D.y-b.y)-V.y*(D.x-b.x))/Y;return-n<=G&&G<=1-n&&-n<=H&&H<=1-n?new t.Point(D.x+H*j.x,D.y+H*j.y):null}if(s.length===0)return null;for(var F=s[0].x,C=s[0].x,R=s[0].y,M=s[0].y,k=1;k<s.length;k++){var z=s[k];z.x<F&&(F=z.x),z.x>C&&(C=z.x),z.y<R&&(R=z.y),z.y>M&&(M=z.y)}return new t.Rect(F,R,C-F,M-R)},_getSegments:function(){var i=this.getTopLeft(),n=this.getTopRight(),s=this.getBottomLeft(),o=this.getBottomRight();return[[i,n],[n,o],[o,s],[s,i]]},rotate:function(i,n){if(i=t.positiveModulo(i,360),i===0)return this.clone();n=n||this.getCenter();var s=this.getTopLeft().rotate(i,n),o=this.getTopRight().rotate(i,n),a=o.minus(s);a=a.apply(function(h){var u=1e-15;return Math.abs(h)<u?0:h});var l=Math.atan(a.y/a.x);return a.x<0?l+=Math.PI:a.y<0&&(l+=2*Math.PI),new t.Rect(s.x,s.y,this.width,this.height,l/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var i=this.getTopLeft(),n=this.getTopRight(),s=this.getBottomLeft(),o=this.getBottomRight(),a=Math.min(i.x,n.x,s.x,o.x),l=Math.max(i.x,n.x,s.x,o.x),h=Math.min(i.y,n.y,s.y,o.y),u=Math.max(i.y,n.y,s.y,o.y);return new t.Rect(a,h,l-a,u-h)},getIntegerBoundingBox:function(){var i=this.getBoundingBox(),n=Math.floor(i.x),s=Math.floor(i.y),o=Math.ceil(i.width+i.x-n),a=Math.ceil(i.height+i.y-s);return new t.Rect(n,s,o,a)},containsPoint:function(i,n){n=n||0;var s=this.getTopLeft(),o=this.getTopRight(),a=this.getBottomLeft(),l=o.minus(s),h=a.minus(s);return(i.x-s.x)*l.x+(i.y-s.y)*l.y>=-n&&(i.x-o.x)*l.x+(i.y-o.y)*l.y<=n&&(i.x-s.x)*h.x+(i.y-s.y)*h.y>=-n&&(i.x-a.x)*h.x+(i.y-a.y)*h.y<=n},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]"}}})(e),(function(t){var i={};t.ReferenceStrip=function(d){var f=this,g=d.viewer,p=t.getElementSize(g.element),m,v,y;for(d.id||(d.id="referencestrip-"+t.now(),this.element=t.makeNeutralElement("div"),this.element.id=d.id,this.element.className="referencestrip"),d=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.referenceStripSizeRatio,position:t.DEFAULT_SETTINGS.referenceStripPosition,scroll:t.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold},d,{element:this.element}),t.extend(this,d),i[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,v=this.element.style,v.marginTop="0px",v.marginRight="0px",v.marginBottom="0px",v.marginLeft="0px",v.left="0px",v.bottom="0px",v.border="0px",v.background="#000",v.position="relative",t.setElementTouchActionNone(this.element),t.setElementOpacity(this.element,.8),this.viewer=g,this.tracker=new t.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:t.delegate(this,n),dragHandler:t.delegate(this,s),scrollHandler:t.delegate(this,o),enterHandler:t.delegate(this,l),leaveHandler:t.delegate(this,h),keyDownHandler:t.delegate(this,u),keyHandler:t.delegate(this,c),preProcessEventHandler:function(_){_.eventType==="wheel"&&(_.preventDefault=!0)}}),d.width&&d.height?(this.element.style.width=d.width+"px",this.element.style.height=d.height+"px",g.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):d.scroll==="horizontal"?(this.element.style.width=p.x*d.sizeRatio*g.tileSources.length+12*g.tileSources.length+"px",this.element.style.height=p.y*d.sizeRatio+"px",g.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=p.y*d.sizeRatio*g.tileSources.length+12*g.tileSources.length+"px",this.element.style.width=p.x*d.sizeRatio+"px",g.addControl(this.element,{anchor:t.ControlAnchor.TOP_LEFT})),this.panelWidth=p.x*this.sizeRatio+8,this.panelHeight=p.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},y=0;y<g.tileSources.length;y++)m=t.makeNeutralElement("div"),m.id=this.element.id+"-"+y,m.style.width=f.panelWidth+"px",m.style.height=f.panelHeight+"px",m.style.display="inline",m.style.float="left",m.style.cssFloat="left",m.style.padding="2px",t.setElementTouchActionNone(m),t.setElementPointerEventsNone(m),this.element.appendChild(m),m.activePanel=!1,this.panels.push(m);a(this,this.scroll==="vertical"?p.y:p.x,0),this.setFocus(0)},t.ReferenceStrip.prototype={setFocus:function(d){var f=this.element.querySelector("#"+this.element.id+"-"+d),g=t.getElementSize(this.viewer.canvas),p=Number(this.element.style.width.replace("px","")),m=Number(this.element.style.height.replace("px","")),v=-Number(this.element.style.marginLeft.replace("px","")),y=-Number(this.element.style.marginTop.replace("px","")),_;this.currentSelected!==f&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=f,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(_=Number(d)*(this.panelWidth+3),_>v+g.x-this.panelWidth?(_=Math.min(_,p-g.x),this.element.style.marginLeft=-_+"px",a(this,g.x,-_)):_<v&&(_=Math.max(0,_-g.x/2),this.element.style.marginLeft=-_+"px",a(this,g.x,-_))):(_=Number(d)*(this.panelHeight+3),_>y+g.y-this.panelHeight?(_=Math.min(_,m-g.y),this.element.style.marginTop=-_+"px",a(this,g.y,-_)):_<y&&(_=Math.max(0,_-g.y/2),this.element.style.marginTop=-_+"px",a(this,g.y,-_))),this.currentPage=d,l.call(this,{eventSource:this.tracker}))},update:function(){return!!i[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 n(d){if(d.quick){var f;this.scroll==="horizontal"?f=Math.floor(d.position.x/(this.panelWidth+4)):f=Math.floor(d.position.y/this.panelHeight),this.viewer.goToPage(f)}this.element.focus()}function s(d){if(this.dragging=!0,this.element){var f=Number(this.element.style.marginLeft.replace("px","")),g=Number(this.element.style.marginTop.replace("px","")),p=Number(this.element.style.width.replace("px","")),m=Number(this.element.style.height.replace("px","")),v=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?f>-(p-v.x)&&(this.element.style.marginLeft=f+d.delta.x*2+"px",a(this,v.x,f+d.delta.x*2)):-d.delta.x<0&&f<0&&(this.element.style.marginLeft=f+d.delta.x*2+"px",a(this,v.x,f+d.delta.x*2)):-d.delta.y>0?g>-(m-v.y)&&(this.element.style.marginTop=g+d.delta.y*2+"px",a(this,v.y,g+d.delta.y*2)):-d.delta.y<0&&g<0&&(this.element.style.marginTop=g+d.delta.y*2+"px",a(this,v.y,g+d.delta.y*2))}}function o(d){if(this.element){var f=Number(this.element.style.marginLeft.replace("px","")),g=Number(this.element.style.marginTop.replace("px","")),p=Number(this.element.style.width.replace("px","")),m=Number(this.element.style.height.replace("px","")),v=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?f>-(p-v.x)&&(this.element.style.marginLeft=f-d.scroll*60+"px",a(this,v.x,f-d.scroll*60)):d.scroll<0&&f<0&&(this.element.style.marginLeft=f-d.scroll*60+"px",a(this,v.x,f-d.scroll*60)):d.scroll<0?g>v.y-m&&(this.element.style.marginTop=g+d.scroll*60+"px",a(this,v.y,g+d.scroll*60)):d.scroll>0&&g<0&&(this.element.style.marginTop=g+d.scroll*60+"px",a(this,v.y,g+d.scroll*60)),d.preventDefault=!0}}function a(d,f,g){var p,m,v,y,_,w;for(d.scroll==="horizontal"?p=d.panelWidth:p=d.panelHeight,m=Math.ceil(f/p)+5,v=Math.ceil((Math.abs(g)+f)/p)+1,m=v-m,m=m<0?0:m,_=m;_<v&&_<d.panels.length;_++)if(w=d.panels[_],!w.activePanel){var A,F=d.viewer.tileSources[_];F.referenceStripThumbnailUrl?A={type:"image",url:F.referenceStripThumbnailUrl}:A=F,y=new t.Viewer({id:w.id,tileSources:[A],element:w,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"}),t.setElementPointerEventsNone(y.canvas),t.setElementPointerEventsNone(y.container),y.innerTracker.setTracking(!1),y.outerTracker.setTracking(!1),d.miniViewers[w.id]=y,w.activePanel=!0}}function l(d){var f=d.eventSource.element;this.scroll==="horizontal"?f.style.marginBottom="0px":f.style.marginLeft="0px"}function h(d){var f=d.eventSource.element;this.scroll==="horizontal"?f.style.marginBottom="-"+t.getElementSize(f).y/2+"px":f.style.marginLeft="-"+t.getElementSize(f).x/2+"px"}function u(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}})(e),(function(t){t.DisplayRect=function(i,n,s,o,a,l){t.Rect.apply(this,[i,n,s,o]),this.minLevel=a,this.maxLevel=l},t.extend(t.DisplayRect.prototype,t.Rect.prototype)})(e),(function(t){t.Spring=function(n){var s=arguments;typeof n!="object"&&(n={initial:s.length&&typeof s[0]=="number"?s[0]:void 0,springStiffness:s.length>1?s[1].springStiffness:5,animationTime:s.length>1?s[1].animationTime:1.5}),t.console.assert(typeof n.springStiffness=="number"&&n.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),t.console.assert(typeof n.animationTime=="number"&&n.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),n.exponential&&(this._exponential=!0,delete n.exponential),t.extend(!0,this,n),this.current={value:typeof this.initial=="number"?this.initial:this._exponential?0:1,time:t.now()},t.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))},t.Spring.prototype={resetTo:function(n){t.console.assert(!this._exponential||n!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=n,this.start.time=this.target.time=this.current.time=t.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(n){t.console.assert(!this._exponential||n!==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=n,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(n){this.start.value+=n,this.target.value+=n,this._exponential&&(t.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(n){this._exponential=n,this._exponential&&(t.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=t.now();let n,s;if(this._exponential?(n=this.start._logValue,s=this.target._logValue):(n=this.start.value,s=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let o=n+(s-n)*i(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 i(n,s){return(1-Math.exp(n*-s))/(1-Math.exp(-n))}})(e),(function(t){t.ImageJob=function(n){t.extend(!0,this,{timeout:t.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},n),this.data=null,this.userData={},this.errorMsg=null},t.ImageJob.prototype={start:function(){this.tries++;var n=this,s=this.abort;this.jobId=window.setTimeout(function(){n.finish(null,null,"Image load exceeded timeout ("+n.timeout+" ms)")},this.timeout),this.abort=function(){n.source.downloadTileAbort(n),typeof s=="function"&&s()},this.source.downloadTileStart(this)},finish:function(n,s,o){this.data=n,this.request=s,this.errorMsg=o,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},t.ImageLoader=function(n){t.extend(!0,this,{jobLimit:t.DEFAULT_SETTINGS.imageLoaderLimit,timeout:t.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},n)},t.ImageLoader.prototype={addJob:function(n){if(!n.source){t.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var s=t.TileSource.prototype;n.source={downloadTileStart:s.downloadTileStart,downloadTileAbort:s.downloadTileAbort}}var o=this,a=function(u){i(o,u,n.callback)},l={src:n.src,tile:n.tile||{},source:n.source,loadWithAjax:n.loadWithAjax,ajaxHeaders:n.loadWithAjax?n.ajaxHeaders:null,crossOriginPolicy:n.crossOriginPolicy,ajaxWithCredentials:n.ajaxWithCredentials,postData:n.postData,callback:a,abort:n.abort,timeout:this.timeout},h=new t.ImageJob(l);!this.jobLimit||this.jobsInProgress<this.jobLimit?(h.start(),this.jobsInProgress++):this.jobQueue.push(h)},clear:function(){for(var n=0;n<this.jobQueue.length;n++){var s=this.jobQueue[n];typeof s.abort=="function"&&s.abort()}this.jobQueue=[]}};function i(n,s,o){s.errorMsg!==""&&(s.data===null||s.data===void 0)&&s.tries<1+n.tileRetryMax&&n.failedTiles.push(s);var a;n.jobsInProgress--,(!n.jobLimit||n.jobsInProgress<n.jobLimit)&&n.jobQueue.length>0&&(a=n.jobQueue.shift(),a.start(),n.jobsInProgress++),n.tileRetryMax>0&&n.jobQueue.length===0&&(!n.jobLimit||n.jobsInProgress<n.jobLimit)&&n.failedTiles.length>0&&(a=n.failedTiles.shift(),setTimeout(function(){a.start()},n.tileRetryDelay),n.jobsInProgress++),o(s.data,s.errorMsg,s.request)}})(e),(function(t){t.Tile=function(i,n,s,o,a,l,h,u,c,d,f,g){this.level=i,this.x=n,this.y=s,this.bounds=o,this.positionedBounds=new e.Rect(o.x,o.y,o.width,o.height),this.sourceBounds=d,this.exists=a,this._url=l,this.postData=f,this.context2D=h,this.loadWithAjax=u,this.ajaxHeaders=c,g===void 0&&(t.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),g=t.TileSource.prototype.getTileHashKey(i,n,s,l,c,f)),this.cacheKey=g,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},t.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 t.console.error("[Tile.image] property has been deprecated. Use [Tile.prototype.getImage] instead."),this.getImage()},get url(){return t.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 i;if(this.cacheImageRecord)i=this.cacheImageRecord.getRenderedContext();else if(this.context2D)i=this.context2D;else return t.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString()),1;return i.canvas.width/(this.size.x*t.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(i,n,s){var o=Math.max(1,Math.ceil((s.x-n.x)/2)),a=Math.max(1,Math.ceil((s.y-n.y)/2));return new t.Point(o,a).minus(this.position.times(t.pixelDensityRatio).times(i||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}}})(e),(function(t){t.OverlayPlacement=t.Placement,t.OverlayRotationMode=t.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),t.Overlay=function(i,n,s){var o;t.isPlainObject(i)?o=i:o={element:i,location:n,placement:s},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)},t.Overlay.prototype={_init:function(i){this.location=i.location,this.placement=i.placement===void 0?t.Placement.TOP_LEFT:i.placement,this.onDraw=i.onDraw,this.checkResize=i.checkResize===void 0?!0:i.checkResize,this.width=i.width===void 0?null:i.width,this.height=i.height===void 0?null:i.height,this.rotationMode=i.rotationMode||t.OverlayRotationMode.EXACT,this.location instanceof t.Rect&&(this.width=this.location.width,this.height=this.location.height,this.location=this.location.getTopLeft(),this.placement=t.Placement.TOP_LEFT),this.scales=this.width!==null&&this.height!==null,this.bounds=new t.Rect(this.location.x,this.location.y,this.width,this.height),this.position=this.location},adjust:function(i,n){var s=t.Placement.properties[this.placement];s&&(s.isHorizontallyCentered?i.x-=n.x/2:s.isRight&&(i.x-=n.x),s.isVerticallyCentered?i.y-=n.y/2:s.isBottom&&(i.y-=n.y))},destroy:function(){var i=this.elementWrapper,n=this.style;i.parentNode&&(i.parentNode.removeChild(i),i.prevElementParent&&(n.display="none",document.body.appendChild(i))),this.onDraw=null,n.top="",n.left="",n.position="",this.width!==null&&(n.width=""),this.height!==null&&(n.height="");var s=t.getCssPropertyWithVendorPrefix("transformOrigin"),o=t.getCssPropertyWithVendorPrefix("transform");s&&o&&(n[s]="",n[o]="")},drawHTML:function(i,n){var s=this.elementWrapper;s.parentNode!==i&&(s.prevElementParent=s.parentNode,s.prevNextSibling=s.nextSibling,i.appendChild(s),this.style.position="absolute",this.size=t.getElementSize(this.elementWrapper));var o=this._getOverlayPositionAndSize(n),a=o.position,l=this.size=o.size,h="";n.overlayPreserveContentDirection&&(h=n.flipped?" scaleX(-1)":" scaleX(1)");var u=n.flipped?-o.rotate:o.rotate,c=n.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(a,l,this.element);else{var d=this.style,f=this.element.style;f.display="block",d.left=a.x+"px",d.top=a.y+"px",this.width!==null&&(f.width=l.x+"px"),this.height!==null&&(f.height=l.y+"px");var g=t.getCssPropertyWithVendorPrefix("transformOrigin"),p=t.getCssPropertyWithVendorPrefix("transform");g&&p&&(u&&!n.flipped?(f[p]="",d[g]=this._getTransformOrigin(),d[p]="rotate("+u+"deg)"):!u&&n.flipped?(f[p]=h,d[g]=this._getTransformOrigin(),d[p]=c):u&&n.flipped?(f[p]=h,d[g]=this._getTransformOrigin(),d[p]="rotate("+u+"deg)"+c):(f[p]="",d[g]="",d[p]="")),d.display="flex"}},_getOverlayPositionAndSize:function(i){var n=i.pixelFromPoint(this.location,!0),s=this._getSizeInPixels(i);this.adjust(n,s);var o=0;if(i.getRotation(!0)&&this.rotationMode!==t.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX&&this.width!==null&&this.height!==null){var a=new t.Rect(n.x,n.y,s.x,s.y),l=this._getBoundingBox(a,i.getRotation(!0));n=l.getTopLeft(),s=l.getSize()}else o=i.getRotation(!0);return i.flipped&&(n.x=i.getContainerSize().x-n.x),{position:n,size:s,rotate:o}},_getSizeInPixels:function(i){var n=this.size.x,s=this.size.y;if(this.width!==null||this.height!==null){var o=i.deltaPixelsFromPointsNoRotate(new t.Point(this.width||0,this.height||0),!0);this.width!==null&&(n=o.x),this.height!==null&&(s=o.y)}if(this.checkResize&&(this.width===null||this.height===null)){var a=this.size=t.getElementSize(this.elementWrapper);this.width===null&&(n=a.x),this.height===null&&(s=a.y)}return new t.Point(n,s)},_getBoundingBox:function(i,n){var s=this._getPlacementPoint(i);return i.rotate(n,s).getBoundingBox()},_getPlacementPoint:function(i){var n=new t.Point(i.x,i.y),s=t.Placement.properties[this.placement];return s&&(s.isHorizontallyCentered?n.x+=i.width/2:s.isRight&&(n.x+=i.width),s.isVerticallyCentered?n.y+=i.height/2:s.isBottom&&(n.y+=i.height)),n},_getTransformOrigin:function(){var i="",n=t.Placement.properties[this.placement];return n&&(n.isLeft?i="left":n.isRight&&(i="right"),n.isTop?i+=" top":n.isBottom&&(i+=" bottom")),i},update:function(i,n){var s=t.isPlainObject(i)?i:{location:i,placement:n};this._init({location:s.location||this.location,placement:s.placement!==void 0?s.placement:this.placement,onDraw:s.onDraw||this.onDraw,checkResize:s.checkResize||this.checkResize,width:s.width!==void 0?s.width:this.width,height:s.height!==void 0?s.height:this.height,rotationMode:s.rotationMode||this.rotationMode})},getBounds:function(i){t.console.assert(i,"A viewport must now be passed to Overlay.getBounds.");var n=this.width,s=this.height;if(n===null||s===null){var o=i.deltaPointsFromPixelsNoRotate(this.size,!0);n===null&&(n=o.x),s===null&&(s=o.y)}var a=this.location.clone();return this.adjust(a,new t.Point(n,s)),this._adjustBoundsForRotation(i,new t.Rect(a.x,a.y,n,s))},_adjustBoundsForRotation:function(i,n){if(!i||i.getRotation(!0)===0||this.rotationMode===t.OverlayRotationMode.EXACT)return n;if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return n;var s=this._getOverlayPositionAndSize(i);return i.viewerElementToViewportRectangle(new t.Rect(s.position.x,s.position.y,s.size.x,s.size.y))}return n.rotate(-i.getRotation(!0),this._getPlacementPoint(n))}}})(e),(function(t){const i=t;i.DrawerBase=class{constructor(s){t.console.assert(s.viewer,"[Drawer] options.viewer is required"),t.console.assert(s.viewport,"[Drawer] options.viewport is required"),t.console.assert(s.element,"[Drawer] options.element is required"),this.viewer=s.viewer,this.viewport=s.viewport,this.debugGridColor=typeof s.debugGridColor=="string"?[s.debugGridColor]:s.debugGridColor||t.DEFAULT_SETTINGS.debugGridColor,this.options=s.options||{},this.container=t.getElement(s.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",t.setElementOpacity(this.canvas,this.viewer.opacity,!0),t.setElementPointerEventsNone(this.canvas),t.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._checkForAPIOverrides()}get canvas(){return this._renderingTarget}get element(){return t.console.error("Drawer.element is deprecated. Use Drawer.container instead."),this.container}getType(){t.console.error("Drawer.getType must be implemented by child class")}static isSupported(){t.console.error("Drawer.isSupported must be implemented by child class")}_createDrawingElement(){return t.console.error("Drawer._createDrawingElement must be implemented by child class"),null}draw(s){t.console.error("Drawer.draw must be implemented by child class")}canRotate(){t.console.error("Drawer.canRotate must be implemented by child class")}destroy(){t.console.error("Drawer.destroy must be implemented by child class")}minimumOverlapRequired(s){return!1}setImageSmoothingEnabled(s){t.console.error("Drawer.setImageSmoothingEnabled must be implemented by child class")}drawDebuggingRect(s){t.console.warn("[drawer].drawDebuggingRect is not implemented by this drawer")}clear(){t.console.warn("[drawer].clear() is deprecated. The drawer is responsible for clearing itself as needed before drawing tiles.")}_checkForAPIOverrides(){if(this._createDrawingElement===t.DrawerBase.prototype._createDrawingElement)throw new Error("[drawer]._createDrawingElement must be implemented by child class");if(this.draw===t.DrawerBase.prototype.draw)throw new Error("[drawer].draw must be implemented by child class");if(this.canRotate===t.DrawerBase.prototype.canRotate)throw new Error("[drawer].canRotate must be implemented by child class");if(this.destroy===t.DrawerBase.prototype.destroy)throw new Error("[drawer].destroy must be implemented by child class");if(this.setImageSmoothingEnabled===t.DrawerBase.prototype.setImageSmoothingEnabled)throw new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")}viewportToDrawerRectangle(s){var o=this.viewport.pixelFromPointNoRotate(s.getTopLeft(),!0),a=this.viewport.deltaPixelsFromPointsNoRotate(s.getSize(),!0);return new t.Rect(o.x*t.pixelDensityRatio,o.y*t.pixelDensityRatio,a.x*t.pixelDensityRatio,a.y*t.pixelDensityRatio)}viewportCoordToDrawerCoord(s){var o=this.viewport.pixelFromPointNoRotate(s,!0);return new t.Point(o.x*t.pixelDensityRatio,o.y*t.pixelDensityRatio)}_calculateCanvasSize(){var s=t.pixelDensityRatio,o=this.viewport.getContainerSize();return new i.Point(Math.round(o.x*s),Math.round(o.y*s))}_raiseTiledImageDrawnEvent(s,o){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:s,tiles:o})}_raiseDrawerErrorEvent(s,o){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:s,drawer:this,error:o})}}})(e),(function(t){const i=t;class n extends i.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 t.makeNeutralElement("div")}draw(o){var a=this;this._prepareNewFrame(),o.forEach(function(l){l.opacity!==0&&a._drawTiles(l)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(o){var a=o.getTilesToDraw().map(u=>u.tile);if(!(o.opacity===0||a.length===0&&!o.placeholderFillStyle))for(var l=a.length-1;l>=0;l--){var h=a[l];this._drawTile(h),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:o,tile:h})}}_drawTile(o){t.console.assert(o,"[Drawer._drawTile] tile is required");let a=this.canvas;if(!o.cacheImageRecord){t.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",o.toString());return}if(!o.loaded){t.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=t.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!==a&&a.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)"),t.setElementOpacity(o.element,o.opacity)}}t.HTMLDrawer=n})(e),(function(t){const i=t;class n extends i.DrawerBase{constructor(u){super(u),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 t.supportsCanvas}getType(){return"canvas"}_createDrawingElement(){let u=t.makeNeutralElement("canvas"),c=this._calculateCanvasSize();return u.width=c.x,u.height=c.y,u}draw(u){this._prepareNewFrame(),this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const c of u)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(u){return!0}setImageSmoothingEnabled(u){this._imageSmoothingEnabled=!!u,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw()}drawDebuggingRect(u){var c=this.context;c.save(),c.lineWidth=2*t.pixelDensityRatio,c.strokeStyle=this.debugGridColor[0],c.fillStyle=this.debugGridColor[0],c.strokeRect(u.x*t.pixelDensityRatio,u.y*t.pixelDensityRatio,u.width*t.pixelDensityRatio,u.height*t.pixelDensityRatio),c.restore()}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(u,c,d,f){this.viewer.raiseEvent("tile-drawing",{tiledImage:u,context:c,tile:d,rendered:f})}_prepareNewFrame(){var u=this._calculateCanvasSize();if((this.canvas.width!==u.x||this.canvas.height!==u.y)&&(this.canvas.width=u.x,this.canvas.height=u.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(u,c){var d=this._getContext(u);if(c)d.clearRect(c.x,c.y,c.width,c.height);else{var f=d.canvas;d.clearRect(0,0,f.width,f.height)}}_drawTiles(u){var c=u.getTilesToDraw().map(D=>D.tile);if(!(u.opacity===0||c.length===0&&!u.placeholderFillStyle)){var d=c[0],f;d&&(f=u.opacity<1||u.compositeOperation&&u.compositeOperation!=="source-over"||!u._isBottomItem()&&u.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var g,p,m=this.viewport.getZoom(!0),v=u.viewportToImageZoom(m);c.length>1&&v>u.smoothTileEdgesMinZoom&&!u.iOSDevice&&u.getRotation(!0)%360===0&&(f=!0,g=d.getScaleForEdgeSmoothing(),p=d.getTranslationForEdgeSmoothing(g,this._getCanvasSize(!1),this._getCanvasSize(!0)));var y;f&&(g||(y=this.viewport.viewportToViewerElementRectangle(u.getClippedBounds(!0)).getIntegerBoundingBox(),y=y.times(t.pixelDensityRatio)),this._clear(!0,y)),g||this._setRotations(u,f);var _=!1;if(u._clip){this._saveContext(f);var w=u.imageToViewportRectangle(u._clip,!0);w=w.rotate(-u.getRotation(!0),u._getRotationPoint(!0));var A=this.viewportToDrawerRectangle(w);g&&(A=A.times(g)),p&&(A=A.translate(p)),this._setClip(A,f),_=!0}if(u._croppingPolygons){var F=this;_||this._saveContext(f);try{var C=u._croppingPolygons.map(function(D){return D.map(function(S){var b=u.imageToViewportCoordinates(S.x,S.y,!0).rotate(-u.getRotation(!0),u._getRotationPoint(!0)),O=F.viewportCoordToDrawerCoord(b);return g&&(O=O.times(g)),p&&(O=O.plus(p)),O})});this._clipWithPolygons(C,f)}catch(D){t.console.error(D)}_=!0}if(u._hasOpaqueTile=!1,u.placeholderFillStyle&&u._hasOpaqueTile===!1){let D=this.viewportToDrawerRectangle(u.getBoundsNoRotate(!0));g&&(D=D.times(g)),p&&(D=D.translate(p));let S=null;typeof u.placeholderFillStyle=="function"?S=u.placeholderFillStyle(u,this.context):S=u.placeholderFillStyle,this._drawRectangle(D,S,f)}var R=l(u.subPixelRoundingForTransparency),M=!1;if(R===t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)M=!0;else if(R===t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var k=this.viewer&&this.viewer.isAnimating();M=!k}for(var z=0;z<c.length;z++)d=c[z],this._drawTile(d,u,f,g,p,M,u.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:u,tile:d});_&&this._restoreContext(f),g||(u.getRotation(!0)%360!==0&&this._restoreRotationChanges(f),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(f)),f&&(g&&this._setRotations(u),this.blendSketch({opacity:u.opacity,scale:g,translate:p,compositeOperation:u.compositeOperation,bounds:y}),g&&(u.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1))),this._drawDebugInfo(u,c),this._raiseTiledImageDrawnEvent(u,c)}}_drawDebugInfo(u,c){if(u.debugMode)for(var d=c.length-1;d>=0;d--){var f=c[d];try{this._drawDebugInfoOnTile(f,c.length,d,u)}catch(g){t.console.error(g)}}}_clipWithPolygons(u,c){var d=this._getContext(c);d.beginPath();for(const f of u)for(const[g,p]of f.entries())d[g===0?"moveTo":"lineTo"](p.x,p.y);d.clip()}_drawTile(u,c,d,f,g,p,m){t.console.assert(u,"[Drawer._drawTile] tile is required"),t.console.assert(c,"[Drawer._drawTile] drawingHandler is required");var v=this._getContext(d);f=f||1,this._drawTileToCanvas(u,v,c,f,g,p,m)}_drawTileToCanvas(u,c,d,f,g,p,m){var v=u.position.times(t.pixelDensityRatio),y=u.size.times(t.pixelDensityRatio),_;if(!u.context2D&&!u.cacheImageRecord){t.console.warn("[Drawer._drawTileToCanvas] attempting to draw tile %s when it's not cached",u.toString());return}if(_=u.getCanvasContext(),!u.loaded||!_){t.console.warn("Attempting to draw tile %s when it's not yet loaded.",u.toString());return}c.save(),typeof f=="number"&&f!==1&&(v=v.times(f),y=y.times(f)),g instanceof t.Point&&(v=v.plus(g)),c.globalAlpha===1&&u.hasTransparency&&(p&&(v.x=Math.round(v.x),v.y=Math.round(v.y),y.x=Math.round(y.x),y.y=Math.round(y.y)),c.clearRect(v.x,v.y,y.x,y.y)),this._raiseTileDrawingEvent(d,c,u,_);var w,A;u.sourceBounds?(w=Math.min(u.sourceBounds.width,_.canvas.width),A=Math.min(u.sourceBounds.height,_.canvas.height)):(w=_.canvas.width,A=_.canvas.height),c.translate(v.x+y.x/2,0),u.flipped&&c.scale(-1,1),c.drawImage(_.canvas,0,0,w,A,-y.x/2,v.y,y.x,y.y),c.restore()}_getContext(u){var c=this.context;if(u){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 f=this;this.viewer.addHandler("rotate",function g(){if(f.viewport.getRotation()!==0){f.viewer.removeHandler("rotate",g);var p=f._calculateSketchCanvasSize();f.sketchCanvas.width=p.x,f.sketchCanvas.height=p.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}c=this.sketchContext}return c}_saveContext(u){this._getContext(u).save()}_restoreContext(u){this._getContext(u).restore()}_setClip(u,c){var d=this._getContext(c);d.beginPath(),d.rect(u.x,u.y,u.width,u.height),d.clip()}_drawRectangle(u,c,d){var f=this._getContext(d);f.save(),f.fillStyle=c,f.fillRect(u.x,u.y,u.width,u.height),f.restore()}blendSketch(u,c,d,f){var g=u;t.isPlainObject(g)||(g={opacity:u,scale:c,translate:d,compositeOperation:f}),u=g.opacity,f=g.compositeOperation;var p=g.bounds;if(this.context.save(),this.context.globalAlpha=u,f&&(this.context.globalCompositeOperation=f),p)p.x<0&&(p.width+=p.x,p.x=0),p.x+p.width>this.canvas.width&&(p.width=this.canvas.width-p.x),p.y<0&&(p.height+=p.y,p.y=0),p.y+p.height>this.canvas.height&&(p.height=this.canvas.height-p.y),this.context.drawImage(this.sketchCanvas,p.x,p.y,p.width,p.height,p.x,p.y,p.width,p.height);else{c=g.scale||1,d=g.translate;var m=d instanceof t.Point?d:new t.Point(0,0),v=0,y=0;if(d){var _=this.sketchCanvas.width-this.canvas.width,w=this.sketchCanvas.height-this.canvas.height;v=Math.round(_/2),y=Math.round(w/2)}this.context.drawImage(this.sketchCanvas,m.x-v*c,m.y-y*c,(this.canvas.width+2*v)*c,(this.canvas.height+2*y)*c,-v,-y,this.canvas.width+2*v,this.canvas.height+2*y)}this.context.restore()}_drawDebugInfoOnTile(u,c,d,f){var g=this.viewer.world.getIndexOfItem(f)%this.debugGridColor.length,p=this.context;p.save(),p.lineWidth=2*t.pixelDensityRatio,p.font="small-caps bold "+13*t.pixelDensityRatio+"px arial",p.strokeStyle=this.debugGridColor[g],p.fillStyle=this.debugGridColor[g],this._setRotations(f),this._viewportFlipped&&this._flip({point:u.position.plus(u.size.divide(2))}),p.strokeRect(u.position.x*t.pixelDensityRatio,u.position.y*t.pixelDensityRatio,u.size.x*t.pixelDensityRatio,u.size.y*t.pixelDensityRatio);var m=(u.position.x+u.size.x/2)*t.pixelDensityRatio,v=(u.position.y+u.size.y/2)*t.pixelDensityRatio;p.translate(m,v);const y=this.viewport.getRotation(!0);p.rotate(Math.PI/180*-y),p.translate(-m,-v),u.x===0&&u.y===0&&(p.fillText("Zoom: "+this.viewport.getZoom(),u.position.x*t.pixelDensityRatio,(u.position.y-30)*t.pixelDensityRatio),p.fillText("Pan: "+this.viewport.getBounds().toString(),u.position.x*t.pixelDensityRatio,(u.position.y-20)*t.pixelDensityRatio)),p.fillText("Level: "+u.level,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+20)*t.pixelDensityRatio),p.fillText("Column: "+u.x,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+30)*t.pixelDensityRatio),p.fillText("Row: "+u.y,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+40)*t.pixelDensityRatio),p.fillText("Order: "+d+" of "+c,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+50)*t.pixelDensityRatio),p.fillText("Size: "+u.size.toString(),(u.position.x+10)*t.pixelDensityRatio,(u.position.y+60)*t.pixelDensityRatio),p.fillText("Position: "+u.position.toString(),(u.position.x+10)*t.pixelDensityRatio,(u.position.y+70)*t.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),f.getRotation(!0)%360!==0&&this._restoreRotationChanges(),p.restore()}_updateImageSmoothingEnabled(u){u.msImageSmoothingEnabled=this._imageSmoothingEnabled,u.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(u){var c=this._getContext(u).canvas;return new t.Point(c.width,c.height)}_getCanvasCenter(){return new t.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(u,c=!1){var d=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:c,saveContext:d}),d=!1),u.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:u.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(u._getRotationPoint(!0),!0),useSketch:c,saveContext:d})}_offsetForRotation(u){var c=u.point?u.point.times(t.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(u.useSketch);d.save(),d.translate(c.x,c.y),d.rotate(Math.PI/180*u.degrees),d.translate(-c.x,-c.y)}_flip(u){u=u||{};var c=u.point?u.point.times(t.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(u.useSketch);d.translate(c.x,0),d.scale(-1,1),d.translate(-c.x,0)}_restoreRotationChanges(u){var c=this._getContext(u);c.restore()}_calculateCanvasSize(){var u=t.pixelDensityRatio,c=this.viewport.getContainerSize();return{x:Math.round(c.x*u),y:Math.round(c.y*u)}}_calculateSketchCanvasSize(){var u=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return u;var c=Math.ceil(Math.sqrt(u.x*u.x+u.y*u.y));return{x:c,y:c}}}t.CanvasDrawer=n;var s=t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function o(h){return h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function a(h){return o(h)?s:h}function l(h){if(typeof h=="number")return a(h);if(!h||!t.Browser)return s;var u=h[t.Browser.vendor];return o(u)&&(u=h["*"]),a(u)}})(e),(function(t){const i=t;i.WebGLDrawer=class extends i.DrawerBase{constructor(s){super(s),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=o=>this._tileReadyHandler(o),this._boundToImageUnloaded=o=>this._imageUnloadedHandler(o),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 s=this._gl;var o=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS);for(let l=0;l<o;++l)s.activeTexture(s.TEXTURE0+l),s.bindTexture(s.TEXTURE_2D,null),s.bindTexture(s.TEXTURE_CUBE_MAP,null);s.bindBuffer(s.ARRAY_BUFFER,null),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,null),s.bindRenderbuffer(s.RENDERBUFFER,null),s.bindFramebuffer(s.FRAMEBUFFER,null),this._unloadTextures(),s.deleteBuffer(this._secondPass.bufferOutputPosition),s.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 a=s.getExtension("WEBGL_lose_context");a&&a.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 s=document.createElement("canvas"),o=t.isFunction(s.getContext)&&s.getContext("webgl"),a=o&&o.getExtension("WEBGL_lose_context");return a&&a.loseContext(),!!o}getType(){return"webgl"}minimumOverlapRequired(s){return s.isTainted()}_createDrawingElement(){let s=t.makeNeutralElement("canvas"),o=this._calculateCanvasSize();return s.width=o.x,s.height=o.y,s}_getBackupCanvasDrawer(){return this._backupCanvasDrawer||(this._backupCanvasDrawer=this.viewer.requestDrawer("canvas",{mainDrawer:!1}),this._backupCanvasDrawer.canvas.style.setProperty("visibility","hidden")),this._backupCanvasDrawer}draw(s){let o=this._gl;const a=this.viewport.getBoundsNoRotateWithMargins(!0);let l={bounds:a,center:new i.Point(a.x+a.width/2,a.y+a.height/2),rotation:this.viewport.getRotation(!0)*Math.PI/180},h=this.viewport.flipped?-1:1,u=t.Mat3.makeTranslation(-l.center.x,-l.center.y),c=t.Mat3.makeScaling(2/l.bounds.width*h,-2/l.bounds.height),d=t.Mat3.makeRotation(-l.rotation),f=c.multiply(d).multiply(u);o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let g=!1;s.forEach((p,m)=>{if(p.isTainted()){g&&(this._outputContext.drawImage(this._renderingCanvas,0,0),o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT),g=!1);const v=this._getBackupCanvasDrawer();v.draw([p]),this._outputContext.drawImage(v.canvas,0,0)}else{let v=p.getTilesToDraw();if(p.placeholderFillStyle&&p._hasOpaqueTile===!1&&this._drawPlaceholder(p),v.length===0||p.getOpacity()===0)return;let y=v[0],_=p.compositeOperation||this.viewer.compositeOperation||p._clip||p._croppingPolygons||p.debugMode,w=_||p.opacity<1||y.hasTransparency;_&&(g&&this._outputContext.drawImage(this._renderingCanvas,0,0),o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT)),o.useProgram(this._firstPass.shaderProgram),w?(o.bindFramebuffer(o.FRAMEBUFFER,this._glFrameBuffer),o.clear(o.COLOR_BUFFER_BIT)):o.bindFramebuffer(o.FRAMEBUFFER,null);let A=f,F=p.getRotation(!0);if(F%360!==0){let D=t.Mat3.makeRotation(-F*Math.PI/180),S=p.getBoundsNoRotate(!0).getCenter(),b=t.Mat3.makeTranslation(S.x,S.y),O=t.Mat3.makeTranslation(-S.x,-S.y),j=b.multiply(D).multiply(O);A=f.multiply(j)}let C=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(C<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${C}). This could happen
|
|
9
|
+
if too many contexts have been created and not released, or there is another problem with the graphics card.`);let R=new Float32Array(C*12),M=new Array(C),k=new Array(C),z=new Array(C);for(let D=0;D<v.length;D++){let S=v[D].tile,b=D%C,O=b+1,j=S.getCanvasContext(),V=j?this._TextureMap.get(j.canvas):null;if(V||(this._tileReadyHandler({tile:S,tiledImage:p}),V=j?this._TextureMap.get(j.canvas):null),V&&this._getTileData(S,p,V,A,b,R,M,k,z),O===C||D===v.length-1){for(let Y=0;Y<=O;Y++)o.activeTexture(o.TEXTURE0+Y),o.bindTexture(o.TEXTURE_2D,M[Y]);o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),o.bufferData(o.ARRAY_BUFFER,R,o.DYNAMIC_DRAW),k.forEach((Y,G)=>{o.uniformMatrix3fv(this._firstPass.uTransformMatrices[G],!1,Y)}),o.uniform1fv(this._firstPass.uOpacities,new Float32Array(z)),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),o.vertexAttribPointer(this._firstPass.aOutputPosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),o.vertexAttribPointer(this._firstPass.aTexturePosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferIndex),o.vertexAttribPointer(this._firstPass.aIndex,1,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,6*O)}}w&&(o.useProgram(this._secondPass.shaderProgram),o.bindFramebuffer(o.FRAMEBUFFER,null),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._renderToTexture),this._gl.uniform1f(this._secondPass.uOpacityMultiplier,p.opacity),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),o.vertexAttribPointer(this._secondPass.aTexturePosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),o.vertexAttribPointer(this._secondPass.aOutputPosition,2,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,6)),g=!0,_&&(this._applyContext2dPipeline(p,v,m),g=!1,o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT)),m===0&&this._raiseTiledImageDrawnEvent(p,v.map(D=>D.tile))}}),g&&this._outputContext.drawImage(this._renderingCanvas,0,0)}setImageSmoothingEnabled(s){this._imageSmoothingEnabled!==s&&(this._imageSmoothingEnabled=s,this._unloadTextures(),this.viewer.world.draw())}drawDebuggingRect(s){let o=this._outputContext;o.save(),o.lineWidth=2*t.pixelDensityRatio,o.strokeStyle=this.debugGridColor[0],o.fillStyle=this.debugGridColor[0],o.strokeRect(s.x*t.pixelDensityRatio,s.y*t.pixelDensityRatio,s.width*t.pixelDensityRatio,s.height*t.pixelDensityRatio),o.restore()}_getTextureDataFromTile(s){return s.getCanvasContext().canvas}_applyContext2dPipeline(s,o,a){if(this._outputContext.save(),this._outputContext.globalCompositeOperation=a===0?null:s.compositeOperation||this.viewer.compositeOperation,s._croppingPolygons||s._clip?(this._renderToClippingCanvas(s),this._outputContext.drawImage(this._clippingCanvas,0,0)):this._outputContext.drawImage(this._renderingCanvas,0,0),this._outputContext.restore(),s.debugMode){const l=this.viewer.viewport.getFlip();l&&this._flip(),this._drawDebugInfo(o,s,l),l&&this._flip()}}_getTileData(s,o,a,l,h,u,c,d,f){let g=a.texture,p=a.position;u.set(p,h*12);let m=this._calculateOverlapFraction(s,o),v=s.positionedBounds.width*m.x,y=s.positionedBounds.height*m.y,_=s.positionedBounds.x+(s.x===0?0:v),w=s.positionedBounds.y+(s.y===0?0:y),A=s.positionedBounds.x+s.positionedBounds.width-(s.isRightMost?0:v),F=s.positionedBounds.y+s.positionedBounds.height-(s.isBottomMost?0:y),C=A-_,R=F-w,M=new t.Mat3([C,0,0,0,R,0,_,w,1]);if(s.flipped){let z=t.Mat3.makeTranslation(.5,0),D=t.Mat3.makeTranslation(-.5,0),S=z.multiply(t.Mat3.makeScaling(-1,1)).multiply(D);M=M.multiply(S)}let k=l.multiply(M);f[h]=s.opacity,c[h]=g,d[h]=k.values}_textureFilter(){return this._imageSmoothingEnabled?this._gl.LINEAR:this._gl.NEAREST}_setupRenderer(){let s=this._gl;s||t.console.error("_setupCanvases must be called before _setupRenderer"),this._unitQuad=this._makeQuadVertexBuffer(0,1,0,1),this._makeFirstPassShaderProgram(),this._makeSecondPassShaderProgram(),this._renderToTexture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._renderToTexture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,this._renderingCanvas.width,this._renderingCanvas.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this._textureFilter()),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),this._glFrameBuffer=s.createFramebuffer(),s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._renderToTexture,0),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA)}_makeFirstPassShaderProgram(){let s=this._glNumTextures=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),o=()=>[...Array(s).keys()].map(g=>`uniform mat3 u_matrix_${g};`).join(`
|
|
10
|
+
`),a=()=>[...Array(s).keys()].map(g=>`${g>0?"else ":""}if(int(a_index) == ${g}) { transform_matrix = u_matrix_${g}; }`).join(`
|
|
11
|
+
`);const l=`
|
|
12
|
+
attribute vec2 a_output_position;
|
|
13
|
+
attribute vec2 a_texture_position;
|
|
14
|
+
attribute float a_index;
|
|
15
|
+
|
|
16
|
+
${o()} // create a uniform mat3 for each potential tile to draw
|
|
17
|
+
|
|
18
|
+
varying vec2 v_texture_position;
|
|
19
|
+
varying float v_image_index;
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
|
|
23
|
+
mat3 transform_matrix; // value will be set by the if/elses in makeConditional()
|
|
24
|
+
|
|
25
|
+
${a()}
|
|
26
|
+
|
|
27
|
+
gl_Position = vec4(transform_matrix * vec3(a_output_position, 1), 1);
|
|
28
|
+
|
|
29
|
+
v_texture_position = a_texture_position;
|
|
30
|
+
v_image_index = a_index;
|
|
31
|
+
}
|
|
32
|
+
`,h=`
|
|
33
|
+
precision mediump float;
|
|
34
|
+
|
|
35
|
+
// our textures
|
|
36
|
+
uniform sampler2D u_images[${s}];
|
|
37
|
+
// our opacities
|
|
38
|
+
uniform float u_opacities[${s}];
|
|
39
|
+
|
|
40
|
+
// the varyings passed in from the vertex shader.
|
|
41
|
+
varying vec2 v_texture_position;
|
|
42
|
+
varying float v_image_index;
|
|
43
|
+
|
|
44
|
+
void main() {
|
|
45
|
+
// can't index directly with a variable, need to use a loop iterator hack
|
|
46
|
+
for(int i = 0; i < ${s}; ++i){
|
|
47
|
+
if(i == int(v_image_index)){
|
|
48
|
+
gl_FragColor = texture2D(u_images[i], v_texture_position) * u_opacities[i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;let u=this._gl,c=this.constructor.initShaderProgram(u,l,h);u.useProgram(c),this._firstPass={shaderProgram:c,aOutputPosition:u.getAttribLocation(c,"a_output_position"),aTexturePosition:u.getAttribLocation(c,"a_texture_position"),aIndex:u.getAttribLocation(c,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(g=>u.getUniformLocation(c,`u_matrix_${g}`)),uImages:u.getUniformLocation(c,"u_images"),uOpacities:u.getUniformLocation(c,"u_opacities"),bufferOutputPosition:u.createBuffer(),bufferTexturePosition:u.createBuffer(),bufferIndex:u.createBuffer()},u.uniform1iv(this._firstPass.uImages,[...Array(s).keys()]);let d=new Float32Array(s*12);for(let g=0;g<s;++g)d.set(Float32Array.from(this._unitQuad),g*12);u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),u.bufferData(u.ARRAY_BUFFER,d,u.STATIC_DRAW),u.enableVertexAttribArray(this._firstPass.aOutputPosition),u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),u.enableVertexAttribArray(this._firstPass.aTexturePosition),u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferIndex);let f=[...Array(this._glNumTextures).keys()].map(g=>Array(6).fill(g)).flat();u.bufferData(u.ARRAY_BUFFER,new Float32Array(f),u.STATIC_DRAW),u.enableVertexAttribArray(this._firstPass.aIndex)}_makeSecondPassShaderProgram(){const s=`
|
|
53
|
+
attribute vec2 a_output_position;
|
|
54
|
+
attribute vec2 a_texture_position;
|
|
55
|
+
|
|
56
|
+
uniform mat3 u_matrix;
|
|
57
|
+
|
|
58
|
+
varying vec2 v_texture_position;
|
|
59
|
+
|
|
60
|
+
void main() {
|
|
61
|
+
gl_Position = vec4(u_matrix * vec3(a_output_position, 1), 1);
|
|
62
|
+
|
|
63
|
+
v_texture_position = a_texture_position;
|
|
64
|
+
}
|
|
65
|
+
`,o=`
|
|
66
|
+
precision mediump float;
|
|
67
|
+
|
|
68
|
+
// our texture
|
|
69
|
+
uniform sampler2D u_image;
|
|
70
|
+
|
|
71
|
+
// the texCoords passed in from the vertex shader.
|
|
72
|
+
varying vec2 v_texture_position;
|
|
73
|
+
|
|
74
|
+
// the opacity multiplier for the image
|
|
75
|
+
uniform float u_opacity_multiplier;
|
|
76
|
+
|
|
77
|
+
void main() {
|
|
78
|
+
gl_FragColor = texture2D(u_image, v_texture_position);
|
|
79
|
+
gl_FragColor *= u_opacity_multiplier;
|
|
80
|
+
}
|
|
81
|
+
`;let a=this._gl,l=this.constructor.initShaderProgram(a,s,o);a.useProgram(l),this._secondPass={shaderProgram:l,aOutputPosition:a.getAttribLocation(l,"a_output_position"),aTexturePosition:a.getAttribLocation(l,"a_texture_position"),uMatrix:a.getUniformLocation(l,"u_matrix"),uImage:a.getUniformLocation(l,"u_image"),uOpacityMultiplier:a.getUniformLocation(l,"u_opacity_multiplier"),bufferOutputPosition:a.createBuffer(),bufferTexturePosition:a.createBuffer()},a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.STATIC_DRAW),a.enableVertexAttribArray(this._secondPass.aOutputPosition),a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.DYNAMIC_DRAW),a.enableVertexAttribArray(this._secondPass.aTexturePosition);let h=t.Mat3.makeScaling(2,2).multiply(t.Mat3.makeTranslation(-.5,-.5));a.uniformMatrix3fv(this._secondPass.uMatrix,!1,h.values)}_resizeRenderer(){let s=this._gl,o=this._renderingCanvas.width,a=this._renderingCanvas.height;s.viewport(0,0,o,a),s.deleteTexture(this._renderToTexture),this._renderToTexture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._renderToTexture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o,a,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this._textureFilter()),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._renderToTexture,0)}_setupCanvases(){let s=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(){s._outputCanvas!==s.viewer.drawer.canvas&&(s._outputCanvas.style.width=s.viewer.drawer.canvas.clientWidth+"px",s._outputCanvas.style.height=s.viewer.drawer.canvas.clientHeight+"px");let o=s._calculateCanvasSize();(s._outputCanvas.width!==o.x||s._outputCanvas.height!==o.y)&&(s._outputCanvas.width=o.x,s._outputCanvas.height=o.y),s._renderingCanvas.style.width=s._outputCanvas.clientWidth+"px",s._renderingCanvas.style.height=s._outputCanvas.clientHeight+"px",s._renderingCanvas.width=s._clippingCanvas.width=s._outputCanvas.width,s._renderingCanvas.height=s._clippingCanvas.height=s._outputCanvas.height,s._resizeRenderer()},this.viewer.addHandler("resize",this._resizeHandler)}_makeQuadVertexBuffer(s,o,a,l){return new Float32Array([s,l,o,l,s,a,s,a,o,l,o,a])}_tileReadyHandler(s){let o=s.tile,a=s.tiledImage;if(a.isTainted())return;let l=o.getCanvasContext(),h=l&&l.canvas;if(!h||t.isCanvasTainted(h)){a.isTainted()||(a.setTainted(!0),t.console.warn("WebGL cannot be used to draw this TiledImage because it has tainted data. Does crossOriginPolicy need to be set?"),this._raiseDrawerErrorEvent(a,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(h)){let c=this._gl,d=c.createTexture(),f,g=a.source.tileOverlap,p,m;if(o.sourceBounds?(p=Math.min(o.sourceBounds.width,h.width)/h.width,m=Math.min(o.sourceBounds.height,h.height)/h.height):(p=1,m=1),g>0){let y=this._calculateOverlapFraction(o,a),_=(o.x===0?0:y.x)*p,w=(o.y===0?0:y.y)*m,A=(o.isRightMost?1:1-y.x)*p,F=(o.isBottomMost?1:1-y.y)*m;f=this._makeQuadVertexBuffer(_,A,w,F)}else p===1&&m===1?f=this._unitQuad:f=this._makeQuadVertexBuffer(0,p,0,m);let v={texture:d,position:f};this._TextureMap.set(h,v),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(l)}}_calculateOverlapFraction(s,o){let a=o.source.tileOverlap,l=s.sourceBounds.width,h=s.sourceBounds.height,u=(s.x===0?0:a)+(s.isRightMost?0:a),c=(s.y===0?0:a)+(s.isBottomMost?0:a),d=a/(l+u),f=a/(h+c);return{x:d,y:f}}_unloadTextures(){Array.from(this._TextureMap.keys()).forEach(o=>{this._cleanupImageData(o)})}_uploadImageData(s){let o=this._gl,a=s.canvas;try{if(!a)throw s;o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a)}catch(l){t.console.error("Error uploading image data to WebGL",l)}}_imageUnloadedHandler(s){let o=s.context2D.canvas;this._cleanupImageData(o)}_cleanupImageData(s){let o=this._TextureMap.get(s);this._TextureMap.delete(s),o&&this._gl.deleteTexture(o.texture)}_setClip(){}_renderToClippingCanvas(s){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const o=new t.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(o.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-o.x,0)}if(s._clip){let a=[{x:s._clip.x,y:s._clip.y},{x:s._clip.x+s._clip.width,y:s._clip.y},{x:s._clip.x+s._clip.width,y:s._clip.y+s._clip.height},{x:s._clip.x,y:s._clip.y+s._clip.height}].map(l=>{let h=s.imageToViewportCoordinates(l.x,l.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(h)});this._clippingContext.beginPath(),a.forEach((l,h)=>{this._clippingContext[h===0?"moveTo":"lineTo"](l.x,l.y)}),this._clippingContext.clip(),this._setClip()}if(s._croppingPolygons){let o=s._croppingPolygons.map(a=>a.map(l=>{let h=s.imageToViewportCoordinates(l.x,l.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(h)}));this._clippingContext.beginPath(),o.forEach(a=>{a.forEach((l,h)=>{this._clippingContext[h===0?"moveTo":"lineTo"](l.x,l.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const o=new t.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(o.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-o.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(s){var o=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:o}),o=!1),s.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:s.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(s._getRotationPoint(!0),!0),saveContext:o})}_offsetForRotation(s){var o=s.point?s.point.times(t.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.save(),a.translate(o.x,o.y),a.rotate(Math.PI/180*s.degrees),a.translate(-o.x,-o.y)}_flip(s){s=s||{};var o=s.point?s.point.times(t.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.translate(o.x,0),a.scale(-1,1),a.translate(-o.x,0)}_drawDebugInfo(s,o,a){for(var l=s.length-1;l>=0;l--){var h=s[l].tile;try{this._drawDebugInfoOnTile(h,s.length,l,o,a)}catch(u){t.console.error(u)}}}_drawDebugInfoOnTile(s,o,a,l,h){var u=this.viewer.world.getIndexOfItem(l)%this.debugGridColor.length,c=this.context;c.save(),c.lineWidth=2*t.pixelDensityRatio,c.font="small-caps bold "+13*t.pixelDensityRatio+"px arial",c.strokeStyle=this.debugGridColor[u],c.fillStyle=this.debugGridColor[u],this._setRotations(l),h&&this._flip({point:s.position.plus(s.size.divide(2))}),c.strokeRect(s.position.x*t.pixelDensityRatio,s.position.y*t.pixelDensityRatio,s.size.x*t.pixelDensityRatio,s.size.y*t.pixelDensityRatio);var d=(s.position.x+s.size.x/2)*t.pixelDensityRatio,f=(s.position.y+s.size.y/2)*t.pixelDensityRatio;c.translate(d,f);const g=this.viewport.getRotation(!0);c.rotate(Math.PI/180*-g),c.translate(-d,-f),s.x===0&&s.y===0&&(c.fillText("Zoom: "+this.viewport.getZoom(),s.position.x*t.pixelDensityRatio,(s.position.y-30)*t.pixelDensityRatio),c.fillText("Pan: "+this.viewport.getBounds().toString(),s.position.x*t.pixelDensityRatio,(s.position.y-20)*t.pixelDensityRatio)),c.fillText("Level: "+s.level,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+20)*t.pixelDensityRatio),c.fillText("Column: "+s.x,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+30)*t.pixelDensityRatio),c.fillText("Row: "+s.y,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+40)*t.pixelDensityRatio),c.fillText("Order: "+a+" of "+o,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+50)*t.pixelDensityRatio),c.fillText("Size: "+s.size.toString(),(s.position.x+10)*t.pixelDensityRatio,(s.position.y+60)*t.pixelDensityRatio),c.fillText("Position: "+s.position.toString(),(s.position.x+10)*t.pixelDensityRatio,(s.position.y+70)*t.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),l.getRotation(!0)%360!==0&&this._restoreRotationChanges(),c.restore()}_drawPlaceholder(s){const o=s.getBounds(!0),a=this.viewportToDrawerRectangle(s.getBounds(!0)),l=this._outputContext;let h;typeof s.placeholderFillStyle=="function"?h=s.placeholderFillStyle(s,l):h=s.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),l.fillStyle=h,l.translate(a.x,a.y),l.rotate(Math.PI/180*o.degrees),l.translate(-a.x,-a.y),l.fillRect(a.x,a.y,a.width,a.height),this._restoreRotationChanges()}_getCanvasCenter(){return new t.Point(this.canvas.width/2,this.canvas.height/2)}_restoreRotationChanges(){var s=this._outputContext;s.restore()}static initShaderProgram(s,o,a){function l(d,f,g){const p=d.createShader(f);return d.shaderSource(p,g),d.compileShader(p),d.getShaderParameter(p,d.COMPILE_STATUS)?p:(t.console.error(`An error occurred compiling the shaders: ${d.getShaderInfoLog(p)}`),d.deleteShader(p),null)}const h=l(s,s.VERTEX_SHADER,o),u=l(s,s.FRAGMENT_SHADER,a),c=s.createProgram();return s.attachShader(c,h),s.attachShader(c,u),s.linkProgram(c),s.getProgramParameter(c,s.LINK_STATUS)?c:(t.console.error(`Unable to initialize the shader program: ${s.getProgramInfoLog(c)}`),null)}}})(e),(function(t){t.Viewport=function(i){var n=arguments;n.length&&n[0]instanceof t.Point&&(i={containerSize:n[0],contentSize:n[1],config:n[2]}),i.config&&(t.extend(!0,i,i.config),delete i.config),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i.margins||{}),delete i.margins,i.initialDegrees=i.degrees,delete i.degrees,t.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:t.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:t.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:t.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:t.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:t.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:t.DEFAULT_SETTINGS.degrees,flipped:t.DEFAULT_SETTINGS.flipped,homeFillsViewer:t.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:t.DEFAULT_SETTINGS.silenceMultiImageWarnings},i),this._updateContainerInnerSize(),this.centerSpringX=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.centerSpringY=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.zoomSpring=new t.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.degreesSpring=new t.Spring({initial:i.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 t.Rect(0,0,1,1),1),this.goHome(!0),this.update()},t.Viewport.prototype={get degrees(){return t.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead."),this.getRotation()},set degrees(i){t.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead."),this.rotateTo(i)},resetContentSize:function(i){return t.console.assert(i,"[Viewport.resetContentSize] contentSize is required"),t.console.assert(i instanceof t.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"),t.console.assert(i.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),t.console.assert(i.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this._setContentBounds(new t.Rect(0,0,1,i.y/i.x),i.x),this},setHomeBounds:function(i,n){t.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(i,n)},_setContentBounds:function(i,n){t.console.assert(i,"[Viewport._setContentBounds] bounds is required"),t.console.assert(i instanceof t.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect"),t.console.assert(i.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0"),t.console.assert(i.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0"),this._contentBoundsNoRotate=i.clone(),this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(n),this._contentBounds=i.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(n),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:n,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var i=this._contentAspectRatio/this.getAspectRatio(),n;return this.homeFillsViewer?n=i>=1?i:1:n=i>=1?1:i,n/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var i=this._contentBounds.getCenter(),n=1/this.getHomeZoom(),s=n/this.getAspectRatio();return new t.Rect(i.x-n/2,i.y-s/2,n,s)},goHome:function(i){return this.viewer&&this.viewer.raiseEvent("home",{immediately:i}),this.fitBounds(this.getHomeBounds(),i)},getMinZoom:function(){var i=this.getHomeZoom(),n=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*i;return n},getMaxZoom:function(){var i=this.maxZoomLevel;return i||(i=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,i/=this._contentBounds.width),Math.max(i,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new t.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return t.extend({},this._margins)},setMargins:function(i){t.console.assert(t.type(i)==="object","[Viewport.setMargins] margins must be an object"),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i),this._updateContainerInnerSize(),this.viewer&&this.viewer.forceRedraw()},getBounds:function(i){return this.getBoundsNoRotate(i).rotate(-this.getRotation(i))},getBoundsNoRotate:function(i){var n=this.getCenter(i),s=1/this.getZoom(i),o=s/this.getAspectRatio();return new t.Rect(n.x-s/2,n.y-o/2,s,o)},getBoundsWithMargins:function(i){return this.getBoundsNoRotateWithMargins(i).rotate(-this.getRotation(i),this.getCenter(i))},getBoundsNoRotateWithMargins:function(i){var n=this.getBoundsNoRotate(i),s=this._containerInnerSize.x*this.getZoom(i);return n.x-=this._margins.left/s,n.y-=this._margins.top/s,n.width+=(this._margins.left+this._margins.right)/s,n.height+=(this._margins.top+this._margins.bottom)/s,n},getCenter:function(i){var n=new t.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),s=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),o,a,l,h,u,c,d,f;return i?n:this.zoomPoint?(o=this.pixelFromPoint(this.zoomPoint,!0),a=this.getZoom(),l=1/a,h=l/this.getAspectRatio(),u=new t.Rect(n.x-l/2,n.y-h/2,l,h),c=this._pixelFromPoint(this.zoomPoint,u),d=c.minus(o).rotate(-this.getRotation(!0)),f=d.divide(this._containerInnerSize.x*a),s.plus(f)):s},getZoom:function(i){return i?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(i){return Math.max(Math.min(i,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(i){var n=this.viewportToViewerElementRectangle(i).getBoundingBox(),s=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),o=!1,a=!1;if(!this.wrapHorizontal){var l=n.x+n.width,h=s.x+s.width,u,c,d;n.width>s.width?u=this.visibilityRatio*s.width:u=this.visibilityRatio*n.width,c=s.x-l+u,d=h-n.x-u,u>s.width?(n.x+=(c+d)/2,o=!0):d<0?(n.x+=d,o=!0):c>0&&(n.x+=c,o=!0)}if(!this.wrapVertical){var f=n.y+n.height,g=s.y+s.height,p,m,v;n.height>s.height?p=this.visibilityRatio*s.height:p=this.visibilityRatio*n.height,m=s.y-f+p,v=g-n.y-p,p>s.height?(n.y+=(m+v)/2,a=!0):v<0?(n.y+=v,a=!0):m>0&&(n.y+=m,a=!0)}var y=o||a,_=y?this.viewerElementToViewportRectangle(n):i.clone();return _.xConstrained=o,_.yConstrained=a,_.constraintApplied=y,_},_raiseConstraintsEvent:function(i){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:i})},applyConstraints:function(i){var n=this.getZoom(),s=this._applyZoomConstraints(n);n!==s&&this.zoomTo(s,this.zoomPoint,i);var o=this.getConstrainedBounds(!1);return o.constraintApplied&&(this.fitBounds(o,i),this._raiseConstraintsEvent(i)),this},ensureVisible:function(i){return this.applyConstraints(i)},_fitBounds:function(i,n){n=n||{};var s=n.immediately||!1,o=n.constraints||!1,a=this.getAspectRatio(),l=i.getCenter(),h=new t.Rect(i.x,i.y,i.width,i.height,i.degrees+this.getRotation()).getBoundingBox();h.getAspectRatio()>=a?h.height=h.width/a:h.width=h.height*a,h.x=l.x-h.width/2,h.y=l.y-h.height/2;var u=1/h.width;if(s)return this.panTo(l,!0),this.zoomTo(u,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 f=this.getBounds(),g=this.getZoom();if(g===0||Math.abs(u/g-1)<1e-8)return this.zoomTo(u,null,!0),this.panTo(l,s),o&&this.applyConstraints(!1),this;if(o){this.panTo(l,!1),u=this._applyZoomConstraints(u),this.zoomTo(u,null,!1);var p=this.getConstrainedBounds();this.panTo(c,!0),this.zoomTo(d,null,!0),this.fitBounds(p)}else{var m=h.rotate(-this.getRotation()),v=m.getTopLeft().times(u).minus(f.getTopLeft().times(g)).divide(u-g);this.zoomTo(u,v,s)}return this},fitBounds:function(i,n){return this._fitBounds(i,{immediately:n,constraints:!1})},fitBoundsWithConstraints:function(i,n){return this._fitBounds(i,{immediately:n,constraints:!0})},fitVertically:function(i){var n=new t.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(n,i)},fitHorizontally:function(i){var n=new t.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(n,i)},getConstrainedBounds:function(i){var n,s;return n=this.getBounds(i),s=this._applyBoundaryConstraints(n),s},panBy:function(i,n){var s=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(s.plus(i),n)},panTo:function(i,n){return n?(this.centerSpringX.resetTo(i.x),this.centerSpringY.resetTo(i.y)):(this.centerSpringX.springTo(i.x),this.centerSpringY.springTo(i.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:i,immediately:n}),this},zoomBy:function(i,n,s){return this.zoomTo(this.zoomSpring.target.value*i,n,s)},zoomTo:function(i,n,s){var o=this;return this.zoomPoint=n instanceof t.Point&&!isNaN(n.x)&&!isNaN(n.y)?n:null,s?this._adjustCenterSpringsForZoomPoint(function(){o.zoomSpring.resetTo(i)}):this.zoomSpring.springTo(i),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:i,refPoint:n,immediately:s}),this},setRotation:function(i,n){return this.rotateTo(i,null,n)},getRotation:function(i){return i?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(i,n,s){return this.rotateTo(i,n,s)},rotateTo:function(i,n,s){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===i&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=n instanceof t.Point&&!isNaN(n.x)&&!isNaN(n.y)?n:null,s)if(this.rotationPivot){var o=i-this._oldDegrees;if(!o)return this.rotationPivot=null,this;this._rotateAboutPivot(i)}else this.degreesSpring.resetTo(i);else{var a=t.positiveModulo(this.degreesSpring.current.value,360),l=t.positiveModulo(i,360),h=l-a;h>180?l-=360:h<-180&&(l+=360);var u=a-l;this.degreesSpring.resetTo(i+u),this.degreesSpring.springTo(i)}return this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor()),this.viewer.forceRedraw(),this.viewer.raiseEvent("rotate",{degrees:i,immediately:!!s,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(i,n,s){return this.rotateTo(this.degreesSpring.target.value+i,n,s)},resize:function(i,n){var s=this.getBoundsNoRotate(),o=s,a;this.containerSize.x=i.x,this.containerSize.y=i.y,this._updateContainerInnerSize(),n&&(a=i.x/this.containerSize.x,o.width=s.width*a,o.height=o.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:i,maintain:n});var l=this.fitBounds(o,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:i,maintain:n}),l},_updateContainerInnerSize:function(){this._containerInnerSize=new t.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 i=this;this._adjustCenterSpringsForZoomPoint(function(){i.zoomSpring.update()}),this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null),this.centerSpringX.update(),this.centerSpringY.update(),this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var n=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 s=n||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return s},_rotateAboutPivot:function(i){var n=i===!0,s=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(s.x),this.centerSpringY.shiftBy(s.y),n?this.degreesSpring.update():this.degreesSpring.resetTo(i);var o=this.degreesSpring.current.value-this._oldDegrees,a=s.rotate(o*-1).times(-1);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y)},_adjustCenterSpringsForZoomPoint:function(i){if(this.zoomPoint){var n=this.pixelFromPoint(this.zoomPoint,!0);i();var s=this.pixelFromPoint(this.zoomPoint,!0),o=s.minus(n),a=this.deltaPointsFromPixels(o,!0);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else i()},deltaPixelsFromPointsNoRotate:function(i,n){return i.times(this._containerInnerSize.x*this.getZoom(n))},deltaPixelsFromPoints:function(i,n){return this.deltaPixelsFromPointsNoRotate(i.rotate(this.getRotation(n)),n)},deltaPointsFromPixelsNoRotate:function(i,n){return i.divide(this._containerInnerSize.x*this.getZoom(n))},deltaPointsFromPixels:function(i,n){return this.deltaPointsFromPixelsNoRotate(i,n).rotate(-this.getRotation(n))},pixelFromPointNoRotate:function(i,n){return this._pixelFromPointNoRotate(i,this.getBoundsNoRotate(n))},pixelFromPoint:function(i,n){return this._pixelFromPoint(i,this.getBoundsNoRotate(n))},_pixelFromPointNoRotate:function(i,n){return i.minus(n.getTopLeft()).times(this._containerInnerSize.x/n.width).plus(new t.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(i,n){return this._pixelFromPointNoRotate(i.rotate(this.getRotation(!0),this.getCenter(!0)),n)},pointFromPixelNoRotate:function(i,n){var s=this.getBoundsNoRotate(n);return i.minus(new t.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/s.width).plus(s.getTopLeft())},pointFromPixel:function(i,n){return this.pointFromPixelNoRotate(i,n).rotate(-this.getRotation(n),this.getCenter(n))},_viewportToImageDelta:function(i,n){var s=this._contentBoundsNoRotate.width;return new t.Point(i*this._contentSizeNoRotate.x/s,n*this._contentSizeNoRotate.x/s)},viewportToImageCoordinates:function(i,n){if(i instanceof t.Point)return this.viewportToImageCoordinates(i.x,i.y);if(this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageCoordinates(i,n,!0)}}return this._viewportToImageDelta(i-this._contentBoundsNoRotate.x,n-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(i,n){var s=this._contentBoundsNoRotate.width;return new t.Point(i/this._contentSizeNoRotate.x*s,n/this._contentSizeNoRotate.x*s)},imageToViewportCoordinates:function(i,n){if(i instanceof t.Point)return this.imageToViewportCoordinates(i.x,i.y);if(this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportCoordinates(i,n,!0)}}var a=this._imageToViewportDelta(i,n);return a.x+=this._contentBoundsNoRotate.x,a.y+=this._contentBoundsNoRotate.y,a},imageToViewportRectangle:function(i,n,s,o){var a=i;if(a instanceof t.Rect||(a=new t.Rect(i,n,s,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(l===1){var h=this.viewer.world.getItemAt(0);return h.imageToViewportRectangle(i,n,s,o,!0)}}var u=this.imageToViewportCoordinates(a.x,a.y),c=this._imageToViewportDelta(a.width,a.height);return new t.Rect(u.x,u.y,c.x,c.y,a.degrees)},viewportToImageRectangle:function(i,n,s,o){var a=i;if(a instanceof t.Rect||(a=new t.Rect(i,n,s,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(l===1){var h=this.viewer.world.getItemAt(0);return h.viewportToImageRectangle(i,n,s,o,!0)}}var u=this.viewportToImageCoordinates(a.x,a.y),c=this._viewportToImageDelta(a.width,a.height);return new t.Rect(u.x,u.y,c.x,c.y,a.degrees)},viewerElementToImageCoordinates:function(i){var n=this.pointFromPixel(i,!0);return this.viewportToImageCoordinates(n)},imageToViewerElementCoordinates:function(i){var n=this.imageToViewportCoordinates(i);return this.pixelFromPoint(n,!0)},windowToImageCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var n=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(n)},imageToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var n=this.imageToViewerElementCoordinates(i);return n.plus(t.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(i){return this.pointFromPixel(i,!0)},viewportToViewerElementCoordinates:function(i){return this.pixelFromPoint(i,!0)},viewerElementToViewportRectangle:function(i){return t.Rect.fromSummits(this.pointFromPixel(i.getTopLeft(),!0),this.pointFromPixel(i.getTopRight(),!0),this.pointFromPixel(i.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(i){return t.Rect.fromSummits(this.pixelFromPoint(i.getTopLeft(),!0),this.pixelFromPoint(i.getTopRight(),!0),this.pixelFromPoint(i.getBottomLeft(),!0))},windowToViewportCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");var n=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(n)},viewportToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var n=this.viewportToViewerElementCoordinates(i);return n.plus(t.getElementPosition(this.viewer.element))},viewportToImageZoom:function(i){if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(n===1){var s=this.viewer.world.getItemAt(0);return s.viewportToImageZoom(i)}}var o=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,h=a/o*l;return i*h},imageToViewportZoom:function(i){if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image. Instead, use [TiledImage.imageToViewportZoom] for the specific image of interest");else if(n===1){var s=this.viewer.world.getItemAt(0);return s.imageToViewportZoom(i)}}var o=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,h=o/a/l;return i*h},toggleFlip:function(){return this.setFlip(!this.getFlip()),this},getFlip:function(){return this.flipped},setFlip:function(i){return this.flipped===i?this:(this.flipped=i,this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip()),this.viewer.forceRedraw(),this.viewer.raiseEvent("flip",{flipped:i}),this)},getMaxZoomPixelRatio:function(){return this.maxZoomPixelRatio},setMaxZoomPixelRatio:function(i,n=!0,s=!1){t.console.assert(!isNaN(i),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(i)&&(this.maxZoomPixelRatio=i,n&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(s))}}})(e),(function(t){t.TiledImage=function(i){this._initialized=!1,t.console.assert(i.tileCache,"[TiledImage] options.tileCache is required"),t.console.assert(i.drawer,"[TiledImage] options.drawer is required"),t.console.assert(i.viewer,"[TiledImage] options.viewer is required"),t.console.assert(i.imageLoader,"[TiledImage] options.imageLoader is required"),t.console.assert(i.source,"[TiledImage] options.source is required"),t.console.assert(!i.clip||i.clip instanceof t.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),t.EventSource.call(this),this._tileCache=i.tileCache,delete i.tileCache,this._drawer=i.drawer,delete i.drawer,this._imageLoader=i.imageLoader,delete i.imageLoader,i.clip instanceof t.Rect&&(this._clip=i.clip.clone()),delete i.clip;var n=i.x||0;delete i.x;var s=i.y||0;delete i.y,this.normHeight=i.source.dimensions.y/i.source.dimensions.x,this.contentAspectX=i.source.dimensions.x/i.source.dimensions.y;var o=1;i.width?(o=i.width,delete i.width,i.height&&(t.console.error("specifying both width and height to a tiledImage is not supported"),delete i.height)):i.height&&(o=i.height/this.normHeight,delete i.height);var a=i.fitBounds;delete i.fitBounds;var l=i.fitBoundsPlacement||e.Placement.CENTER;delete i.fitBoundsPlacement;var h=i.degrees||0;delete i.degrees;var u=i.ajaxHeaders;delete i.ajaxHeaders,t.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:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,immediateRender:t.DEFAULT_SETTINGS.immediateRender,blendTime:t.DEFAULT_SETTINGS.blendTime,alwaysBlend:t.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:t.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:t.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:t.DEFAULT_SETTINGS.iOSDevice,debugMode:t.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:t.DEFAULT_SETTINGS.crossOriginPolicy,ajaxWithCredentials:t.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:t.DEFAULT_SETTINGS.placeholderFillStyle,opacity:t.DEFAULT_SETTINGS.opacity,preload:t.DEFAULT_SETTINGS.preload,compositeOperation:t.DEFAULT_SETTINGS.compositeOperation,subPixelRoundingForTransparency:t.DEFAULT_SETTINGS.subPixelRoundingForTransparency,maxTilesPerFrame:t.DEFAULT_SETTINGS.maxTilesPerFrame},i),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new t.Spring({initial:n,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new t.Spring({initial:s,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new t.Spring({initial:o,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new t.Spring({initial:h,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),a&&this.fitBounds(a,l,!0),this._ownAjaxHeaders={},this.setAjaxHeaders(u,!1),this._initialized=!0},t.extend(t.TiledImage.prototype,t.EventSource.prototype,{needsDraw:function(){return this._needsDraw},redraw:function(){this._needsDraw=!0},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(i){i!==this._fullyLoaded&&(this._fullyLoaded=i,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=t.now(),this._needsDraw=!0},update:function(i){let n=this._xSpring.update(),s=this._ySpring.update(),o=this._scaleSpring.update(),a=this._degreesSpring.update(),l=n||s||o||a||this._needsUpdate;if(l||i||!this._fullyLoaded){let h=this._updateLevelsForViewport();this._setFullyLoaded(h)}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(i){this._isTainted=i},isTainted(){return this._isTainted},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy(this.viewer)},getBounds:function(i){return this.getBoundsNoRotate(i).rotate(this.getRotation(i),this._getRotationPoint(i))},getBoundsNoRotate:function(i){return i?new t.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new t.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return t.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(i){var n=this.getBoundsNoRotate(i);if(this._clip){var s=i?this._worldWidthCurrent:this._worldWidthTarget,o=s/this.source.dimensions.x,a=this._clip.times(o);n=new t.Rect(n.x+a.x,n.y+a.y,a.width,a.height)}return n.rotate(this.getRotation(i),this._getRotationPoint(i))},getTileBounds:function(i,n,s){var o=this.source.getNumTiles(i),a=(o.x+n%o.x)%o.x,l=(o.y+s%o.y)%o.y,h=this.source.getTileBounds(i,a,l);return this.getFlip()&&(h.x=Math.max(0,1-h.x-h.width)),h.x+=(n-a)/o.x,h.y+=this._worldHeightCurrent/this._worldWidthCurrent*((s-l)/o.y),h},getContentSize:function(){return new t.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var i=this.imageToWindowCoordinates(new t.Point(0,0)),n=this.imageToWindowCoordinates(this.getContentSize());return new t.Point(n.x-i.x,n.y-i.y)},_viewportToImageDelta:function(i,n,s){var o=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(i*(this.source.dimensions.x/o),n*(this.source.dimensions.y*this.contentAspectX/o))},viewportToImageCoordinates:function(i,n,s){var o;return i instanceof t.Point?(s=n,o=i):o=new t.Point(i,n),o=o.rotate(-this.getRotation(s),this._getRotationPoint(s)),s?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(i,n,s){var o=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(i/this.source.dimensions.x*o,n/this.source.dimensions.y/this.contentAspectX*o)},imageToViewportCoordinates:function(i,n,s){i instanceof t.Point&&(s=n,n=i.y,i=i.x);var o=this._imageToViewportDelta(i,n,s);return s?(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(s),this._getRotationPoint(s))},imageToViewportRectangle:function(i,n,s,o,a){var l=i;l instanceof t.Rect?a=n:l=new t.Rect(i,n,s,o);var h=this.imageToViewportCoordinates(l.getTopLeft(),a),u=this._imageToViewportDelta(l.width,l.height,a);return new t.Rect(h.x,h.y,u.x,u.y,l.degrees+this.getRotation(a))},viewportToImageRectangle:function(i,n,s,o,a){var l=i;i instanceof t.Rect?a=n:l=new t.Rect(i,n,s,o);var h=this.viewportToImageCoordinates(l.getTopLeft(),a),u=this._viewportToImageDelta(l.width,l.height,a);return new t.Rect(h.x,h.y,u.x,u.y,l.degrees-this.getRotation(a))},viewerElementToImageCoordinates:function(i){var n=this.viewport.pointFromPixel(i,!0);return this.viewportToImageCoordinates(n)},imageToViewerElementCoordinates:function(i){var n=this.imageToViewportCoordinates(i);return this.viewport.pixelFromPoint(n,!0)},windowToImageCoordinates:function(i){var n=i.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(n)},imageToWindowCoordinates:function(i){var n=this.imageToViewerElementCoordinates(i);return n.plus(e.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(i){var n=this._scaleSpring.current.value;return i=i.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new t.Rect((i.x-this._xSpring.current.value)/n,(i.y-this._ySpring.current.value)/n,i.width/n,i.height/n,i.degrees)},viewportToImageZoom:function(i){var n=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return n*i},imageToViewportZoom:function(i){var n=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return i/n},setPosition:function(i,n){var s=this._xSpring.target.value===i.x&&this._ySpring.target.value===i.y;if(n){if(s&&this._xSpring.current.value===i.x&&this._ySpring.current.value===i.y)return;this._xSpring.resetTo(i.x),this._ySpring.resetTo(i.y),this._needsDraw=!0,this._needsUpdate=!0}else{if(s)return;this._xSpring.springTo(i.x),this._ySpring.springTo(i.y),this._needsDraw=!0,this._needsUpdate=!0}s||this._raiseBoundsChange()},setWidth:function(i,n){this._setScale(i,n)},setHeight:function(i,n){this._setScale(i/this.normHeight,n)},setCroppingPolygons:function(i){var n=function(o){return o instanceof t.Point||typeof o.x=="number"&&typeof o.y=="number"},s=function(o){return o.map(function(a){try{if(n(a))return{x:a.x,y:a.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!t.isArray(i))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=i.map(function(o){return s(o)}),this._needsDraw=!0}catch(o){t.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),t.console.error(o),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(i,n,s){n=n||t.Placement.CENTER;var o=t.Placement.properties[n],a=this.contentAspectX,l=0,h=0,u=1,c=1;if(this._clip&&(a=this._clip.getAspectRatio(),u=this._clip.width/this.source.dimensions.x,c=this._clip.height/this.source.dimensions.y,i.getAspectRatio()>a?(l=this._clip.x/this._clip.height*i.height,h=this._clip.y/this._clip.height*i.height):(l=this._clip.x/this._clip.width*i.width,h=this._clip.y/this._clip.width*i.width)),i.getAspectRatio()>a){var d=i.height/c,f=0;o.isHorizontallyCentered?f=(i.width-i.height*a)/2:o.isRight&&(f=i.width-i.height*a),this.setPosition(new t.Point(i.x-l+f,i.y-h),s),this.setHeight(d,s)}else{var g=i.width/u,p=0;o.isVerticallyCentered?p=(i.height-i.width/a)/2:o.isBottom&&(p=i.height-i.width/a),this.setPosition(new t.Point(i.x-l,i.y-h+p),s),this.setWidth(g,s)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(i){t.console.assert(!i||i instanceof t.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),i instanceof t.Rect?this._clip=i.clone():this._clip=null,this._needsUpdate=!0,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return this.flipped},setFlip:function(i){this.flipped=i},get flipped(){return this._flipped},set flipped(i){let n=this._flipped!==!!i;this._flipped=!!i,n&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(i){let n=this._wrapHorizontal!==!!i;this._wrapHorizontal=!!i,this._initialized&&n&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(i){let n=this._wrapVertical!==!!i;this._wrapVertical=!!i,this._initialized&&n&&(this.update(!0),this._needsDraw=!0)},get debugMode(){return this._debugMode},set debugMode(i){this._debugMode=!!i,this._needsDraw=!0},getOpacity:function(){return this.opacity},setOpacity:function(i){this.opacity=i},get opacity(){return this._opacity},set opacity(i){i!==this.opacity&&(this._opacity=i,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(i){this._preload=!!i,this._needsDraw=!0},getRotation:function(i){return i?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(i,n){this._degreesSpring.target.value===i&&this._degreesSpring.isAtTargetValue()||(n?this._degreesSpring.resetTo(i):this._degreesSpring.springTo(i),this._needsDraw=!0,this._needsUpdate=!0,this._raiseBoundsChange())},getDrawArea:function(){if(this._opacity===0&&!this._preload)return!1;var i=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var n=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));i=i.intersection(n)}return i},getTilesToDraw:function(){let i=this._tilesToDraw.flat();return this._updateTilesInViewport(i),i=this._tilesToDraw.flat(),i.forEach(n=>{n.tile.beingDrawn=!0}),this._lastDrawn=i,i},_getRotationPoint:function(i){return this.getBoundsNoRotate(i).getCenter()},get compositeOperation(){return this._compositeOperation},set compositeOperation(i){i!==this._compositeOperation&&(this._compositeOperation=i,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this._compositeOperation}))},getCompositeOperation:function(){return this._compositeOperation},setCompositeOperation:function(i){this.compositeOperation=i},setAjaxHeaders:function(i,n){if(i===null&&(i={}),!t.isPlainObject(i)){console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}this._ownAjaxHeaders=i,this._updateAjaxHeaders(n)},_updateAjaxHeaders:function(i){if(i===void 0&&(i=!0),t.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=t.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders,i){var n,s,o,a;for(var l in this.tilesMatrix){n=this.source.getNumTiles(l);for(var h in this.tilesMatrix[l]){s=(n.x+h%n.x)%n.x;for(var u in this.tilesMatrix[l][h])if(o=(n.y+u%n.y)%n.y,a=this.tilesMatrix[l][h][u],a.loadWithAjax=this.loadTilesWithAjax,a.loadWithAjax){var c=this.source.getTileAjaxHeaders(l,s,o);a.ajaxHeaders=t.extend({},this.ajaxHeaders,c)}else a.ajaxHeaders=null}}for(var d=0;d<this._imageLoader.jobQueue.length;d++){var f=this._imageLoader.jobQueue[d];f.loadWithAjax=f.tile.loadWithAjax,f.ajaxHeaders=f.tile.loadWithAjax?f.tile.ajaxHeaders:null}}},_setScale:function(i,n){var s=this._scaleSpring.target.value===i;if(n){if(s&&this._scaleSpring.current.value===i)return;this._scaleSpring.resetTo(i),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}else{if(s)return;this._scaleSpring.springTo(i),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}s||this._raiseBoundsChange()},_updateForScale:function(){this._worldWidthTarget=this._scaleSpring.target.value,this._worldHeightTarget=this.normHeight*this._scaleSpring.target.value,this._worldWidthCurrent=this._scaleSpring.current.value,this._worldHeightCurrent=this.normHeight*this._scaleSpring.current.value},_raiseBoundsChange:function(){this.raiseEvent("bounds-change")},_isBottomItem:function(){return this.viewer.world.getItemAt(0)===this},_getLevelsInterval:function(){var i=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),n=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,s=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(n/this.minPixelRatio)/Math.log(2))));return s=Math.max(s,this.source.minLevel||0),i=Math.min(i,s),{lowestLevel:i,highestLevel:s}},_updateLevelsForViewport:function(){var i=this._getLevelsInterval(),n=i.lowestLevel,s=i.highestLevel,o=[],a=this.getDrawArea(),l=t.now();if(this._lastDrawn.forEach(A=>{A.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!a)return this._needsDraw=!1,this._fullyLoaded;var h=new Array(s-n+1);for(let A=0,F=s;F>=n;F--,A++)h[A]=F;for(let A=s+1;A<=this.source.maxLevel;A++){var u=this.tilesMatrix[A]&&this.tilesMatrix[A][0]&&this.tilesMatrix[A][0][0];if(u&&u.isBottomMost&&u.isRightMost&&u.loaded){h.push(A);break}}let c=!1;for(let A=0;A<h.length;A++){let F=h[A];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(F),!0).x*this._scaleSpring.current.value;if(A===h.length-1||d>=this.minPixelRatio)c=!0;else if(!c)continue;var f=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(F),!1).x*this._scaleSpring.current.value,g=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,p=this.immediateRender?1:g,m=Math.min(1,(d-.5)/.5),v=p/Math.abs(p-f),y=this._updateLevel(F,m,v,a,l,o);o=y.bestTiles;var _=y.updatedTiles.filter(C=>C.loaded),w=(function(C,R,M){return function(k){return{tile:k,level:C,levelOpacity:R,currentTime:M}}})(F,m,l);if(this._tilesToDraw[F]=_.map(w),this._providesCoverage(this.coverage,F))break}return o&&o.length>0?(o.forEach(function(A){A&&!A.context2D&&this._loadTile(A,l)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(i){let n=t.now(),s=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let o=i.length?i[0].level:0;if(!this.getDrawArea())return;function l(u){let c=u.tile;if(c&&c.loaded){let d=s._blendTile(c,c.x,c.y,u.level,u.levelOpacity,n,o);s._isBlending=s._isBlending||d,s._needsDraw=s._needsDraw||d||s._wasBlending}}let h=0;for(let u=0;u<i.length;u++){let c=i[u];l(c),this._providesCoverage(this.coverage,c.level)&&(h=Math.max(h,c.level))}if(h>0)for(let u in this._tilesToDraw)u<h&&delete this._tilesToDraw[u]},_blendTile:function(i,n,s,o,a,l,h){let u=1e3*this.blendTime,c,d;return i.blendStart||(i.blendStart=l),c=l-i.blendStart,d=u?Math.min(1,c/u):1,o===h&&(d=1,c=u),this.alwaysBlend&&(d*=a),i.opacity=d,d===1&&(this._setCoverage(this.coverage,o,n,s,!0),this._hasOpaqueTile=!0),c<u},_updateLevel:function(i,n,s,o,a,l){var h=o.getBoundingBox().getTopLeft(),u=o.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:i,opacity:n,visibility:s,drawArea:o,topleft:h,bottomright:u,currenttime:a,best:l}),this._resetCoverage(this.coverage,i),this._resetCoverage(this.loadingCoverage,i);var c=this._getCornerTiles(i,h,u),d=c.topLeft,f=c.bottomRight,g=this.source.getNumTiles(i),p=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(f.x+=1,this.wrapHorizontal||(f.x=Math.min(f.x,g.x-1)));for(var m=Math.max(0,(f.x-d.x)*(f.y-d.y)),v=new Array(m),y=0,_=d.x;_<=f.x;_++)for(var w=d.y;w<=f.y;w++){var A;if(this.getFlip()){var F=(g.x+_%g.x)%g.x;A=_+g.x-F-F-1}else A=_;if(o.intersection(this.getTileBounds(i,A,w))!==null){var C=this._updateTile(A,w,i,s,p,g,a,l);l=C.bestTiles,v[y]=C.tile,y+=1}}return{bestTiles:l,updatedTiles:v}},_positionTile:function(i,n,s,o,a){var l=i.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 h=i.bounds.getSize();h.x*=this._scaleSpring.current.value,h.y*=this._scaleSpring.current.value,i.positionedBounds.x=l.x,i.positionedBounds.y=l.y,i.positionedBounds.width=h.x,i.positionedBounds.height=h.y;var u=s.pixelFromPointNoRotate(l,!0),c=s.pixelFromPointNoRotate(l,!1),d=s.deltaPixelsFromPointsNoRotate(h,!0),f=s.deltaPixelsFromPointsNoRotate(h,!1),g=c.plus(f.divide(2)),p=o.squaredDistanceTo(g);this.viewer.drawer.minimumOverlapRequired(this)&&(n||(d=d.plus(new t.Point(1,1))),i.isRightMost&&this.wrapHorizontal&&(d.x+=.75),i.isBottomMost&&this.wrapVertical&&(d.y+=.75)),i.position=u,i.size=d,i.squaredDistance=p,i.visibility=a},_updateTile:function(i,n,s,o,a,l,h,u){var c=this._getTile(i,n,s,h,l);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:c}),this._setCoverage(this.coverage,s,i,n,!1);var d=c.loaded||c.loading||this._isCovered(this.loadingCoverage,s,i,n);if(this._setCoverage(this.loadingCoverage,s,i,n,d),!c.exists)return{bestTiles:u,tile:c};if(c.loaded&&c.opacity===1&&this._setCoverage(this.coverage,s,i,n,!0),this._positionTile(c,this.source.tileOverlap,this.viewport,a,o),!c.loaded)if(c.context2D)this._setTileLoaded(c);else{var f=this._tileCache.getImageRecord(c.cacheKey);f&&this._setTileLoaded(c,f.getData())}return c.loading?this._tilesLoading++:d||(u=this._compareTiles(u,c,this.maxTilesPerFrame)),{bestTiles:u,tile:c}},_getCornerTiles:function(i,n,s){var o,a;this.wrapHorizontal?(o=t.positiveModulo(n.x,1),a=t.positiveModulo(s.x,1)):(o=Math.max(0,n.x),a=Math.min(1,s.x));var l,h,u=1/this.source.aspectRatio;this.wrapVertical?(l=t.positiveModulo(n.y,u),h=t.positiveModulo(s.y,u)):(l=Math.max(0,n.y),h=Math.min(u,s.y));var c=this.source.getTileAtPoint(i,new t.Point(o,l)),d=this.source.getTileAtPoint(i,new t.Point(a,h)),f=this.source.getNumTiles(i);return this.wrapHorizontal&&(c.x+=f.x*Math.floor(n.x),d.x+=f.x*Math.floor(s.x)),this.wrapVertical&&(c.y+=f.y*Math.floor(n.y/u),d.y+=f.y*Math.floor(s.y/u)),{topLeft:c,bottomRight:d}},_getTile:function(i,n,s,o,a){var l,h,u,c,d,f,g,p,m,v,y=this.tilesMatrix,_=this.source;return y[s]||(y[s]={}),y[s][i]||(y[s][i]={}),(!y[s][i][n]||!y[s][i][n].flipped!=!this.flipped)&&(l=(a.x+i%a.x)%a.x,h=(a.y+n%a.y)%a.y,u=this.getTileBounds(s,i,n),c=_.getTileBounds(s,l,h,!0),d=_.tileExists(s,l,h),f=_.getTileUrl(s,l,h),g=_.getTilePostData(s,l,h),this.loadTilesWithAjax?(p=_.getTileAjaxHeaders(s,l,h),t.isPlainObject(this.ajaxHeaders)&&(p=t.extend({},this.ajaxHeaders,p))):p=null,m=_.getContext2D?_.getContext2D(s,l,h):void 0,v=new t.Tile(s,i,n,u,d,f,m,this.loadTilesWithAjax,p,c,g,_.getTileHashKey(s,l,h,f,p,g)),this.getFlip()?l===0&&(v.isRightMost=!0):l===a.x-1&&(v.isRightMost=!0),h===a.y-1&&(v.isBottomMost=!0),v.flipped=this.flipped,y[s][i][n]=v),v=y[s][i][n],v.lastTouchTime=o,v},_loadTile:function(i,n){var s=this;i.loading=!0,this._imageLoader.addJob({src:i.getUrl(),tile:i,source:this.source,postData:i.postData,loadWithAjax:i.loadWithAjax,ajaxHeaders:i.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(o,a,l){s._onTileLoad(i,n,o,a,l)},abort:function(){i.loading=!1}})},_onTileLoad:function(i,n,s,o,a){if(s)i.exists=!0;else{t.console.error("Tile %s failed to load: %s - error: %s",i,i.getUrl(),o),this.viewer.raiseEvent("tile-load-failed",{tile:i,tiledImage:this,time:n,message:o,tileRequest:a}),i.loading=!1,i.exists=!1;return}if(n<this.lastResetTime){t.console.warn("Ignoring tile %s loaded before reset: %s",i,i.getUrl()),i.loading=!1;return}var l=this,h=function(){var u=l.source,c=u.getClosestLevel();l._setTileLoaded(i,s,c,a)};h()},_setTileLoaded:function(i,n,s,o){var a=0,l=!1,h=this;function u(){return l&&t.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),a++,c}function c(){a--,a===0&&(i.loading=!1,i.loaded=!0,i.hasTransparency=h.source.hasTransparency(i.context2D,i.getUrl(),i.ajaxHeaders,i.postData),i.context2D||h._tileCache.cacheTile({data:n,tile:i,cutoff:s,tiledImage:h}),h.viewer.raiseEvent("tile-ready",{tile:i,tiledImage:h,tileRequest:o}),h._needsDraw=!0)}var d=u();this.viewer.raiseEvent("tile-loaded",{tile:i,tiledImage:this,tileRequest:o,get image(){return t.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),n},data:n,getCompletionCallback:u}),l=!0,d()},_compareTiles:function(i,n,s){return i?(i.push(n),this._sortTiles(i),i.length>s&&i.pop(),i):[n]},_sortTiles:function(i){i.sort(function(n,s){return n===null?1:s===null?-1:n.visibility===s.visibility?n.squaredDistance-s.squaredDistance:s.visibility-n.visibility})},_providesCoverage:function(i,n,s,o){var a,l,h,u;if(!i[n])return!1;if(s===void 0||o===void 0){a=i[n];for(h in a)if(Object.prototype.hasOwnProperty.call(a,h)){l=a[h];for(u in l)if(Object.prototype.hasOwnProperty.call(l,u)&&!l[u])return!1}return!0}return i[n][s]===void 0||i[n][s][o]===void 0||i[n][s][o]===!0},_isCovered:function(i,n,s,o){return s===void 0||o===void 0?this._providesCoverage(i,n+1):this._providesCoverage(i,n+1,2*s,2*o)&&this._providesCoverage(i,n+1,2*s,2*o+1)&&this._providesCoverage(i,n+1,2*s+1,2*o)&&this._providesCoverage(i,n+1,2*s+1,2*o+1)},_setCoverage:function(i,n,s,o,a){if(!i[n]){t.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",n);return}i[n][s]||(i[n][s]={}),i[n][s][o]=a},_resetCoverage:function(i,n){i[n]={}}})})(e),(function(t){var i=function(s){t.console.assert(s,"[TileCache.cacheTile] options is required"),t.console.assert(s.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(s.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=s.tile,this.tiledImage=s.tiledImage},n=function(s){t.console.assert(s,"[ImageRecord] options is required"),t.console.assert(s.data,"[ImageRecord] options.data is required"),this._tiles=[],s.create.apply(null,[this,s.data,s.ownerTile]),this._destroyImplementation=s.destroy.bind(null,this),this.getImage=s.getImage.bind(null,this),this.getData=s.getData.bind(null,this),this.getRenderedContext=s.getRenderedContext.bind(null,this)};n.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(s){t.console.assert(s,"[ImageRecord.addTile] tile is required"),this._tiles.push(s)},removeTile:function(s){for(var o=0;o<this._tiles.length;o++)if(this._tiles[o]===s){this._tiles.splice(o,1);return}t.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",s)},getTileCount:function(){return this._tiles.length}},t.TileCache=function(s){s=s||{},this._maxImageCacheCount=s.maxImageCacheCount||t.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},t.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(s){t.console.assert(s,"[TileCache.cacheTile] options is required"),t.console.assert(s.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(s.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),t.console.assert(s.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var o=s.cutoff||0,a=this._tilesLoaded.length,l=this._imagesLoaded[s.tile.cacheKey];if(l||(s.data||(t.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future."),s.data=s.image),t.console.assert(s.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),l=this._imagesLoaded[s.tile.cacheKey]=new n({data:s.data,ownerTile:s.tile,create:s.tiledImage.source.createTileCache,destroy:s.tiledImage.source.destroyTileCache,getImage:s.tiledImage.source.getTileCacheDataAsImage,getData:s.tiledImage.source.getTileCacheData,getRenderedContext:s.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),l.addTile(s.tile),s.tile.cacheImageRecord=l,this._imagesLoadedCount>this._maxImageCacheCount){for(var h=null,u=-1,c=null,d,f,g,p,m,v,y=this._tilesLoaded.length-1;y>=0;y--)if(v=this._tilesLoaded[y],d=v.tile,!(d.level<=o||d.beingDrawn)){if(!h){h=d,u=y,c=v;continue}p=d.lastTouchTime,f=h.lastTouchTime,m=d.level,g=h.level,(p<f||p===f&&m>g)&&(h=d,u=y,c=v)}h&&u>=0&&(this._unloadTile(c),a=u)}this._tilesLoaded[a]=new i({tile:s.tile,tiledImage:s.tiledImage})},clearTilesFor:function(s){t.console.assert(s,"[TileCache.clearTilesFor] tiledImage is required");for(var o,a=0;a<this._tilesLoaded.length;++a)o=this._tilesLoaded[a],o.tiledImage===s&&(this._unloadTile(o),this._tilesLoaded.splice(a,1),a--)},getImageRecord:function(s){return t.console.assert(s,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[s]},_unloadTile:function(s){t.console.assert(s,"[TileCache._unloadTile] tileRecord is required");var o=s.tile,a=s.tiledImage;let l=o.getCanvasContext&&o.getCanvasContext();o.unload(),o.cacheImageRecord=null;var h=this._imagesLoaded[o.cacheKey];h&&(h.removeTile(o),h.getTileCount()||(h.destroy(),delete this._imagesLoaded[o.cacheKey],this._imagesLoadedCount--,l&&(l.canvas.width=0,l.canvas.height=0,a.viewer.raiseEvent("image-unloaded",{context2D:l,tile:o}))),a.viewer.raiseEvent("tile-unloaded",{tile:o,tiledImage:a}))}}})(e),(function(t){t.World=function(i){var n=this;t.console.assert(i.viewer,"[World] options.viewer is required"),t.EventSource.call(this),this.viewer=i.viewer,this._items=[],this._needsDraw=!1,this._autoRefigureSizes=!0,this._needsSizesFigured=!1,this._delegatedFigureSizes=function(s){n._autoRefigureSizes?n._figureSizes():n._needsSizesFigured=!0},this._figureSizes()},t.extend(t.World.prototype,t.EventSource.prototype,{addItem:function(i,n){if(t.console.assert(i,"[World.addItem] item is required"),t.console.assert(i instanceof t.TiledImage,"[World.addItem] only TiledImages supported at this time"),n=n||{},n.index!==void 0){var s=Math.max(0,Math.min(this._items.length,n.index));this._items.splice(s,0,i)}else this._items.push(i);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0,this._needsDraw=!0,i.addHandler("bounds-change",this._delegatedFigureSizes),i.addHandler("clip-change",this._delegatedFigureSizes),this.raiseEvent("add-item",{item:i})},getItemAt:function(i){return t.console.assert(i!==void 0,"[World.getItemAt] index is required"),this._items[i]},getIndexOfItem:function(i){return t.console.assert(i,"[World.getIndexOfItem] item is required"),t.indexOf(this._items,i)},getItemCount:function(){return this._items.length},setItemIndex:function(i,n){t.console.assert(i,"[World.setItemIndex] item is required"),t.console.assert(n!==void 0,"[World.setItemIndex] index is required");var s=this.getIndexOfItem(i);if(n>=this._items.length)throw new Error("Index bigger than number of layers.");n===s||s===-1||(this._items.splice(s,1),this._items.splice(n,0,i),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:i,previousIndex:s,newIndex:n}))},removeItem:function(i){t.console.assert(i,"[World.removeItem] item is required");var n=t.indexOf(this._items,i);n!==-1&&(i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy(),this._items.splice(n,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(i))},removeAll:function(){this.viewer._cancelPendingImages();var i,n;for(n=0;n<this._items.length;n++)i=this._items[n],i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy();var s=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,n=0;n<s.length;n++)i=s[n],this._raiseRemoveItem(i)},resetItems:function(){for(var i=0;i<this._items.length;i++)this._items[i].reset()},update:function(i){for(var n=!1,s=0;s<this._items.length;s++)n=this._items[s].update(i)||n;return n},draw:function(){this.viewer.drawer.draw(this._items),this._needsDraw=!1,this._items.forEach(i=>{this._needsDraw=i.setDrawn()||this._needsDraw})},needsDraw:function(){for(var i=0;i<this._items.length;i++)if(this._items[i].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(i){this._autoRefigureSizes=i,i&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(i){i=i||{};var n=i.immediately||!1,s=i.layout||t.DEFAULT_SETTINGS.collectionLayout,o=i.rows||t.DEFAULT_SETTINGS.collectionRows,a=i.columns||t.DEFAULT_SETTINGS.collectionColumns,l=i.tileSize||t.DEFAULT_SETTINGS.collectionTileSize,h=i.tileMargin||t.DEFAULT_SETTINGS.collectionTileMargin,u=l+h,c;!i.rows&&a?c=a:c=Math.ceil(this._items.length/o);var d=0,f=0,g,p,m,v,y;this.setAutoRefigureSizes(!1);for(var _=0;_<this._items.length;_++)_&&_%c===0&&(s==="horizontal"?(f+=u,d=0):(d+=u,f=0)),g=this._items[_],p=g.getBounds(),p.width>p.height?m=l:m=l*(p.width/p.height),v=m*(p.height/p.width),y=new t.Point(d+(l-m)/2,f+(l-v)/2),g.setPosition(y,n),g.setWidth(m,n),s==="horizontal"?d+=u:f+=u;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var i=this._homeBounds?this._homeBounds.clone():null,n=this._contentSize?this._contentSize.clone():null,s=this._contentFactor||0;if(!this._items.length)this._homeBounds=new t.Rect(0,0,1,1),this._contentSize=new t.Point(1,1),this._contentFactor=1;else{var o=this._items[0],a=o.getBounds();this._contentFactor=o.getContentSize().x/a.width;for(var l=o.getClippedBounds().getBoundingBox(),h=l.x,u=l.y,c=l.x+l.width,d=l.y+l.height,f=1;f<this._items.length;f++)o=this._items[f],a=o.getBounds(),this._contentFactor=Math.max(this._contentFactor,o.getContentSize().x/a.width),l=o.getClippedBounds().getBoundingBox(),h=Math.min(h,l.x),u=Math.min(u,l.y),c=Math.max(c,l.x+l.width),d=Math.max(d,l.y+l.height);this._homeBounds=new t.Rect(h,u,c-h,d-u),this._contentSize=new t.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==s||!this._homeBounds.equals(i)||!this._contentSize.equals(n))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(i){this.raiseEvent("remove-item",{item:i})}})})(e)})(Al)),Al.exports}var tw=ew();const Jn=Iu(tw);var iw=Object.defineProperty,rw=(r,e,t)=>e in r?iw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,xg=(r,e,t)=>rw(r,typeof e!="symbol"?e+"":e,t),wg=Object.prototype.hasOwnProperty;function $n(r,e){var t,i;if(r===e)return!0;if(r&&e&&(t=r.constructor)===e.constructor){if(t===Date)return r.getTime()===e.getTime();if(t===RegExp)return r.toString()===e.toString();if(t===Array){if((i=r.length)===e.length)for(;i--&&$n(r[i],e[i]););return i===-1}if(!t||typeof r=="object"){i=0;for(t in r)if(wg.call(r,t)&&++i&&!wg.call(e,t)||!(t in e)||!$n(r[t],e[t]))return!1;return Object.keys(e).length===i}}return r!==r&&e!==e}var Eg=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Eg||{});const nw=[];for(let r=0;r<256;++r)nw.push((r+256).toString(16).slice(1));typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const tc=r=>{const e=t=>{const i={...t};return t.created&&typeof t.created=="string"&&(i.created=new Date(t.created)),t.updated&&typeof t.updated=="string"&&(i.updated=new Date(t.updated)),i};return{...r,bodies:(r.bodies||[]).map(e),target:e(r.target)}},sw=(r,e)=>{const t=new Set(r.bodies.map(i=>i.id));return e.bodies.filter(i=>!t.has(i.id))},ow=(r,e)=>{const t=new Set(e.bodies.map(i=>i.id));return r.bodies.filter(i=>!t.has(i.id))},aw=(r,e)=>e.bodies.map(t=>{const i=r.bodies.find(n=>n.id===t.id);return{newBody:t,oldBody:i&&!$n(i,t)?i:void 0}}).filter(({oldBody:t})=>t).map(({oldBody:t,newBody:i})=>({oldBody:t,newBody:i})),lw=(r,e)=>!$n(r.target,e.target),hw=(r,e)=>{const t=sw(r,e),i=ow(r,e),n=aw(r,e);return{oldValue:r,newValue:e,bodiesCreated:t.length>0?t:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:n.length>0?n:void 0,targetUpdated:lw(r,e)?{oldTarget:r.target,newTarget:e.target}:void 0}};var fn=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(fn||{});const uw=(r,e)=>{const t=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),n=new Set((e.created||[]).map(c=>c.id)),s=new Set((e.deleted||[]).map(c=>c.id)),o=new Set((e.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((e.updated||[]).filter(({oldValue:c})=>t.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!s.has(c.id)).map(c=>o.has(c.id)?e.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...e.created||[]],h=[...(r.deleted||[]).filter(c=>!n.has(c.id)),...(e.deleted||[]).filter(c=>!t.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!s.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const g=e.updated.find(p=>p.oldValue.id===f.id).newValue;return hw(d,g)}else return c}),...(e.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let cw=()=>({emit(r,...e){for(let t=this.events[r]||[],i=0,n=t.length;i<n;i++)t[i](...e)},events:{},on(r,e){var t;return((t=this.events)[r]||(t[r]=[])).push(e),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(n=>e!==n)}}});const dw=250,fw=(r,e)=>{const t=cw(),i=(e==null?void 0:e.changes)||[];let n=e?e.pointer:-1,s=!1,o=0;const a=g=>{if(!s){const{changes:p}=g,m=performance.now();if(m-o>dw)i.splice(n+1),i.push(p),n=i.length-1;else{const v=i.length-1;i[v]=uw(i[v],p)}o=m}s=!1};r.observe(a,{origin:fn.LOCAL});const l=g=>g&&g.length>0&&r.bulkDeleteAnnotations(g),h=g=>g&&g.length>0&&r.bulkAddAnnotations(g,!1),u=g=>g&&g.length>0&&r.bulkUpdateAnnotations(g.map(({oldValue:p})=>p)),c=g=>g&&g.length>0&&r.bulkUpdateAnnotations(g.map(({newValue:p})=>p)),d=g=>g&&g.length>0&&r.bulkAddAnnotations(g,!1),f=g=>g&&g.length>0&&r.bulkDeleteAnnotations(g);return{canRedo:()=>i.length-1>n,canUndo:()=>n>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:n}),on:(g,p)=>t.on(g,p),redo:()=>{if(i.length-1>n){s=!0;const{created:g,updated:p,deleted:m}=i[n+1];h(g),c(p),f(m),t.emit("redo",i[n+1]),n+=1}},undo:()=>{if(n>-1){s=!0;const{created:g,updated:p,deleted:m}=i[n];l(g),u(p),d(m),t.emit("undo",i[n]),n-=1}}}},pw=(r,e,t,i)=>{const{hover:n,selection:s,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(v,y)=>{l.has(v)?l.get(v).push(y):l.set(v,[y])},f=(v,y)=>{const _=l.get(v);if(_){const w=_.indexOf(y);w!==-1&&_.splice(w,1)}},g=(v,y,_)=>{l.has(v)&&setTimeout(()=>{l.get(v).forEach(w=>{if(t){const A=Array.isArray(y)?y.map(C=>t.serialize(C)):t.serialize(y),F=_?_ instanceof PointerEvent?_:t.serialize(_):void 0;w(A,F)}else w(y,_)})},1)},p=()=>{const{selected:v}=s,y=(v||[]).map(({id:_})=>o.getAnnotation(_));y.forEach(_=>{const w=h.find(A=>A.id===_.id);(!w||!$n(w,_))&&g("updateAnnotation",_,w)}),h=h.map(_=>y.find(({id:w})=>w===_.id)||_)};s.subscribe(({selected:v})=>{if(!(h.length===0&&v.length===0)){if(h.length===0&&v.length>0)h=v.map(({id:y})=>o.getAnnotation(y));else if(h.length>0&&v.length===0)h.forEach(y=>{const _=o.getAnnotation(y.id);_&&!$n(_,y)&&g("updateAnnotation",_,y)}),h=[];else{const y=new Set(h.map(w=>w.id)),_=new Set(v.map(({id:w})=>w));h.filter(w=>!_.has(w.id)).forEach(w=>{const A=o.getAnnotation(w.id);A&&!$n(A,w)&&g("updateAnnotation",A,w)}),h=[...h.filter(w=>_.has(w.id)),...v.filter(({id:w})=>!y.has(w)).map(({id:w})=>o.getAnnotation(w))]}g("selectionChanged",h)}}),n.subscribe(v=>{!u&&v?g("mouseEnterAnnotation",o.getAnnotation(v)):u&&!v?g("mouseLeaveAnnotation",o.getAnnotation(u)):u&&v&&(g("mouseLeaveAnnotation",o.getAnnotation(u)),g("mouseEnterAnnotation",o.getAnnotation(v))),u=v}),a==null||a.subscribe(v=>g("viewportIntersect",v.map(y=>o.getAnnotation(y)))),o.observe(v=>{i&&(c&&clearTimeout(c),c=setTimeout(p,1e3));const{created:y,deleted:_}=v.changes;(y||[]).forEach(w=>g("createAnnotation",w)),(_||[]).forEach(w=>g("deleteAnnotation",w)),(v.changes.updated||[]).filter(w=>[...w.bodiesCreated||[],...w.bodiesDeleted||[],...w.bodiesUpdated||[]].length>0).forEach(({oldValue:w,newValue:A})=>{const F=h.find(C=>C.id===w.id)||w;h=h.map(C=>C.id===w.id?A:C),g("updateAnnotation",A,F)})},{origin:fn.LOCAL}),o.observe(v=>{if(h){const y=new Set(h.map(w=>w.id)),_=(v.changes.updated||[]).filter(({newValue:w})=>y.has(w.id)).map(({newValue:w})=>w);_.length>0&&(h=h.map(w=>_.find(A=>A.id===w.id)||w))}},{origin:fn.REMOTE});const m=v=>y=>{const{updated:_}=y;v?(_||[]).forEach(w=>g("updateAnnotation",w.oldValue,w.newValue)):(_||[]).forEach(w=>g("updateAnnotation",w.newValue,w.oldValue))};return e.on("undo",m(!0)),e.on("redo",m(!1)),{on:d,off:f,emit:g}},gw=r=>e=>e.reduce((t,i)=>{const{parsed:n,error:s}=r.parse(i);return s?{parsed:t.parsed,failed:[...t.failed,i]}:n?{parsed:[...t.parsed,n],failed:t.failed}:{...t}},{parsed:[],failed:[]}),mw=(r,e,t)=>{const{store:i,selection:n}=r,s=v=>{if(t){const{parsed:y,error:_}=t.parse(v);y?i.addAnnotation(y,fn.REMOTE):console.error(_)}else i.addAnnotation(tc(v),fn.REMOTE)},o=()=>n.clear(),a=()=>i.clear(),l=v=>{const y=i.getAnnotation(v);return t&&y?t.serialize(y):y},h=()=>t?i.all().map(t.serialize):i.all(),u=()=>{var v;const y=(((v=n.selected)==null?void 0:v.map(_=>_.id))||[]).map(_=>i.getAnnotation(_)).filter(Boolean);return t?y.map(t.serialize):y},c=(v,y=!0)=>fetch(v).then(_=>_.json()).then(_=>(f(_,y),_)),d=v=>{if(typeof v=="string"){const y=i.getAnnotation(v);if(i.deleteAnnotation(v),y)return t?t.serialize(y):y}else{const y=t?t.parse(v).parsed:v;if(y)return i.deleteAnnotation(y),v}},f=(v,y=!0)=>{if(t){const _=t.parseAll||gw(t),{parsed:w,failed:A}=_(v);A.length>0&&console.warn(`Discarded ${A.length} invalid annotations`,A),i.bulkAddAnnotations(w,y,fn.REMOTE)}else i.bulkAddAnnotations(v.map(tc),y,fn.REMOTE)},g=(v,y)=>{v?n.setSelected(v,y):n.clear()},p=v=>{n.setUserSelectAction(v)},m=v=>{if(t){const y=t.parse(v).parsed,_=t.serialize(i.getAnnotation(y.id));return i.updateAnnotation(y),_}else{const y=i.getAnnotation(v.id);return i.updateAnnotation(tc(v)),y}};return{addAnnotation:s,cancelSelected:o,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:e.getHistory,getSelected:u,loadAnnotations:c,redo:e.redo,removeAnnotation:d,setAnnotations:f,setSelected:g,setUserSelectAction:p,undo:e.undo,updateAnnotation:m}},vw="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let yw=r=>crypto.getRandomValues(new Uint8Array(r)),_w=(r,e,t)=>{let i=(2<<Math.log2(r.length-1))-1,n=-~(1.6*i*e/r.length);return(s=e)=>{let o="";for(;;){let a=t(n),l=n|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=s)return o}}},xw=(r,e=21)=>_w(r,e|0,yw),ww=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=vw[t[r]&63];return e};const Ew=()=>({isGuest:!0,id:xw("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()});ww();var Tw=Object.defineProperty,bw=(r,e,t)=>e in r?Tw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Tg=(r,e,t)=>bw(r,typeof e!="symbol"?e+"":e,t);function or(){}function ic(r,e){for(const t in e)r[t]=e[t];return r}function bg(r){return r()}function Ag(){return Object.create(null)}function Wi(r){r.forEach(bg)}function Ft(r){return typeof r=="function"}function pn(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Aw(r){return Object.keys(r).length===0}function Sw(r,e,t,i){if(r){const n=Sg(r,e,t,i);return r[0](n)}}function Sg(r,e,t,i){return r[1]&&i?ic(t.ctx.slice(),r[1](i(e))):t.ctx}function Rw(r,e,t,i){if(r[2]&&i){const n=r[2](i(t));if(e.dirty===void 0)return n;if(typeof n=="object"){const s=[],o=Math.max(e.dirty.length,n.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|n[a];return s}return e.dirty|n}return e.dirty}function Cw(r,e,t,i,n,s){if(n){const o=Sg(e,t,i,s);r.p(o,n)}}function Pw(r){if(r.ctx.length>32){const e=[],t=r.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}function Rg(r){const e={};for(const t in r)t[0]!=="$"&&(e[t]=r[t]);return e}function Cg(r){return r??""}function lt(r,e){r.appendChild(e)}function Le(r,e,t){r.insertBefore(e,t||null)}function De(r){r.parentNode&&r.parentNode.removeChild(r)}function Sl(r,e){for(let t=0;t<r.length;t+=1)r[t]&&r[t].d(e)}function be(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Pg(r){return document.createTextNode(r)}function pi(){return Pg(" ")}function Bs(){return Pg("")}function ot(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function I(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function Iw(r){return Array.from(r.childNodes)}function Ig(r,e,t){r.classList.toggle(e,!!t)}function Mw(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}let Xo;function Yo(r){Xo=r}function Mg(){if(!Xo)throw new Error("Function called outside component initialization");return Xo}function Rl(r){Mg().$$.on_mount.push(r)}function Zo(){const r=Mg();return(e,t,{cancelable:i=!1}={})=>{const n=r.$$.callbacks[e];if(n){const s=Mw(e,t,{cancelable:i});return n.slice().forEach(o=>{o.call(r,s)}),!s.defaultPrevented}return!0}}function jt(r,e){const t=r.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}const ks=[],Dg=[];let Us=[];const Og=[],Lg=Promise.resolve();let rc=!1;function Ng(){rc||(rc=!0,Lg.then(Bg))}function Fg(){return Ng(),Lg}function nc(r){Us.push(r)}const sc=new Set;let Hs=0;function Bg(){if(Hs!==0)return;const r=Xo;do{try{for(;Hs<ks.length;){const e=ks[Hs];Hs++,Yo(e),Dw(e.$$)}}catch(e){throw ks.length=0,Hs=0,e}for(Yo(null),ks.length=0,Hs=0;Dg.length;)Dg.pop()();for(let e=0;e<Us.length;e+=1){const t=Us[e];sc.has(t)||(sc.add(t),t())}Us.length=0}while(ks.length);for(;Og.length;)Og.pop()();rc=!1,sc.clear(),Yo(r)}function Dw(r){if(r.fragment!==null){r.update(),Wi(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(nc)}}function Ow(r){const e=[],t=[];Us.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),Us=e}const Cl=new Set;let es;function Gs(){es={r:0,c:[],p:es}}function Vs(){es.r||Wi(es.c),es=es.p}function at(r,e){r&&r.i&&(Cl.delete(r),r.i(e))}function _t(r,e,t,i){if(r&&r.o){if(Cl.has(r))return;Cl.add(r),es.c.push(()=>{Cl.delete(r),i&&(t&&r.d(1),i())}),r.o(e)}else i&&i()}function gn(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ar(r){r&&r.c()}function Xi(r,e,t){const{fragment:i,after_update:n}=r.$$;i&&i.m(e,t),nc(()=>{const s=r.$$.on_mount.map(bg).filter(Ft);r.$$.on_destroy?r.$$.on_destroy.push(...s):Wi(s),r.$$.on_mount=[]}),n.forEach(nc)}function Yi(r,e){const t=r.$$;t.fragment!==null&&(Ow(t.after_update),Wi(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Lw(r,e){r.$$.dirty[0]===-1&&(ks.push(r),Ng(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function mn(r,e,t,i,n,s,o=null,a=[-1]){const l=Xo;Yo(r);const h=r.$$={fragment:null,ctx:[],props:s,update:or,not_equal:n,bound:Ag(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Ag(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=t?t(r,e.props||{},(c,d,...f)=>{const g=f.length?f[0]:d;return h.ctx&&n(h.ctx[c],h.ctx[c]=g)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](g),u&&Lw(r,c)),d}):[],h.update(),u=!0,Wi(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const c=Iw(e.target);h.fragment&&h.fragment.l(c),c.forEach(De)}else h.fragment&&h.fragment.c();e.intro&&at(r.$$.fragment),Xi(r,e.target,e.anchor),Bg()}Yo(l)}class vn{constructor(){Tg(this,"$$"),Tg(this,"$$set")}$destroy(){Yi(this,1),this.$destroy=or}$on(e,t){if(!Ft(t))return or;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const n=i.indexOf(t);n!==-1&&i.splice(n,1)}}$set(e){this.$$set&&!Aw(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Nw="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Nw);var ht=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.POLYLINE="POLYLINE",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(ht||{}),Fw={exports:{}};(function(r){(function(){function e(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function t(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var g=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);g>1?(u=h.x,c=h.y):g>0&&(u+=d*g,c+=f*g)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],e(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function n(a,l,h,u,c){for(var d=u,f,g=l+1;g<h;g++){var p=t(a[g],a[l],a[h]);p>d&&(f=g,d=p)}d>u&&(f-l>1&&n(a,l,f,u,c),c.push(a[f]),h-f>1&&n(a,f,h,u,c))}function s(a,l){var h=a.length-1,u=[a[0]];return n(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=s(a,u),a}r.exports=o,r.exports.default=o})()})(Fw);const oc={},zs=(r,e)=>oc[r]=e,ac=r=>oc[r.type].area(r),Bw=(r,e,t,i)=>oc[r.type].intersects(r,e,t,i),lr=r=>{let e=1/0,t=1/0,i=-1/0,n=-1/0;return r.forEach(([s,o])=>{e=Math.min(e,s),t=Math.min(t,o),i=Math.max(i,s),n=Math.max(n,o)}),{minX:e,minY:t,maxX:i,maxY:n}},Pl=r=>{let e=0,t=r.length-1;for(let i=0;i<r.length;i++)e+=(r[t][0]+r[i][0])*(r[t][1]-r[i][1]),t=i;return Math.abs(.5*e)},Il=(r,e,t)=>{let i=!1;for(let n=0,s=r.length-1;n<r.length;s=n++){const o=r[n][0],a=r[n][1],l=r[s][0],h=r[s][1];a>t!=h>t&&e<(l-o)*(t-a)/(h-a)+o&&(i=!i)}return i},kw=(r,e=!0)=>{let t="M ";return r.forEach(([i,n],s)=>{s===0?t+=`${i},${n}`:t+=` L ${i},${n}`}),e&&(t+=" Z"),t},Ml=(r,e)=>{const t=Math.abs(e[0]-r[0]),i=Math.abs(e[1]-r[1]);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},Uw={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,e,t)=>{const{cx:i,cy:n,rx:s,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=e-i,c=t-n,d=l*u+h*c,f=h*u-l*c;return d*d/(s*s)+f*f/(o*o)<=1}};zs(ht.ELLIPSE,Uw);const Hw={area:r=>0,intersects:(r,e,t,i=2)=>{const[[n,s],[o,a]]=r.geometry.points,l=Math.abs((a-s)*e-(o-n)*t+o*s-a*n),h=Ml([n,s],[o,a]);return l/h<=i}};zs(ht.LINE,Hw);const Gw={area:r=>{const{polygons:e}=r.geometry;return e.reduce((t,i)=>{const[n,...s]=i.rings,o=Pl(n.points),a=s.reduce((l,h)=>l+Pl(h.points),0);return t+o-a},0)},intersects:(r,e,t)=>{const{polygons:i}=r.geometry;for(const n of i){const[s,...o]=n.rings;if(Il(s.points,e,t)){let a=!1;for(const l of o)if(Il(l.points,e,t)){a=!0;break}if(!a)return!0}}return!1}},lc=r=>{const e=r.reduce((t,i)=>[...t,...i.rings[0].points],[]);return lr(e)},yn=r=>r.rings.map(e=>kw(e.points)).join(" "),Vw=r=>r.polygons.reduce((e,t)=>[...e,...t.rings.reduce((i,n)=>[...i,...n.points],[])],[]);zs(ht.MULTIPOLYGON,Gw);const zw={area:r=>{const e=r.geometry.points;return Pl(e)},intersects:(r,e,t)=>{const i=r.geometry.points;return Il(i,e,t)}};zs(ht.POLYGON,zw);const jw={area:r=>{const e=r.geometry;if(!e.closed||e.points.length<3)return 0;const t=kg(e.points,e.closed);return Pl(t)},intersects:(r,e,t,i=2)=>{const n=r.geometry;if(n.closed){const s=kg(n.points,n.closed);return Il(s,e,t)}else return Ww(n,[e,t],i)}},kg=(r,e=!1)=>{const t=[];for(let i=0;i<r.length;i++){const n=r[i],s=r[(i+1)%r.length];if(t.push(n.point),(i<r.length-1||e)&&(n.type==="CURVE"||s.type=="CURVE")){const o=Ug(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);t.push(...o.slice(1))}}return t},Ug=(r,e,t,i,n=10)=>{const s=[];for(let o=0;o<=n;o++){const a=o/n,l=Math.pow(1-a,3)*r[0]+3*Math.pow(1-a,2)*a*e[0]+3*(1-a)*Math.pow(a,2)*t[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*r[1]+3*Math.pow(1-a,2)*a*e[1]+3*(1-a)*Math.pow(a,2)*t[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},Ww=(r,e,t)=>{for(let i=0;i<r.points.length-1;i++){const n=r.points[i],s=r.points[i+1];if(n.type==="CURVE"||s.type==="CURVE"){const o=Ug(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(Hg(e,o[a],o[a+1])<=t)return!0}else if(Hg(e,n.point,s.point)<=t)return!0}return!1},Hg=(r,e,t)=>{const[i,n]=r,[s,o]=e,[a,l]=t,h=a-s,u=l-o,c=Math.sqrt(h*h+u*u);if(c===0)return Math.sqrt((i-s)*(i-s)+(n-o)*(n-o));const d=((i-s)*h+(n-o)*u)/(c*c);return d<=0?Math.sqrt((i-s)*(i-s)+(n-o)*(n-o)):d>=1?Math.sqrt((i-a)*(i-a)+(n-l)*(n-l)):Math.abs((l-o)*i-(a-s)*n+a*o-l*s)/c},Xw=r=>{if(!r.points||r.points.length===0)return"";const e=[],t=r.points[0];e.push(`M ${t.point[0]} ${t.point[1]}`);for(let i=1;i<r.points.length;i++){const n=r.points[i],s=r.points[i-1];if(n.type==="CURVE"||s.type==="CURVE"){const o=s.type==="CURVE"&&s.outHandle||s.point,a=n.type==="CURVE"&&n.inHandle||n.point,l=n.point;e.push(`C ${o[0]} ${o[1]} ${a[0]} ${a[1]} ${l[0]} ${l[1]}`)}else e.push(`L ${n.point[0]} ${n.point[1]}`)}if(r.closed){const i=r.points[r.points.length-1],n=r.points[0];if(i.type==="CURVE"||n.type==="CURVE"){const s=i.outHandle||i.point,o=n.inHandle||n.point,a=n.point;e.push(`C ${s[0]} ${s[1]} ${o[0]} ${o[1]} ${a[0]} ${a[1]}`)}e.push("Z")}return e.join(" ")};zs(ht.POLYLINE,jw);const Yw={area:r=>r.geometry.w*r.geometry.h,intersects:(r,e,t)=>e>=r.geometry.x&&e<=r.geometry.x+r.geometry.w&&t>=r.geometry.y&&t<=r.geometry.y+r.geometry.h};zs(ht.RECTANGLE,Yw);const _n=r=>Dl(r.target),Dl=r=>{var e,t;return(r==null?void 0:r.annotation)!==void 0&&((t=(e=r==null?void 0:r.selector)==null?void 0:e.geometry)==null?void 0:t.bounds)!==void 0},Zw=[];for(let r=0;r<256;++r)Zw.push((r+256).toString(16).slice(1));typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var Gg=Object.prototype.hasOwnProperty;function qo(r,e){var t,i;if(r===e)return!0;if(r&&e&&(t=r.constructor)===e.constructor){if(t===Date)return r.getTime()===e.getTime();if(t===RegExp)return r.toString()===e.toString();if(t===Array){if((i=r.length)===e.length)for(;i--&&qo(r[i],e[i]););return i===-1}if(!t||typeof r=="object"){i=0;for(t in r)if(Gg.call(r,t)&&++i&&!Gg.call(e,t)||!(t in e)||!qo(r[t],e[t]))return!1;return Object.keys(e).length===i}}return r!==r&&e!==e}let qw=Symbol("clean"),hr=[],xn=0;const Ol=4;let hc=r=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(i){return t.lc=e.push(i),()=>{for(let s=xn+Ol;s<hr.length;)hr[s]===i?hr.splice(s,Ol):s+=Ol;let n=e.indexOf(i);~n&&(e.splice(n,1),--t.lc||t.off())}},notify(i,n){let s=!hr.length;for(let o of e)hr.push(o,t.value,i,n);if(s){for(xn=0;xn<hr.length;xn+=Ol)hr[xn](hr[xn+1],hr[xn+2],hr[xn+3]);hr.length=0}},off(){},set(i){let n=t.value;n!==i&&(t.value=i,t.notify(n))},subscribe(i){let n=t.listen(i);return i(t.value),n},value:r};return process.env.NODE_ENV!=="production"&&(t[qw]=()=>{e=[],t.lc=0,t.off()}),t};const Kw=r=>{const e=hc(null);return r.observe(({changes:t})=>{const i=e.get();if(i){(t.deleted||[]).some(s=>s.id===i)&&e.set(null);const n=(t.updated||[]).find(({oldValue:s})=>s.id===i);n&&e.set(n.newValue.id)}}),{get current(){return e.get()},subscribe:e.subscribe.bind(e),set:e.set.bind(e)}},uc={selected:[]},Qw=(r,e,t)=>{const i=hc(uc);let n=e;const s=()=>{qo(i.get(),uc)||i.set(uc)},o=()=>{var f;return((f=i.get().selected)==null?void 0:f.length)===0},a=f=>{if(o())return!1;const g=typeof f=="string"?f:f.id;return i.get().selected.some(p=>p.id===g)},l=(f,g)=>{let p;if(Array.isArray(f)){if(p=f.map(v=>r.getAnnotation(v)).filter(Boolean),p.length<f.length){console.warn("Invalid selection: "+f.filter(v=>!p.some(y=>y.id===v)));return}}else{const v=r.getAnnotation(f);if(!v){console.warn("Invalid selection: "+f);return}p=[v]}const m=p.reduce((v,y)=>{const _=d(y);return _==="EDIT"?[...v,{id:y.id,editable:!0}]:_==="SELECT"?[...v,{id:y.id}]:v},[]);i.set({selected:m,event:g})},h=(f,g)=>{const p=Array.isArray(f)?f:[f],m=p.map(v=>r.getAnnotation(v)).filter(v=>!!v);i.set({selected:m.map(v=>{const y=g===void 0?d(v)==="EDIT":g;return{id:v.id,editable:y}})}),m.length!==p.length&&console.warn("Invalid selection",f)},u=f=>{if(o())return!1;const{selected:g}=i.get();g.some(({id:p})=>f.includes(p))&&i.set({selected:g.filter(({id:p})=>!f.includes(p))})},c=f=>{n=f,h(i.get().selected.map(({id:g})=>g))},d=f=>Jw(f,n,t);return r.observe(({changes:f})=>u((f.deleted||[]).map(g=>g.id))),{get event(){const f=i.get();return f?f.event:null},get selected(){const f=i.get();return f?[...f.selected]:null},get userSelectAction(){return n},clear:s,evalSelectAction:d,isEmpty:o,isSelected:a,setSelected:h,setUserSelectAction:c,subscribe:i.subscribe.bind(i),userSelect:l}},Jw=(r,e,t)=>{const i=t?t.serialize(r):r;return typeof e=="function"?e(i):e||"EDIT"},$t=[];for(let r=0;r<256;++r)$t.push((r+256).toString(16).slice(1));function $w(r,e=0){return($t[r[e+0]]+$t[r[e+1]]+$t[r[e+2]]+$t[r[e+3]]+"-"+$t[r[e+4]]+$t[r[e+5]]+"-"+$t[r[e+6]]+$t[r[e+7]]+"-"+$t[r[e+8]]+$t[r[e+9]]+"-"+$t[r[e+10]]+$t[r[e+11]]+$t[r[e+12]]+$t[r[e+13]]+$t[r[e+14]]+$t[r[e+15]]).toLowerCase()}let cc;const eE=new Uint8Array(16);function tE(){if(!cc){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");cc=crypto.getRandomValues.bind(crypto)}return cc(eE)}const iE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Vg={randomUUID:iE};function rE(r,e,t){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??tE();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,$w(n)}function nE(r,e,t){return Vg.randomUUID&&!r?Vg.randomUUID():rE(r)}const sE=(r,e)=>{const t=new Set(r.bodies.map(i=>i.id));return e.bodies.filter(i=>!t.has(i.id))},oE=(r,e)=>{const t=new Set(e.bodies.map(i=>i.id));return r.bodies.filter(i=>!t.has(i.id))},aE=(r,e)=>e.bodies.map(t=>{const i=r.bodies.find(n=>n.id===t.id);return{newBody:t,oldBody:i&&!qo(i,t)?i:void 0}}).filter(({oldBody:t})=>t).map(({oldBody:t,newBody:i})=>({oldBody:t,newBody:i})),lE=(r,e)=>!qo(r.target,e.target),hE=(r,e)=>{const t=sE(r,e),i=oE(r,e),n=aE(r,e);return{oldValue:r,newValue:e,bodiesCreated:t.length>0?t:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:n.length>0?n:void 0,targetUpdated:lE(r,e)?{oldTarget:r.target,newTarget:e.target}:void 0}};var Wt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Wt||{});const uE=(r,e)=>{var t,i;const{changes:n,origin:s}=e;if(!(r.options.origin?r.options.origin===s:s!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(n.created)||a(n.deleted))){const l=(t=n.updated)==null?void 0:t.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=n.updated)==null?void 0:i.some(u=>u.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(n.created||[]).map(a=>a.id),...(n.deleted||[]).map(a=>a.id),...(n.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},Ll=r=>{const e=r.id===void 0?nE():r.id;return{...r,id:e,bodies:r.bodies===void 0?[]:r.bodies.map(t=>({...t,annotation:e})),target:{...r.target,annotation:e}}},cE=r=>r.id!==void 0,dE=()=>{const r=new Map,e=new Map,t=[],i=(D,S={})=>{t.push({onChange:D,options:S})},n=D=>{const S=t.findIndex(b=>b.onChange==D);S>-1&&t.splice(S,1)},s=(D,S)=>{const b={origin:D,changes:{created:S.created||[],updated:S.updated||[],deleted:S.deleted||[]},state:[...r.values()]};t.forEach(O=>{uE(O,b)&&O.onChange(b)})},o=(D,S=Wt.LOCAL)=>{if(D.id&&r.get(D.id))throw Error(`Cannot add annotation ${D.id} - exists already`);{const b=Ll(D);r.set(b.id,b),b.bodies.forEach(O=>e.set(O.id,b.id)),s(S,{created:[b]})}},a=(D,S)=>{const b=Ll(typeof D=="string"?S:D),O=typeof D=="string"?D:D.id,j=O&&r.get(O);if(j){const V=hE(j,b);return O===b.id?r.set(O,b):(r.delete(O),r.set(b.id,b)),j.bodies.forEach(Y=>e.delete(Y.id)),b.bodies.forEach(Y=>e.set(Y.id,b.id)),V}else console.warn(`Cannot update annotation ${O} - does not exist`)},l=(D,S=Wt.LOCAL,b=Wt.LOCAL)=>{const O=cE(S)?b:S,j=a(D,S);j&&s(O,{updated:[j]})},h=(D,S=Wt.LOCAL)=>{r.get(D.id)?l(D,S):o(D,S)},u=(D,S=Wt.LOCAL)=>{const b=D.reduce((O,j)=>{const V=a(j);return V?[...O,V]:O},[]);b.length>0&&s(S,{updated:b})},c=(D,S=Wt.LOCAL)=>{const b=D.map(Ll),{toAdd:O,toUpdate:j}=b.reduce((Y,G)=>r.get(G.id)?{...Y,toUpdate:[...Y.toUpdate,G]}:{...Y,toAdd:[...Y.toAdd,G]},{toAdd:[],toUpdate:[]}),V=j.map(Y=>a(Y,S)).filter(Boolean);O.forEach(Y=>{r.set(Y.id,Y),Y.bodies.forEach(G=>e.set(G.id,Y.id))}),s(S,{created:O,updated:V})},d=(D,S=Wt.LOCAL)=>{const b=r.get(D.annotation);if(b){const O={...b,bodies:[...b.bodies,D]};r.set(b.id,O),e.set(D.id,O.id),s(S,{updated:[{oldValue:b,newValue:O,bodiesCreated:[D]}]})}else console.warn(`Attempt to add body to missing annotation: ${D.annotation}`)},f=()=>[...r.values()],g=(D=Wt.LOCAL)=>{const S=[...r.values()];r.clear(),e.clear(),s(D,{deleted:S})},p=(D,S=!0,b=Wt.LOCAL)=>{const O=D.map(Ll);if(S){const j=[...r.values()];r.clear(),e.clear(),O.forEach(V=>{r.set(V.id,V),V.bodies.forEach(Y=>e.set(Y.id,V.id))}),s(b,{created:O,deleted:j})}else{const j=D.reduce((V,Y)=>{const G=Y.id&&r.get(Y.id);return G?[...V,G]:V},[]);if(j.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${j.map(V=>V.id).join(", ")}`);O.forEach(V=>{r.set(V.id,V),V.bodies.forEach(Y=>e.set(Y.id,V.id))}),s(b,{created:O})}},m=D=>{const S=typeof D=="string"?D:D.id,b=r.get(S);if(b)return r.delete(S),b.bodies.forEach(O=>e.delete(O.id)),b;console.warn(`Attempt to delete missing annotation: ${S}`)},v=(D,S=Wt.LOCAL)=>{const b=m(D);b&&s(S,{deleted:[b]})},y=(D,S=Wt.LOCAL)=>{const b=D.reduce((O,j)=>{const V=m(j);return V?[...O,V]:O},[]);b.length>0&&s(S,{deleted:b})},_=D=>{const S=r.get(D.annotation);if(S){const b=S.bodies.find(O=>O.id===D.id);if(b){e.delete(b.id);const O={...S,bodies:S.bodies.filter(j=>j.id!==D.id)};return r.set(S.id,O),{oldValue:S,newValue:O,bodiesDeleted:[b]}}else console.warn(`Attempt to delete missing body ${D.id} from annotation ${D.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${D.annotation}`)},w=(D,S=Wt.LOCAL)=>{const b=_(D);b&&s(S,{updated:[b]})},A=(D,S=Wt.LOCAL)=>{const b=D.map(O=>_(O)).filter(Boolean);b.length>0&&s(S,{updated:b})},F=D=>{const S=r.get(D);return S?{...S}:void 0},C=D=>{const S=e.get(D);if(S){const b=F(S).bodies.find(O=>O.id===D);if(b)return b;console.error(`Store integrity error: body ${D} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${D}`)},R=(D,S)=>{if(D.annotation!==S.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const b=r.get(D.annotation);if(b){const O=b.bodies.find(V=>V.id===D.id),j={...b,bodies:b.bodies.map(V=>V.id===O.id?S:V)};return r.set(b.id,j),O.id!==S.id&&(e.delete(O.id),e.set(S.id,j.id)),{oldValue:b,newValue:j,bodiesUpdated:[{oldBody:O,newBody:S}]}}else console.warn(`Attempt to add body to missing annotation ${D.annotation}`)},M=(D,S,b=Wt.LOCAL)=>{const O=R(D,S);O&&s(b,{updated:[O]})},k=(D,S=Wt.LOCAL)=>{const b=D.map(O=>R({id:O.id,annotation:O.annotation},O)).filter(Boolean);s(S,{updated:b})},z=D=>{const S=r.get(D.annotation);if(S){const b={...S,target:{...S.target,...D}};return r.set(S.id,b),{oldValue:S,newValue:b,targetUpdated:{oldTarget:S.target,newTarget:D}}}else console.warn(`Attempt to update target on missing annotation: ${D.annotation}`)};return{addAnnotation:o,addBody:d,all:f,bulkAddAnnotations:p,bulkDeleteAnnotations:y,bulkDeleteBodies:A,bulkUpdateAnnotations:u,bulkUpdateBodies:k,bulkUpdateTargets:(D,S=Wt.LOCAL)=>{const b=D.map(O=>z(O)).filter(Boolean);b.length>0&&s(S,{updated:b})},bulkUpsertAnnotations:c,clear:g,deleteAnnotation:v,deleteBody:w,getAnnotation:F,getBody:C,observe:i,unobserve:n,updateAnnotation:l,updateBody:M,updateTarget:(D,S=Wt.LOCAL)=>{const b=z(D);b&&s(S,{updated:[b]})},upsertAnnotation:h}},fE=()=>{const r=hc([]);return{subscribe:r.subscribe.bind(r),set:r.set.bind(r)}},pE="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";((r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=pE[t[r]&63];return e})();const Nl=(r,e=0)=>{const{minX:t,minY:i,maxX:n,maxY:s}=r;return{x:t-e,y:i-e,w:n-t+2*e,h:s-i+2*e}},ur=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,gE=r=>({}),zg=r=>({grab:r[0]});function mE(r){let e,t,i,n;const s=r[8].default,o=Sw(s,r,r[7],zg);return{c(){e=be("g"),o&&o.c(),I(e,"class","a9s-annotation selected")},m(a,l){Le(a,e,l),o&&o.m(e,null),t=!0,i||(n=[ot(e,"pointerup",r[2]),ot(e,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!t||l&128)&&Cw(o,s,a,a[7],t?Rw(s,a[7],l,gE):Pw(a[7]),zg)},i(a){t||(at(o,a),t=!0)},o(a){_t(o,a),t=!1},d(a){a&&De(e),o&&o.d(a),i=!1,Wi(n)}}}function vE(r,e,t){let{$$slots:i={},$$scope:n}=e;const s=Zo();let{shape:o}=e,{editor:a}=e,{transform:l}=e,{svgEl:h}=e,u,c,d;const f=m=>v=>{if(u=m,h){const{left:y,top:_}=h.getBoundingClientRect(),w=v.clientX-y,A=v.clientY-_;c=l.elementToImage(w,A)}else{const{offsetX:y,offsetY:_}=v;c=l.elementToImage(y,_)}d=o,v.target.setPointerCapture(v.pointerId),s("grab",v)},g=m=>{if(u){const[v,y]=l.elementToImage(m.offsetX,m.offsetY),_=[v-c[0],y-c[1]];t(3,o=a(d,u,_)),s("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),u=void 0,d=o,s("release",m)};return r.$$set=m=>{"shape"in m&&t(3,o=m.shape),"editor"in m&&t(4,a=m.editor),"transform"in m&&t(5,l=m.transform),"svgEl"in m&&t(6,h=m.svgEl),"$$scope"in m&&t(7,n=m.$$scope)},[f,g,p,o,a,l,h,n,i]}class dc extends vn{constructor(e){super(),mn(this,e,vE,mE,pn,{shape:3,editor:4,transform:5,svgEl:6})}}function yE(r){let e,t,i,n,s,o,a,l,h=r[3]&&jg(r);return{c(){e=be("g"),t=be("circle"),h&&h.c(),n=be("circle"),I(t,"class","a9s-handle-buffer svelte-qtyc7s"),I(t,"cx",r[0]),I(t,"cy",r[1]),I(t,"r",i=r[5]+6/r[2]),I(t,"role","button"),I(t,"tabindex","0"),I(n,"class",s=Cg(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-qtyc7s"),I(n,"cx",r[0]),I(n,"cy",r[1]),I(n,"r",r[5]),I(e,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(u,c){Le(u,e,c),lt(e,t),h&&h.m(e,null),lt(e,n),a||(l=[ot(t,"dblclick",r[12]),ot(t,"pointerenter",r[13]),ot(t,"pointerleave",r[14]),ot(t,"pointerdown",r[15]),ot(t,"pointerdown",r[6]),ot(t,"pointerup",r[16]),ot(t,"pointerup",r[7])],a=!0)},p(u,c){c&1&&I(t,"cx",u[0]),c&2&&I(t,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&I(t,"r",i),u[3]?h?h.p(u,c):(h=jg(u),h.c(),h.m(e,n)):h&&(h.d(1),h=null),c&8&&s!==(s=Cg(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-qtyc7s")&&I(n,"class",s),c&1&&I(n,"cx",u[0]),c&2&&I(n,"cy",u[1]),c&32&&I(n,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&I(e,"class",o)},d(u){u&&De(e),h&&h.d(),a=!1,Wi(l)}}}function _E(r){let e,t,i,n,s,o,a,l,h;return{c(){e=be("g"),t=be("circle"),n=be("circle"),o=be("circle"),I(t,"cx",r[0]),I(t,"cy",r[1]),I(t,"r",i=r[5]*10),I(t,"class","a9s-touch-halo"),Ig(t,"touched",r[4]),I(n,"cx",r[0]),I(n,"cy",r[1]),I(n,"r",s=r[5]+10/r[2]),I(n,"class","a9s-handle-buffer svelte-qtyc7s"),I(n,"role","button"),I(n,"tabindex","0"),I(o,"class","a9s-handle-dot"),I(o,"cx",r[0]),I(o,"cy",r[1]),I(o,"r",a=r[5]+2/r[2]),I(e,"class","a9s-touch-handle")},m(u,c){Le(u,e,c),lt(e,t),lt(e,n),lt(e,o),l||(h=[ot(n,"dblclick",r[9]),ot(n,"pointerdown",r[10]),ot(n,"pointerdown",r[6]),ot(n,"pointerup",r[11]),ot(n,"pointerup",r[7])],l=!0)},p(u,c){c&1&&I(t,"cx",u[0]),c&2&&I(t,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&I(t,"r",i),c&16&&Ig(t,"touched",u[4]),c&1&&I(n,"cx",u[0]),c&2&&I(n,"cy",u[1]),c&36&&s!==(s=u[5]+10/u[2])&&I(n,"r",s),c&1&&I(o,"cx",u[0]),c&2&&I(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&I(o,"r",a)},d(u){u&&De(e),l=!1,Wi(h)}}}function jg(r){let e,t;return{c(){e=be("circle"),I(e,"class","a9s-handle-selected"),I(e,"cx",r[0]),I(e,"cy",r[1]),I(e,"r",t=r[5]+8/r[2])},m(i,n){Le(i,e,n)},p(i,n){n&1&&I(e,"cx",i[0]),n&2&&I(e,"cy",i[1]),n&36&&t!==(t=i[5]+8/i[2])&&I(e,"r",t)},d(i){i&&De(e)}}}function xE(r){let e;function t(n,s){return ur?_E:yE}let i=t()(r);return{c(){i.c(),e=Bs()},m(n,s){i.m(n,s),Le(n,e,s)},p(n,[s]){i.p(n,s)},i:or,o:or,d(n){n&&De(e),i.d(n)}}}function wE(r,e,t){let i,{x:n}=e,{y:s}=e,{scale:o}=e,{selected:a=void 0}=e,l=!1;const h=_=>{_.pointerType==="touch"&&t(4,l=!0)},u=()=>t(4,l=!1);function c(_){jt.call(this,r,_)}function d(_){jt.call(this,r,_)}function f(_){jt.call(this,r,_)}function g(_){jt.call(this,r,_)}function p(_){jt.call(this,r,_)}function m(_){jt.call(this,r,_)}function v(_){jt.call(this,r,_)}function y(_){jt.call(this,r,_)}return r.$$set=_=>{t(8,e=ic(ic({},e),Rg(_))),"x"in _&&t(0,n=_.x),"y"in _&&t(1,s=_.y),"scale"in _&&t(2,o=_.scale),"selected"in _&&t(3,a=_.selected)},r.$$.update=()=>{r.$$.dirty&4&&t(5,i=4/o)},e=Rg(e),[n,s,o,a,l,i,h,u,e,c,d,f,g,p,m,v,y]}class js extends vn{constructor(e){super(),mn(this,e,wE,xE,pn,{x:0,y:1,scale:2,selected:3})}}function EE(r){let e,t,i,n,s,o,a;return{c(){e=be("g"),t=be("circle"),n=be("circle"),s=be("circle"),I(t,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),I(t,"cx",r[0]),I(t,"cy",r[1]),I(t,"r",i=1.75*r[2]),I(n,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),I(n,"cx",r[0]),I(n,"cy",r[1]),I(n,"r",r[2]),I(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),I(s,"cx",r[0]),I(s,"cy",r[1]),I(s,"r",r[2]),I(e,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){Le(l,e,h),lt(e,t),lt(e,n),lt(e,s),o||(a=[ot(t,"pointerdown",r[5]),ot(t,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&I(t,"cx",l[0]),h&2&&I(t,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&I(t,"r",i),h&1&&I(n,"cx",l[0]),h&2&&I(n,"cy",l[1]),h&4&&I(n,"r",l[2]),h&1&&I(s,"cx",l[0]),h&2&&I(s,"cy",l[1]),h&4&&I(s,"r",l[2])},d(l){l&&De(e),o=!1,Wi(a)}}}function TE(r){let e;return{c(){e=be("circle"),I(e,"cx",r[0]),I(e,"cy",r[1]),I(e,"r",r[2])},m(t,i){Le(t,e,i)},p(t,i){i&1&&I(e,"cx",t[0]),i&2&&I(e,"cy",t[1]),i&4&&I(e,"r",t[2])},d(t){t&&De(e)}}}function bE(r){let e;function t(n,s){return ur?TE:EE}let i=t()(r);return{c(){i.c(),e=Bs()},m(n,s){i.m(n,s),Le(n,e,s)},p(n,[s]){i.p(n,s)},i:or,o:or,d(n){n&&De(e),i.d(n)}}}function AE(r,e,t){let i,{x:n}=e,{y:s}=e,{scale:o}=e;const a=h=>{h.pointerType};function l(h){jt.call(this,r,h)}return r.$$set=h=>{"x"in h&&t(0,n=h.x),"y"in h&&t(1,s=h.y),"scale"in h&&t(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&t(2,i=4/o)},[n,s,i,a,o,l]}class Wg extends vn{constructor(e){super(),mn(this,e,AE,bE,pn,{x:0,y:1,scale:4})}}function fc(r){const e=r.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Xg(r,e,t){const i=r.slice();return i[28]=e[t],i[30]=t,i}function pc(r){const e=r.slice(),t=e[10][e[6]];return e[28]=t.point,e}function gc(r){const e=r.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Yg(r){let e,t,i,n;return{c(){e=be("circle"),I(e,"cx",t=r[28][0]),I(e,"cy",i=r[28][1]),I(e,"r",n=Ko/r[3]),I(e,"class","svelte-1h2slbm")},m(s,o){Le(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[28][0])&&I(e,"cx",t),o[0]&1088&&i!==(i=s[28][1])&&I(e,"cy",i),o[0]&8&&n!==(n=Ko/s[3])&&I(e,"r",n)},d(s){s&&De(e)}}}function Zg(r){let e,t,i,n,s,o,a,l,h,u;return{c(){e=be("mask"),t=be("rect"),a=be("circle"),I(t,"x",i=r[9].x),I(t,"y",n=r[9].y),I(t,"width",s=r[9].w),I(t,"height",o=r[9].h),I(t,"class","svelte-1h2slbm"),I(a,"cx",l=r[28][0]),I(a,"cy",h=r[28][1]),I(a,"r",u=Ko/r[3]),I(a,"class","svelte-1h2slbm"),I(e,"id",`${r[19]}-inner`),I(e,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){Le(c,e,d),lt(e,t),lt(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&I(t,"x",i),d[0]&512&&n!==(n=c[9].y)&&I(t,"y",n),d[0]&512&&s!==(s=c[9].w)&&I(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&I(t,"height",o),d[0]&1088&&l!==(l=c[28][0])&&I(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&I(a,"cy",h),d[0]&8&&u!==(u=Ko/c[3])&&I(a,"r",u)},d(c){c&&De(e)}}}function qg(r){let e,t;return e=new js({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),e.$on("pointerenter",r[11]),e.$on("pointerleave",r[12]),e.$on("pointerdown",r[15]),e.$on("pointerdown",function(){Ft(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),e.$on("pointerup",r[16](r[30])),{c(){ar(e.$$.fragment)},m(i,n){Xi(e,i,n),t=!0},p(i,n){r=i;const s={};n[0]&32&&(s.x=r[28][0]),n[0]&32&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),n[0]&256&&(s.selected=r[8].includes(r[30])),e.$set(s)},i(i){t||(at(e.$$.fragment,i),t=!0)},o(i){_t(e.$$.fragment,i),t=!1},d(i){Yi(e,i)}}}function Kg(r){let e,t;return e=new Wg({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),e.$on("pointerdown",function(){Ft(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){ar(e.$$.fragment)},m(i,n){Xi(e,i,n),t=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[28][0]),n[0]&1088&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),e.$set(s)},i(i){t||(at(e.$$.fragment,i),t=!0)},o(i){_t(e.$$.fragment,i),t=!1},d(i){Yi(e,i)}}}function SE(r){let e,t,i,n,s,o,a,l,h,u,c,d,f,g,p,m,v,y,_,w,A,F=r[6]!==void 0&&!r[7]&&Yg(gc(r)),C=r[6]!==void 0&&!r[7]&&Zg(pc(r)),R=gn(r[5].points),M=[];for(let D=0;D<R.length;D+=1)M[D]=qg(Xg(r,R,D));const k=D=>_t(M[D],1,1,()=>{M[D]=null});let z=r[6]!==void 0&&!r[7]&&Kg(fc(r));return{c(){e=be("defs"),t=be("mask"),i=be("rect"),l=be("polygon"),F&&F.c(),C&&C.c(),u=pi(),c=be("polygon"),f=pi(),g=be("polygon"),m=pi();for(let D=0;D<M.length;D+=1)M[D].c();v=pi(),z&&z.c(),y=Bs(),I(i,"x",n=r[9].x),I(i,"y",s=r[9].y),I(i,"width",o=r[9].w),I(i,"height",a=r[9].h),I(i,"class","svelte-1h2slbm"),I(l,"points",h=r[5].points.map(Qg).join(" ")),I(l,"class","svelte-1h2slbm"),I(t,"id",`${r[19]}-outer`),I(t,"class","a9s-polygon-editor-mask svelte-1h2slbm"),I(c,"class","a9s-outer"),I(c,"mask",`url(#${r[19]}-outer)`),I(c,"points",d=r[5].points.map(Jg).join(" ")),I(g,"class","a9s-inner a9s-shape-handle"),I(g,"mask",`url(#${r[19]}-inner)`),I(g,"style",r[1]),I(g,"points",p=r[5].points.map($g).join(" "))},m(D,S){Le(D,e,S),lt(e,t),lt(t,i),lt(t,l),F&&F.m(t,null),C&&C.m(e,null),Le(D,u,S),Le(D,c,S),Le(D,f,S),Le(D,g,S),Le(D,m,S);for(let b=0;b<M.length;b+=1)M[b]&&M[b].m(D,S);Le(D,v,S),z&&z.m(D,S),Le(D,y,S),_=!0,w||(A=[ot(c,"pointerup",r[14]),ot(c,"pointerdown",function(){Ft(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),ot(g,"pointermove",r[13]),ot(g,"pointerup",r[14]),ot(g,"pointerdown",function(){Ft(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],w=!0)},p(D,S){if(r=D,(!_||S[0]&512&&n!==(n=r[9].x))&&I(i,"x",n),(!_||S[0]&512&&s!==(s=r[9].y))&&I(i,"y",s),(!_||S[0]&512&&o!==(o=r[9].w))&&I(i,"width",o),(!_||S[0]&512&&a!==(a=r[9].h))&&I(i,"height",a),(!_||S[0]&32&&h!==(h=r[5].points.map(Qg).join(" ")))&&I(l,"points",h),r[6]!==void 0&&!r[7]?F?F.p(gc(r),S):(F=Yg(gc(r)),F.c(),F.m(t,null)):F&&(F.d(1),F=null),r[6]!==void 0&&!r[7]?C?C.p(pc(r),S):(C=Zg(pc(r)),C.c(),C.m(e,null)):C&&(C.d(1),C=null),(!_||S[0]&32&&d!==(d=r[5].points.map(Jg).join(" ")))&&I(c,"points",d),(!_||S[0]&2)&&I(g,"style",r[1]),(!_||S[0]&32&&p!==(p=r[5].points.map($g).join(" ")))&&I(g,"points",p),S[0]&134322472){R=gn(r[5].points);let b;for(b=0;b<R.length;b+=1){const O=Xg(r,R,b);M[b]?(M[b].p(O,S),at(M[b],1)):(M[b]=qg(O),M[b].c(),at(M[b],1),M[b].m(v.parentNode,v))}for(Gs(),b=R.length;b<M.length;b+=1)k(b);Vs()}r[6]!==void 0&&!r[7]?z?(z.p(fc(r),S),S[0]&192&&at(z,1)):(z=Kg(fc(r)),z.c(),at(z,1),z.m(y.parentNode,y)):z&&(Gs(),_t(z,1,1,()=>{z=null}),Vs())},i(D){if(!_){for(let S=0;S<R.length;S+=1)at(M[S]);at(z),_=!0}},o(D){M=M.filter(Boolean);for(let S=0;S<M.length;S+=1)_t(M[S]);_t(z),_=!1},d(D){D&&(De(e),De(u),De(c),De(f),De(g),De(m),De(v),De(y)),F&&F.d(),C&&C.d(),Sl(M,D),z&&z.d(D),w=!1,Wi(A)}}}function RE(r){let e,t;return e=new dc({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[SE,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),e.$on("change",r[20]),e.$on("grab",r[21]),e.$on("release",r[22]),{c(){ar(e.$$.fragment)},m(i,n){Xi(e,i,n),t=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&134219754|n[1]&1&&(s.$$scope={dirty:n,ctx:i}),e.$set(s)},i(i){t||(at(e.$$.fragment,i),t=!0)},o(i){_t(e.$$.fragment,i),t=!1},d(i){Yi(e,i)}}}const CE=250,PE=1e3,IE=12,Ko=4.5,Qg=r=>r.join(","),Jg=r=>r.join(","),$g=r=>r.join(",");function ME(r,e,t){let i,n,s;const o=Zo();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,g,p=[];const m=()=>t(7,f=!0),v=()=>t(7,f=!1),y=b=>{if(p.length>0||!n.some(X=>X.visible)){t(6,d=void 0);return}const[O,j]=h.elementToImage(b.offsetX,b.offsetY),V=X=>Math.pow(X[0]-O,2)+Math.pow(X[1]-j,2),Y=i.points.reduce((X,K)=>V(K)<V(X)?K:X),G=n.filter(X=>X.visible).reduce((X,K)=>V(K.point)<V(X.point)?K:X),H=Math.pow(PE/u,2);V(Y)<H||V(G.point)<H?t(6,d=n.indexOf(G)):t(6,d=void 0)},_=()=>{document.activeElement!==c&&c.focus()},w=()=>{t(8,p=[]),_()},A=b=>{t(7,f=!0),b.preventDefault(),b.stopPropagation(),g=performance.now()},F=b=>O=>{if(!g||ur||performance.now()-g>CE)return;const j=p.includes(b);O.metaKey||O.ctrlKey||O.shiftKey?j?t(8,p=p.filter(V=>V!==b)):t(8,p=[...p,b]):j&&p.length>1?t(8,p=[b]):j?t(8,p=[]):t(8,p=[b]),_()},C=(b,O,j)=>{_();let V;const Y=b.geometry;p.length>1?V=Y.points.map(([H,X],K)=>p.includes(K)?[H+j[0],X+j[1]]:[H,X]):O==="SHAPE"?V=Y.points.map(([H,X])=>[H+j[0],X+j[1]]):V=Y.points.map(([H,X],K)=>O===`HANDLE-${K}`?[H+j[0],X+j[1]]:[H,X]);const G=lr(V);return{...b,geometry:{points:V,bounds:G}}},R=b=>async O=>{O.stopPropagation();const j=[...i.points.slice(0,b+1),n[b].point,...i.points.slice(b+1)],V=lr(j);o("change",{...a,geometry:{points:j,bounds:V}}),await Fg();const Y=[...document.querySelectorAll(".a9s-handle")][b+1];if(Y!=null&&Y.firstChild){const G=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:O.clientX,clientY:O.clientY,pointerId:O.pointerId,pointerType:O.pointerType,isPrimary:O.isPrimary,buttons:O.buttons});Y.firstChild.dispatchEvent(G)}},M=()=>{if(i.points.length-p.length<3)return;const b=i.points.filter((j,V)=>!p.includes(V)),O=lr(b);o("change",{...a,geometry:{points:b,bounds:O}}),t(8,p=[])};Rl(()=>{if(ur)return;const b=O=>{(O.key==="Delete"||O.key==="Backspace")&&(O.preventDefault(),M())};return c.addEventListener("pointermove",y),c.addEventListener("keydown",b),()=>{c.removeEventListener("pointermove",y),c.removeEventListener("keydown",b)}});const k=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function z(b){jt.call(this,r,b)}function D(b){jt.call(this,r,b)}function S(b){jt.call(this,r,b)}return r.$$set=b=>{"shape"in b&&t(0,a=b.shape),"computedStyle"in b&&t(1,l=b.computedStyle),"transform"in b&&t(2,h=b.transform),"viewportScale"in b&&t(3,u=b.viewportScale),"svgEl"in b&&t(4,c=b.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&t(5,i=a.geometry),r.$$.dirty[0]&40&&t(10,n=ur?[]:i.points.map((b,O)=>{const j=O===i.points.length-1?i.points[0]:i.points[O+1],V=(b[0]+j[0])/2,Y=(b[1]+j[1])/2,G=Math.sqrt(Math.pow(j[0]-V,2)+Math.pow(j[1]-Y,2))>IE/u;return{point:[V,Y],visible:G}})),r.$$.dirty[0]&40&&t(9,s=Nl(i.bounds,Ko/u))},[a,l,h,u,c,i,d,f,p,s,n,m,v,y,w,A,F,C,R,k,z,D,S]}class DE extends vn{constructor(e){super(),mn(this,e,ME,RE,pn,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function OE(r){let e,t,i,n,s,o,a,l,h,u,c,d,f,g,p,m,v,y,_,w,A,F,C,R,M,k,z,D,S,b,O,j,V,Y,G,H,X,K,Q,W,$,ne,_e,pe,Ce,Pe,Be,ke,Ge,$e,ft,Pt,x,L,q;return Pe=new js({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),Pe.$on("pointerdown",function(){Ft(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),ke=new js({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),ke.$on("pointerdown",function(){Ft(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),$e=new js({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),$e.$on("pointerdown",function(){Ft(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Pt=new js({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Pt.$on("pointerdown",function(){Ft(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){e=be("defs"),t=be("mask"),i=be("rect"),l=be("rect"),f=pi(),g=be("rect"),_=pi(),w=be("rect"),M=pi(),k=be("rect"),b=pi(),O=be("rect"),G=pi(),H=be("rect"),W=pi(),$=be("rect"),Ce=pi(),ar(Pe.$$.fragment),Be=pi(),ar(ke.$$.fragment),Ge=pi(),ar($e.$$.fragment),ft=pi(),ar(Pt.$$.fragment),I(i,"class","rect-mask-bg svelte-1njczvj"),I(i,"x",n=r[6].x),I(i,"y",s=r[6].y),I(i,"width",o=r[6].w),I(i,"height",a=r[6].h),I(l,"class","rect-mask-fg svelte-1njczvj"),I(l,"x",h=r[5].x),I(l,"y",u=r[5].y),I(l,"width",c=r[5].w),I(l,"height",d=r[5].h),I(t,"id",r[8]),I(t,"class","a9s-rectangle-editor-mask svelte-1njczvj"),I(g,"class","a9s-outer"),I(g,"mask",`url(#${r[8]})`),I(g,"x",p=r[5].x),I(g,"y",m=r[5].y),I(g,"width",v=r[5].w),I(g,"height",y=r[5].h),I(w,"class","a9s-inner a9s-shape-handle"),I(w,"style",r[1]),I(w,"x",A=r[5].x),I(w,"y",F=r[5].y),I(w,"width",C=r[5].w),I(w,"height",R=r[5].h),I(k,"class","a9s-edge-handle a9s-edge-handle-top"),I(k,"x",z=r[5].x),I(k,"y",D=r[5].y),I(k,"height",1),I(k,"width",S=r[5].w),I(O,"class","a9s-edge-handle a9s-edge-handle-right"),I(O,"x",j=r[5].x+r[5].w),I(O,"y",V=r[5].y),I(O,"height",Y=r[5].h),I(O,"width",1),I(H,"class","a9s-edge-handle a9s-edge-handle-bottom"),I(H,"x",X=r[5].x),I(H,"y",K=r[5].y+r[5].h),I(H,"height",1),I(H,"width",Q=r[5].w),I($,"class","a9s-edge-handle a9s-edge-handle-left"),I($,"x",ne=r[5].x),I($,"y",_e=r[5].y),I($,"height",pe=r[5].h),I($,"width",1)},m(ee,J){Le(ee,e,J),lt(e,t),lt(t,i),lt(t,l),Le(ee,f,J),Le(ee,g,J),Le(ee,_,J),Le(ee,w,J),Le(ee,M,J),Le(ee,k,J),Le(ee,b,J),Le(ee,O,J),Le(ee,G,J),Le(ee,H,J),Le(ee,W,J),Le(ee,$,J),Le(ee,Ce,J),Xi(Pe,ee,J),Le(ee,Be,J),Xi(ke,ee,J),Le(ee,Ge,J),Xi($e,ee,J),Le(ee,ft,J),Xi(Pt,ee,J),x=!0,L||(q=[ot(g,"pointerdown",function(){Ft(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),ot(w,"pointerdown",function(){Ft(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),ot(k,"pointerdown",function(){Ft(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),ot(O,"pointerdown",function(){Ft(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),ot(H,"pointerdown",function(){Ft(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),ot($,"pointerdown",function(){Ft(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],L=!0)},p(ee,J){r=ee,(!x||J&64&&n!==(n=r[6].x))&&I(i,"x",n),(!x||J&64&&s!==(s=r[6].y))&&I(i,"y",s),(!x||J&64&&o!==(o=r[6].w))&&I(i,"width",o),(!x||J&64&&a!==(a=r[6].h))&&I(i,"height",a),(!x||J&32&&h!==(h=r[5].x))&&I(l,"x",h),(!x||J&32&&u!==(u=r[5].y))&&I(l,"y",u),(!x||J&32&&c!==(c=r[5].w))&&I(l,"width",c),(!x||J&32&&d!==(d=r[5].h))&&I(l,"height",d),(!x||J&32&&p!==(p=r[5].x))&&I(g,"x",p),(!x||J&32&&m!==(m=r[5].y))&&I(g,"y",m),(!x||J&32&&v!==(v=r[5].w))&&I(g,"width",v),(!x||J&32&&y!==(y=r[5].h))&&I(g,"height",y),(!x||J&2)&&I(w,"style",r[1]),(!x||J&32&&A!==(A=r[5].x))&&I(w,"x",A),(!x||J&32&&F!==(F=r[5].y))&&I(w,"y",F),(!x||J&32&&C!==(C=r[5].w))&&I(w,"width",C),(!x||J&32&&R!==(R=r[5].h))&&I(w,"height",R),(!x||J&32&&z!==(z=r[5].x))&&I(k,"x",z),(!x||J&32&&D!==(D=r[5].y))&&I(k,"y",D),(!x||J&32&&S!==(S=r[5].w))&&I(k,"width",S),(!x||J&32&&j!==(j=r[5].x+r[5].w))&&I(O,"x",j),(!x||J&32&&V!==(V=r[5].y))&&I(O,"y",V),(!x||J&32&&Y!==(Y=r[5].h))&&I(O,"height",Y),(!x||J&32&&X!==(X=r[5].x))&&I(H,"x",X),(!x||J&32&&K!==(K=r[5].y+r[5].h))&&I(H,"y",K),(!x||J&32&&Q!==(Q=r[5].w))&&I(H,"width",Q),(!x||J&32&&ne!==(ne=r[5].x))&&I($,"x",ne),(!x||J&32&&_e!==(_e=r[5].y))&&I($,"y",_e),(!x||J&32&&pe!==(pe=r[5].h))&&I($,"height",pe);const xe={};J&32&&(xe.x=r[5].x),J&32&&(xe.y=r[5].y),J&8&&(xe.scale=r[3]),Pe.$set(xe);const re={};J&32&&(re.x=r[5].x+r[5].w),J&32&&(re.y=r[5].y),J&8&&(re.scale=r[3]),ke.$set(re);const Ue={};J&32&&(Ue.x=r[5].x+r[5].w),J&32&&(Ue.y=r[5].y+r[5].h),J&8&&(Ue.scale=r[3]),$e.$set(Ue);const it={};J&32&&(it.x=r[5].x),J&32&&(it.y=r[5].y+r[5].h),J&8&&(it.scale=r[3]),Pt.$set(it)},i(ee){x||(at(Pe.$$.fragment,ee),at(ke.$$.fragment,ee),at($e.$$.fragment,ee),at(Pt.$$.fragment,ee),x=!0)},o(ee){_t(Pe.$$.fragment,ee),_t(ke.$$.fragment,ee),_t($e.$$.fragment,ee),_t(Pt.$$.fragment,ee),x=!1},d(ee){ee&&(De(e),De(f),De(g),De(_),De(w),De(M),De(k),De(b),De(O),De(G),De(H),De(W),De($),De(Ce),De(Be),De(Ge),De(ft)),Yi(Pe,ee),Yi(ke,ee),Yi($e,ee),Yi(Pt,ee),L=!1,Wi(q)}}}function LE(r){let e,t;return e=new dc({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[OE,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),e.$on("grab",r[9]),e.$on("change",r[10]),e.$on("release",r[11]),{c(){ar(e.$$.fragment)},m(i,n){Xi(e,i,n),t=!0},p(i,[n]){const s={};n&1&&(s.shape=i[0]),n&4&&(s.transform=i[2]),n&16&&(s.svgEl=i[4]),n&12394&&(s.$$scope={dirty:n,ctx:i}),e.$set(s)},i(i){t||(at(e.$$.fragment,i),t=!0)},o(i){_t(e.$$.fragment,i),t=!1},d(i){Yi(e,i)}}}function NE(r,e,t){let i,n,{shape:s}=e,{computedStyle:o}=e,{transform:a}=e,{viewportScale:l=1}=e,{svgEl:h}=e;const u=(p,m,v)=>{const y=p.geometry.bounds;let[_,w]=[y.minX,y.minY],[A,F]=[y.maxX,y.maxY];const[C,R]=v;if(m==="SHAPE")_+=C,A+=C,w+=R,F+=R;else{switch(m){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{w+=R;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{F+=R;break}}switch(m){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=C;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{A+=C;break}}}const M=Math.min(_,A),k=Math.min(w,F),z=Math.abs(A-_),D=Math.abs(F-w);return{...p,geometry:{x:M,y:k,w:z,h:D,bounds:{minX:M,minY:k,maxX:M+z,maxY:k+D}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(p){jt.call(this,r,p)}function f(p){jt.call(this,r,p)}function g(p){jt.call(this,r,p)}return r.$$set=p=>{"shape"in p&&t(0,s=p.shape),"computedStyle"in p&&t(1,o=p.computedStyle),"transform"in p&&t(2,a=p.transform),"viewportScale"in p&&t(3,l=p.viewportScale),"svgEl"in p&&t(4,h=p.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&t(5,i=s.geometry),r.$$.dirty&40&&t(6,n=Nl(i.bounds,2/l))},[s,o,a,l,h,i,n,u,c,d,f,g]}class FE extends vn{constructor(e){super(),mn(this,e,NE,LE,pn,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var em=Object.prototype.hasOwnProperty;function mc(r,e){var t,i;if(r===e)return!0;if(r&&e&&(t=r.constructor)===e.constructor){if(t===Date)return r.getTime()===e.getTime();if(t===RegExp)return r.toString()===e.toString();if(t===Array){if((i=r.length)===e.length)for(;i--&&mc(r[i],e[i]););return i===-1}if(!t||typeof r=="object"){i=0;for(t in r)if(em.call(r,t)&&++i&&!em.call(e,t)||!(t in e)||!mc(r[t],e[t]))return!1;return Object.keys(e).length===i}}return r!==r&&e!==e}const BE=12,kE=(r,e)=>r.polygons.reduce((t,i,n)=>{const s=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],f=(u[0]+d[0])/2,g=(u[1]+d[1])/2,p=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-g,2))>BE/e;return{point:[f,g],visible:p,elementIdx:n,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...t,...s]},[]);function vc(r){const e=r.slice(),t=e[10][e[6]];return e[29]=t.point,e}function tm(r,e,t){const i=r.slice();return i[30]=e[t],i[32]=t,i}function im(r,e,t){const i=r.slice();return i[33]=e[t],i[35]=t,i}function rm(r,e,t){const i=r.slice();return i[29]=e[t],i[37]=t,i}function yc(r){const e=r.slice(),t=e[10][e[6]];return e[29]=t.point,e}function _c(r){const e=r.slice(),t=e[10][e[6]];return e[29]=t.point,e}function nm(r){let e,t,i,n;return{c(){e=be("circle"),I(e,"cx",t=r[29][0]),I(e,"cy",i=r[29][1]),I(e,"r",n=Qo/r[3]),I(e,"class","svelte-1vxo6dc")},m(s,o){Le(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[29][0])&&I(e,"cx",t),o[0]&1088&&i!==(i=s[29][1])&&I(e,"cy",i),o[0]&8&&n!==(n=Qo/s[3])&&I(e,"r",n)},d(s){s&&De(e)}}}function sm(r){let e,t,i,n,s,o,a,l,h,u;return{c(){e=be("mask"),t=be("rect"),a=be("circle"),I(t,"x",i=r[9].x),I(t,"y",n=r[9].y),I(t,"width",s=r[9].w),I(t,"height",o=r[9].h),I(t,"class","svelte-1vxo6dc"),I(a,"cx",l=r[29][0]),I(a,"cy",h=r[29][1]),I(a,"r",u=Qo/r[3]),I(a,"class","svelte-1vxo6dc"),I(e,"id",`${r[18]}-${r[32]}-inner`),I(e,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){Le(c,e,d),lt(e,t),lt(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&I(t,"x",i),d[0]&512&&n!==(n=c[9].y)&&I(t,"y",n),d[0]&512&&s!==(s=c[9].w)&&I(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&I(t,"height",o),d[0]&1088&&l!==(l=c[29][0])&&I(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&I(a,"cy",h),d[0]&8&&u!==(u=Qo/c[3])&&I(a,"r",u)},d(c){c&&De(e)}}}function om(r){let e,t;function i(...n){return r[19](r[32],r[35],r[37],...n)}return e=new js({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),e.$on("pointerenter",r[11]),e.$on("pointerleave",r[12]),e.$on("pointerdown",r[14]),e.$on("pointerdown",function(){Ft(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),e.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){ar(e.$$.fragment)},m(n,s){Xi(e,n,s),t=!0},p(n,s){r=n;const o={};s[0]&32&&(o.x=r[29][0]),s[0]&32&&(o.y=r[29][1]),s[0]&8&&(o.scale=r[3]),s[0]&256&&(o.selected=r[8].some(i)),e.$set(o)},i(n){t||(at(e.$$.fragment,n),t=!0)},o(n){_t(e.$$.fragment,n),t=!1},d(n){Yi(e,n)}}}function am(r){let e,t,i=gn(r[33].points),n=[];for(let o=0;o<i.length;o+=1)n[o]=om(rm(r,i,o));const s=o=>_t(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();e=Bs()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);Le(o,e,a),t=!0},p(o,a){if(a[0]&268491048){i=gn(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=rm(o,i,l);n[l]?(n[l].p(h,a),at(n[l],1)):(n[l]=om(h),n[l].c(),at(n[l],1),n[l].m(e.parentNode,e))}for(Gs(),l=i.length;l<n.length;l+=1)s(l);Vs()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)at(n[a]);t=!0}},o(o){n=n.filter(Boolean);for(let a=0;a<n.length;a+=1)_t(n[a]);t=!1},d(o){o&&De(e),Sl(n,o)}}}function lm(r){let e,t,i,n,s,o,a,l,h,u,c,d,f,g,p,m,v,y=r[6]!==void 0&&!r[7]&&nm(_c(r)),_=r[6]!==void 0&&!r[7]&&sm(yc(r)),w=gn(r[30].rings),A=[];for(let C=0;C<w.length;C+=1)A[C]=am(im(r,w,C));const F=C=>_t(A[C],1,1,()=>{A[C]=null});return{c(){e=be("g"),t=be("defs"),i=be("mask"),n=be("rect"),h=be("path"),y&&y.c(),_&&_.c(),c=be("path"),f=be("path");for(let C=0;C<A.length;C+=1)A[C].c();I(n,"x",s=r[9].x),I(n,"y",o=r[9].y),I(n,"width",a=r[9].w),I(n,"height",l=r[9].h),I(n,"class","svelte-1vxo6dc"),I(h,"d",u=yn(r[30])),I(h,"class","svelte-1vxo6dc"),I(i,"id",`${r[18]}-${r[32]}-outer`),I(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),I(c,"class","a9s-outer"),I(c,"mask",`url(#${r[18]}-${r[32]}-outer)`),I(c,"fill-rule","evenodd"),I(c,"d",d=yn(r[30])),I(f,"class","a9s-inner"),I(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),I(f,"style",r[1]),I(f,"fill-rule","evenodd"),I(f,"d",g=yn(r[30]))},m(C,R){Le(C,e,R),lt(e,t),lt(t,i),lt(i,n),lt(i,h),y&&y.m(i,null),_&&_.m(t,null),lt(e,c),lt(e,f);for(let M=0;M<A.length;M+=1)A[M]&&A[M].m(e,null);p=!0,m||(v=[ot(c,"pointerup",r[13]),ot(c,"pointerdown",function(){Ft(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),ot(f,"pointerup",r[13]),ot(f,"pointerdown",function(){Ft(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],m=!0)},p(C,R){if(r=C,(!p||R[0]&512&&s!==(s=r[9].x))&&I(n,"x",s),(!p||R[0]&512&&o!==(o=r[9].y))&&I(n,"y",o),(!p||R[0]&512&&a!==(a=r[9].w))&&I(n,"width",a),(!p||R[0]&512&&l!==(l=r[9].h))&&I(n,"height",l),(!p||R[0]&32&&u!==(u=yn(r[30])))&&I(h,"d",u),r[6]!==void 0&&!r[7]?y?y.p(_c(r),R):(y=nm(_c(r)),y.c(),y.m(i,null)):y&&(y.d(1),y=null),r[6]!==void 0&&!r[7]?_?_.p(yc(r),R):(_=sm(yc(r)),_.c(),_.m(t,null)):_&&(_.d(1),_=null),(!p||R[0]&32&&d!==(d=yn(r[30])))&&I(c,"d",d),(!p||R[0]&2)&&I(f,"style",r[1]),(!p||R[0]&32&&g!==(g=yn(r[30])))&&I(f,"d",g),R[0]&268491048){w=gn(r[30].rings);let M;for(M=0;M<w.length;M+=1){const k=im(r,w,M);A[M]?(A[M].p(k,R),at(A[M],1)):(A[M]=am(k),A[M].c(),at(A[M],1),A[M].m(e,null))}for(Gs(),M=w.length;M<A.length;M+=1)F(M);Vs()}},i(C){if(!p){for(let R=0;R<w.length;R+=1)at(A[R]);p=!0}},o(C){A=A.filter(Boolean);for(let R=0;R<A.length;R+=1)_t(A[R]);p=!1},d(C){C&&De(e),y&&y.d(),_&&_.d(),Sl(A,C),m=!1,Wi(v)}}}function hm(r){let e,t;return e=new Wg({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),e.$on("pointerdown",function(){Ft(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){ar(e.$$.fragment)},m(i,n){Xi(e,i,n),t=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[29][0]),n[0]&1088&&(s.y=r[29][1]),n[0]&8&&(s.scale=r[3]),e.$set(s)},i(i){t||(at(e.$$.fragment,i),t=!0)},o(i){_t(e.$$.fragment,i),t=!1},d(i){Yi(e,i)}}}function UE(r){let e,t,i,n=gn(r[5].polygons),s=[];for(let l=0;l<n.length;l+=1)s[l]=lm(tm(r,n,l));const o=l=>_t(s[l],1,1,()=>{s[l]=null});let a=r[6]!==void 0&&!r[7]&&hm(vc(r));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();e=pi(),a&&a.c(),t=Bs()},m(l,h){for(let u=0;u<s.length;u+=1)s[u]&&s[u].m(l,h);Le(l,e,h),a&&a.m(l,h),Le(l,t,h),i=!0},p(l,h){if(h[0]&268763114){n=gn(l[5].polygons);let u;for(u=0;u<n.length;u+=1){const c=tm(l,n,u);s[u]?(s[u].p(c,h),at(s[u],1)):(s[u]=lm(c),s[u].c(),at(s[u],1),s[u].m(e.parentNode,e))}for(Gs(),u=n.length;u<s.length;u+=1)o(u);Vs()}l[6]!==void 0&&!l[7]?a?(a.p(vc(l),h),h[0]&192&&at(a,1)):(a=hm(vc(l)),a.c(),at(a,1),a.m(t.parentNode,t)):a&&(Gs(),_t(a,1,1,()=>{a=null}),Vs())},i(l){if(!i){for(let h=0;h<n.length;h+=1)at(s[h]);at(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)_t(s[h]);_t(a),i=!1},d(l){l&&(De(e),De(t)),Sl(s,l),a&&a.d(l)}}}function HE(r){let e,t;return e=new dc({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[UE,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),e.$on("change",r[20]),e.$on("grab",r[21]),e.$on("release",r[22]),{c(){ar(e.$$.fragment)},m(i,n){Xi(e,i,n),t=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&268437482|n[1]&128&&(s.$$scope={dirty:n,ctx:i}),e.$set(s)},i(i){t||(at(e.$$.fragment,i),t=!0)},o(i){_t(e.$$.fragment,i),t=!1},d(i){Yi(e,i)}}}const GE=250,VE=1e3,Qo=4.5;function zE(r,e,t){let i,n,s;const o=Zo();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,g,p=[];const m=()=>t(7,f=!0),v=()=>t(7,f=!1),y=O=>{if(p.length>0||!n.some(K=>K.visible)){t(6,d=void 0);return}const[j,V]=h.elementToImage(O.offsetX,O.offsetY),Y=K=>Math.pow(K[0]-j,2)+Math.pow(K[1]-V,2),G=Vw(i).reduce((K,Q)=>Y(Q)<Y(K)?Q:K),H=n.filter(K=>K.visible).reduce((K,Q)=>Y(Q.point)<Y(K.point)?Q:K),X=Math.pow(VE/u,2);Y(G)<X||Y(H.point)<X?t(6,d=n.indexOf(H)):t(6,d=void 0)},_=()=>{document.activeElement!==c&&c.focus()},w=()=>{t(8,p=[]),_()},A=O=>{t(7,f=!0),O.preventDefault(),O.stopPropagation(),g=performance.now()},F=(O,j,V)=>Y=>{if(!g||ur||performance.now()-g>GE)return;const G=X=>X.polygon===O&&X.ring===j&&X.point===V,H=p.some(G);Y.metaKey||Y.ctrlKey||Y.shiftKey?H?t(8,p=p.filter(X=>!G(X))):t(8,p=[...p,{polygon:O,ring:j,point:V}]):H&&p.length>1?t(8,p=[{polygon:O,ring:j,point:V}]):H?t(8,p=[]):t(8,p=[{polygon:O,ring:j,point:V}]),_()},C=(O,j,V)=>{_();const Y=O.geometry.polygons;let G;if(j==="SHAPE")G=Y.map(H=>{const X=H.rings.map((Q,W)=>({points:Q.points.map(($,ne)=>[$[0]+V[0],$[1]+V[1]])})),K=lr(X[0].points);return{rings:X,bounds:K}});else{const[H,X,K,Q]=j.split("-").map(W=>parseInt(W));G=Y.map((W,$)=>{if($===X){const ne=W.rings.map((pe,Ce)=>Ce===K?{points:pe.points.map((Pe,Be)=>Be===Q?[Pe[0]+V[0],Pe[1]+V[1]]:Pe)}:pe),_e=lr(ne[0].points);return{rings:ne,bounds:_e}}else return W})}return{...O,geometry:{polygons:G,bounds:lc(G)}}},R=O=>async j=>{j.stopPropagation();const V=n[O],Y=i.polygons.map((H,X)=>{if(X===V.elementIdx){const K=H.rings.map((W,$)=>$===V.ringIdx?{points:[...W.points.slice(0,V.pointIdx+1),V.point,...W.points.slice(V.pointIdx+1)]}:W),Q=lr(K[0].points);return{rings:K,bounds:Q}}else return H});o("change",{...a,geometry:{polygons:Y,bounds:lc(Y)}}),await Fg();const G=[...document.querySelectorAll(".a9s-handle")][O+1];if(G!=null&&G.firstChild){const H=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:j.clientX,clientY:j.clientY,pointerId:j.pointerId,pointerType:j.pointerType,isPrimary:j.isPrimary,buttons:j.buttons});G.firstChild.dispatchEvent(H)}},M=()=>{const O=i.polygons.map((j,V)=>{if(p.some(Y=>Y.polygon===V)){const Y=j.rings.map((H,X)=>{const K=p.filter(Q=>Q.polygon===V&&Q.ring===X);return K.length&&H.points.length-K.length>=3?{points:H.points.filter((Q,W)=>!K.some($=>$.point===W))}:H}),G=lr(Y[0].points);return{rings:Y,bounds:G}}else return j});!mc(i.polygons,O)&&(o("change",{...a,geometry:{polygons:O,bounds:lc(O)}}),t(8,p=[]))};Rl(()=>{if(ur)return;const O=j=>{(j.key==="Delete"||j.key==="Backspace")&&(j.preventDefault(),M())};return c.addEventListener("pointermove",y),c.addEventListener("keydown",O),()=>{c.removeEventListener("pointermove",y),c.removeEventListener("keydown",O)}});const k=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,z=(O,j,V,{polygon:Y,ring:G,point:H})=>Y===O&&G===j&&H===V;function D(O){jt.call(this,r,O)}function S(O){jt.call(this,r,O)}function b(O){jt.call(this,r,O)}return r.$$set=O=>{"shape"in O&&t(0,a=O.shape),"computedStyle"in O&&t(1,l=O.computedStyle),"transform"in O&&t(2,h=O.transform),"viewportScale"in O&&t(3,u=O.viewportScale),"svgEl"in O&&t(4,c=O.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&t(5,i=a.geometry),r.$$.dirty[0]&40&&t(10,n=ur?[]:kE(i,u)),r.$$.dirty[0]&40&&t(9,s=Nl(i.bounds,Qo/u))},[a,l,h,u,c,i,d,f,p,s,n,m,v,w,A,F,C,R,k,z,D,S,b]}class jE extends vn{constructor(e){super(),mn(this,e,zE,HE,pn,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const um=new Map([[ht.RECTANGLE,FE],[ht.POLYGON,DE],[ht.MULTIPOLYGON,jE]]),cm=r=>um.get(r.type),WE=(r,e)=>um.set(r,e);function dm(r){let e,t,i,n,s,o,a,l,h,u;return{c(){e=be("defs"),t=be("mask"),i=be("rect"),l=be("rect"),h=be("rect"),u=be("rect"),I(i,"class","rect-mask-bg svelte-1a76qe7"),I(i,"x",n=r[1]-r[5]),I(i,"y",s=r[2]-r[5]),I(i,"width",o=r[3]+2*r[5]),I(i,"height",a=r[4]+2*r[5]),I(l,"class","rect-mask-fg svelte-1a76qe7"),I(l,"x",r[1]),I(l,"y",r[2]),I(l,"width",r[3]),I(l,"height",r[4]),I(t,"id",r[6]),I(t,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),I(h,"class","a9s-outer"),I(h,"mask",`url(#${r[6]})`),I(h,"x",r[1]),I(h,"y",r[2]),I(h,"width",r[3]),I(h,"height",r[4]),I(u,"class","a9s-inner"),I(u,"x",r[1]),I(u,"y",r[2]),I(u,"width",r[3]),I(u,"height",r[4])},m(c,d){Le(c,e,d),lt(e,t),lt(t,i),lt(t,l),Le(c,h,d),Le(c,u,d)},p(c,d){d&34&&n!==(n=c[1]-c[5])&&I(i,"x",n),d&36&&s!==(s=c[2]-c[5])&&I(i,"y",s),d&40&&o!==(o=c[3]+2*c[5])&&I(i,"width",o),d&48&&a!==(a=c[4]+2*c[5])&&I(i,"height",a),d&2&&I(l,"x",c[1]),d&4&&I(l,"y",c[2]),d&8&&I(l,"width",c[3]),d&16&&I(l,"height",c[4]),d&2&&I(h,"x",c[1]),d&4&&I(h,"y",c[2]),d&8&&I(h,"width",c[3]),d&16&&I(h,"height",c[4]),d&2&&I(u,"x",c[1]),d&4&&I(u,"y",c[2]),d&8&&I(u,"width",c[3]),d&16&&I(u,"height",c[4])},d(c){c&&(De(e),De(h),De(u))}}}function XE(r){let e,t=r[0]&&dm(r);return{c(){e=be("g"),t&&t.c(),I(e,"class","a9s-annotation a9s-rubberband")},m(i,n){Le(i,e,n),t&&t.m(e,null)},p(i,[n]){i[0]?t?t.p(i,n):(t=dm(i),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},i:or,o:or,d(i){i&&De(e),t&&t.d()}}}function YE(r,e,t){let i;const n=Zo();let{addEventListener:s}=e,{drawingMode:o}=e,{transform:a}=e,{viewportScale:l=1}=e,h,u,c,d,f,g,p;const m=A=>{const F=A;h=performance.now(),o==="drag"&&(t(0,u=a.elementToImage(F.offsetX,F.offsetY)),c=u,t(1,d=u[0]),t(2,f=u[1]),t(3,g=1),t(4,p=1))},v=A=>{const F=A;u&&(c=a.elementToImage(F.offsetX,F.offsetY),t(1,d=Math.min(c[0],u[0])),t(2,f=Math.min(c[1],u[1])),t(3,g=Math.abs(c[0]-u[0])),t(4,p=Math.abs(c[1]-u[1])))},y=A=>{const F=A,C=performance.now()-h;if(o==="click"){if(C>300)return;u?_():(t(0,u=a.elementToImage(F.offsetX,F.offsetY)),c=u,t(1,d=u[0]),t(2,f=u[1]),t(3,g=1),t(4,p=1))}else u&&(C>300||g*p>100?(F.stopPropagation(),_()):(t(0,u=void 0),c=void 0))},_=()=>{if(g*p>15){const A={type:ht.RECTANGLE,geometry:{bounds:{minX:d,minY:f,maxX:d+g,maxY:f+p},x:d,y:f,w:g,h:p}};n("create",A)}t(0,u=void 0),c=void 0};Rl(()=>{s("pointerdown",m),s("pointermove",v),s("pointerup",y,!0)});const w=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=A=>{"addEventListener"in A&&t(7,s=A.addEventListener),"drawingMode"in A&&t(8,o=A.drawingMode),"transform"in A&&t(9,a=A.transform),"viewportScale"in A&&t(10,l=A.viewportScale)},r.$$.update=()=>{r.$$.dirty&1024&&t(5,i=2/l)},[u,d,f,g,p,i,w,s,o,a,l]}class ZE extends vn{constructor(e){super(),mn(this,e,YE,XE,pn,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function xc(r){const e=r.slice(),t=e[2].map(i=>i.join(",")).join(" ");return e[19]=t,e}function fm(r){let e,t,i,n,s,o,a,l,h,u,c,d,f,g,p=r[1]&&pm(r);return{c(){e=be("defs"),t=be("mask"),i=be("rect"),l=be("polygon"),u=be("polygon"),d=be("polygon"),p&&p.c(),g=Bs(),I(i,"x",n=r[3].x),I(i,"y",s=r[3].y),I(i,"width",o=r[3].w),I(i,"height",a=r[3].h),I(i,"class","svelte-18wrg3t"),I(l,"points",h=r[19]),I(l,"class","svelte-18wrg3t"),I(t,"id",r[5]),I(t,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),I(u,"class","a9s-outer"),I(u,"mask",`url(#${r[5]})`),I(u,"points",c=r[19]),I(d,"class","a9s-inner"),I(d,"points",f=r[19])},m(m,v){Le(m,e,v),lt(e,t),lt(t,i),lt(t,l),Le(m,u,v),Le(m,d,v),p&&p.m(m,v),Le(m,g,v)},p(m,v){v&8&&n!==(n=m[3].x)&&I(i,"x",n),v&8&&s!==(s=m[3].y)&&I(i,"y",s),v&8&&o!==(o=m[3].w)&&I(i,"width",o),v&8&&a!==(a=m[3].h)&&I(i,"height",a),v&4&&h!==(h=m[19])&&I(l,"points",h),v&4&&c!==(c=m[19])&&I(u,"points",c),v&4&&f!==(f=m[19])&&I(d,"points",f),m[1]?p?p.p(m,v):(p=pm(m),p.c(),p.m(g.parentNode,g)):p&&(p.d(1),p=null)},d(m){m&&(De(e),De(u),De(d),De(g)),p&&p.d(m)}}}function pm(r){let e,t,i;return{c(){e=be("circle"),I(e,"class","a9s-handle svelte-18wrg3t"),I(e,"cx",t=r[0][0][0]),I(e,"cy",i=r[0][0][1]),I(e,"r",r[4])},m(n,s){Le(n,e,s)},p(n,s){s&1&&t!==(t=n[0][0][0])&&I(e,"cx",t),s&1&&i!==(i=n[0][0][1])&&I(e,"cy",i),s&16&&I(e,"r",n[4])},d(n){n&&De(e)}}}function qE(r){let e,t=r[3]&&fm(xc(r));return{c(){e=be("g"),t&&t.c(),I(e,"class","a9s-annotation a9s-rubberband")},m(i,n){Le(i,e,n),t&&t.m(e,null)},p(i,[n]){i[3]?t?t.p(xc(i),n):(t=fm(xc(i)),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},i:or,o:or,d(i){i&&De(e),t&&t.d()}}}const KE=20,QE=1500;function JE(r,e,t){let i,n,s;const o=Zo();let{addEventListener:a}=e,{drawingMode:l}=e,{transform:h}=e,{viewportScale:u=1}=e,c,d=[],f,g,p=!1;const m=F=>{const C=F,{timeStamp:R,offsetX:M,offsetY:k}=C;if(c={timeStamp:R,offsetX:M,offsetY:k},l==="drag"&&d.length===0){const z=h.elementToImage(C.offsetX,C.offsetY);d.push(z),t(10,f=z)}},v=F=>{const C=F;if(g&&clearTimeout(g),d.length>0){if(t(10,f=h.elementToImage(C.offsetX,C.offsetY)),d.length>2){const R=Ml(f,d[0])*u;t(1,p=R<KE)}C.pointerType==="touch"&&(g=setTimeout(()=>{_()},QE))}},y=F=>{const C=F;if(g&&clearTimeout(g),l==="click"){const R=C.timeStamp-c.timeStamp,M=Ml([c.offsetX,c.offsetY],[C.offsetX,C.offsetY]);if(R>300||M>15)return;if(p)w();else if(d.length===0){const k=h.elementToImage(C.offsetX,C.offsetY);d.push(k),t(10,f=k)}else f&&d.push(f)}else{if(!f)return;if(d.length===1&&Ml(d[0],f)<=4){t(0,d=[]),t(10,f=void 0);return}C.stopImmediatePropagation(),p?w():d.push(f)}},_=()=>{if(!f)return;const F=d.slice(0,-1);if(F.length<3)return;const C={type:ht.POLYGON,geometry:{bounds:lr(d),points:F}};ac(C)>4&&(t(0,d=[]),t(10,f=void 0),o("create",C))},w=()=>{const F={type:ht.POLYGON,geometry:{bounds:lr(d),points:[...d]}};t(0,d=[]),t(10,f=void 0),o("create",F)};Rl(()=>{a("pointerdown",m,!0),a("pointermove",v),a("pointerup",y,!0),a("dblclick",_,!0)});const A=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=F=>{"addEventListener"in F&&t(6,a=F.addEventListener),"drawingMode"in F&&t(7,l=F.drawingMode),"transform"in F&&t(8,h=F.transform),"viewportScale"in F&&t(9,u=F.viewportScale)},r.$$.update=()=>{r.$$.dirty&512&&t(4,i=4/u),r.$$.dirty&1027&&t(2,n=f?p?d:[...d,f]:[]),r.$$.dirty&516&&t(3,s=n.length>0?Nl(lr(n),2/u):void 0)},[d,p,n,s,i,A,a,l,h,u,f]}class $E extends vn{constructor(e){super(),mn(this,e,JE,qE,pn,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const wc=new Map([["rectangle",{tool:ZE}],["polygon",{tool:$E}]]),gm=()=>[...wc.keys()],mm=r=>wc.get(r),eT=(r,e,t={})=>wc.set(r,{tool:e,opts:t});function vm(r,e,t=0,i=r.length-1,n=tT){for(;i>t;){if(i-t>600){const l=i-t+1,h=e-t+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),f=Math.max(t,Math.floor(e-h*c/l+d)),g=Math.min(i,Math.floor(e+(l-h)*c/l+d));vm(r,e,f,g,n)}const s=r[e];let o=t,a=i;for(Jo(r,t,e),n(r[i],s)>0&&Jo(r,t,i);o<a;){for(Jo(r,o,a),o++,a--;n(r[o],s)<0;)o++;for(;n(r[a],s)>0;)a--}n(r[t],s)===0?Jo(r,t,a):(a++,Jo(r,a,i)),a<=e&&(t=a+1),e<=a&&(i=a-1)}}function Jo(r,e,t){const i=r[e];r[e]=r[t],r[t]=i}function tT(r,e){return r<e?-1:r>e?1:0}class iT{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!Bl(e,t))return i;const n=this.toBBox,s=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],l=t.leaf?n(a):a;Bl(e,l)&&(t.leaf?i.push(a):Tc(e,l)?this._all(a,i):s.push(a))}t=s.pop()}return i}collides(e){let t=this.data;if(!Bl(e,t))return!1;const i=[];for(;t;){for(let n=0;n<t.children.length;n++){const s=t.children[n],o=t.leaf?this.toBBox(s):s;if(Bl(e,o)){if(t.leaf||Tc(e,o))return!0;i.push(s)}}t=i.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let i=0;i<e.length;i++)this.insert(e[i]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const i=this.data;this.data=t,t=i}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Xs([]),this}remove(e,t){if(!e)return this;let i=this.data;const n=this.toBBox(e),s=[],o=[];let a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){const u=rT(e,i.children,t);if(u!==-1)return i.children.splice(u,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&Tc(i,n)?(s.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,n){const s=i-t+1;let o=this._maxEntries,a;if(s<=o)return a=Xs(e.slice(t,i+1)),Ws(a,this.toBBox),a;n||(n=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,n-1))),a=Xs([]),a.leaf=!1,a.height=n;const l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));ym(e,t,i,h,this.compareMinX);for(let u=t;u<=i;u+=h){const c=Math.min(u+h-1,i);ym(e,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const f=Math.min(d+l-1,c);a.children.push(this._build(e,d,f,n-1))}}return Ws(a,this.toBBox),a}_chooseSubtree(e,t,i,n){for(;n.push(t),!(t.leaf||n.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){const h=t.children[l],u=Ec(h),c=oT(e,h)-u;c<o?(o=c,s=u<s?u:s,a=h):c===o&&u<s&&(s=u,a=h)}t=a||t.children[0]}return t}_insert(e,t,i){const n=i?e:this.toBBox(e),s=[],o=this._chooseSubtree(n,this.data,t,s);for(o.children.push(e),ea(o,n);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(n,s,t)}_split(e,t){const i=e[t],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);const o=this._chooseSplitIndex(i,s,n),a=Xs(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Ws(i,this.toBBox),Ws(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=Xs([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Ws(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let n,s=1/0,o=1/0;for(let a=t;a<=i-t;a++){const l=$o(e,0,a,this.toBBox),h=$o(e,a,i,this.toBBox),u=aT(l,h),c=Ec(l)+Ec(h);u<s?(s=u,n=a,o=c<o?c:o):u===s&&c<o&&(o=c,n=a)}return n||i-t}_chooseSplitAxis(e,t,i){const n=e.leaf?this.compareMinX:nT,s=e.leaf?this.compareMinY:sT,o=this._allDistMargin(e,t,i,n),a=this._allDistMargin(e,t,i,s);o<a&&e.children.sort(n)}_allDistMargin(e,t,i,n){e.children.sort(n);const s=this.toBBox,o=$o(e,0,t,s),a=$o(e,i-t,i,s);let l=Fl(o)+Fl(a);for(let h=t;h<i-t;h++){const u=e.children[h];ea(o,e.leaf?s(u):u),l+=Fl(o)}for(let h=i-t-1;h>=t;h--){const u=e.children[h];ea(a,e.leaf?s(u):u),l+=Fl(a)}return l}_adjustParentBBoxes(e,t,i){for(let n=i;n>=0;n--)ea(t[n],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():Ws(e[t],this.toBBox)}}function rT(r,e,t){if(!t)return e.indexOf(r);for(let i=0;i<e.length;i++)if(t(r,e[i]))return i;return-1}function Ws(r,e){$o(r,0,r.children.length,e,r)}function $o(r,e,t,i,n){n||(n=Xs(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let s=e;s<t;s++){const o=r.children[s];ea(n,r.leaf?i(o):o)}return n}function ea(r,e){return r.minX=Math.min(r.minX,e.minX),r.minY=Math.min(r.minY,e.minY),r.maxX=Math.max(r.maxX,e.maxX),r.maxY=Math.max(r.maxY,e.maxY),r}function nT(r,e){return r.minX-e.minX}function sT(r,e){return r.minY-e.minY}function Ec(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Fl(r){return r.maxX-r.minX+(r.maxY-r.minY)}function oT(r,e){return(Math.max(e.maxX,r.maxX)-Math.min(e.minX,r.minX))*(Math.max(e.maxY,r.maxY)-Math.min(e.minY,r.minY))}function aT(r,e){const t=Math.max(r.minX,e.minX),i=Math.max(r.minY,e.minY),n=Math.min(r.maxX,e.maxX),s=Math.min(r.maxY,e.maxY);return Math.max(0,n-t)*Math.max(0,s-i)}function Tc(r,e){return r.minX<=e.minX&&r.minY<=e.minY&&e.maxX<=r.maxX&&e.maxY<=r.maxY}function Bl(r,e){return e.minX<=r.maxX&&e.minY<=r.maxY&&e.maxX>=r.minX&&e.maxY>=r.minY}function Xs(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function ym(r,e,t,i,n){const s=[e,t];for(;s.length;){if(t=s.pop(),e=s.pop(),t-e<=i)continue;const o=e+Math.ceil((t-e)/i/2)*i;vm(r,o,e,t,n),s.push(e,o,o,t)}}const lT=()=>{const r=new iT,e=new Map,t=()=>[...e.values()],i=()=>{r.clear(),e.clear()},n=o=>{if(!Dl(o))return;const{minX:a,minY:l,maxX:h,maxY:u}=o.selector.geometry.bounds,c={minX:a,minY:l,maxX:h,maxY:u,target:o};r.insert(c),e.set(o.annotation,c)},s=o=>{if(!Dl(o))return;const a=e.get(o.annotation);a&&r.remove(a),e.delete(o.annotation)};return{all:t,clear:i,getAt:(o,a,l=0)=>{const h=r.search({minX:o-l,minY:a-l,maxX:o+l,maxY:a+l}).map(u=>u.target).filter(u=>u.selector.type===ht.RECTANGLE||Bw(u.selector,o,a,l));return h.length>0?(h.sort((u,c)=>ac(u.selector)-ac(c.selector)),h):[]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:n,remove:s,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(Dl(u)){const{minX:c,minY:d,maxX:f,maxY:g}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:f,maxY:g,target:u}]}else return h},[]);l.forEach(h=>e.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{s(o),n(a)}}},hT=r=>{const e=dE(),t=lT(),i=Qw(e,r.userSelectAction,r.adapter),n=Kw(e),s=fE();return e.observe(({changes:o})=>{t.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>t.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>t.update(a.target,l.target))}),{store:{...e,getAt:(o,a,l,h)=>{const u=t.getAt(o,a,h);if(l)return u.map(c=>e.getAnnotation(c.annotation)).filter(Boolean).filter(l)[0];{const c=u[0];return c?e.getAnnotation(c.annotation):void 0}},getIntersecting:(o,a,l,h)=>t.getIntersecting(o,a,l,h).map(u=>e.getAnnotation(u.annotation)).filter(Boolean)},selection:i,hover:n,viewport:s}},uT=r=>{let e,t;if(r.nodeName==="CANVAS")e=r,t=e.getContext("2d",{willReadFrequently:!0});else{const n=r;e=document.createElement("canvas"),e.width=n.width,e.height=n.height,t=e.getContext("2d",{willReadFrequently:!0}),t.drawImage(n,0,0,n.width,n.height)}let i=0;for(let n=1;n<10;n++)for(let s=1;s<10;s++){const o=Math.round(s*e.width/10),a=Math.round(n*e.height/10),l=t.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},cT=r=>{const e=uT(r),t=e>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${e.toFixed(1)}. Setting ${t} theme.`),t},dT=(r,e)=>({...r,drawingEnabled:r.drawingEnabled===void 0?e.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||e.drawingMode,userSelectAction:r.userSelectAction||e.userSelectAction,theme:r.theme||e.theme}),_m=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,fT=(r,e)=>{const t=e||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},n=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},s=()=>{_m?t.removeEventListener("keydown",n):t.removeEventListener("keydown",i)};return _m?t.addEventListener("keydown",n):t.addEventListener("keydown",i),{destroy:s}};function It(){}function pT(r,e){for(const t in e)r[t]=e[t];return r}function xm(r){return r()}function wm(){return Object.create(null)}function ta(r){r.forEach(xm)}function bc(r){return typeof r=="function"}function Xt(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function gT(r){return Object.keys(r).length===0}function mT(r,...e){if(r==null){for(const i of e)i(void 0);return It}const t=r.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ia(r,e,t){r.$$.on_destroy.push(mT(e,t))}function vT(r,e,t,i){if(r){const n=Em(r,e,t,i);return r[0](n)}}function Em(r,e,t,i){return r[1]&&i?pT(t.ctx.slice(),r[1](i(e))):t.ctx}function yT(r,e,t,i){if(r[2]&&i){const n=r[2](i(t));if(e.dirty===void 0)return n;if(typeof n=="object"){const s=[],o=Math.max(e.dirty.length,n.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|n[a];return s}return e.dirty|n}return e.dirty}function _T(r,e,t,i,n,s){if(n){const o=Em(e,t,i,s);r.p(o,n)}}function xT(r){if(r.ctx.length>32){const e=[],t=r.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}const Ac=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ar(r,e){r.appendChild(e)}function bt(r,e,t){r.insertBefore(e,t||null)}function xt(r){r.parentNode&&r.parentNode.removeChild(r)}function kl(r,e){for(let t=0;t<r.length;t+=1)r[t]&&r[t].d(e)}function At(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Tm(r){return document.createTextNode(r)}function Zr(){return Tm("")}function wT(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function se(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function ET(r){return Array.from(r.childNodes)}function TT(r,e){e=""+e,r.data!==e&&(r.data=e)}function Ys(r,e,t){r.classList.toggle(e,!!t)}function bT(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}let ra;function na(r){ra=r}function Sc(){if(!ra)throw new Error("Function called outside component initialization");return ra}function sa(r){Sc().$$.on_mount.push(r)}function AT(r){Sc().$$.on_destroy.push(r)}function Rc(){const r=Sc();return(e,t,{cancelable:i=!1}={})=>{const n=r.$$.callbacks[e];if(n){const s=bT(e,t,{cancelable:i});return n.slice().forEach(o=>{o.call(r,s)}),!s.defaultPrevented}return!0}}const Zs=[],Ul=[];let qs=[];const bm=[],ST=Promise.resolve();let Cc=!1;function RT(){Cc||(Cc=!0,ST.then(Am))}function Pc(r){qs.push(r)}const Ic=new Set;let Ks=0;function Am(){if(Ks!==0)return;const r=ra;do{try{for(;Ks<Zs.length;){const e=Zs[Ks];Ks++,na(e),CT(e.$$)}}catch(e){throw Zs.length=0,Ks=0,e}for(na(null),Zs.length=0,Ks=0;Ul.length;)Ul.pop()();for(let e=0;e<qs.length;e+=1){const t=qs[e];Ic.has(t)||(Ic.add(t),t())}qs.length=0}while(Zs.length);for(;bm.length;)bm.pop()();Cc=!1,Ic.clear(),na(r)}function CT(r){if(r.fragment!==null){r.update(),ta(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(Pc)}}function PT(r){const e=[],t=[];qs.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),qs=e}const Hl=new Set;let ts;function Zi(){ts={r:0,c:[],p:ts}}function qi(){ts.r||ta(ts.c),ts=ts.p}function He(r,e){r&&r.i&&(Hl.delete(r),r.i(e))}function Ye(r,e,t,i){if(r&&r.o){if(Hl.has(r))return;Hl.add(r),ts.c.push(()=>{Hl.delete(r),i&&(t&&r.d(1),i())}),r.o(e)}else i&&i()}function wn(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function gi(r){r&&r.c()}function li(r,e,t){const{fragment:i,after_update:n}=r.$$;i&&i.m(e,t),Pc(()=>{const s=r.$$.on_mount.map(xm).filter(bc);r.$$.on_destroy?r.$$.on_destroy.push(...s):ta(s),r.$$.on_mount=[]}),n.forEach(Pc)}function hi(r,e){const t=r.$$;t.fragment!==null&&(PT(t.after_update),ta(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function IT(r,e){r.$$.dirty[0]===-1&&(Zs.push(r),RT(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function ui(r,e,t,i,n,s,o=null,a=[-1]){const l=ra;na(r);const h=r.$$={fragment:null,ctx:[],props:s,update:It,not_equal:n,bound:wm(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:wm(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=t?t(r,e.props||{},(c,d,...f)=>{const g=f.length?f[0]:d;return h.ctx&&n(h.ctx[c],h.ctx[c]=g)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](g),u&&IT(r,c)),d}):[],h.update(),u=!0,ta(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const c=ET(e.target);h.fragment&&h.fragment.l(c),c.forEach(xt)}else h.fragment&&h.fragment.c();e.intro&&He(r.$$.fragment),li(r,e.target,e.anchor),Am()}na(l)}class ci{constructor(){xg(this,"$$"),xg(this,"$$set")}$destroy(){hi(this,1),this.$destroy=It}$on(e,t){if(!bc(t))return It;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const n=i.indexOf(t);n!==-1&&i.splice(n,1)}}$set(e){this.$$set&&!gT(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const MT="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(MT);var Sr=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.POLYLINE="POLYLINE",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(Sr||{}),Mc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Dc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function DT(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}var Sm={exports:{}};(function(r){(function(){function e(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function t(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var g=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);g>1?(u=h.x,c=h.y):g>0&&(u+=d*g,c+=f*g)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],e(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function n(a,l,h,u,c){for(var d=u,f,g=l+1;g<h;g++){var p=t(a[g],a[l],a[h]);p>d&&(f=g,d=p)}d>u&&(f-l>1&&n(a,l,f,u,c),c.push(a[f]),h-f>1&&n(a,f,h,u,c))}function s(a,l){var h=a.length-1,u=[a[0]];return n(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=s(a,u),a}r.exports=o,r.exports.default=o})()})(Sm);var OT=Sm.exports;const LT=Dc(OT),Qs=(r,e)=>e,Oc=r=>{let e=1/0,t=1/0,i=-1/0,n=-1/0;return r.forEach(([s,o])=>{e=Math.min(e,s),t=Math.min(t,o),i=Math.max(i,s),n=Math.max(n,o)}),{minX:e,minY:t,maxX:i,maxY:n}},Gl=r=>{let e=0,t=r.length-1;for(let i=0;i<r.length;i++)e+=(r[t][0]+r[i][0])*(r[t][1]-r[i][1]),t=i;return Math.abs(.5*e)},Vl=(r,e,t)=>{let i=!1;for(let n=0,s=r.length-1;n<r.length;s=n++){const o=r[n][0],a=r[n][1],l=r[s][0],h=r[s][1];a>t!=h>t&&e<(l-o)*(t-a)/(h-a)+o&&(i=!i)}return i},Rm=(r,e=1)=>{const t=r.map(([i,n])=>({x:i,y:n}));return LT(t,e,!0).map(i=>[i.x,i.y])},NT=(r,e)=>{const t=Math.abs(e[0]-r[0]),i=Math.abs(e[1]-r[1]);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},FT={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,e,t)=>{const{cx:i,cy:n,rx:s,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=e-i,c=t-n,d=l*u+h*c,f=h*u-l*c;return d*d/(s*s)+f*f/(o*o)<=1}};Qs(Sr.ELLIPSE,FT);const BT={area:r=>0,intersects:(r,e,t,i=2)=>{const[[n,s],[o,a]]=r.geometry.points,l=Math.abs((a-s)*e-(o-n)*t+o*s-a*n),h=NT([n,s],[o,a]);return l/h<=i}};Qs(Sr.LINE,BT);const kT={area:r=>{const{polygons:e}=r.geometry;return e.reduce((t,i)=>{const[n,...s]=i.rings,o=Gl(n.points),a=s.reduce((l,h)=>l+Gl(h.points),0);return t+o-a},0)},intersects:(r,e,t)=>{const{polygons:i}=r.geometry;for(const n of i){const[s,...o]=n.rings;if(Vl(s.points,e,t)){let a=!1;for(const l of o)if(Vl(l.points,e,t)){a=!0;break}if(!a)return!0}}return!1}},UT=r=>{const e=r.reduce((t,i)=>[...t,...i.rings[0].points],[]);return Oc(e)},HT=(r,e=1)=>{const t=r.geometry.polygons.map(n=>{const s=n.rings.map(a=>{const l=Rm(a.points,e);return{...a,points:l}}),o=Oc(s[0].points);return{...n,rings:s,bounds:o}}),i=UT(t);return{...r,geometry:{...r.geometry,polygons:t,bounds:i}}};Qs(Sr.MULTIPOLYGON,kT);const GT={area:r=>{const e=r.geometry.points;return Gl(e)},intersects:(r,e,t)=>{const i=r.geometry.points;return Vl(i,e,t)}},VT=(r,e=1)=>{const t=Rm(r.geometry.points,e),i=Oc(t);return{...r,geometry:{...r.geometry,bounds:i,points:t}}};Qs(Sr.POLYGON,GT);const zT={area:r=>{const e=r.geometry;if(!e.closed||e.points.length<3)return 0;const t=Cm(e.points,e.closed);return Gl(t)},intersects:(r,e,t,i=2)=>{const n=r.geometry;if(n.closed){const s=Cm(n.points,n.closed);return Vl(s,e,t)}else return jT(n,[e,t],i)}},Cm=(r,e=!1)=>{const t=[];for(let i=0;i<r.length;i++){const n=r[i],s=r[(i+1)%r.length];if(t.push(n.point),(i<r.length-1||e)&&(n.type==="CURVE"||s.type=="CURVE")){const o=Pm(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);t.push(...o.slice(1))}}return t},Pm=(r,e,t,i,n=10)=>{const s=[];for(let o=0;o<=n;o++){const a=o/n,l=Math.pow(1-a,3)*r[0]+3*Math.pow(1-a,2)*a*e[0]+3*(1-a)*Math.pow(a,2)*t[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*r[1]+3*Math.pow(1-a,2)*a*e[1]+3*(1-a)*Math.pow(a,2)*t[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},jT=(r,e,t)=>{for(let i=0;i<r.points.length-1;i++){const n=r.points[i],s=r.points[i+1];if(n.type==="CURVE"||s.type==="CURVE"){const o=Pm(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(Im(e,o[a],o[a+1])<=t)return!0}else if(Im(e,n.point,s.point)<=t)return!0}return!1},Im=(r,e,t)=>{const[i,n]=r,[s,o]=e,[a,l]=t,h=a-s,u=l-o,c=Math.sqrt(h*h+u*u);if(c===0)return Math.sqrt((i-s)*(i-s)+(n-o)*(n-o));const d=((i-s)*h+(n-o)*u)/(c*c);return d<=0?Math.sqrt((i-s)*(i-s)+(n-o)*(n-o)):d>=1?Math.sqrt((i-a)*(i-a)+(n-l)*(n-l)):Math.abs((l-o)*i-(a-s)*n+a*o-l*s)/c};Qs(Sr.POLYLINE,zT);const WT={area:r=>r.geometry.w*r.geometry.h,intersects:(r,e,t)=>e>=r.geometry.x&&e<=r.geometry.x+r.geometry.w&&t>=r.geometry.y&&t<=r.geometry.y+r.geometry.h};Qs(Sr.RECTANGLE,WT);const ei=[];for(let r=0;r<256;++r)ei.push((r+256).toString(16).slice(1));function XT(r,e=0){return(ei[r[e+0]]+ei[r[e+1]]+ei[r[e+2]]+ei[r[e+3]]+"-"+ei[r[e+4]]+ei[r[e+5]]+"-"+ei[r[e+6]]+ei[r[e+7]]+"-"+ei[r[e+8]]+ei[r[e+9]]+"-"+ei[r[e+10]]+ei[r[e+11]]+ei[r[e+12]]+ei[r[e+13]]+ei[r[e+14]]+ei[r[e+15]]).toLowerCase()}let Lc;const YT=new Uint8Array(16);function ZT(){if(!Lc){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Lc=crypto.getRandomValues.bind(crypto)}return Lc(YT)}const qT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Mm={randomUUID:qT};function KT(r,e,t){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??ZT();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,XT(n)}function QT(r,e,t){return Mm.randomUUID&&!r?Mm.randomUUID():KT(r)}const JT=(r,e,t)=>{const i=typeof e=="function"?e(r,t):e;if(i){const{fill:n,fillOpacity:s,stroke:o,strokeWidth:a,strokeOpacity:l}=i;let h="";return n&&(h+=`fill:${n};`),s||s===0?h+=`fill-opacity:${s};`:n&&(h+="fill-opacity:0.25;"),o&&(h+=`stroke:${o};`,h+=`stroke-width:${a||"1"};`,h+=`stroke-opacity:${l||"1"};`),h}};Sr.RECTANGLE,Sr.POLYGON,Sr.MULTIPOLYGON;function $T(r,e,t){let i;const n=Rc();let{annotation:s}=e,{editor:o}=e,{style:a}=e,{target:l}=e,{transform:h}=e,{viewportScale:u}=e,c;return sa(()=>(t(6,c=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),n("change",d.detail)}),c.$on("grab",d=>n("grab",d.detail)),c.$on("release",d=>n("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&t(0,s=d.annotation),"editor"in d&&t(1,o=d.editor),"style"in d&&t(2,a=d.style),"target"in d&&t(3,l=d.target),"transform"in d&&t(4,h=d.transform),"viewportScale"in d&&t(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&t(7,i=JT(s,a,{selected:!0,hovered:!0})),r.$$.dirty&65&&s&&(c==null||c.$set({shape:s.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[s,o,a,l,h,u,c,i]}class eb extends ci{constructor(e){super(),ui(this,e,$T,null,Xt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"||navigator.userAgent.indexOf("Mac OS X");var is=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(is||{}),Dm=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Dm||{}),Nc=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Nc||{}),Ne=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(Ne||{}),Rr=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Rr||{}),he=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(he||{}),Js=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(Js||{}),Re=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(Re||{}),ve=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(ve||{}),qr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(qr||{}),En=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(En||{}),Cr=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Cr||{}),bi=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(bi||{}),Pr=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Pr||{}),Fc=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Fc||{}),Ki=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(Ki||{}),Gt=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(Gt||{}),Bt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Bt||{}),Ir=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Ir||{});const tb={createCanvas:(r,e)=>{const t=document.createElement("canvas");return t.width=r,t.height=e,t},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,e)=>fetch(r,e),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},ye={ADAPTER:tb,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Bc=/iPhone/i,Om=/iPod/i,Lm=/iPad/i,Nm=/\biOS-universal(?:.+)Mac\b/i,kc=/\bAndroid(?:.+)Mobile\b/i,Fm=/Android/i,$s=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,zl=/Silk/i,Kr=/Windows Phone/i,Bm=/\bWindows(?:.+)ARM\b/i,km=/BlackBerry/i,Um=/BB10/i,Hm=/Opera Mini/i,Gm=/\b(CriOS|Chrome)(?:.+)Mobile/i,Vm=/Mobile(?:.+)Firefox\b/i,zm=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function ib(r){return function(e){return e.test(r)}}function jm(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var n=ib(t),s={apple:{phone:n(Bc)&&!n(Kr),ipod:n(Om),tablet:!n(Bc)&&(n(Lm)||zm(e))&&!n(Kr),universal:n(Nm),device:(n(Bc)||n(Om)||n(Lm)||n(Nm)||zm(e))&&!n(Kr)},amazon:{phone:n($s),tablet:!n($s)&&n(zl),device:n($s)||n(zl)},android:{phone:!n(Kr)&&n($s)||!n(Kr)&&n(kc),tablet:!n(Kr)&&!n($s)&&!n(kc)&&(n(zl)||n(Fm)),device:!n(Kr)&&(n($s)||n(zl)||n(kc)||n(Fm))||n(/\bokhttp\b/i)},windows:{phone:n(Kr),tablet:n(Bm),device:n(Kr)||n(Bm)},other:{blackberry:n(km),blackberry10:n(Um),opera:n(Hm),firefox:n(Vm),chrome:n(Gm),device:n(km)||n(Um)||n(Hm)||n(Vm)||n(Gm)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const rb=jm.default??jm,Qr=rb(globalThis.navigator);ye.RETINA_PREFIX=/@([0-9\.]+)x/,ye.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Wm={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function n(l,h,u){this.fn=l,this.context=h,this.once=u||!1}function s(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new n(u,c||l,d),g=t?t+h:h;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,u;if(this._eventsCount===0)return l;for(u in h=this._events)e.call(h,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,u=this._events[h];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,d=u.length,f=new Array(d);c<d;c++)f[c]=u[c].fn;return f},a.prototype.listenerCount=function(l){var h=t?t+l:l,u=this._events[h];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,h,u,c,d,f){var g=t?t+l:l;if(!this._events[g])return!1;var p=this._events[g],m=arguments.length,v,y;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,!0),m){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,h),!0;case 3:return p.fn.call(p.context,h,u),!0;case 4:return p.fn.call(p.context,h,u,c),!0;case 5:return p.fn.call(p.context,h,u,c,d),!0;case 6:return p.fn.call(p.context,h,u,c,d,f),!0}for(y=1,v=new Array(m-1);y<m;y++)v[y-1]=arguments[y];p.fn.apply(p.context,v)}else{var _=p.length,w;for(y=0;y<_;y++)switch(p[y].once&&this.removeListener(l,p[y].fn,void 0,!0),m){case 1:p[y].fn.call(p[y].context);break;case 2:p[y].fn.call(p[y].context,h);break;case 3:p[y].fn.call(p[y].context,h,u);break;case 4:p[y].fn.call(p[y].context,h,u,c);break;default:if(!v)for(w=1,v=new Array(m-1);w<m;w++)v[w-1]=arguments[w];p[y].fn.apply(p[y].context,v)}}return!0},a.prototype.on=function(l,h,u){return s(this,l,h,u,!1)},a.prototype.once=function(l,h,u){return s(this,l,h,u,!0)},a.prototype.removeListener=function(l,h,u,c){var d=t?t+l:l;if(!this._events[d])return this;if(!h)return o(this,d),this;var f=this._events[d];if(f.fn)f.fn===h&&(!c||f.once)&&(!u||f.context===u)&&o(this,d);else{for(var g=0,p=[],m=f.length;g<m;g++)(f[g].fn!==h||c&&!f[g].once||u&&f[g].context!==u)&&p.push(f[g]);p.length?this._events[d]=p.length===1?p[0]:p:o(this,d)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(Wm);var nb=Wm.exports;const oa=Dc(nb);var Uc={exports:{}};Uc.exports=jl,Uc.exports.default=jl;function jl(r,e,t){t=t||2;var i=e&&e.length,n=i?e[0]*t:r.length,s=Xm(r,0,n,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,l,h,u,c,d,f;if(i&&(s=hb(r,e,s,t)),r.length>80*t){a=h=r[0],l=u=r[1];for(var g=t;g<n;g+=t)c=r[g],d=r[g+1],c<a&&(a=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);f=Math.max(h-a,u-l),f=f!==0?32767/f:0}return aa(s,o,t,a,l,f,0),o}function Xm(r,e,t,i,n){var s,o;if(n===Vc(r,e,t,i)>0)for(s=e;s<t;s+=i)o=qm(s,r[s],r[s+1],o);else for(s=t-i;s>=e;s-=i)o=qm(s,r[s],r[s+1],o);return o&&Wl(o,o.next)&&(ha(o),o=o.next),o}function rs(r,e){if(!r)return r;e||(e=r);var t=r,i;do if(i=!1,!t.steiner&&(Wl(t,t.next)||St(t.prev,t,t.next)===0)){if(ha(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function aa(r,e,t,i,n,s,o){if(r){!o&&s&&pb(r,i,n,s);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,s?ob(r,i,n,s):sb(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(h.i/t|0),ha(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=ab(rs(r),e,t),aa(r,e,t,i,n,s,2)):o===2&&lb(r,e,t,i,n,s):aa(rs(r),e,t,i,n,s,1);break}}}}function sb(r){var e=r.prev,t=r,i=r.next;if(St(e,t,i)>=0)return!1;for(var n=e.x,s=t.x,o=i.x,a=e.y,l=t.y,h=i.y,u=n<s?n<o?n:o:s<o?s:o,c=a<l?a<h?a:h:l<h?l:h,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>h?a:h:l>h?l:h,g=i.next;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=c&&g.y<=f&&eo(n,a,s,l,o,h,g.x,g.y)&&St(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function ob(r,e,t,i){var n=r.prev,s=r,o=r.next;if(St(n,s,o)>=0)return!1;for(var a=n.x,l=s.x,h=o.x,u=n.y,c=s.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,g=u<c?u<d?u:d:c<d?c:d,p=a>l?a>h?a:h:l>h?l:h,m=u>c?u>d?u:d:c>d?c:d,v=Hc(f,g,e,t,i),y=Hc(p,m,e,t,i),_=r.prevZ,w=r.nextZ;_&&_.z>=v&&w&&w.z<=y;){if(_.x>=f&&_.x<=p&&_.y>=g&&_.y<=m&&_!==n&&_!==o&&eo(a,u,l,c,h,d,_.x,_.y)&&St(_.prev,_,_.next)>=0||(_=_.prevZ,w.x>=f&&w.x<=p&&w.y>=g&&w.y<=m&&w!==n&&w!==o&&eo(a,u,l,c,h,d,w.x,w.y)&&St(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;_&&_.z>=v;){if(_.x>=f&&_.x<=p&&_.y>=g&&_.y<=m&&_!==n&&_!==o&&eo(a,u,l,c,h,d,_.x,_.y)&&St(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;w&&w.z<=y;){if(w.x>=f&&w.x<=p&&w.y>=g&&w.y<=m&&w!==n&&w!==o&&eo(a,u,l,c,h,d,w.x,w.y)&&St(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function ab(r,e,t){var i=r;do{var n=i.prev,s=i.next.next;!Wl(n,s)&&Ym(n,i,i.next,s)&&la(n,s)&&la(s,n)&&(e.push(n.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),ha(i),ha(i.next),i=r=s),i=i.next}while(i!==r);return rs(i)}function lb(r,e,t,i,n,s){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&vb(o,a)){var l=Zm(o,a);o=rs(o,o.next),l=rs(l,l.next),aa(o,e,t,i,n,s,0),aa(l,e,t,i,n,s,0);return}a=a.next}o=o.next}while(o!==r)}function hb(r,e,t,i){var n=[],s,o,a,l,h;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:r.length,h=Xm(r,a,l,i,!1),h===h.next&&(h.steiner=!0),n.push(mb(h));for(n.sort(ub),s=0;s<n.length;s++)t=cb(n[s],t);return t}function ub(r,e){return r.x-e.x}function cb(r,e){var t=db(r,e);if(!t)return e;var i=Zm(t,r);return rs(i,i.next),rs(t,t.next)}function db(r,e){var t=e,i=r.x,n=r.y,s=-1/0,o;do{if(n<=t.y&&n>=t.next.y&&t.next.y!==t.y){var a=t.x+(n-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x<t.next.x?t:t.next,a===i))return o}t=t.next}while(t!==e);if(!o)return null;var l=o,h=o.x,u=o.y,c=1/0,d;t=o;do i>=t.x&&t.x>=h&&i!==t.x&&eo(n<u?i:s,n,h,u,n<u?s:i,n,t.x,t.y)&&(d=Math.abs(n-t.y)/(i-t.x),la(t,r)&&(d<c||d===c&&(t.x>o.x||t.x===o.x&&fb(o,t)))&&(o=t,c=d)),t=t.next;while(t!==l);return o}function fb(r,e){return St(r.prev,r,e.prev)<0&&St(e.next,r,r.next)<0}function pb(r,e,t,i){var n=r;do n.z===0&&(n.z=Hc(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,gb(n)}function gb(r){var e,t,i,n,s,o,a,l,h=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<h&&(a++,i=i.nextZ,!!i);e++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;t=i}s.nextZ=null,h*=2}while(o>1);return r}function Hc(r,e,t,i,n){return r=(r-t)*n|0,e=(e-i)*n|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function mb(r){var e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function eo(r,e,t,i,n,s,o,a){return(n-o)*(e-a)>=(r-o)*(s-a)&&(r-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(n-o)*(i-a)}function vb(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!yb(r,e)&&(la(r,e)&&la(e,r)&&_b(r,e)&&(St(r.prev,r,e.prev)||St(r,e.prev,e))||Wl(r,e)&&St(r.prev,r,r.next)>0&&St(e.prev,e,e.next)>0)}function St(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Wl(r,e){return r.x===e.x&&r.y===e.y}function Ym(r,e,t,i){var n=Yl(St(r,e,t)),s=Yl(St(r,e,i)),o=Yl(St(t,i,r)),a=Yl(St(t,i,e));return!!(n!==s&&o!==a||n===0&&Xl(r,t,e)||s===0&&Xl(r,i,e)||o===0&&Xl(t,r,i)||a===0&&Xl(t,e,i))}function Xl(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Yl(r){return r>0?1:r<0?-1:0}function yb(r,e){var t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Ym(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function la(r,e){return St(r.prev,r,r.next)<0?St(r,e,r.next)>=0&&St(r,r.prev,e)>=0:St(r,e,r.prev)<0||St(r,r.next,e)<0}function _b(r,e){var t=r,i=!1,n=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&n<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function Zm(r,e){var t=new Gc(r.i,r.x,r.y),i=new Gc(e.i,e.x,e.y),n=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=n,n.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function qm(r,e,t,i){var n=new Gc(r,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function ha(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Gc(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}jl.deviation=function(r,e,t,i){var n=e&&e.length,s=n?e[0]*t:r.length,o=Math.abs(Vc(r,0,s,t));if(n)for(var a=0,l=e.length;a<l;a++){var h=e[a]*t,u=a<l-1?e[a+1]*t:r.length;o-=Math.abs(Vc(r,h,u,t))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*t,f=i[a+1]*t,g=i[a+2]*t;c+=Math.abs((r[d]-r[g])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[g+1]-r[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function Vc(r,e,t,i){for(var n=0,s=e,o=t-i;s<t;s+=i)n+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return n}jl.flatten=function(r){for(var e=r[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0,n=0;n<r.length;n++){for(var s=0;s<r[n].length;s++)for(var o=0;o<e;o++)t.vertices.push(r[n][s][o]);n>0&&(i+=r[n-1].length,t.holes.push(i))}return t};var xb=Uc.exports;const wb=Dc(xb);var Zl={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Zl.exports,(function(r,e){(function(t){var i=e&&!e.nodeType&&e,n=r&&!r.nodeType&&r,s=typeof Mc=="object"&&Mc;(s.global===s||s.window===s||s.self===s)&&(t=s);var o,a=2147483647,l=36,h=1,u=26,c=38,d=700,f=72,g=128,p="-",m=/^xn--/,v=/[^\x20-\x7E]/,y=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=l-h,A=Math.floor,F=String.fromCharCode,C;function R(H){throw new RangeError(_[H])}function M(H,X){for(var K=H.length,Q=[];K--;)Q[K]=X(H[K]);return Q}function k(H,X){var K=H.split("@"),Q="";K.length>1&&(Q=K[0]+"@",H=K[1]),H=H.replace(y,".");var W=H.split("."),$=M(W,X).join(".");return Q+$}function z(H){for(var X=[],K=0,Q=H.length,W,$;K<Q;)W=H.charCodeAt(K++),W>=55296&&W<=56319&&K<Q?($=H.charCodeAt(K++),($&64512)==56320?X.push(((W&1023)<<10)+($&1023)+65536):(X.push(W),K--)):X.push(W);return X}function D(H){return M(H,function(X){var K="";return X>65535&&(X-=65536,K+=F(X>>>10&1023|55296),X=56320|X&1023),K+=F(X),K}).join("")}function S(H){return H-48<10?H-22:H-65<26?H-65:H-97<26?H-97:l}function b(H,X){return H+22+75*(H<26)-((X!=0)<<5)}function O(H,X,K){var Q=0;for(H=K?A(H/d):H>>1,H+=A(H/X);H>w*u>>1;Q+=l)H=A(H/w);return A(Q+(w+1)*H/(H+c))}function j(H){var X=[],K=H.length,Q,W=0,$=g,ne=f,_e,pe,Ce,Pe,Be,ke,Ge,$e,ft;for(_e=H.lastIndexOf(p),_e<0&&(_e=0),pe=0;pe<_e;++pe)H.charCodeAt(pe)>=128&&R("not-basic"),X.push(H.charCodeAt(pe));for(Ce=_e>0?_e+1:0;Ce<K;){for(Pe=W,Be=1,ke=l;Ce>=K&&R("invalid-input"),Ge=S(H.charCodeAt(Ce++)),(Ge>=l||Ge>A((a-W)/Be))&&R("overflow"),W+=Ge*Be,$e=ke<=ne?h:ke>=ne+u?u:ke-ne,!(Ge<$e);ke+=l)ft=l-$e,Be>A(a/ft)&&R("overflow"),Be*=ft;Q=X.length+1,ne=O(W-Pe,Q,Pe==0),A(W/Q)>a-$&&R("overflow"),$+=A(W/Q),W%=Q,X.splice(W++,0,$)}return D(X)}function V(H){var X,K,Q,W,$,ne,_e,pe,Ce,Pe,Be,ke=[],Ge,$e,ft,Pt;for(H=z(H),Ge=H.length,X=g,K=0,$=f,ne=0;ne<Ge;++ne)Be=H[ne],Be<128&&ke.push(F(Be));for(Q=W=ke.length,W&&ke.push(p);Q<Ge;){for(_e=a,ne=0;ne<Ge;++ne)Be=H[ne],Be>=X&&Be<_e&&(_e=Be);for($e=Q+1,_e-X>A((a-K)/$e)&&R("overflow"),K+=(_e-X)*$e,X=_e,ne=0;ne<Ge;++ne)if(Be=H[ne],Be<X&&++K>a&&R("overflow"),Be==X){for(pe=K,Ce=l;Pe=Ce<=$?h:Ce>=$+u?u:Ce-$,!(pe<Pe);Ce+=l)Pt=pe-Pe,ft=l-Pe,ke.push(F(b(Pe+Pt%ft,0))),pe=A(Pt/ft);ke.push(F(b(pe,0))),$=O(K,$e,Q==W),K=0,++Q}++K,++X}return ke.join("")}function Y(H){return k(H,function(X){return m.test(X)?j(X.slice(4).toLowerCase()):X})}function G(H){return k(H,function(X){return v.test(X)?"xn--"+V(X):X})}if(o={version:"1.4.1",ucs2:{decode:z,encode:D},decode:j,encode:V,toASCII:G,toUnicode:Y},i&&n)if(r.exports==i)n.exports=o;else for(C in o)o.hasOwnProperty(C)&&(i[C]=o[C]);else t.punycode=o})(Mc)})(Zl,Zl.exports),Zl.exports;var Km=TypeError;const Eb={},Tb=Object.freeze(Object.defineProperty({__proto__:null,default:Eb},Symbol.toStringTag,{value:"Module"})),bb=DT(Tb);var Qm=typeof Map=="function"&&Map.prototype,zc=Object.getOwnPropertyDescriptor&&Qm?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null;Qm&&zc&&typeof zc.get=="function"&&zc.get;var Jm=typeof Set=="function"&&Set.prototype,jc=Object.getOwnPropertyDescriptor&&Jm?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null;Jm&&jc&&typeof jc.get=="function"&&jc.get;var $m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ab=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Sb=bb,ev=Sb.custom;Rb(ev);function Rb(r){if(Ab)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!$m)return!1;try{return $m.call(r),!0}catch{}return!1}var tv=Object,Cb=Error,Pb=EvalError,Ib=RangeError,Mb=ReferenceError,Db=SyntaxError,Ob=URIError,Lb=Math.abs,Nb=Math.floor,Fb=Math.max,Bb=Math.min,kb=Math.pow,Ub=Math.round,Hb=Number.isNaN||function(r){return r!==r},Gb=Hb,Vb=function(r){return Gb(r)||r===0?r:r<0?-1:1},zb=Object.getOwnPropertyDescriptor,ql=zb;if(ql)try{ql([],"length")}catch{ql=null}var iv=ql,Kl=Object.defineProperty||!1;if(Kl)try{Kl({},"a",{value:1})}catch{Kl=!1}var jb=Kl,rv,nv;function Wb(){return nv||(nv=1,rv=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var r={},e=Symbol("test"),t=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(t)!=="[object Symbol]")return!1;var i=42;r[e]=i;for(var n in r)return!1;if(typeof Object.keys=="function"&&Object.keys(r).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(r).length!==0)return!1;var s=Object.getOwnPropertySymbols(r);if(s.length!==1||s[0]!==e||!Object.prototype.propertyIsEnumerable.call(r,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(r,e);if(o.value!==i||o.enumerable!==!0)return!1}return!0}),rv}var Wc,sv;function Xb(){if(sv)return Wc;sv=1;var r=typeof Symbol<"u"&&Symbol,e=Wb();return Wc=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Wc}var ov,av;function lv(){return av||(av=1,ov=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),ov}var Xc,hv;function uv(){if(hv)return Xc;hv=1;var r=tv;return Xc=r.getPrototypeOf||null,Xc}var Yb="Function.prototype.bind called on incompatible ",Zb=Object.prototype.toString,qb=Math.max,Kb="[object Function]",cv=function(r,e){for(var t=[],i=0;i<r.length;i+=1)t[i]=r[i];for(var n=0;n<e.length;n+=1)t[n+r.length]=e[n];return t},Qb=function(r,e){for(var t=[],i=e,n=0;i<r.length;i+=1,n+=1)t[n]=r[i];return t},Jb=function(r,e){for(var t="",i=0;i<r.length;i+=1)t+=r[i],i+1<r.length&&(t+=e);return t},$b=function(r){var e=this;if(typeof e!="function"||Zb.apply(e)!==Kb)throw new TypeError(Yb+e);for(var t=Qb(arguments,1),i,n=function(){if(this instanceof i){var h=e.apply(this,cv(t,arguments));return Object(h)===h?h:this}return e.apply(r,cv(t,arguments))},s=qb(0,e.length-t.length),o=[],a=0;a<s;a++)o[a]="$"+a;if(i=Function("binder","return function ("+Jb(o,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var l=function(){};l.prototype=e.prototype,i.prototype=new l,l.prototype=null}return i},e2=$b,Ql=Function.prototype.bind||e2,dv,fv;function Yc(){return fv||(fv=1,dv=Function.prototype.call),dv}var pv,gv;function mv(){return gv||(gv=1,pv=Function.prototype.apply),pv}var t2=typeof Reflect<"u"&&Reflect&&Reflect.apply,i2=Ql,r2=mv(),n2=Yc(),s2=t2,o2=s2||i2.call(n2,r2),a2=Ql,l2=Km,h2=Yc(),u2=o2,vv=function(r){if(r.length<1||typeof r[0]!="function")throw new l2("a function is required");return u2(a2,h2,r)},Zc,yv;function c2(){if(yv)return Zc;yv=1;var r=vv,e=iv,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!t&&e&&e(Object.prototype,"__proto__"),n=Object,s=n.getPrototypeOf;return Zc=i&&typeof i.get=="function"?r([i.get]):typeof s=="function"?(function(o){return s(o==null?o:n(o))}):!1,Zc}var qc,_v;function d2(){if(_v)return qc;_v=1;var r=lv(),e=uv(),t=c2();return qc=r?function(i){return r(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,qc}var Kc,xv;function f2(){if(xv)return Kc;xv=1;var r=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=Ql;return Kc=t.call(r,e),Kc}var et,p2=tv,g2=Cb,m2=Pb,v2=Ib,y2=Mb,to=Db,io=Km,_2=Ob,x2=Lb,w2=Nb,E2=Fb,T2=Bb,b2=kb,A2=Ub,S2=Vb,wv=Function,Qc=function(r){try{return wv('"use strict"; return ('+r+").constructor;")()}catch{}},ua=iv,R2=jb,Jc=function(){throw new io},C2=ua?(function(){try{return arguments.callee,Jc}catch{try{return ua(arguments,"callee").get}catch{return Jc}}})():Jc,ro=Xb()(),Yt=d2(),P2=uv(),I2=lv(),Ev=mv(),ca=Yc(),no={},M2=typeof Uint8Array>"u"||!Yt?et:Yt(Uint8Array),ns={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?et:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?et:ArrayBuffer,"%ArrayIteratorPrototype%":ro&&Yt?Yt([][Symbol.iterator]()):et,"%AsyncFromSyncIteratorPrototype%":et,"%AsyncFunction%":no,"%AsyncGenerator%":no,"%AsyncGeneratorFunction%":no,"%AsyncIteratorPrototype%":no,"%Atomics%":typeof Atomics>"u"?et:Atomics,"%BigInt%":typeof BigInt>"u"?et:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?et:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?et:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?et:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":g2,"%eval%":eval,"%EvalError%":m2,"%Float16Array%":typeof Float16Array>"u"?et:Float16Array,"%Float32Array%":typeof Float32Array>"u"?et:Float32Array,"%Float64Array%":typeof Float64Array>"u"?et:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?et:FinalizationRegistry,"%Function%":wv,"%GeneratorFunction%":no,"%Int8Array%":typeof Int8Array>"u"?et:Int8Array,"%Int16Array%":typeof Int16Array>"u"?et:Int16Array,"%Int32Array%":typeof Int32Array>"u"?et:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ro&&Yt?Yt(Yt([][Symbol.iterator]())):et,"%JSON%":typeof JSON=="object"?JSON:et,"%Map%":typeof Map>"u"?et:Map,"%MapIteratorPrototype%":typeof Map>"u"||!ro||!Yt?et:Yt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":p2,"%Object.getOwnPropertyDescriptor%":ua,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?et:Promise,"%Proxy%":typeof Proxy>"u"?et:Proxy,"%RangeError%":v2,"%ReferenceError%":y2,"%Reflect%":typeof Reflect>"u"?et:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?et:Set,"%SetIteratorPrototype%":typeof Set>"u"||!ro||!Yt?et:Yt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?et:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ro&&Yt?Yt(""[Symbol.iterator]()):et,"%Symbol%":ro?Symbol:et,"%SyntaxError%":to,"%ThrowTypeError%":C2,"%TypedArray%":M2,"%TypeError%":io,"%Uint8Array%":typeof Uint8Array>"u"?et:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?et:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?et:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?et:Uint32Array,"%URIError%":_2,"%WeakMap%":typeof WeakMap>"u"?et:WeakMap,"%WeakRef%":typeof WeakRef>"u"?et:WeakRef,"%WeakSet%":typeof WeakSet>"u"?et:WeakSet,"%Function.prototype.call%":ca,"%Function.prototype.apply%":Ev,"%Object.defineProperty%":R2,"%Object.getPrototypeOf%":P2,"%Math.abs%":x2,"%Math.floor%":w2,"%Math.max%":E2,"%Math.min%":T2,"%Math.pow%":b2,"%Math.round%":A2,"%Math.sign%":S2,"%Reflect.getPrototypeOf%":I2};if(Yt)try{null.error}catch(r){var D2=Yt(Yt(r));ns["%Error.prototype%"]=D2}var O2=function r(e){var t;if(e==="%AsyncFunction%")t=Qc("async function () {}");else if(e==="%GeneratorFunction%")t=Qc("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Qc("async function* () {}");else if(e==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(t=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var n=r("%AsyncGenerator%");n&&Yt&&(t=Yt(n.prototype))}return ns[e]=t,t},Tv={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},da=Ql,Jl=f2(),L2=da.call(ca,Array.prototype.concat),N2=da.call(Ev,Array.prototype.splice),bv=da.call(ca,String.prototype.replace),$l=da.call(ca,String.prototype.slice),F2=da.call(ca,RegExp.prototype.exec),B2=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,k2=/\\(\\)?/g,U2=function(r){var e=$l(r,0,1),t=$l(r,-1);if(e==="%"&&t!=="%")throw new to("invalid intrinsic syntax, expected closing `%`");if(t==="%"&&e!=="%")throw new to("invalid intrinsic syntax, expected opening `%`");var i=[];return bv(r,B2,function(n,s,o,a){i[i.length]=o?bv(a,k2,"$1"):s||n}),i},H2=function(r,e){var t=r,i;if(Jl(Tv,t)&&(i=Tv[t],t="%"+i[0]+"%"),Jl(ns,t)){var n=ns[t];if(n===no&&(n=O2(t)),typeof n>"u"&&!e)throw new io("intrinsic "+r+" exists, but is not available. Please file an issue!");return{alias:i,name:t,value:n}}throw new to("intrinsic "+r+" does not exist!")},$c=function(r,e){if(typeof r!="string"||r.length===0)throw new io("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new io('"allowMissing" argument must be a boolean');if(F2(/^%?[^%]*%?$/,r)===null)throw new to("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var t=U2(r),i=t.length>0?t[0]:"",n=H2("%"+i+"%",e),s=n.name,o=n.value,a=!1,l=n.alias;l&&(i=l[0],N2(t,L2([0,1],l)));for(var h=1,u=!0;h<t.length;h+=1){var c=t[h],d=$l(c,0,1),f=$l(c,-1);if((d==='"'||d==="'"||d==="`"||f==='"'||f==="'"||f==="`")&&d!==f)throw new to("property names with quotes must have matching quotes");if((c==="constructor"||!u)&&(a=!0),i+="."+c,s="%"+i+"%",Jl(ns,s))o=ns[s];else if(o!=null){if(!(c in o)){if(!e)throw new io("base intrinsic for "+r+" exists, but the property is not available.");return}if(ua&&h+1>=t.length){var g=ua(o,c);u=!!g,u&&"get"in g&&!("originalValue"in g.get)?o=g.get:o=o[c]}else u=Jl(o,c),o=o[c];u&&!a&&(ns[s]=o)}}return o},Av=$c,Sv=vv,G2=Sv([Av("%String.prototype.indexOf%")]),Rv=function(r,e){var t=Av(r,!!e);return typeof t=="function"&&G2(r,".prototype.")>-1?Sv([t]):t},V2=$c,fa=Rv;V2("%Map%",!0),fa("Map.prototype.get",!0),fa("Map.prototype.set",!0),fa("Map.prototype.has",!0),fa("Map.prototype.delete",!0),fa("Map.prototype.size",!0);var z2=$c,eh=Rv;z2("%WeakMap%",!0),eh("WeakMap.prototype.get",!0),eh("WeakMap.prototype.set",!0),eh("WeakMap.prototype.has",!0),eh("WeakMap.prototype.delete",!0),(function(){for(var r=[],e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})();const Cv={};function Je(r,e,t=3){if(Cv[e])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${e}
|
|
82
|
+
Deprecated since v${r}`):(i=i.split(`
|
|
83
|
+
`).splice(t).join(`
|
|
84
|
+
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}
|
|
85
|
+
Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}
|
|
86
|
+
Deprecated since v${r}`),console.warn(i))),Cv[e]=!0}function cr(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function pa(r){return r.split("?")[0].split("#")[0]}function j2(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function W2(r,e,t){return r.replace(new RegExp(j2(e),"g"),t)}function X2(r,e){let t="",i=0,n=-1,s=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(n===a-1||s===1))if(n!==a-1&&s===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",i=0):(t=t.slice(0,l),i=t.length-1-t.lastIndexOf("/")),n=a,s=0;continue}}else if(t.length===2||t.length===1){t="",i=0,n=a,s=0;continue}}}else t.length>0?t+=`/${r.slice(n+1,a)}`:t=r.slice(n+1,a),i=a-n-1;n=a,s=0}else o===46&&s!==-1?++s:s=-1}return t}const Zt={toPosix(r){return W2(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){cr(r),r=this.toPosix(r);const e=/^file:\/\/\//.exec(r);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(cr(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=pa(this.toPosix(e??ye.ADAPTER.getBaseUrl())),n=pa(this.toPosix(t??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Zt.join(n,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(cr(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="";const t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));const i=r.endsWith("/");return r=X2(r),r.length>0&&i&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return cr(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){const i=r[t];if(cr(i),i.length>0)if(e===void 0)e=i;else{const n=r[t-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(cr(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0);const t=e===47;let i=-1,n=!0;const s=this.getProtocol(r),o=r;r=r.slice(s.length);for(let a=r.length-1;a>=1;--a)if(e=r.charCodeAt(a),e===47){if(!n){i=a;break}}else n=!1;return i===-1?t?"/":this.isUrl(o)?s+r:s:t&&i===1?"//":s+r.slice(0,i)},rootname(r){cr(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){const t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){cr(r),e&&cr(e),r=pa(this.toPosix(r));let t=0,i=-1,n=!0,s;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let o=e.length-1,a=-1;for(s=r.length-1;s>=0;--s){const l=r.charCodeAt(s);if(l===47){if(!n){t=s+1;break}}else a===-1&&(n=!1,a=s+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(i=s):(o=-1,i=a))}return t===i?i=a:i===-1&&(i=r.length),r.slice(t,i)}for(s=r.length-1;s>=0;--s)if(r.charCodeAt(s)===47){if(!n){t=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":r.slice(t,i)},extname(r){cr(r),r=pa(this.toPosix(r));let e=-1,t=0,i=-1,n=!0,s=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!n){t=o+1;break}continue}i===-1&&(n=!1,i=o+1),a===46?e===-1?e=o:s!==1&&(s=1):e!==-1&&(s=-1)}return e===-1||i===-1||s===0||s===1&&e===i-1&&e===t+1?"":r.slice(e,i)},parse(r){cr(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=pa(this.toPosix(r));let t=r.charCodeAt(0);const i=this.isAbsolute(r);let n;e.root=this.rootname(r),i||this.hasProtocol(r)?n=1:n=0;let s=-1,o=0,a=-1,l=!0,h=r.length-1,u=0;for(;h>=n;--h){if(t=r.charCodeAt(h),t===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),t===46?s===-1?s=h:u!==1&&(u=1):s!==-1&&(u=-1)}return s===-1||a===-1||u===0||u===1&&s===a-1&&s===o+1?a!==-1&&(o===0&&i?e.base=e.name=r.slice(1,a):e.base=e.name=r.slice(o,a)):(o===0&&i?(e.name=r.slice(1,s),e.base=r.slice(1,a)):(e.name=r.slice(o,s),e.base=r.slice(o,a)),e.ext=r.slice(s,a)),e.dir=this.dirname(r),e},sep:"/",delimiter:":",joinExtensions:[".html"]};let ed;async function Y2(){return ed??(ed=(async()=>{var r;const e=document.createElement("canvas").getContext("webgl");if(!e)return bi.UNPACK;const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return bi.UNPACK;const i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);const n=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,n),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,s),e.deleteFramebuffer(n),e.deleteTexture(i),(r=e.getExtension("WEBGL_lose_context"))==null||r.loseContext(),s[0]<=s[3]?bi.PMA:bi.UNPACK})()),ed}let td;function Z2(){return typeof td>"u"&&(td=(function(){var r;const e={stencil:!0,failIfMajorPerformanceCaveat:ye.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!ye.ADAPTER.getWebGLRenderingContext())return!1;const t=ye.ADAPTER.createCanvas();let i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);const n=!!((r=i==null?void 0:i.getContextAttributes())!=null&&r.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,n}catch{return!1}})()),td}var q2={grad:.9,turn:360,rad:360/(2*Math.PI)},Jr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},qt=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},Qi=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},Pv=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Iv=function(r){return{r:Qi(r.r,0,255),g:Qi(r.g,0,255),b:Qi(r.b,0,255),a:Qi(r.a)}},id=function(r){return{r:qt(r.r),g:qt(r.g),b:qt(r.b),a:qt(r.a,3)}},K2=/^#([0-9a-f]{3,8})$/i,th=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},Mv=function(r){var e=r.r,t=r.g,i=r.b,n=r.a,s=Math.max(e,t,i),o=s-Math.min(e,t,i),a=o?s===e?(t-i)/o:s===t?2+(i-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:n}},Dv=function(r){var e=r.h,t=r.s,i=r.v,n=r.a;e=e/360*6,t/=100,i/=100;var s=Math.floor(e),o=i*(1-t),a=i*(1-(e-s)*t),l=i*(1-(1-e+s)*t),h=s%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:n}},Ov=function(r){return{h:Pv(r.h),s:Qi(r.s,0,100),l:Qi(r.l,0,100),a:Qi(r.a)}},Lv=function(r){return{h:qt(r.h),s:qt(r.s),l:qt(r.l),a:qt(r.a,3)}},Nv=function(r){return Dv((t=(e=r).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},ga=function(r){return{h:(e=Mv(r)).h,s:(n=(200-(t=e.s))*(i=e.v)/100)>0&&n<200?t*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:e.a};var e,t,i,n},Q2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,J2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$2=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,eA=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rd={string:[[function(r){var e=K2.exec(r);return e?(r=e[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?qt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?qt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=$2.exec(r)||eA.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:Iv({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(r){var e=Q2.exec(r)||J2.exec(r);if(!e)return null;var t,i,n=Ov({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(q2[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Nv(n)},"hsl"]],object:[[function(r){var e=r.r,t=r.g,i=r.b,n=r.a,s=n===void 0?1:n;return Jr(e)&&Jr(t)&&Jr(i)?Iv({r:Number(e),g:Number(t),b:Number(i),a:Number(s)}):null},"rgb"],[function(r){var e=r.h,t=r.s,i=r.l,n=r.a,s=n===void 0?1:n;if(!Jr(e)||!Jr(t)||!Jr(i))return null;var o=Ov({h:Number(e),s:Number(t),l:Number(i),a:Number(s)});return Nv(o)},"hsl"],[function(r){var e=r.h,t=r.s,i=r.v,n=r.a,s=n===void 0?1:n;if(!Jr(e)||!Jr(t)||!Jr(i))return null;var o=(function(a){return{h:Pv(a.h),s:Qi(a.s,0,100),v:Qi(a.v,0,100),a:Qi(a.a)}})({h:Number(e),s:Number(t),v:Number(i),a:Number(s)});return Dv(o)},"hsv"]]},Fv=function(r,e){for(var t=0;t<e.length;t++){var i=e[t][0](r);if(i)return[i,e[t][1]]}return[null,void 0]},tA=function(r){return typeof r=="string"?Fv(r.trim(),rd.string):typeof r=="object"&&r!==null?Fv(r,rd.object):[null,void 0]},nd=function(r,e){var t=ga(r);return{h:t.h,s:Qi(t.s+100*e,0,100),l:t.l,a:t.a}},sd=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Bv=function(r,e){var t=ga(r);return{h:t.h,s:t.s,l:Qi(t.l+100*e,0,100),a:t.a}},od=(function(){function r(e){this.parsed=tA(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return qt(sd(this.rgba),2)},r.prototype.isDark=function(){return sd(this.rgba)<.5},r.prototype.isLight=function(){return sd(this.rgba)>=.5},r.prototype.toHex=function(){return e=id(this.rgba),t=e.r,i=e.g,n=e.b,o=(s=e.a)<1?th(qt(255*s)):"","#"+th(t)+th(i)+th(n)+o;var e,t,i,n,s,o},r.prototype.toRgb=function(){return id(this.rgba)},r.prototype.toRgbString=function(){return e=id(this.rgba),t=e.r,i=e.g,n=e.b,(s=e.a)<1?"rgba("+t+", "+i+", "+n+", "+s+")":"rgb("+t+", "+i+", "+n+")";var e,t,i,n,s},r.prototype.toHsl=function(){return Lv(ga(this.rgba))},r.prototype.toHslString=function(){return e=Lv(ga(this.rgba)),t=e.h,i=e.s,n=e.l,(s=e.a)<1?"hsla("+t+", "+i+"%, "+n+"%, "+s+")":"hsl("+t+", "+i+"%, "+n+"%)";var e,t,i,n,s},r.prototype.toHsv=function(){return e=Mv(this.rgba),{h:qt(e.h),s:qt(e.s),v:qt(e.v),a:qt(e.a,3)};var e},r.prototype.invert=function(){return Mr({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},r.prototype.saturate=function(e){return e===void 0&&(e=.1),Mr(nd(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),Mr(nd(this.rgba,-e))},r.prototype.grayscale=function(){return Mr(nd(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),Mr(Bv(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),Mr(Bv(this.rgba,-e))},r.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},r.prototype.alpha=function(e){return typeof e=="number"?Mr({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):qt(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=ga(this.rgba);return typeof e=="number"?Mr({h:e,s:t.s,l:t.l,a:t.a}):qt(t.h)},r.prototype.isEqual=function(e){return this.toHex()===Mr(e).toHex()},r})(),Mr=function(r){return r instanceof od?r:new od(r)},kv=[],iA=function(r){r.forEach(function(e){kv.indexOf(e)<0&&(e(od,rd),kv.push(e))})};function rA(r,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in t)i[t[n]]=n;var s={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var u=this.toRgb(),c=1/0,d="black";if(!s.length)for(var f in t)s[f]=new r(t[f]).toRgb();for(var g in t){var p=(a=u,l=s[g],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));p<c&&(c=p,d=g)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new r(l).toRgb():null},"name"])}iA([rA]);const so=class Kh{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(e){if(e instanceof Kh)this._value=this.cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,e))&&(this.normalize(e),this._value=this.cloneSource(e))}}get value(){return this._value}cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}isSourceEqual(e,t){const i=typeof e;if(i!==typeof t)return!1;if(i==="number"||i==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((n,s)=>n===t[s]);if(e!==null&&t!==null){const n=Object.keys(e),s=Object.keys(t);return n.length!==s.length?!1:n.every(o=>e[o]===t[o])}return e===t}toRgba(){const[e,t,i,n]=this._components;return{r:e,g:t,b:i,a:n}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,n]=this._components;return e=e??[],e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(n*255),e}toRgbArray(e){e=e??[];const[t,i,n]=this._components;return e[0]=t,e[1]=i,e[2]=n,e}toNumber(){return this._int}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,n,s]=Kh.temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=n,this._components[3]*=s,this.refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this.refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,s=this._int&255;return t&&(i=i*e+.5|0,n=n*e+.5|0,s=s*e+.5|0),(e*255<<24)+(i<<16)+(n<<8)+s}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this}round(e){const[t,i,n]=this._components;return this._components[0]=Math.round(t*e)/e,this._components[1]=Math.round(i*e)/e,this._components[2]=Math.round(n*e)/e,this.refreshInt(),this._value=null,this}toArray(e){e=e??[];const[t,i,n,s]=this._components;return e[0]=t,e[1]=i,e[2]=n,e[3]=s,e}normalize(e){let t,i,n,s;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,i=(o>>8&255)/255,n=(o&255)/255,s=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,n,s=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,n,s=255]=e,t/=255,i/=255,n/=255,s/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=Kh.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=Mr(e);o.isValid()&&({r:t,g:i,b:n,a:s}=o.rgba,t/=255,i/=255,n/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=n,this._components[3]=s,this.refreshInt();else throw new Error(`Unable to convert color ${e}`)}refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((n,s)=>{e[s]=Math.min(Math.max(n,t),i)}),e)}};so.shared=new so,so.temp=new so,so.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ut=so;function nA(r){return Je("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),ut.shared.setValue(r).toHex()}function sA(r){return Je("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),ut.shared.setValue(r).toNumber()}function oA(){const r=[],e=[];for(let i=0;i<32;i++)r[i]=i,e[i]=i;r[Ne.NORMAL_NPM]=Ne.NORMAL,r[Ne.ADD_NPM]=Ne.ADD,r[Ne.SCREEN_NPM]=Ne.SCREEN,e[Ne.NORMAL]=Ne.NORMAL_NPM,e[Ne.ADD]=Ne.ADD_NPM,e[Ne.SCREEN]=Ne.SCREEN_NPM;const t=[];return t.push(e),t.push(r),t}const Uv=oA();function Hv(r,e){return Uv[e?1:0][r]}function aA(r,e=null){const t=r*6;if(e=e||new Uint16Array(t),e.length!==t)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);for(let i=0,n=0;i<t;i+=6,n+=4)e[i+0]=n+0,e[i+1]=n+1,e[i+2]=n+2,e[i+3]=n+0,e[i+4]=n+2,e[i+5]=n+3;return e}function Gv(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}function ih(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Vv(r){return!(r&r-1)&&!!r}function zv(r){let e=(r>65535?1:0)<<4;r>>>=e;let t=(r>255?1:0)<<3;return r>>>=t,e|=t,t=(r>15?1:0)<<2,r>>>=t,e|=t,t=(r>3?1:0)<<1,r>>>=t,e|=t,e|r>>1}function oo(r,e,t){const i=r.length;let n;if(e>=i||t===0)return;t=e+t>i?i-e:t;const s=i-t;for(n=e;n<s;++n)r[n]=r[n+t];r.length=s}function Tn(r){return r===0?0:r<0?-1:1}let lA=0;function ss(){return++lA}const ad=class{constructor(r,e,t,i){this.left=r,this.top=e,this.right=t,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};ad.EMPTY=new ad(0,0,0,0);let jv=ad;const Wv={},Dr=Object.create(null),bn=Object.create(null);class hA{constructor(e,t,i){this._canvas=ye.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||ye.RESOLUTION,this.resize(e,t)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(e,t){this._checkDestroyed(),this._canvas.width=Math.round(e*this.resolution),this._canvas.height=Math.round(t*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(e){this._checkDestroyed(),this._canvas.width=Math.round(e)}get height(){return this._checkDestroyed(),this._canvas.height}set height(e){this._checkDestroyed(),this._canvas.height=Math.round(e)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Xv(r,e,t){for(let i=0,n=4*t*e;i<e;++i,n+=4)if(r[n+3]!==0)return!1;return!0}function Yv(r,e,t,i,n){const s=4*e;for(let o=i,a=i*s+4*t;o<=n;++o,a+=s)if(r[a+3]!==0)return!1;return!0}function uA(r){const{width:e,height:t}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const n=i.getImageData(0,0,e,t).data;let s=0,o=0,a=e-1,l=t-1;for(;o<t&&Xv(n,e,o);)++o;if(o===t)return jv.EMPTY;for(;Xv(n,e,l);)--l;for(;Yv(n,e,s,o,l);)++s;for(;Yv(n,e,a,o,l);)--a;return++a,++l,new jv(s,o,a,l)}function cA(r){const e=uA(r),{width:t,height:i}=e;let n=null;if(!e.isEmpty()){const s=r.getContext("2d");if(s===null)throw new TypeError("Failed to get canvas 2D context");n=s.getImageData(e.left,e.top,t,i)}return{width:t,height:i,data:n}}function dA(r,e=globalThis.location){if(r.startsWith("data:"))return"";e=e||globalThis.location;const t=new URL(r,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function $r(r,e=1){var t;const i=(t=ye.RETINA_PREFIX)==null?void 0:t.exec(r);return i?parseFloat(i[1]):e}var ge=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))(ge||{});const ld=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Zv=(r,e)=>ld(r).priority??e,Ee={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(ld).forEach(e=>{e.type.forEach(t=>{var i,n;return(n=(i=this._removeHandlers)[t])==null?void 0:n.call(i,e)})}),this},add(...r){return r.map(ld).forEach(e=>{e.type.forEach(t=>{var i,n;const s=this._addHandlers,o=this._queue;s[t]?(i=s[t])==null||i.call(s,e):(o[t]=o[t]||[],(n=o[t])==null||n.push(e))})}),this},handle(r,e,t){var i;const n=this._addHandlers,s=this._removeHandlers;if(n[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);n[r]=e,s[r]=t;const o=this._queue;return o[r]&&((i=o[r])==null||i.forEach(a=>e(a)),delete o[r]),this},handleByMap(r,e){return this.handle(r,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByList(r,e,t=-1){return this.handle(r,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((n,s)=>Zv(s,t)-Zv(n,t)))},i=>{const n=e.indexOf(i.ref);n!==-1&&e.splice(n,1)})}};class hd{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}const fA=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
87
|
+
`);function pA(r){let e="";for(let t=0;t<r;++t)t>0&&(e+=`
|
|
88
|
+
else `),t<r-1&&(e+=`if(test == ${t}.0){}`);return e}function gA(r,e){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);for(;;){const i=fA.replace(/%forloop%/gi,pA(r));if(e.shaderSource(t,i),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))r=r/2|0;else break}return r}const ud=0,cd=1,dd=2,fd=3,pd=4,gd=5;class Or{constructor(){this.data=0,this.blendMode=Ne.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<ud)}set blend(e){!!(this.data&1<<ud)!==e&&(this.data^=1<<ud)}get offsets(){return!!(this.data&1<<cd)}set offsets(e){!!(this.data&1<<cd)!==e&&(this.data^=1<<cd)}get culling(){return!!(this.data&1<<dd)}set culling(e){!!(this.data&1<<dd)!==e&&(this.data^=1<<dd)}get depthTest(){return!!(this.data&1<<fd)}set depthTest(e){!!(this.data&1<<fd)!==e&&(this.data^=1<<fd)}get depthMask(){return!!(this.data&1<<gd)}set depthMask(e){!!(this.data&1<<gd)!==e&&(this.data^=1<<gd)}get clockwiseFrontFace(){return!!(this.data&1<<pd)}set clockwiseFrontFace(e){!!(this.data&1<<pd)!==e&&(this.data^=1<<pd)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==Ne.NONE,this._blendMode=e}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}static for2d(){const e=new Or;return e.depthTest=!1,e.blend=!0,e}}Or.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const md=[];function qv(r,e){if(!r)return null;let t="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(t=i[1].toLowerCase())}for(let i=md.length-1;i>=0;--i){const n=md[i];if(n.test&&n.test(r,t))return new n(r,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class dr{constructor(e){this.items=[],this._name=e,this._aliasCount=0}emit(e,t,i,n,s,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](e,t,i,n,s,o,a,l);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this}contains(e){return this.items.includes(e)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(dr.prototype,{dispatch:{value:dr.prototype.emit},run:{value:dr.prototype.emit}});class ma{constructor(e=0,t=0){this._width=e,this._height=t,this.destroyed=!1,this.internal=!1,this.onResize=new dr("setRealSize"),this.onUpdate=new dr("update"),this.onError=new dr("onError")}bind(e){this.onResize.add(e),this.onUpdate.add(e),this.onError.add(e),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(e){this.onResize.remove(e),this.onUpdate.remove(e),this.onError.remove(e)}resize(e,t){(e!==this._width||t!==this._height)&&(this._width=e,this._height=t,this.onResize.emit(e,t))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(e,t,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(e,t){return!1}}class rh extends ma{constructor(e,t){const{width:i,height:n}=t||{};if(!i||!n)throw new Error("BufferResource width or height invalid");super(i,n),this.data=e,this.unpackAlignment=t.unpackAlignment??4}upload(e,t,i){const n=e.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,this.unpackAlignment),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===bi.UNPACK);const s=t.realWidth,o=t.realHeight;return i.width===s&&i.height===o?n.texSubImage2D(t.target,0,0,0,s,o,t.format,i.type,this.data):(i.width=s,i.height=o,n.texImage2D(t.target,0,i.internalFormat,s,o,0,t.format,i.type,this.data)),!0}dispose(){this.data=null}static test(e){return e===null||e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}const mA={scaleMode:qr.NEAREST,alphaMode:bi.NPM},vd=class Ao extends oa{constructor(e=null,t=null){super(),t=Object.assign({},Ao.defaultOptions,t);const{alphaMode:i,mipmap:n,anisotropicLevel:s,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:f,resourceOptions:g}=t;e&&!(e instanceof ma)&&(e=qv(e,g),e.internal=!0),this.resolution=f||ye.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=n,this.anisotropicLevel=s,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=ss(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(e)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(e){this._mipmap!==e&&(this._mipmap=e,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(e){this._scaleMode!==e&&(this._scaleMode=e,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(e){this._wrapMode!==e&&(this._wrapMode=e,this.dirtyStyleId++)}setStyle(e,t){let i;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,i=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,i=!0),i&&this.dirtyStyleId++,this}setSize(e,t,i){return i=i||this.resolution,this.setRealSize(e*i,t*i,i)}setRealSize(e,t,i){return this.resolution=i||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Vv(this.realWidth)&&Vv(this.realHeight)}setResolution(e){const t=this.resolution;return t===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*t)/e,this.height=Math.round(this.height*t)/e,this.emit("update",this)),this._refreshPOT(),this)}setResource(e){if(this.resource===e)return this;if(this.resource)throw new Error("Resource can be set only once");return e.bind(this),this.resource=e,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(e){this.emit("error",this,e)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete bn[this.cacheId],delete Dr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Ao.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(e,t,i=ye.STRICT_TEXTURE_CACHE){const n=typeof e=="string";let s=null;if(n)s=e;else{if(!e._pixiId){const a=(t==null?void 0:t.pixiIdPrefix)||"pixiid";e._pixiId=`${a}_${ss()}`}s=e._pixiId}let o=bn[s];if(n&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in BaseTextureCache.`);return o||(o=new Ao(e,t),o.cacheId=s,Ao.addToCache(o,s)),o}static fromBuffer(e,t,i,n){e=e||new Float32Array(t*i*4);const s=new rh(e,{width:t,height:i,...n==null?void 0:n.resourceOptions});let o,a;return e instanceof Float32Array?(o=he.RGBA,a=Re.FLOAT):e instanceof Int32Array?(o=he.RGBA_INTEGER,a=Re.INT):e instanceof Uint32Array?(o=he.RGBA_INTEGER,a=Re.UNSIGNED_INT):e instanceof Int16Array?(o=he.RGBA_INTEGER,a=Re.SHORT):e instanceof Uint16Array?(o=he.RGBA_INTEGER,a=Re.UNSIGNED_SHORT):e instanceof Int8Array?(o=he.RGBA,a=Re.BYTE):(o=he.RGBA,a=Re.UNSIGNED_BYTE),s.internal=!0,new Ao(s,Object.assign({},mA,{type:a,format:o},n))}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),bn[t]&&bn[t]!==e&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),bn[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=bn[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete bn[e],t}}else if(e!=null&&e.textureCacheIds){for(let t=0;t<e.textureCacheIds.length;++t)delete bn[e.textureCacheIds[t]];return e.textureCacheIds.length=0,e}return null}};vd.defaultOptions={mipmap:Cr.POW2,anisotropicLevel:0,scaleMode:qr.LINEAR,wrapMode:En.CLAMP,alphaMode:bi.UNPACK,target:Js.TEXTURE_2D,format:he.RGBA,type:Re.UNSIGNED_BYTE},vd._globalBatch=0;let ze=vd;class yd{constructor(){this.texArray=null,this.blend=0,this.type=Rr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let vA=0;class Mt{constructor(e,t=!0,i=!1){this.data=e||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=t,this.id=vA++,this.disposeRunner=new dr("disposeBuffer")}update(e){e instanceof Array&&(e=new Float32Array(e)),this.data=e||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(e){this.type=e?Ir.ELEMENT_ARRAY_BUFFER:Ir.ARRAY_BUFFER}get index(){return this.type===Ir.ELEMENT_ARRAY_BUFFER}static from(e){return e instanceof Array&&(e=new Float32Array(e)),new Mt(e)}}class nh{constructor(e,t=0,i=!1,n=Re.FLOAT,s,o,a,l=1){this.buffer=e,this.size=t,this.normalized=i,this.type=n,this.stride=s,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(e,t,i,n,s){return new nh(e,t,i,n,s)}}const yA={Float32Array,Uint32Array,Int32Array,Uint8Array};function _A(r,e){let t=0,i=0;const n={};for(let l=0;l<r.length;l++)i+=e[l],t+=r[l].length;const s=new ArrayBuffer(t*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=e[l],u=r[l],c=Gv(u);n[c]||(n[c]=new yA[c](s)),o=n[c];for(let d=0;d<u.length;d++){const f=(d/h|0)*i+a,g=d%h;o[f+g]=u[d]}a+=h}return new Float32Array(s)}const Kv={5126:4,5123:2,5121:1};let xA=0;const wA={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class An{constructor(e=[],t={}){this.buffers=e,this.indexBuffer=null,this.attributes=t,this.glVertexArrayObjects={},this.id=xA++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new dr("disposeGeometry"),this.refCount=0}addAttribute(e,t,i=0,n=!1,s,o,a,l=!1){if(!t)throw new Error("You must pass a buffer when creating an attribute");t instanceof Mt||(t instanceof Array&&(t=new Float32Array(t)),t=new Mt(t));const h=e.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],t,i,n,s);return this}let u=this.buffers.indexOf(t);return u===-1&&(this.buffers.push(t),u=this.buffers.length-1),this.attributes[e]=new nh(u,i,n,s,o,a,l),this.instanced=this.instanced||l,this}getAttribute(e){return this.attributes[e]}getBuffer(e){return this.buffers[this.getAttribute(e).buffer]}addIndex(e){return e instanceof Mt||(e instanceof Array&&(e=new Uint16Array(e)),e=new Mt(e)),e.type=Ir.ELEMENT_ARRAY_BUFFER,this.indexBuffer=e,this.buffers.includes(e)||this.buffers.push(e),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const e=[],t=[],i=new Mt;let n;for(n in this.attributes){const s=this.attributes[n],o=this.buffers[s.buffer];e.push(o.data),t.push(s.size*Kv[s.type]/4),s.buffer=0}for(i.data=_A(e,t),n=0;n<this.buffers.length;n++)this.buffers[n]!==this.indexBuffer&&this.buffers[n].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const e in this.attributes){const t=this.attributes[e];return this.buffers[t.buffer].data.length/(t.stride/4||t.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const e=new An;for(let t=0;t<this.buffers.length;t++)e.buffers[t]=new Mt(this.buffers[t].data.slice(0));for(const t in this.attributes){const i=this.attributes[t];e.attributes[t]=new nh(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(e.indexBuffer=e.buffers[this.buffers.indexOf(this.indexBuffer)],e.indexBuffer.type=Ir.ELEMENT_ARRAY_BUFFER),e}static merge(e){const t=new An,i=[],n=[],s=[];let o;for(let a=0;a<e.length;a++){o=e[a];for(let l=0;l<o.buffers.length;l++)n[l]=n[l]||0,n[l]+=o.buffers[l].data.length,s[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new wA[Gv(o.buffers[a].data)](n[a]),t.buffers[a]=new Mt(i[a]);for(let a=0;a<e.length;a++){o=e[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,s[l]),s[l]+=o.buffers[l].data.length}if(t.attributes=o.attributes,o.indexBuffer){t.indexBuffer=t.buffers[o.buffers.indexOf(o.indexBuffer)],t.indexBuffer.type=Ir.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(l+=d.size*Kv[d.type]/4)}for(let c=0;c<e.length;c++){const d=e[c].indexBuffer.data;for(let f=0;f<d.length;f++)t.indexBuffer.data[f+h]+=a;a+=e[c].buffers[u].data.length/l,h+=d.length}}return t}}class Qv extends An{constructor(e=!1){super(),this._buffer=new Mt(null,e,!1),this._indexBuffer=new Mt(null,e,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Re.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Re.FLOAT).addAttribute("aColor",this._buffer,4,!0,Re.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Re.FLOAT).addIndex(this._indexBuffer)}}const sh=Math.PI*2,EA=180/Math.PI,TA=Math.PI/180;var ti=(r=>(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(ti||{});class nt{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new nt(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}}nt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const oh=[new nt,new nt,new nt,new nt];class We{constructor(e=0,t=0,i=0,n=0){this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(n),this.type=ti.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new We(0,0,0,0)}clone(){return new We(this.x,this.y,this.width,this.height)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}intersects(e,t){if(!t){const R=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=R)return!1;const M=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>M}const i=this.left,n=this.right,s=this.top,o=this.bottom;if(n<=i||o<=s)return!1;const a=oh[0].set(e.left,e.top),l=oh[1].set(e.left,e.bottom),h=oh[2].set(e.right,e.top),u=oh[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(t.a*t.d-t.b*t.c);if(c===0||(t.apply(a,a),t.apply(l,l),t.apply(h,h),t.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=n||Math.max(a.y,l.y,h.y,u.y)<=s||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;const d=c*(l.y-a.y),f=c*(a.x-l.x),g=d*i+f*s,p=d*n+f*s,m=d*i+f*o,v=d*n+f*o;if(Math.max(g,p,m,v)<=d*a.x+f*a.y||Math.min(g,p,m,v)>=d*u.x+f*u.y)return!1;const y=c*(a.y-h.y),_=c*(h.x-a.x),w=y*i+_*s,A=y*n+_*s,F=y*i+_*o,C=y*n+_*o;return!(Math.max(w,A,F,C)<=y*a.x+_*a.y||Math.min(w,A,F,C)>=y*u.x+_*u.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),n=Math.max(this.y,e.y),s=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=n,this.height=Math.max(s-n,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,n=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=n-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),n=Math.min(this.y,e.y),s=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=n,this.height=s-n,this}}We.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class ah{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.radius=i,this.type=ti.CIRC}clone(){return new ah(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-e,s=this.y-t;return n*=n,s*=s,n+s<=i}getBounds(){return new We(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}ah.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class lh{constructor(e=0,t=0,i=0,n=0){this.x=e,this.y=t,this.width=i,this.height=n,this.type=ti.ELIP}clone(){return new lh(this.x,this.y,this.width,this.height)}contains(e,t){if(this.width<=0||this.height<=0)return!1;let i=(e-this.x)/this.width,n=(t-this.y)/this.height;return i*=i,n*=n,i+n<=1}getBounds(){return new We(this.x-this.width,this.y-this.height,this.width,this.height)}}lh.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class os{constructor(...e){let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let n=0,s=t.length;n<s;n++)i.push(t[n].x,t[n].y);t=i}this.points=t,this.type=ti.POLY,this.closeStroke=!0}clone(){const e=this.points.slice(),t=new os(e);return t.closeStroke=this.closeStroke,t}contains(e,t){let i=!1;const n=this.points.length/2;for(let s=0,o=n-1;s<n;o=s++){const a=this.points[s*2],l=this.points[s*2+1],h=this.points[o*2],u=this.points[o*2+1];l>t!=u>t&&e<(h-a)*((t-l)/(u-l))+a&&(i=!i)}return i}}os.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,e)=>`${r}, ${e}`,"")}]`};class hh{constructor(e=0,t=0,i=0,n=0,s=20){this.x=e,this.y=t,this.width=i,this.height=n,this.radius=s,this.type=ti.RREC}clone(){return new hh(this.x,this.y,this.width,this.height,this.radius)}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let n=e-(this.x+i),s=t-(this.y+i);const o=i*i;if(n*n+s*s<=o||(n=e-(this.x+this.width-i),n*n+s*s<=o)||(s=t-(this.y+this.height-i),n*n+s*s<=o)||(n=e-(this.x+i),n*n+s*s<=o))return!0}return!1}}hh.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class pt{constructor(e=1,t=0,i=0,n=1,s=0,o=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=n,this.tx=s,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,n,s,o){return this.a=e,this.b=t,this.c=i,this.d=n,this.tx=s,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(e,t){t=t||new nt;const i=e.x,n=e.y;return t.x=this.a*i+this.c*n+this.tx,t.y=this.b*i+this.d*n+this.ty,t}applyInverse(e,t){t=t||new nt;const i=1/(this.a*this.d+this.c*-this.b),n=e.x,s=e.y;return t.x=this.d*i*n+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,t.y=this.a*i*s+-this.b*i*n+(-this.ty*this.a+this.tx*this.b)*i,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),n=this.a,s=this.c,o=this.tx;return this.a=n*t-this.b*i,this.b=n*i+this.b*t,this.c=s*t-this.d*i,this.d=s*i+this.d*t,this.tx=o*t-this.ty*i,this.ty=o*i+this.ty*t,this}append(e){const t=this.a,i=this.b,n=this.c,s=this.d;return this.a=e.a*t+e.b*n,this.b=e.a*i+e.b*s,this.c=e.c*t+e.d*n,this.d=e.c*i+e.d*s,this.tx=e.tx*t+e.ty*n+this.tx,this.ty=e.tx*i+e.ty*s+this.ty,this}setTransform(e,t,i,n,s,o,a,l,h){return this.a=Math.cos(a+h)*s,this.b=Math.sin(a+h)*s,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(i*this.a+n*this.c),this.ty=t-(i*this.b+n*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,n=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,n=this.c,s=this.d,o=e.pivot,a=-Math.atan2(-n,s),l=Math.atan2(i,t),h=Math.abs(a+l);return h<1e-5||Math.abs(sh-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(n*n+s*s),e.position.x=this.tx+(o.x*t+o.y*n),e.position.y=this.ty+(o.x*i+o.y*s),e}invert(){const e=this.a,t=this.b,i=this.c,n=this.d,s=this.tx,o=e*n-t*i;return this.a=n/o,this.b=-t/o,this.c=-i/o,this.d=e/o,this.tx=(i*this.ty-n*s)/o,this.ty=-(e*this.ty-t*s)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new pt;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}static get IDENTITY(){return new pt}static get TEMP_MATRIX(){return new pt}}pt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const as=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ls=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],hs=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],us=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],_d=[],Jv=[],uh=Math.sign;function bA(){for(let r=0;r<16;r++){const e=[];_d.push(e);for(let t=0;t<16;t++){const i=uh(as[r]*as[t]+hs[r]*ls[t]),n=uh(ls[r]*as[t]+us[r]*ls[t]),s=uh(as[r]*hs[t]+hs[r]*us[t]),o=uh(ls[r]*hs[t]+us[r]*us[t]);for(let a=0;a<16;a++)if(as[a]===i&&ls[a]===n&&hs[a]===s&&us[a]===o){e.push(a);break}}}for(let r=0;r<16;r++){const e=new pt;e.set(as[r],ls[r],hs[r],us[r],0,0),Jv.push(e)}}bA();const Rt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>as[r],uY:r=>ls[r],vX:r=>hs[r],vY:r=>us[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>_d[r][e],sub:(r,e)=>_d[r][Rt.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?Rt.S:Rt.N:Math.abs(e)*2<=Math.abs(r)?r>0?Rt.E:Rt.W:e>0?r>0?Rt.SE:Rt.SW:r>0?Rt.NE:Rt.NW,matrixAppendRotationInv:(r,e,t=0,i=0)=>{const n=Jv[Rt.inv(e)];n.tx=t,n.ty=i,r.append(n)}};class en{constructor(e,t,i=0,n=0){this._x=i,this._y=n,this.cb=e,this.scope=t}clone(e=this.cb,t=this.scope){return new en(e,t,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this.cb.call(this.scope)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))}}en.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const xd=class{constructor(){this.worldTransform=new pt,this.localTransform=new pt,this.position=new en(this.onChange,this,0,0),this.scale=new en(this.onChange,this,1,1),this.pivot=new en(this.onChange,this,0,0),this.skew=new en(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const t=r.worldTransform,i=this.worldTransform;i.a=e.a*t.a+e.b*t.c,i.b=e.a*t.b+e.b*t.d,i.c=e.c*t.a+e.d*t.c,i.d=e.c*t.b+e.d*t.d,i.tx=e.tx*t.a+e.ty*t.c+t.tx,i.ty=e.tx*t.b+e.ty*t.d+t.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};xd.IDENTITY=new xd;let wd=xd;wd.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var AA=`varying vec2 vTextureCoord;
|
|
89
|
+
|
|
90
|
+
uniform sampler2D uSampler;
|
|
91
|
+
|
|
92
|
+
void main(void){
|
|
93
|
+
gl_FragColor *= texture2D(uSampler, vTextureCoord);
|
|
94
|
+
}`,SA=`attribute vec2 aVertexPosition;
|
|
95
|
+
attribute vec2 aTextureCoord;
|
|
96
|
+
|
|
97
|
+
uniform mat3 projectionMatrix;
|
|
98
|
+
|
|
99
|
+
varying vec2 vTextureCoord;
|
|
100
|
+
|
|
101
|
+
void main(void){
|
|
102
|
+
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
103
|
+
vTextureCoord = aTextureCoord;
|
|
104
|
+
}
|
|
105
|
+
`;function $v(r,e,t){const i=r.createShader(e);return r.shaderSource(i,t),r.compileShader(i),i}function Ed(r){const e=new Array(r);for(let t=0;t<e.length;t++)e[t]=!1;return e}function e0(r,e){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Ed(2*e);case"bvec3":return Ed(3*e);case"bvec4":return Ed(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const ao=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
|
|
106
|
+
if(uv["${r}"] !== ud["${r}"].value)
|
|
107
|
+
{
|
|
108
|
+
ud["${r}"].value = uv["${r}"]
|
|
109
|
+
gl.uniform1f(ud["${r}"].location, uv["${r}"])
|
|
110
|
+
}
|
|
111
|
+
`},{test:(r,e)=>(r.type==="sampler2D"||r.type==="samplerCube"||r.type==="sampler2DArray")&&r.size===1&&!r.isArray&&(e==null||e.castToBaseTexture!==void 0),code:r=>`t = syncData.textureCount++;
|
|
112
|
+
|
|
113
|
+
renderer.texture.bind(uv["${r}"], t);
|
|
114
|
+
|
|
115
|
+
if(ud["${r}"].value !== t)
|
|
116
|
+
{
|
|
117
|
+
ud["${r}"].value = t;
|
|
118
|
+
gl.uniform1i(ud["${r}"].location, t);
|
|
119
|
+
; // eslint-disable-line max-len
|
|
120
|
+
}`},{test:(r,e)=>r.type==="mat3"&&r.size===1&&!r.isArray&&e.a!==void 0,code:r=>`
|
|
121
|
+
gl.uniformMatrix3fv(ud["${r}"].location, false, uv["${r}"].toArray(true));
|
|
122
|
+
`,codeUbo:r=>`
|
|
123
|
+
var ${r}_matrix = uv.${r}.toArray(true);
|
|
124
|
+
|
|
125
|
+
data[offset] = ${r}_matrix[0];
|
|
126
|
+
data[offset+1] = ${r}_matrix[1];
|
|
127
|
+
data[offset+2] = ${r}_matrix[2];
|
|
128
|
+
|
|
129
|
+
data[offset + 4] = ${r}_matrix[3];
|
|
130
|
+
data[offset + 5] = ${r}_matrix[4];
|
|
131
|
+
data[offset + 6] = ${r}_matrix[5];
|
|
132
|
+
|
|
133
|
+
data[offset + 8] = ${r}_matrix[6];
|
|
134
|
+
data[offset + 9] = ${r}_matrix[7];
|
|
135
|
+
data[offset + 10] = ${r}_matrix[8];
|
|
136
|
+
`},{test:(r,e)=>r.type==="vec2"&&r.size===1&&!r.isArray&&e.x!==void 0,code:r=>`
|
|
137
|
+
cv = ud["${r}"].value;
|
|
138
|
+
v = uv["${r}"];
|
|
139
|
+
|
|
140
|
+
if(cv[0] !== v.x || cv[1] !== v.y)
|
|
141
|
+
{
|
|
142
|
+
cv[0] = v.x;
|
|
143
|
+
cv[1] = v.y;
|
|
144
|
+
gl.uniform2f(ud["${r}"].location, v.x, v.y);
|
|
145
|
+
}`,codeUbo:r=>`
|
|
146
|
+
v = uv.${r};
|
|
147
|
+
|
|
148
|
+
data[offset] = v.x;
|
|
149
|
+
data[offset+1] = v.y;
|
|
150
|
+
`},{test:r=>r.type==="vec2"&&r.size===1&&!r.isArray,code:r=>`
|
|
151
|
+
cv = ud["${r}"].value;
|
|
152
|
+
v = uv["${r}"];
|
|
153
|
+
|
|
154
|
+
if(cv[0] !== v[0] || cv[1] !== v[1])
|
|
155
|
+
{
|
|
156
|
+
cv[0] = v[0];
|
|
157
|
+
cv[1] = v[1];
|
|
158
|
+
gl.uniform2f(ud["${r}"].location, v[0], v[1]);
|
|
159
|
+
}
|
|
160
|
+
`},{test:(r,e)=>r.type==="vec4"&&r.size===1&&!r.isArray&&e.width!==void 0,code:r=>`
|
|
161
|
+
cv = ud["${r}"].value;
|
|
162
|
+
v = uv["${r}"];
|
|
163
|
+
|
|
164
|
+
if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)
|
|
165
|
+
{
|
|
166
|
+
cv[0] = v.x;
|
|
167
|
+
cv[1] = v.y;
|
|
168
|
+
cv[2] = v.width;
|
|
169
|
+
cv[3] = v.height;
|
|
170
|
+
gl.uniform4f(ud["${r}"].location, v.x, v.y, v.width, v.height)
|
|
171
|
+
}`,codeUbo:r=>`
|
|
172
|
+
v = uv.${r};
|
|
173
|
+
|
|
174
|
+
data[offset] = v.x;
|
|
175
|
+
data[offset+1] = v.y;
|
|
176
|
+
data[offset+2] = v.width;
|
|
177
|
+
data[offset+3] = v.height;
|
|
178
|
+
`},{test:(r,e)=>r.type==="vec4"&&r.size===1&&!r.isArray&&e.red!==void 0,code:r=>`
|
|
179
|
+
cv = ud["${r}"].value;
|
|
180
|
+
v = uv["${r}"];
|
|
181
|
+
|
|
182
|
+
if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
|
|
183
|
+
{
|
|
184
|
+
cv[0] = v.red;
|
|
185
|
+
cv[1] = v.green;
|
|
186
|
+
cv[2] = v.blue;
|
|
187
|
+
cv[3] = v.alpha;
|
|
188
|
+
gl.uniform4f(ud["${r}"].location, v.red, v.green, v.blue, v.alpha)
|
|
189
|
+
}`,codeUbo:r=>`
|
|
190
|
+
v = uv.${r};
|
|
191
|
+
|
|
192
|
+
data[offset] = v.red;
|
|
193
|
+
data[offset+1] = v.green;
|
|
194
|
+
data[offset+2] = v.blue;
|
|
195
|
+
data[offset+3] = v.alpha;
|
|
196
|
+
`},{test:(r,e)=>r.type==="vec3"&&r.size===1&&!r.isArray&&e.red!==void 0,code:r=>`
|
|
197
|
+
cv = ud["${r}"].value;
|
|
198
|
+
v = uv["${r}"];
|
|
199
|
+
|
|
200
|
+
if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
|
|
201
|
+
{
|
|
202
|
+
cv[0] = v.red;
|
|
203
|
+
cv[1] = v.green;
|
|
204
|
+
cv[2] = v.blue;
|
|
205
|
+
|
|
206
|
+
gl.uniform3f(ud["${r}"].location, v.red, v.green, v.blue)
|
|
207
|
+
}`,codeUbo:r=>`
|
|
208
|
+
v = uv.${r};
|
|
209
|
+
|
|
210
|
+
data[offset] = v.red;
|
|
211
|
+
data[offset+1] = v.green;
|
|
212
|
+
data[offset+2] = v.blue;
|
|
213
|
+
`},{test:r=>r.type==="vec4"&&r.size===1&&!r.isArray,code:r=>`
|
|
214
|
+
cv = ud["${r}"].value;
|
|
215
|
+
v = uv["${r}"];
|
|
216
|
+
|
|
217
|
+
if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
218
|
+
{
|
|
219
|
+
cv[0] = v[0];
|
|
220
|
+
cv[1] = v[1];
|
|
221
|
+
cv[2] = v[2];
|
|
222
|
+
cv[3] = v[3];
|
|
223
|
+
|
|
224
|
+
gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3])
|
|
225
|
+
}`}],RA={float:`
|
|
226
|
+
if (cv !== v)
|
|
227
|
+
{
|
|
228
|
+
cu.value = v;
|
|
229
|
+
gl.uniform1f(location, v);
|
|
230
|
+
}`,vec2:`
|
|
231
|
+
if (cv[0] !== v[0] || cv[1] !== v[1])
|
|
232
|
+
{
|
|
233
|
+
cv[0] = v[0];
|
|
234
|
+
cv[1] = v[1];
|
|
235
|
+
|
|
236
|
+
gl.uniform2f(location, v[0], v[1])
|
|
237
|
+
}`,vec3:`
|
|
238
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
239
|
+
{
|
|
240
|
+
cv[0] = v[0];
|
|
241
|
+
cv[1] = v[1];
|
|
242
|
+
cv[2] = v[2];
|
|
243
|
+
|
|
244
|
+
gl.uniform3f(location, v[0], v[1], v[2])
|
|
245
|
+
}`,vec4:`
|
|
246
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
247
|
+
{
|
|
248
|
+
cv[0] = v[0];
|
|
249
|
+
cv[1] = v[1];
|
|
250
|
+
cv[2] = v[2];
|
|
251
|
+
cv[3] = v[3];
|
|
252
|
+
|
|
253
|
+
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
254
|
+
}`,int:`
|
|
255
|
+
if (cv !== v)
|
|
256
|
+
{
|
|
257
|
+
cu.value = v;
|
|
258
|
+
|
|
259
|
+
gl.uniform1i(location, v);
|
|
260
|
+
}`,ivec2:`
|
|
261
|
+
if (cv[0] !== v[0] || cv[1] !== v[1])
|
|
262
|
+
{
|
|
263
|
+
cv[0] = v[0];
|
|
264
|
+
cv[1] = v[1];
|
|
265
|
+
|
|
266
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
267
|
+
}`,ivec3:`
|
|
268
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
269
|
+
{
|
|
270
|
+
cv[0] = v[0];
|
|
271
|
+
cv[1] = v[1];
|
|
272
|
+
cv[2] = v[2];
|
|
273
|
+
|
|
274
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
275
|
+
}`,ivec4:`
|
|
276
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
277
|
+
{
|
|
278
|
+
cv[0] = v[0];
|
|
279
|
+
cv[1] = v[1];
|
|
280
|
+
cv[2] = v[2];
|
|
281
|
+
cv[3] = v[3];
|
|
282
|
+
|
|
283
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
284
|
+
}`,uint:`
|
|
285
|
+
if (cv !== v)
|
|
286
|
+
{
|
|
287
|
+
cu.value = v;
|
|
288
|
+
|
|
289
|
+
gl.uniform1ui(location, v);
|
|
290
|
+
}`,uvec2:`
|
|
291
|
+
if (cv[0] !== v[0] || cv[1] !== v[1])
|
|
292
|
+
{
|
|
293
|
+
cv[0] = v[0];
|
|
294
|
+
cv[1] = v[1];
|
|
295
|
+
|
|
296
|
+
gl.uniform2ui(location, v[0], v[1]);
|
|
297
|
+
}`,uvec3:`
|
|
298
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
299
|
+
{
|
|
300
|
+
cv[0] = v[0];
|
|
301
|
+
cv[1] = v[1];
|
|
302
|
+
cv[2] = v[2];
|
|
303
|
+
|
|
304
|
+
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
305
|
+
}`,uvec4:`
|
|
306
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
307
|
+
{
|
|
308
|
+
cv[0] = v[0];
|
|
309
|
+
cv[1] = v[1];
|
|
310
|
+
cv[2] = v[2];
|
|
311
|
+
cv[3] = v[3];
|
|
312
|
+
|
|
313
|
+
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
314
|
+
}`,bool:`
|
|
315
|
+
if (cv !== v)
|
|
316
|
+
{
|
|
317
|
+
cu.value = v;
|
|
318
|
+
gl.uniform1i(location, v);
|
|
319
|
+
}`,bvec2:`
|
|
320
|
+
if (cv[0] != v[0] || cv[1] != v[1])
|
|
321
|
+
{
|
|
322
|
+
cv[0] = v[0];
|
|
323
|
+
cv[1] = v[1];
|
|
324
|
+
|
|
325
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
326
|
+
}`,bvec3:`
|
|
327
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
328
|
+
{
|
|
329
|
+
cv[0] = v[0];
|
|
330
|
+
cv[1] = v[1];
|
|
331
|
+
cv[2] = v[2];
|
|
332
|
+
|
|
333
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
334
|
+
}`,bvec4:`
|
|
335
|
+
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
336
|
+
{
|
|
337
|
+
cv[0] = v[0];
|
|
338
|
+
cv[1] = v[1];
|
|
339
|
+
cv[2] = v[2];
|
|
340
|
+
cv[3] = v[3];
|
|
341
|
+
|
|
342
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
343
|
+
}`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:`
|
|
344
|
+
if (cv !== v)
|
|
345
|
+
{
|
|
346
|
+
cu.value = v;
|
|
347
|
+
|
|
348
|
+
gl.uniform1i(location, v);
|
|
349
|
+
}`,samplerCube:`
|
|
350
|
+
if (cv !== v)
|
|
351
|
+
{
|
|
352
|
+
cu.value = v;
|
|
353
|
+
|
|
354
|
+
gl.uniform1i(location, v);
|
|
355
|
+
}`,sampler2DArray:`
|
|
356
|
+
if (cv !== v)
|
|
357
|
+
{
|
|
358
|
+
cu.value = v;
|
|
359
|
+
|
|
360
|
+
gl.uniform1i(location, v);
|
|
361
|
+
}`},CA={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function PA(r,e){var t;const i=[`
|
|
362
|
+
var v = null;
|
|
363
|
+
var cv = null;
|
|
364
|
+
var cu = null;
|
|
365
|
+
var t = 0;
|
|
366
|
+
var gl = renderer.gl;
|
|
367
|
+
`];for(const n in r.uniforms){const s=e[n];if(!s){((t=r.uniforms[n])==null?void 0:t.group)===!0&&(r.uniforms[n].ubo?i.push(`
|
|
368
|
+
renderer.shader.syncUniformBufferGroup(uv.${n}, '${n}');
|
|
369
|
+
`):i.push(`
|
|
370
|
+
renderer.shader.syncUniformGroup(uv.${n}, syncData);
|
|
371
|
+
`));continue}const o=r.uniforms[n];let a=!1;for(let l=0;l<ao.length;l++)if(ao[l].test(s,o)){i.push(ao[l].code(n,o)),a=!0;break}if(!a){const l=(s.size===1&&!s.isArray?RA:CA)[s.type].replace("location",`ud["${n}"].location`);i.push(`
|
|
372
|
+
cu = ud["${n}"];
|
|
373
|
+
cv = cu.value;
|
|
374
|
+
v = uv["${n}"];
|
|
375
|
+
${l};`)}}return new Function("ud","uv","renderer","syncData",i.join(`
|
|
376
|
+
`))}const t0={};let va=t0;function IA(){if(va===t0||va!=null&&va.isContextLost()){const r=ye.ADAPTER.createCanvas();let e;ye.PREFER_ENV>=is.WEBGL2&&(e=r.getContext("webgl2",{})),e||(e=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),e?e.getExtension("WEBGL_draw_buffers"):e=null),va=e}return va}let ch;function MA(){if(!ch){ch=Ki.MEDIUM;const r=IA();if(r&&r.getShaderPrecisionFormat){const e=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);e&&(ch=e.precision?Ki.HIGH:Ki.MEDIUM)}}return ch}function i0(r,e){const t=r.getShaderSource(e).split(`
|
|
377
|
+
`).map((h,u)=>`${u}: ${h}`),i=r.getShaderInfoLog(e),n=i.split(`
|
|
378
|
+
`),s={},o=n.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!s[h]?(s[h]=!0,!0):!1),a=[""];o.forEach(h=>{t[h-1]=`%c${t[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=t.join(`
|
|
379
|
+
`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function DA(r,e,t,i){r.getProgramParameter(e,r.LINK_STATUS)||(r.getShaderParameter(t,r.COMPILE_STATUS)||i0(r,t),r.getShaderParameter(i,r.COMPILE_STATUS)||i0(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(e)))}const OA={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function r0(r){return OA[r]}let dh=null;const n0={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function s0(r,e){if(!dh){const t=Object.keys(n0);dh={};for(let i=0;i<t.length;++i){const n=t[i];dh[r[n]]=n0[n]}}return dh[e]}function o0(r,e,t){if(r.substring(0,9)!=="precision"){let i=e;return e===Ki.HIGH&&t!==Ki.HIGH&&(i=Ki.MEDIUM),`precision ${i} float;
|
|
380
|
+
${r}`}else if(t!==Ki.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let ya;function LA(){if(typeof ya=="boolean")return ya;try{ya=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ya=!1}return ya}let NA=0;const fh={},Td=class So{constructor(e,t,i="pixi-shader",n={}){this.extra={},this.id=NA++,this.vertexSrc=e||So.defaultVertexSrc,this.fragmentSrc=t||So.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=n,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),fh[i]?(fh[i]++,i+=`-${fh[i]}`):fh[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
|
|
381
|
+
${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
|
|
382
|
+
${this.fragmentSrc}`,this.vertexSrc=o0(this.vertexSrc,So.defaultVertexPrecision,Ki.HIGH),this.fragmentSrc=o0(this.fragmentSrc,So.defaultFragmentPrecision,MA())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return SA}static get defaultFragmentSrc(){return AA}static from(e,t,i){const n=e+t;let s=Wv[n];return s||(Wv[n]=s=new So(e,t,i)),s}};Td.defaultVertexPrecision=Ki.HIGH,Td.defaultFragmentPrecision=Qr.apple.device?Ki.HIGH:Ki.MEDIUM;let tn=Td,FA=0;class fr{constructor(e,t,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=FA++,this.static=!!t,this.ubo=!!i,e instanceof Mt?(this.buffer=e,this.buffer.type=Ir.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=e,this.ubo&&(this.buffer=new Mt(new Float32Array(1)),this.buffer.type=Ir.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(e,t,i){if(!this.ubo)this.uniforms[e]=new fr(t,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(e,t,i){return new fr(e,t,i)}static uboFrom(e,t){return new fr(e,t??!0,!0)}}class Lr{constructor(e,t){this.uniformBindCount=0,this.program=e,t?t instanceof fr?this.uniformGroup=t:this.uniformGroup=new fr(t):this.uniformGroup=new fr({}),this.disposeRunner=new dr("disposeShader")}checkUniformExists(e,t){if(t.uniforms[e])return!0;for(const i in t.uniforms){const n=t.uniforms[i];if(n.group===!0&&this.checkUniformExists(e,n))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(e,t,i){const n=tn.from(e,t);return new Lr(n,i)}}class BA{constructor(e,t){if(this.vertexSrc=e,this.fragTemplate=t,this.programCache={},this.defaultGroupCache={},!t.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!t.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(e){if(!this.programCache[e]){const i=new Int32Array(e);for(let s=0;s<e;s++)i[s]=s;this.defaultGroupCache[e]=fr.from({uSamplers:i},!0);let n=this.fragTemplate;n=n.replace(/%count%/gi,`${e}`),n=n.replace(/%forloop%/gi,this.generateSampleSrc(e)),this.programCache[e]=new tn(this.vertexSrc,n)}const t={tint:new Float32Array([1,1,1,1]),translationMatrix:new pt,default:this.defaultGroupCache[e]};return new Lr(this.programCache[e],t)}generateSampleSrc(e){let t="";t+=`
|
|
383
|
+
`,t+=`
|
|
384
|
+
`;for(let i=0;i<e;i++)i>0&&(t+=`
|
|
385
|
+
else `),i<e-1&&(t+=`if(vTextureId < ${i}.5)`),t+=`
|
|
386
|
+
{`,t+=`
|
|
387
|
+
color = texture2D(uSamplers[${i}], vTextureCoord);`,t+=`
|
|
388
|
+
}`;return t+=`
|
|
389
|
+
`,t+=`
|
|
390
|
+
`,t}}class bd{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let e=0;e<this.count;e++)this.elements[e]=null;this.count=0}}function kA(){return!Qr.apple.device}function UA(r){let e=!0;const t=ye.ADAPTER.getNavigator();if(Qr.tablet||Qr.phone){if(Qr.apple.device){const i=t.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(e=!1)}if(Qr.android.device){const i=t.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(e=!1)}}return e?r:4}class ph{constructor(e){this.renderer=e}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(e){}}var HA=`varying vec2 vTextureCoord;
|
|
391
|
+
varying vec4 vColor;
|
|
392
|
+
varying float vTextureId;
|
|
393
|
+
uniform sampler2D uSamplers[%count%];
|
|
394
|
+
|
|
395
|
+
void main(void){
|
|
396
|
+
vec4 color;
|
|
397
|
+
%forloop%
|
|
398
|
+
gl_FragColor = color * vColor;
|
|
399
|
+
}
|
|
400
|
+
`,GA=`precision highp float;
|
|
401
|
+
attribute vec2 aVertexPosition;
|
|
402
|
+
attribute vec2 aTextureCoord;
|
|
403
|
+
attribute vec4 aColor;
|
|
404
|
+
attribute float aTextureId;
|
|
405
|
+
|
|
406
|
+
uniform mat3 projectionMatrix;
|
|
407
|
+
uniform mat3 translationMatrix;
|
|
408
|
+
uniform vec4 tint;
|
|
409
|
+
|
|
410
|
+
varying vec2 vTextureCoord;
|
|
411
|
+
varying vec4 vColor;
|
|
412
|
+
varying float vTextureId;
|
|
413
|
+
|
|
414
|
+
void main(void){
|
|
415
|
+
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
416
|
+
|
|
417
|
+
vTextureCoord = aTextureCoord;
|
|
418
|
+
vTextureId = aTextureId;
|
|
419
|
+
vColor = aColor * tint;
|
|
420
|
+
}
|
|
421
|
+
`;const _a=class xr extends ph{constructor(e){super(e),this.setShaderGenerator(),this.geometryClass=Qv,this.vertexSize=6,this.state=Or.for2d(),this.size=xr.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),e.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??UA(32),this._defaultMaxTextures}static set defaultMaxTextures(e){this._defaultMaxTextures=e}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??kA(),this._canUploadSameBuffer}static set canUploadSameBuffer(e){this._canUploadSameBuffer=e}get MAX_TEXTURES(){return Je("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return GA}static get defaultFragmentTemplate(){return HA}setShaderGenerator({vertex:e=xr.defaultVertexSrc,fragment:t=xr.defaultFragmentTemplate}={}){this.shaderGenerator=new BA(e,t)}contextChange(){const e=this.renderer.gl;ye.PREFER_ENV===is.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),xr.defaultMaxTextures),this.maxTextures=gA(this.maxTextures,e)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:e,_textureArrayPool:t}=xr,i=this.size/4,n=Math.floor(i/this.maxTextures)+1;for(;e.length<i;)e.push(new yd);for(;t.length<n;)t.push(new bd);for(let s=0;s<this.maxTextures;s++)this._tempBoundTextures[s]=null}onPrerender(){this._flushId=0}render(e){e._texture.valid&&(this._vertexCount+e.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=e.vertexData.length/2,this._indexCount+=e.indices.length,this._bufferedTextures[this._bufferSize]=e._texture.baseTexture,this._bufferedElements[this._bufferSize++]=e)}buildTexturesAndDrawCalls(){const{_bufferedTextures:e,maxTextures:t}=this,i=xr._textureArrayPool,n=this.renderer.batch,s=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++ze._globalBatch,l=0,h=i[0],u=0;n.copyBoundTextures(s,t);for(let c=0;c<this._bufferSize;++c){const d=e[c];e[c]=null,d._batchEnabled!==a&&(h.count>=t&&(n.boundArray(h,s,a,t),this.buildDrawCalls(h,u,c),u=c,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(n.boundArray(h,s,a,t),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let c=0;c<s.length;c++)s[c]=null;ze._globalBatch=a}buildDrawCalls(e,t,i){const{_bufferedElements:n,_attributeBuffer:s,_indexBuffer:o,vertexSize:a}=this,l=xr._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=e;for(let f=t;f<i;++f){const g=n[f],p=g._texture.baseTexture,m=Uv[p.alphaMode?1:0][g.blendMode];n[f]=null,t<f&&d.blend!==m&&(d.size=c-d.start,t=f,d=l[++h],d.texArray=e,d.start=c),this.packInterleavedGeometry(g,s,o,u,c),u+=g.vertexData.length/2*a,c+=g.indices.length,d.blend=m}t<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(e){const t=this.renderer.texture;for(let i=0;i<e.count;i++)t.bind(e.elements[i],e.ids[i]),e.elements[i]=null;e.count=0}updateGeometry(){const{_packedGeometries:e,_attributeBuffer:t,_indexBuffer:i}=this;xr.canUploadSameBuffer?(e[this._flushId]._buffer.update(t.rawBinaryData),e[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,e[this._flushId]=new this.geometryClass),e[this._flushId]._buffer.update(t.rawBinaryData),e[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(e[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const e=this._dcIndex,{gl:t,state:i}=this.renderer,n=xr._drawCallPool;let s=null;for(let o=0;o<e;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=n[o];s!==a&&(s=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),t.drawElements(l,h,t.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),xr.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]&&this._packedGeometries[e].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(e){const t=ih(Math.ceil(e/8)),i=zv(t),n=t*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._aBuffers[n];return s||(this._aBuffers[n]=s=new hd(n*this.vertexSize*4)),s}getIndexBuffer(e){const t=ih(Math.ceil(e/12)),i=zv(t),n=t*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._iBuffers[i];return s||(this._iBuffers[i]=s=new Uint16Array(n)),s}packInterleavedGeometry(e,t,i,n,s){const{uint32View:o,float32View:a}=t,l=n/this.vertexSize,h=e.uvs,u=e.indices,c=e.vertexData,d=e._texture.baseTexture._batchLocation,f=Math.min(e.worldAlpha,1),g=ut.shared.setValue(e._tintRGB).toPremultiplied(f,e._texture.baseTexture.alphaMode>0);for(let p=0;p<c.length;p+=2)a[n++]=c[p],a[n++]=c[p+1],a[n++]=h[p],a[n++]=h[p+1],o[n++]=g,a[n++]=d;for(let p=0;p<u.length;p++)i[s++]=l+u[p]}};_a.defaultBatchSize=4096,_a.extension={name:"batch",type:ge.RendererPlugin},_a._drawCallPool=[],_a._textureArrayPool=[];let cs=_a;Ee.add(cs);var VA=`varying vec2 vTextureCoord;
|
|
422
|
+
|
|
423
|
+
uniform sampler2D uSampler;
|
|
424
|
+
|
|
425
|
+
void main(void){
|
|
426
|
+
gl_FragColor = texture2D(uSampler, vTextureCoord);
|
|
427
|
+
}
|
|
428
|
+
`,zA=`attribute vec2 aVertexPosition;
|
|
429
|
+
|
|
430
|
+
uniform mat3 projectionMatrix;
|
|
431
|
+
|
|
432
|
+
varying vec2 vTextureCoord;
|
|
433
|
+
|
|
434
|
+
uniform vec4 inputSize;
|
|
435
|
+
uniform vec4 outputFrame;
|
|
436
|
+
|
|
437
|
+
vec4 filterVertexPosition( void )
|
|
438
|
+
{
|
|
439
|
+
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
|
440
|
+
|
|
441
|
+
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
vec2 filterTextureCoord( void )
|
|
445
|
+
{
|
|
446
|
+
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
void main(void)
|
|
450
|
+
{
|
|
451
|
+
gl_Position = filterVertexPosition();
|
|
452
|
+
vTextureCoord = filterTextureCoord();
|
|
453
|
+
}
|
|
454
|
+
`;const Ad=class Za extends Lr{constructor(e,t,i){const n=tn.from(e||Za.defaultVertexSrc,t||Za.defaultFragmentSrc);super(n,i),this.padding=0,this.resolution=Za.defaultResolution,this.multisample=Za.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Or}apply(e,t,i,n,s){e.applyFilter(this,t,i,n)}get blendMode(){return this.state.blendMode}set blendMode(e){this.state.blendMode=e}get resolution(){return this._resolution}set resolution(e){this._resolution=e}static get defaultVertexSrc(){return zA}static get defaultFragmentSrc(){return VA}};Ad.defaultResolution=1,Ad.defaultMultisample=Bt.NONE;let mi=Ad;class gh{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ut(0),this.alpha=1}init(e){this.clearBeforeRender=e.clearBeforeRender;const{backgroundColor:t,background:i,backgroundAlpha:n}=e,s=i??t;s!==void 0&&(this.color=s),this.alpha=n}get color(){return this._backgroundColor.value}set color(e){this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get backgroundColor(){return this._backgroundColor}destroy(){}}gh.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},gh.extension={type:[ge.RendererSystem,ge.CanvasRendererSystem],name:"background"},Ee.add(gh);class a0{constructor(e){this.renderer=e,this.emptyRenderer=new ph(e),this.currentRenderer=this.emptyRenderer}setObjectRenderer(e){this.currentRenderer!==e&&(this.currentRenderer.stop(),this.currentRenderer=e,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(e,t){const{boundTextures:i}=this.renderer.texture;for(let n=t-1;n>=0;--n)e[n]=i[n]||null,e[n]&&(e[n]._batchLocation=n)}boundArray(e,t,i,n){const{elements:s,ids:o,count:a}=e;let l=0;for(let h=0;h<a;h++){const u=s[h],c=u._batchLocation;if(c>=0&&c<n&&t[c]===u){o[h]=c;continue}for(;l<n;){const d=t[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,t[l]=u;break}}}destroy(){this.renderer=null}}a0.extension={type:ge.RendererSystem,name:"batch"},Ee.add(a0);let l0=0;class mh{constructor(e){this.renderer=e,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this.renderer.gl=e,this.renderer.CONTEXT_UID=l0++}init(e){if(e.context)this.initFromContext(e.context);else{const t=this.renderer.background.alpha<1,i=e.premultipliedAlpha;this.preserveDrawingBuffer=e.preserveDrawingBuffer,this.useContextAlpha=e.useContextAlpha,this.powerPreference=e.powerPreference,this.initFromOptions({alpha:t,premultipliedAlpha:i,antialias:e.antialias,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference})}}initFromContext(e){this.gl=e,this.validateContext(e),this.renderer.gl=e,this.renderer.CONTEXT_UID=l0++,this.renderer.runners.contextChange.emit(e);const t=this.renderer.view;t.addEventListener!==void 0&&(t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(e){const t=this.createContext(this.renderer.view,e);this.initFromContext(t)}createContext(e,t){let i;if(ye.PREFER_ENV>=is.WEBGL2&&(i=e.getContext("webgl2",t)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:e}=this,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,t,{drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,t,{colorBufferFloat:e.getExtension("EXT_color_buffer_float")})}handleContextLost(e){e.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this.renderer.view;this.renderer=null,e.removeEventListener!==void 0&&(e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(e){const t=e.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&e instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),t&&!t.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=i||!!e.getExtension("OES_element_index_uint");this.supports.uint32Indices=n,n||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}mh.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},mh.extension={type:ge.RendererSystem,name:"context"},Ee.add(mh);class Sd{constructor(e,t){if(this.width=Math.round(e),this.height=Math.round(t),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new dr("disposeFramebuffer"),this.multisample=Bt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(e=0,t){return this.colorTextures[e]=t||new ze(null,{scaleMode:qr.NEAREST,resolution:1,mipmap:Cr.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(e){return this.depthTexture=e||new ze(null,{scaleMode:qr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Cr.OFF,format:he.DEPTH_COMPONENT,type:Re.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(e,t){if(e=Math.round(e),t=Math.round(t),!e||!t)throw new Error("Framebuffer width and height must not be zero");if(!(e===this.width&&t===this.height)){this.width=e,this.height=t,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const n=this.colorTextures[i],s=n.resolution;n.setSize(e/s,t/s)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(e/i,t/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class h0 extends ze{constructor(e={}){if(typeof e=="number"){const t=arguments[0],i=arguments[1],n=arguments[2],s=arguments[3];e={width:t,height:i,scaleMode:n,resolution:s}}e.width=e.width??100,e.height=e.height??100,e.multisample??(e.multisample=Bt.NONE),super(null,e),this.mipmap=Cr.OFF,this.valid=!0,this._clear=new ut([0,0,0,0]),this.framebuffer=new Sd(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=e.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(e){this._clear.setValue(e)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(e){this.framebuffer.multisample=e}resize(e,t){this.framebuffer.resize(e*this.resolution,t*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class rn extends ma{constructor(e){const t=e,i=t.naturalWidth||t.videoWidth||t.displayWidth||t.width,n=t.naturalHeight||t.videoHeight||t.displayHeight||t.height;super(i,n),this.source=e,this.noSubImage=!1}static crossOrigin(e,t,i){i===void 0&&!t.startsWith("data:")?e.crossOrigin=dA(t):i!==!1&&(e.crossOrigin=typeof i=="string"?i:"anonymous")}upload(e,t,i,n){const s=e.gl,o=t.realWidth,a=t.realHeight;if(n=n||this.source,typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement){if(!n.complete||n.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement&&n.readyState<=1)return!1;return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===bi.UNPACK),!this.noSubImage&&t.target===s.TEXTURE_2D&&i.width===o&&i.height===a?s.texSubImage2D(s.TEXTURE_2D,0,0,0,t.format,i.type,n):(i.width=o,i.height=a,s.texImage2D(t.target,0,i.internalFormat,t.format,i.type,n)),!0}update(){if(this.destroyed)return;const e=this.source,t=e.naturalWidth||e.videoWidth||e.width,i=e.naturalHeight||e.videoHeight||e.height;this.resize(t,i),super.update()}dispose(){this.source=null}}class u0 extends rn{constructor(e,t){if(t=t||{},typeof e=="string"){const i=new Image;rn.crossOrigin(i,e,t.crossorigin),i.src=e,e=i}super(e),!e.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=e.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(t.createBitmap??ye.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof t.alphaMode=="number"?t.alphaMode:null,this.bitmap=null,this._load=null,t.autoLoad!==!1&&this.load()}load(e){return this._load?this._load:(e!==void 0&&(this.createBitmap=e),this._load=new Promise((t,i)=>{const n=this.source;this.url=n.src;const s=()=>{this.destroyed||(n.onload=null,n.onerror=null,this.update(),this._load=null,this.createBitmap?t(this.process()):t(this))};n.complete&&n.src?s():(n.onload=s,n.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const e=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const t=globalThis.createImageBitmap,i=!e.crossOrigin||e.crossOrigin==="anonymous";return this._process=fetch(e.src,{mode:i?"cors":"no-cors"}).then(n=>n.blob()).then(n=>t(n,0,0,e.width,e.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===bi.UNPACK?"premultiply":"none"})).then(n=>this.destroyed?Promise.reject():(this.bitmap=n,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(e,t,i){if(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(e,t,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(e,t,i,this.bitmap),!this.preserveBitmap){let n=!0;const s=t._glTextures;for(const o in s){const a=s[o];if(a!==i&&a.dirtyId!==t.dirtyId){n=!1;break}}n&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(e){return typeof HTMLImageElement<"u"&&(typeof e=="string"||e instanceof HTMLImageElement)}}class Rd{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(e,t,i){const n=t.width,s=t.height;if(i){const o=e.width/2/n,a=e.height/2/s,l=e.x/n+o,h=e.y/s+a;i=Rt.add(i,Rt.NW),this.x0=l+o*Rt.uX(i),this.y0=h+a*Rt.uY(i),i=Rt.add(i,2),this.x1=l+o*Rt.uX(i),this.y1=h+a*Rt.uY(i),i=Rt.add(i,2),this.x2=l+o*Rt.uX(i),this.y2=h+a*Rt.uY(i),i=Rt.add(i,2),this.x3=l+o*Rt.uX(i),this.y3=h+a*Rt.uY(i)}else this.x0=e.x/n,this.y0=e.y/s,this.x1=(e.x+e.width)/n,this.y1=e.y/s,this.x2=(e.x+e.width)/n,this.y2=(e.y+e.height)/s,this.x3=e.x/n,this.y3=(e.y+e.height)/s;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Rd.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const c0=new Rd;function vh(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Te extends oa{constructor(e,t,i,n,s,o,a){if(super(),this.noFrame=!1,t||(this.noFrame=!0,t=new We(0,0,1,1)),e instanceof Te&&(e=e.baseTexture),this.baseTexture=e,this._frame=t,this.trim=n,this.valid=!1,this.destroyed=!1,this._uvs=c0,this.uvMatrix=null,this.orig=i||t,this._rotate=Number(s||0),s===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new nt(o.x,o.y):new nt(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],e.valid?this.noFrame?e.valid&&this.onBaseTextureUpdated(e):this.frame=t:e.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&e.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(e){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=e.width,this._frame.height=e.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(e){if(this.baseTexture){if(e){const{resource:t}=this.baseTexture;t!=null&&t.url&&Dr[t.url]&&Te.removeFromCache(t.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,Te.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var e;const t=this._frame.clone(),i=this._frame===this.orig?t:this.orig.clone(),n=new Te(this.baseTexture,!this.noFrame&&t,i,(e=this.trim)==null?void 0:e.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(n._frame=t),n}updateUvs(){this._uvs===c0&&(this._uvs=new Rd),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(e,t={},i=ye.STRICT_TEXTURE_CACHE){const n=typeof e=="string";let s=null;if(n)s=e;else if(e instanceof ze){if(!e.cacheId){const a=(t==null?void 0:t.pixiIdPrefix)||"pixiid";e.cacheId=`${a}-${ss()}`,ze.addToCache(e,e.cacheId)}s=e.cacheId}else{if(!e._pixiId){const a=(t==null?void 0:t.pixiIdPrefix)||"pixiid";e._pixiId=`${a}_${ss()}`}s=e._pixiId}let o=Dr[s];if(n&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);return!o&&!(e instanceof ze)?(t.resolution||(t.resolution=$r(e)),o=new Te(new ze(e,t)),o.baseTexture.cacheId=s,ze.addToCache(o.baseTexture,s),Te.addToCache(o,s)):!o&&e instanceof ze&&(o=new Te(e),Te.addToCache(o,s)),o}static fromURL(e,t){const i=Object.assign({autoLoad:!1},t==null?void 0:t.resourceOptions),n=Te.from(e,Object.assign({resourceOptions:i},t),!1),s=n.baseTexture.resource;return n.baseTexture.valid?Promise.resolve(n):s.load().then(()=>Promise.resolve(n))}static fromBuffer(e,t,i,n){return new Te(ze.fromBuffer(e,t,i,n))}static fromLoader(e,t,i,n){const s=new ze(e,Object.assign({scaleMode:ze.defaultOptions.scaleMode,resolution:$r(t)},n)),{resource:o}=s;o instanceof u0&&(o.url=t);const a=new Te(s);return i||(i=t),ze.addToCache(a.baseTexture,i),Te.addToCache(a,i),i!==t&&(ze.addToCache(a.baseTexture,t),Te.addToCache(a,t)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),Dr[t]&&Dr[t]!==e&&console.warn(`Texture added to the cache with an id [${t}] that already had an entry`),Dr[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=Dr[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete Dr[e],t}}else if(e!=null&&e.textureCacheIds){for(let t=0;t<e.textureCacheIds.length;++t)Dr[e.textureCacheIds[t]]===e&&delete Dr[e.textureCacheIds[t]];return e.textureCacheIds.length=0,e}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(e){this._frame=e,this.noFrame=!1;const{x:t,y:i,width:n,height:s}=e,o=t+n>this.baseTexture.width,a=i+s>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${t} + ${n} = ${t+n} > ${this.baseTexture.width}`,u=`Y: ${i} + ${s} = ${i+s} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}this.valid=n&&s&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=e),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(e){this._rotate=e,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Te._EMPTY||(Te._EMPTY=new Te(new ze),vh(Te._EMPTY),vh(Te._EMPTY.baseTexture)),Te._EMPTY}static get WHITE(){if(!Te._WHITE){const e=ye.ADAPTER.createCanvas(16,16),t=e.getContext("2d");e.width=16,e.height=16,t.fillStyle="white",t.fillRect(0,0,16,16),Te._WHITE=new Te(ze.from(e)),vh(Te._WHITE),vh(Te._WHITE.baseTexture)}return Te._WHITE}}class ds extends Te{constructor(e,t){super(e,t),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(e){this.framebuffer.multisample=e}resize(e,t,i=!0){const n=this.baseTexture.resolution,s=Math.round(e*n)/n,o=Math.round(t*n)/n;this.valid=s>0&&o>0,this._frame.width=this.orig.width=s,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(s,o),this.updateUvs()}setResolution(e){const{baseTexture:t}=this;t.resolution!==e&&(t.setResolution(e),this.resize(t.width,t.height,!1))}static create(e){return new ds(new h0(e))}}class d0{constructor(e){this.texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(e,t,i=Bt.NONE){const n=new h0(Object.assign({width:e,height:t,resolution:1,multisample:i},this.textureOptions));return new ds(n)}getOptimalTexture(e,t,i=1,n=Bt.NONE){let s;e=Math.max(Math.ceil(e*i-1e-6),1),t=Math.max(Math.ceil(t*i-1e-6),1),!this.enableFullScreen||e!==this._pixelsWidth||t!==this._pixelsHeight?(e=ih(e),t=ih(t),s=((e&65535)<<16|t&65535)>>>0,n>1&&(s+=n*4294967296)):s=n>1?-n:-1,this.texturePool[s]||(this.texturePool[s]=[]);let o=this.texturePool[s].pop();return o||(o=this.createTexture(e,t,n)),o.filterPoolKey=s,o.setResolution(i),o}getFilterTexture(e,t,i){const n=this.getOptimalTexture(e.width,e.height,t||e.resolution,i||Bt.NONE);return n.filterFrame=e.filterFrame,n}returnTexture(e){const t=e.filterPoolKey;e.filterFrame=null,this.texturePool[t].push(e)}returnFilterTexture(e){this.returnTexture(e)}clear(e){if(e=e!==!1,e)for(const t in this.texturePool){const i=this.texturePool[t];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0)}this.texturePool={}}setScreenSize(e){if(!(e.width===this._pixelsWidth&&e.height===this._pixelsHeight)){this.enableFullScreen=e.width>0&&e.height>0;for(const t in this.texturePool){if(!(Number(t)<0))continue;const i=this.texturePool[t];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0);this.texturePool[t]=[]}this._pixelsWidth=e.width,this._pixelsHeight=e.height}}}d0.SCREEN_KEY=-1;class jA extends An{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class f0 extends An{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Mt(this.vertices),this.uvBuffer=new Mt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(e,t){let i=0,n=0;return this.uvs[0]=i,this.uvs[1]=n,this.uvs[2]=i+t.width/e.width,this.uvs[3]=n,this.uvs[4]=i+t.width/e.width,this.uvs[5]=n+t.height/e.height,this.uvs[6]=i,this.uvs[7]=n+t.height/e.height,i=t.x,n=t.y,this.vertices[0]=i,this.vertices[1]=n,this.vertices[2]=i+t.width,this.vertices[3]=n,this.vertices[4]=i+t.width,this.vertices[5]=n+t.height,this.vertices[6]=i,this.vertices[7]=n+t.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class WA{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Bt.NONE,this.sourceFrame=new We,this.destinationFrame=new We,this.bindingSourceFrame=new We,this.bindingDestinationFrame=new We,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const yh=[new nt,new nt,new nt,new nt],Cd=new pt;class p0{constructor(e){this.renderer=e,this.defaultFilterStack=[{}],this.texturePool=new d0,this.statePool=[],this.quad=new jA,this.quadUv=new f0,this.tempRect=new We,this.activeState={},this.globalUniforms=new fr({outputFrame:new We,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(e,t){const i=this.renderer,n=this.defaultFilterStack,s=this.statePool.pop()||new WA,o=i.renderTexture;let a,l;if(o.current){const m=o.current;a=m.resolution,l=m.multisample}else a=i.resolution,l=i.multisample;let h=t[0].resolution||a,u=t[0].multisample??l,c=t[0].padding,d=t[0].autoFit,f=t[0].legacy??!0;for(let m=1;m<t.length;m++){const v=t[m];h=Math.min(h,v.resolution||a),u=Math.min(u,v.multisample??l),c=this.useMaxPadding?Math.max(c,v.padding):c+v.padding,d=d&&v.autoFit,f=f||(v.legacy??!0)}n.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),n.push(s),s.resolution=h,s.multisample=u,s.legacy=f,s.target=e,s.sourceFrame.copyFrom(e.filterArea||e.getBounds(!0)),s.sourceFrame.pad(c);const g=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Cd.copyFrom(i.projection.transform).invert(),g),d?(s.sourceFrame.fit(g),(s.sourceFrame.width<=0||s.sourceFrame.height<=0)&&(s.sourceFrame.width=0,s.sourceFrame.height=0)):s.sourceFrame.intersects(g)||(s.sourceFrame.width=0,s.sourceFrame.height=0),this.roundFrame(s.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),s.renderTexture=this.getOptimalFilterTexture(s.sourceFrame.width,s.sourceFrame.height,h,u),s.filters=t,s.destinationFrame.width=s.renderTexture.width,s.destinationFrame.height=s.renderTexture.height;const p=this.tempRect;p.x=0,p.y=0,p.width=s.sourceFrame.width,p.height=s.sourceFrame.height,s.renderTexture.filterFrame=s.sourceFrame,s.bindingSourceFrame.copyFrom(o.sourceFrame),s.bindingDestinationFrame.copyFrom(o.destinationFrame),s.transform=i.projection.transform,i.projection.transform=null,o.bind(s.renderTexture,s.sourceFrame,p),i.framebuffer.clear(0,0,0,0)}pop(){const e=this.defaultFilterStack,t=e.pop(),i=t.filters;this.activeState=t;const n=this.globalUniforms.uniforms;n.outputFrame=t.sourceFrame,n.resolution=t.resolution;const s=n.inputSize,o=n.inputPixel,a=n.inputClamp;if(s[0]=t.destinationFrame.width,s[1]=t.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],o[0]=Math.round(s[0]*t.resolution),o[1]=Math.round(s[1]*t.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=t.sourceFrame.width*s[2]-.5*o[2],a[3]=t.sourceFrame.height*s[3]-.5*o[3],t.legacy){const h=n.filterArea;h[0]=t.destinationFrame.width,h[1]=t.destinationFrame.height,h[2]=t.sourceFrame.x,h[3]=t.sourceFrame.y,n.filterClamp=n.inputClamp}this.globalUniforms.update();const l=e[e.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,t.renderTexture,l.renderTexture,Pr.BLEND,t),this.returnFilterTexture(t.renderTexture);else{let h=t.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,t.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&t.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,t.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,Pr.CLEAR,t);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,Pr.BLEND,t),c>1&&t.multisample>1&&this.returnFilterTexture(t.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}t.clear(),this.statePool.push(t)}bindAndClear(e,t=Pr.CLEAR){const{renderTexture:i,state:n}=this.renderer;if(e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,e==null?void 0:e.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=e.filterFrame.width,o.height=e.filterFrame.height,i.bind(e,e.filterFrame,o)}else e!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(e):this.renderer.renderTexture.bind(e,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const s=n.stateId&1||this.forceClear;(t===Pr.CLEAR||t===Pr.BLIT&&s)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(e,t,i,n){const s=this.renderer;s.state.set(e.state),this.bindAndClear(i,n),e.uniforms.uSampler=t,e.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(e),e.legacy=!!e.program.attributeData.aTextureCoord,e.legacy?(this.quadUv.map(t._frame,t.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(Rr.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(Rr.TRIANGLE_STRIP))}calculateSpriteMatrix(e,t){const{sourceFrame:i,destinationFrame:n}=this.activeState,{orig:s}=t._texture,o=e.set(n.width,0,0,n.height,i.x,i.y),a=t.worldTransform.copyTo(pt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/s.width,1/s.height),o.translate(t.anchor.x,t.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(e,t,i=1,n=Bt.NONE){return this.texturePool.getOptimalTexture(e,t,i,n)}getFilterTexture(e,t,i){if(typeof e=="number"){const s=e;e=t,t=s}e=e||this.activeState.renderTexture;const n=this.texturePool.getOptimalTexture(e.width,e.height,t||e.resolution,i||Bt.NONE);return n.filterFrame=e.filterFrame,n}returnFilterTexture(e){this.texturePool.returnTexture(e)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(e,t){const i=yh[0],n=yh[1],s=yh[2],o=yh[3];i.set(t.left,t.top),n.set(t.left,t.bottom),s.set(t.right,t.top),o.set(t.right,t.bottom),e.apply(i,i),e.apply(n,n),e.apply(s,s),e.apply(o,o);const a=Math.min(i.x,n.x,s.x,o.x),l=Math.min(i.y,n.y,s.y,o.y),h=Math.max(i.x,n.x,s.x,o.x),u=Math.max(i.y,n.y,s.y,o.y);t.x=a,t.y=l,t.width=h-a,t.height=u-l}roundFrame(e,t,i,n,s){if(!(e.width<=0||e.height<=0||i.width<=0||i.height<=0)){if(s){const{a:o,b:a,c:l,d:h}=s;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}s=s?Cd.copyFrom(s):Cd.identity(),s.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.transformAABB(s,e),e.ceil(t),this.transformAABB(s.invert(),e)}}}p0.extension={type:ge.RendererSystem,name:"filter"},Ee.add(p0);class XA{constructor(e){this.framebuffer=e,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Bt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const YA=new We;class g0{constructor(e){this.renderer=e,this.managedFramebuffers=[],this.unknownFramebuffer=new Sd(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new We,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let t=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;ye.PREFER_ENV===is.WEBGL_LEGACY&&(t=null,i=null),t?e.drawBuffers=n=>t.drawBuffersWEBGL(n):(this.hasMRT=!1,e.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)}bind(e,t,i=0){const{gl:n}=this;if(e){const s=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,n.bindFramebuffer(n.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==i&&(e.dirtyId++,e.dirtyFormat++,s.mipLevel=i),s.dirtyId!==e.dirtyId&&(s.dirtyId=e.dirtyId,s.dirtyFormat!==e.dirtyFormat?(s.dirtyFormat=e.dirtyFormat,s.dirtySize=e.dirtySize,this.updateFramebuffer(e,i)):s.dirtySize!==e.dirtySize&&(s.dirtySize=e.dirtySize,this.resizeFramebuffer(e)));for(let o=0;o<e.colorTextures.length;o++){const a=e.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(e.depthTexture&&this.renderer.texture.unbind(e.depthTexture),t){const o=t.width>>i,a=t.height>>i,l=o/t.width;this.setViewport(t.x*l,t.y*l,o,a)}else{const o=e.width>>i,a=e.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,n.bindFramebuffer(n.FRAMEBUFFER,null)),t?this.setViewport(t.x,t.y,t.width,t.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(e,t,i,n){const s=this.viewport;e=Math.round(e),t=Math.round(t),i=Math.round(i),n=Math.round(n),(s.width!==i||s.height!==n||s.x!==e||s.y!==t)&&(s.x=e,s.y=t,s.width=i,s.height=n,this.gl.viewport(e,t,i,n))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(e,t,i,n,s=Nc.COLOR|Nc.DEPTH){const{gl:o}=this;o.clearColor(e,t,i,n),o.clear(s)}initFramebuffer(e){const{gl:t}=this,i=new XA(t.createFramebuffer());return i.multisample=this.detectSamples(e.multisample),e.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(e),e.disposeRunner.add(this),i}resizeFramebuffer(e){const{gl:t}=this,i=e.glFramebuffers[this.CONTEXT_UID];if(i.stencil){t.bindRenderbuffer(t.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=t.DEPTH_STENCIL:e.depth&&e.stencil?o=t.DEPTH24_STENCIL8:e.depth?o=t.DEPTH_COMPONENT24:o=t.STENCIL_INDEX8,i.msaaBuffer?t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,o,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,o,e.width,e.height)}const n=e.colorTextures;let s=n.length;t.drawBuffers||(s=Math.min(s,1));for(let o=0;o<s;o++){const a=n[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(t.bindRenderbuffer(t.RENDERBUFFER,i.msaaBuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,e.width,e.height))}e.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(e.depthTexture,0)}updateFramebuffer(e,t){const{gl:i}=this,n=e.glFramebuffers[this.CONTEXT_UID],s=e.colorTextures;let o=s.length;i.drawBuffers||(o=Math.min(o,1)),n.multisample>1&&this.canMultisampleFramebuffer(e)?n.msaaBuffer=n.msaaBuffer||i.createRenderbuffer():n.msaaBuffer&&(i.deleteRenderbuffer(n.msaaBuffer),n.msaaBuffer=null,n.blitFramebuffer&&(n.blitFramebuffer.dispose(),n.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=s[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&n.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,t),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),e.depthTexture&&this.writeDepthTexture){const l=e.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,t)}if((e.stencil||e.depth)&&!(e.depthTexture&&this.writeDepthTexture)){n.stencil=n.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):e.depth&&e.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):e.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,h,e.width,e.height):i.renderbufferStorage(i.RENDERBUFFER,h,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,n.stencil)}else n.stencil&&(i.deleteRenderbuffer(n.stencil),n.stencil=null)}canMultisampleFramebuffer(e){return this.renderer.context.webGLVersion!==1&&e.colorTextures.length<=1&&!e.depthTexture}detectSamples(e){const{msaaSamples:t}=this;let i=Bt.NONE;if(e<=1||t===null)return i;for(let n=0;n<t.length;n++)if(t[n]<=e){i=t[n];break}return i===1&&(i=Bt.NONE),i}blit(e,t,i){const{current:n,renderer:s,gl:o,CONTEXT_UID:a}=this;if(s.context.webGLVersion!==2||!n)return;const l=n.glFramebuffers[a];if(!l)return;if(!e){if(!l.msaaBuffer)return;const u=n.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new Sd(n.width,n.height),l.blitFramebuffer.addColorTexture(0,u)),e=l.blitFramebuffer,e.colorTextures[0]!==u&&(e.colorTextures[0]=u,e.dirtyId++,e.dirtyFormat++),(e.width!==n.width||e.height!==n.height)&&(e.width=n.width,e.height=n.height,e.dirtyId++,e.dirtySize++)}t||(t=YA,t.width=n.width,t.height=n.height),i||(i=t);const h=t.width===i.width&&t.height===i.height;this.bind(e),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(t.left,t.top,t.right,t.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,e.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(e,t){const i=e.glFramebuffers[this.CONTEXT_UID],n=this.gl;if(!i)return;delete e.glFramebuffers[this.CONTEXT_UID];const s=this.managedFramebuffers.indexOf(e);s>=0&&this.managedFramebuffers.splice(s,1),e.disposeRunner.remove(this),t||(n.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&n.deleteRenderbuffer(i.msaaBuffer),i.stencil&&n.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,t)}disposeAll(e){const t=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<t.length;i++)this.disposeFramebuffer(t[i],e)}forceStencil(){const e=this.current;if(!e)return;const t=e.glFramebuffers[this.CONTEXT_UID];if(!t||t.stencil&&e.stencil)return;e.stencil=!0;const i=e.width,n=e.height,s=this.gl,o=t.stencil=s.createRenderbuffer();s.bindRenderbuffer(s.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH_STENCIL):e.depth?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH24_STENCIL8):(a=s.STENCIL_ATTACHMENT,l=s.STENCIL_INDEX8),t.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,t.multisample,l,i,n):s.renderbufferStorage(s.RENDERBUFFER,l,i,n),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new We}destroy(){this.renderer=null}}g0.extension={type:ge.RendererSystem,name:"framebuffer"},Ee.add(g0);const Pd={5126:4,5123:2,5121:1};class m0{constructor(e){this.renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl,t=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,t.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;ye.PREFER_ENV===is.WEBGL_LEGACY&&(i=null),i?(e.createVertexArray=()=>i.createVertexArrayOES(),e.bindVertexArray=n=>i.bindVertexArrayOES(n),e.deleteVertexArray=n=>i.deleteVertexArrayOES(n)):(this.hasVao=!1,e.createVertexArray=()=>null,e.bindVertexArray=()=>null,e.deleteVertexArray=()=>null)}if(t.webGLVersion!==2){const i=e.getExtension("ANGLE_instanced_arrays");i?(e.vertexAttribDivisor=(n,s)=>i.vertexAttribDivisorANGLE(n,s),e.drawElementsInstanced=(n,s,o,a,l)=>i.drawElementsInstancedANGLE(n,s,o,a,l),e.drawArraysInstanced=(n,s,o,a)=>i.drawArraysInstancedANGLE(n,s,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=t.webGLVersion===2||!!t.extensions.uint32ElementIndex}bind(e,t){t=t||this.renderer.shader.shader;const{gl:i}=this;let n=e.glVertexArrayObjects[this.CONTEXT_UID],s=!1;n||(this.managedGeometries[e.id]=e,e.disposeRunner.add(this),e.glVertexArrayObjects[this.CONTEXT_UID]=n={},s=!0);const o=n[t.program.id]||this.initGeometryVao(e,t,s);this._activeGeometry=e,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(e,t.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this.renderer.buffer;for(let i=0;i<e.buffers.length;i++){const n=e.buffers[i];t.update(n)}}checkCompatibility(e,t){const i=e.attributes,n=t.attributeData;for(const s in n)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(e,t){const i=e.attributes,n=t.attributeData,s=["g",e.id];for(const o in i)n[o]&&s.push(o,n[o].location);return s.join("-")}initGeometryVao(e,t,i=!0){const n=this.gl,s=this.CONTEXT_UID,o=this.renderer.buffer,a=t.program;a.glPrograms[s]||this.renderer.shader.generateProgram(t),this.checkCompatibility(e,a);const l=this.getSignature(e,a),h=e.glVertexArrayObjects[this.CONTEXT_UID];let u=h[l];if(u)return h[a.id]=u,u;const c=e.buffers,d=e.attributes,f={},g={};for(const p in c)f[p]=0,g[p]=0;for(const p in d)!d[p].size&&a.attributeData[p]?d[p].size=a.attributeData[p].size:d[p].size||console.warn(`PIXI Geometry attribute '${p}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[p].buffer]+=d[p].size*Pd[d[p].type];for(const p in d){const m=d[p],v=m.size;m.stride===void 0&&(f[m.buffer]===v*Pd[m.type]?m.stride=0:m.stride=f[m.buffer]),m.start===void 0&&(m.start=g[m.buffer],g[m.buffer]+=v*Pd[m.type])}u=n.createVertexArray(),n.bindVertexArray(u);for(let p=0;p<c.length;p++){const m=c[p];o.bind(m),i&&m._glBuffers[s].refCount++}return this.activateVao(e,a),h[a.id]=u,h[l]=u,n.bindVertexArray(null),o.unbind(Ir.ARRAY_BUFFER),u}disposeGeometry(e,t){var i;if(!this.managedGeometries[e.id])return;delete this.managedGeometries[e.id];const n=e.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,o=e.buffers,a=(i=this.renderer)==null?void 0:i.buffer;if(e.disposeRunner.remove(this),!!n){if(a)for(let l=0;l<o.length;l++){const h=o[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!t&&a.dispose(o[l],t))}if(!t){for(const l in n)if(l[0]==="g"){const h=n[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete e.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(e){const t=Object.keys(this.managedGeometries);for(let i=0;i<t.length;i++)this.disposeGeometry(this.managedGeometries[t[i]],e)}activateVao(e,t){const i=this.gl,n=this.CONTEXT_UID,s=this.renderer.buffer,o=e.buffers,a=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let l=null;for(const h in a){const u=a[h],c=o[u.buffer],d=c._glBuffers[n];if(t.attributeData[h]){l!==d&&(s.bind(c),l=d);const f=t.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(f,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,i,n){const{gl:s}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?s.UNSIGNED_SHORT:s.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?s.drawElementsInstanced(e,t||o.indexBuffer.data.length,l,(i||0)*a,n||1):s.drawElements(e,t||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?s.drawArraysInstanced(e,i,t||o.getSize(),n||1):s.drawArrays(e,i,t||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}m0.extension={type:ge.RendererSystem,name:"geometry"},Ee.add(m0);const v0=new pt;class y0{constructor(e,t){this._texture=e,this.mapCoord=new pt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof t>"u"?.5:t,this.isSimple=!1}get texture(){return this._texture}set texture(e){this._texture=e,this._textureID=-1}multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let n=0;n<e.length;n+=2){const s=e[n],o=e[n+1];t[n]=s*i.a+o*i.c+i.tx,t[n+1]=s*i.b+o*i.d+i.ty}return t}update(e){const t=this._texture;if(!t||!t.valid||!e&&this._textureID===t._updateID)return!1;this._textureID=t._updateID,this._updateID++;const i=t._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const n=t.orig,s=t.trim;s&&(v0.set(n.width/s.width,0,0,n.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(v0));const o=t.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(t._frame.x+l+h)/o.width,a[1]=(t._frame.y+l+h)/o.height,a[2]=(t._frame.x+t._frame.width-l+h)/o.width,a[3]=(t._frame.y+t._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=t._frame.width===o.width&&t._frame.height===o.height&&t.rotate===0,!0}}var ZA=`varying vec2 vMaskCoord;
|
|
455
|
+
varying vec2 vTextureCoord;
|
|
456
|
+
|
|
457
|
+
uniform sampler2D uSampler;
|
|
458
|
+
uniform sampler2D mask;
|
|
459
|
+
uniform float alpha;
|
|
460
|
+
uniform float npmAlpha;
|
|
461
|
+
uniform vec4 maskClamp;
|
|
462
|
+
|
|
463
|
+
void main(void)
|
|
464
|
+
{
|
|
465
|
+
float clip = step(3.5,
|
|
466
|
+
step(maskClamp.x, vMaskCoord.x) +
|
|
467
|
+
step(maskClamp.y, vMaskCoord.y) +
|
|
468
|
+
step(vMaskCoord.x, maskClamp.z) +
|
|
469
|
+
step(vMaskCoord.y, maskClamp.w));
|
|
470
|
+
|
|
471
|
+
vec4 original = texture2D(uSampler, vTextureCoord);
|
|
472
|
+
vec4 masky = texture2D(mask, vMaskCoord);
|
|
473
|
+
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
474
|
+
|
|
475
|
+
original *= (alphaMul * masky.r * alpha * clip);
|
|
476
|
+
|
|
477
|
+
gl_FragColor = original;
|
|
478
|
+
}
|
|
479
|
+
`,qA=`attribute vec2 aVertexPosition;
|
|
480
|
+
attribute vec2 aTextureCoord;
|
|
481
|
+
|
|
482
|
+
uniform mat3 projectionMatrix;
|
|
483
|
+
uniform mat3 otherMatrix;
|
|
484
|
+
|
|
485
|
+
varying vec2 vMaskCoord;
|
|
486
|
+
varying vec2 vTextureCoord;
|
|
487
|
+
|
|
488
|
+
void main(void)
|
|
489
|
+
{
|
|
490
|
+
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
491
|
+
|
|
492
|
+
vTextureCoord = aTextureCoord;
|
|
493
|
+
vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
|
|
494
|
+
}
|
|
495
|
+
`;class KA extends mi{constructor(e,t,i){let n=null;typeof e!="string"&&t===void 0&&i===void 0&&(n=e,e=void 0,t=void 0,i=void 0),super(e||qA,t||ZA,i),this.maskSprite=n,this.maskMatrix=new pt}get maskSprite(){return this._maskSprite}set maskSprite(e){this._maskSprite=e,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(e,t,i,n){const s=this._maskSprite,o=s._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new y0(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=e.calculateSpriteMatrix(this.maskMatrix,s).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=s.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,e.applyFilter(this,t,i,n))}}class QA{constructor(e=null){this.type=Gt.NONE,this.autoDetect=!0,this.maskObject=e||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=mi.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(e){e?this._filters?this._filters[0]=e:this._filters=[e]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Gt.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(e){e?(this._stencilCounter=e._stencilCounter,this._scissorCounter=e._scissorCounter,this._scissorRect=e._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class _0{constructor(e){this.renderer=e,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(e){this.maskStack=e,this.renderer.scissor.setMaskStack(e),this.renderer.stencil.setMaskStack(e)}push(e,t){let i=t;if(!i.isMaskData){const s=this.maskDataPool.pop()||new QA;s.pooled=!0,s.maskObject=t,i=s}const n=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(n),i._colorMask=n?n._colorMask:15,i.autoDetect&&this.detect(i),i._target=e,i.type!==Gt.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Gt.SCISSOR:this.renderer.scissor.push(i);break;case Gt.STENCIL:this.renderer.stencil.push(i);break;case Gt.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Gt.COLOR:this.pushColorMask(i);break}i.type===Gt.SPRITE&&this.maskStack.push(i)}pop(e){const t=this.maskStack.pop();if(!(!t||t._target!==e)){if(t.enabled)switch(t.type){case Gt.SCISSOR:this.renderer.scissor.pop(t);break;case Gt.STENCIL:this.renderer.stencil.pop(t.maskObject);break;case Gt.SPRITE:this.popSpriteMask(t);break;case Gt.COLOR:this.popColorMask(t);break}if(t.reset(),t.pooled&&this.maskDataPool.push(t),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Gt.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(e){const t=e.maskObject;t?t.isSprite?e.type=Gt.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(e)?e.type=Gt.SCISSOR:e.type=Gt.STENCIL:e.type=Gt.COLOR}pushSpriteMask(e){const{maskObject:t}=e,i=e._target;let n=e._filters;n||(n=this.alphaMaskPool[this.alphaMaskIndex],n||(n=this.alphaMaskPool[this.alphaMaskIndex]=[new KA])),n[0].resolution=e.resolution,n[0].multisample=e.multisample,n[0].maskSprite=t;const s=i.filterArea;i.filterArea=t.getBounds(!0),this.renderer.filter.push(i,n),i.filterArea=s,e._filters||this.alphaMaskIndex++}popSpriteMask(e){this.renderer.filter.pop(),e._filters?e._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(e){const t=e._colorMask,i=e._colorMask=t&e.colorMask;i!==t&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(e){const t=e._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==t&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}_0.extension={type:ge.RendererSystem,name:"mask"},Ee.add(_0);class x0{constructor(e){this.renderer=e,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(e){const{gl:t}=this.renderer,i=this.getStackLength();this.maskStack=e;const n=this.getStackLength();n!==i&&(n===0?t.disable(this.glConst):(t.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const w0=new pt,E0=[],T0=class Qh extends x0{constructor(e){super(e),this.glConst=ye.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const e=this.maskStack[this.maskStack.length-1];return e?e._scissorCounter:0}calcScissorRect(e){if(e._scissorRectLocal)return;const t=e._scissorRect,{maskObject:i}=e,{renderer:n}=this,s=n.renderTexture,o=i.getBounds(!0,E0.pop()??new We);this.roundFrameToPixels(o,s.current?s.current.resolution:n.resolution,s.sourceFrame,s.destinationFrame,n.projection.transform),t&&o.fit(t),e._scissorRectLocal=o}static isMatrixRotated(e){if(!e)return!1;const{a:t,b:i,c:n,d:s}=e;return(Math.abs(i)>1e-4||Math.abs(n)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(s)>1e-4)}testScissor(e){const{maskObject:t}=e;if(!t.isFastRect||!t.isFastRect()||Qh.isMatrixRotated(t.worldTransform)||Qh.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);const i=e._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(e,t,i,n,s){Qh.isMatrixRotated(s)||(s=s?w0.copyFrom(s):w0.identity(),s.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.renderer.filter.transformAABB(s,e),e.fit(n),e.x=Math.round(e.x*t),e.y=Math.round(e.y*t),e.width=Math.round(e.width*t),e.height=Math.round(e.height*t))}push(e){e._scissorRectLocal||this.calcScissorRect(e);const{gl:t}=this.renderer;e._scissorRect||t.enable(t.SCISSOR_TEST),e._scissorCounter++,e._scissorRect=e._scissorRectLocal,this._useCurrent()}pop(e){const{gl:t}=this.renderer;e&&E0.push(e._scissorRectLocal),this.getStackLength()>0?this._useCurrent():t.disable(t.SCISSOR_TEST)}_useCurrent(){const e=this.maskStack[this.maskStack.length-1]._scissorRect;let t;this.renderer.renderTexture.current?t=e.y:t=this.renderer.height-e.height-e.y,this.renderer.gl.scissor(e.x,t,e.width,e.height)}};T0.extension={type:ge.RendererSystem,name:"scissor"};let JA=T0;Ee.add(JA);class b0 extends x0{constructor(e){super(e),this.glConst=ye.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const e=this.maskStack[this.maskStack.length-1];return e?e._stencilCounter:0}push(e){const t=e.maskObject,{gl:i}=this.renderer,n=e._stencilCounter;n===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),e._stencilCounter++;const s=e._colorMask;s!==0&&(e._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,n,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(e._colorMask=s,i.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}pop(e){const t=this.renderer.gl;if(this.getStackLength()===0)t.disable(t.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,n=i?i._colorMask:15;n!==0&&(i._colorMask=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(i._colorMask=n,t.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}}_useCurrent(){const e=this.renderer.gl;e.stencilFunc(e.EQUAL,this.getStackLength(),4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}}b0.extension={type:ge.RendererSystem,name:"stencil"},Ee.add(b0);class A0{constructor(e){this.renderer=e,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return Je("7.0.0","renderer.plugins.extract has moved to renderer.extract"),e.extract}},prepare:{enumerable:!1,get(){return Je("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),e.prepare}},interaction:{enumerable:!1,get(){return Je("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),e.events}}})}init(){const e=this.rendererPlugins;for(const t in e)this.plugins[t]=new e[t](this.renderer)}destroy(){for(const e in this.plugins)this.plugins[e].destroy(),this.plugins[e]=null}}A0.extension={type:[ge.RendererSystem,ge.CanvasRendererSystem],name:"_plugin"},Ee.add(A0);class S0{constructor(e){this.renderer=e,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new pt,this.transform=null}update(e,t,i,n){this.destinationFrame=e||this.destinationFrame||this.defaultFrame,this.sourceFrame=t||this.sourceFrame||e,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,n),this.transform&&this.projectionMatrix.append(this.transform);const s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)}calculateProjection(e,t,i,n){const s=this.projectionMatrix,o=n?-1:1;s.identity(),s.a=1/t.width*2,s.d=o*(1/t.height*2),s.tx=-1-t.x*s.a,s.ty=-o-t.y*s.d}setTransform(e){}destroy(){this.renderer=null}}S0.extension={type:ge.RendererSystem,name:"projection"},Ee.add(S0);const $A=new wd,R0=new We;class C0{constructor(e){this.renderer=e,this._tempMatrix=new pt}generateTexture(e,t){const{region:i,...n}=t||{},s=(i==null?void 0:i.copyTo(R0))||e.getLocalBounds(R0,!0),o=n.resolution||this.renderer.resolution;s.width=Math.max(s.width,1/o),s.height=Math.max(s.height,1/o),n.width=s.width,n.height=s.height,n.resolution=o,n.multisample??(n.multisample=this.renderer.multisample);const a=ds.create(n);this._tempMatrix.tx=-s.x,this._tempMatrix.ty=-s.y;const l=e.transform;return e.transform=$A,this.renderer.render(e,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!e.parent,blit:!0}),e.transform=l,a}destroy(){}}C0.extension={type:[ge.RendererSystem,ge.CanvasRendererSystem],name:"textureGenerator"},Ee.add(C0);const fs=new We,xa=new We;class P0{constructor(e){this.renderer=e,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new We,this.destinationFrame=new We,this.viewportFrame=new We}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(e=null,t,i){const n=this.renderer;this.current=e;let s,o,a;e?(s=e.baseTexture,a=s.resolution,t||(fs.width=e.frame.width,fs.height=e.frame.height,t=fs),i||(xa.x=e.frame.x,xa.y=e.frame.y,xa.width=t.width,xa.height=t.height,i=xa),o=s.framebuffer):(a=n.resolution,t||(fs.width=n._view.screen.width,fs.height=n._view.screen.height,t=fs),i||(i=fs,i.width=t.width,i.height=t.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,e||(l.y=n.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,t,a,!o),e?this.renderer.mask.setMaskStack(s.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(t),this.destinationFrame.copyFrom(i)}clear(e,t){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,n=ut.shared.setValue(e||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&n.premultiply(n.alpha);const s=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=s.width!==o.width||s.height!==o.height;if(a){let{x:l,y:h,width:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}this.renderer.framebuffer.clear(n.red,n.green,n.blue,n.alpha,t),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}P0.extension={type:ge.RendererSystem,name:"renderTexture"},Ee.add(P0);class eS{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function tS(r,e){const t={},i=e.getProgramParameter(r,e.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const s=e.getActiveAttrib(r,n);if(s.name.startsWith("gl_"))continue;const o=s0(e,s.type),a={type:o,name:s.name,size:r0(o),location:e.getAttribLocation(r,s.name)};t[s.name]=a}return t}function iS(r,e){const t={},i=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){const s=e.getActiveUniform(r,n),o=s.name.replace(/\[.*?\]$/,""),a=!!s.name.match(/\[.*?\]$/),l=s0(e,s.type);t[o]={name:o,index:n,type:l,size:s.size,isArray:a,value:e0(l,s.size)}}return t}function rS(r,e){var t;const i=$v(r,r.VERTEX_SHADER,e.vertexSrc),n=$v(r,r.FRAGMENT_SHADER,e.fragmentSrc),s=r.createProgram();r.attachShader(s,i),r.attachShader(s,n);const o=(t=e.extra)==null?void 0:t.transformFeedbackVaryings;if(o&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,o.names,o.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||DA(r,s,i,n),e.attributeData=tS(s,r),e.uniformData=iS(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertexSrc)){const l=Object.keys(e.attributeData);l.sort((h,u)=>h>u?1:-1);for(let h=0;h<l.length;h++)e.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(i),r.deleteShader(n);const a={};for(const l in e.uniformData){const h=e.uniformData[l];a[l]={location:r.getUniformLocation(s,l),value:e0(h.type,h.size)}}return new eS(s,a)}function nS(r,e,t,i,n){t.buffer.update(n)}const sS={float:`
|
|
496
|
+
data[offset] = v;
|
|
497
|
+
`,vec2:`
|
|
498
|
+
data[offset] = v[0];
|
|
499
|
+
data[offset+1] = v[1];
|
|
500
|
+
`,vec3:`
|
|
501
|
+
data[offset] = v[0];
|
|
502
|
+
data[offset+1] = v[1];
|
|
503
|
+
data[offset+2] = v[2];
|
|
504
|
+
|
|
505
|
+
`,vec4:`
|
|
506
|
+
data[offset] = v[0];
|
|
507
|
+
data[offset+1] = v[1];
|
|
508
|
+
data[offset+2] = v[2];
|
|
509
|
+
data[offset+3] = v[3];
|
|
510
|
+
`,mat2:`
|
|
511
|
+
data[offset] = v[0];
|
|
512
|
+
data[offset+1] = v[1];
|
|
513
|
+
|
|
514
|
+
data[offset+4] = v[2];
|
|
515
|
+
data[offset+5] = v[3];
|
|
516
|
+
`,mat3:`
|
|
517
|
+
data[offset] = v[0];
|
|
518
|
+
data[offset+1] = v[1];
|
|
519
|
+
data[offset+2] = v[2];
|
|
520
|
+
|
|
521
|
+
data[offset + 4] = v[3];
|
|
522
|
+
data[offset + 5] = v[4];
|
|
523
|
+
data[offset + 6] = v[5];
|
|
524
|
+
|
|
525
|
+
data[offset + 8] = v[6];
|
|
526
|
+
data[offset + 9] = v[7];
|
|
527
|
+
data[offset + 10] = v[8];
|
|
528
|
+
`,mat4:`
|
|
529
|
+
for(var i = 0; i < 16; i++)
|
|
530
|
+
{
|
|
531
|
+
data[offset + i] = v[i];
|
|
532
|
+
}
|
|
533
|
+
`},I0={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:32,mat3:48,mat4:64};function oS(r){const e=r.map(s=>({data:s,offset:0,dataLen:0,dirty:0}));let t=0,i=0,n=0;for(let s=0;s<e.length;s++){const o=e[s];if(t=I0[o.data.type],o.data.size>1&&(t=Math.max(t,16)*o.data.size),o.dataLen=t,i%t!==0&&i<16){const a=i%t%16;i+=a,n+=a}i+t>16?(n=Math.ceil(n/16)*16,o.offset=n,n+=t,i=t):(o.offset=n,i+=t,n+=t)}return n=Math.ceil(n/16)*16,{uboElements:e,size:n}}function aS(r,e){const t=[];for(const i in r)e[i]&&t.push(e[i]);return t.sort((i,n)=>i.index-n.index),t}function lS(r,e){if(!r.autoManage)return{size:0,syncFunc:nS};const t=aS(r.uniforms,e),{uboElements:i,size:n}=oS(t),s=[`
|
|
534
|
+
var v = null;
|
|
535
|
+
var v2 = null;
|
|
536
|
+
var cv = null;
|
|
537
|
+
var t = 0;
|
|
538
|
+
var gl = renderer.gl
|
|
539
|
+
var index = 0;
|
|
540
|
+
var data = buffer.data;
|
|
541
|
+
`];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<ao.length;c++){const d=ao[c];if(d.codeUbo&&d.test(a.data,l)){s.push(`offset = ${a.offset/4};`,ao[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=r0(a.data.type),d=Math.max(I0[a.data.type]/16,1),f=c/d,g=(4-f%4)%4;s.push(`
|
|
542
|
+
cv = ud.${h}.value;
|
|
543
|
+
v = uv.${h};
|
|
544
|
+
offset = ${a.offset/4};
|
|
545
|
+
|
|
546
|
+
t = 0;
|
|
547
|
+
|
|
548
|
+
for(var i=0; i < ${a.data.size*d}; i++)
|
|
549
|
+
{
|
|
550
|
+
for(var j = 0; j < ${f}; j++)
|
|
551
|
+
{
|
|
552
|
+
data[offset++] = v[t++];
|
|
553
|
+
}
|
|
554
|
+
offset += ${g};
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
`)}else{const c=sS[a.data.type];s.push(`
|
|
558
|
+
cv = ud.${h}.value;
|
|
559
|
+
v = uv.${h};
|
|
560
|
+
offset = ${a.offset/4};
|
|
561
|
+
${c};
|
|
562
|
+
`)}}return s.push(`
|
|
563
|
+
renderer.buffer.update(buffer);
|
|
564
|
+
`),{size:n,syncFunc:new Function("ud","uv","renderer","syncData","buffer",s.join(`
|
|
565
|
+
`))}}let hS=0;const _h={textureCount:0,uboCount:0};class M0{constructor(e){this.destroyed=!1,this.renderer=e,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=hS++}systemCheck(){if(!LA())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(e){this.gl=e,this.reset()}bind(e,t){e.disposeRunner.add(this),e.uniforms.globals=this.renderer.globalUniforms;const i=e.program,n=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(e);return this.shader=e,this.program!==i&&(this.program=i,this.gl.useProgram(n.program)),t||(_h.textureCount=0,_h.uboCount=0,this.syncUniformGroup(e.uniformGroup,_h)),n}setUniforms(e){const t=this.shader.program,i=t.glPrograms[this.renderer.CONTEXT_UID];t.syncUniforms(i.uniformData,e,this.renderer)}syncUniformGroup(e,t){const i=this.getGlProgram();(!e.static||e.dirtyId!==i.uniformDirtyGroups[e.id])&&(i.uniformDirtyGroups[e.id]=e.dirtyId,this.syncUniforms(e,i,t))}syncUniforms(e,t,i){(e.syncUniforms[this.shader.program.id]||this.createSyncGroups(e))(t.uniformData,e.uniforms,this.renderer,i)}createSyncGroups(e){const t=this.getSignature(e,this.shader.program.uniformData,"u");return this.cache[t]||(this.cache[t]=PA(e,this.shader.program.uniformData)),e.syncUniforms[this.shader.program.id]=this.cache[t],e.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(e,t){const i=this.getGlProgram();if(!e.static||e.dirtyId!==0||!i.uniformGroups[e.id]){e.dirtyId=0;const n=i.uniformGroups[e.id]||this.createSyncBufferGroup(e,i,t);e.buffer.update(),n(i.uniformData,e.uniforms,this.renderer,_h,e.buffer)}this.renderer.buffer.bindBufferBase(e.buffer,i.uniformBufferBindings[t])}createSyncBufferGroup(e,t,i){const{gl:n}=this.renderer;this.renderer.buffer.bind(e.buffer);const s=this.gl.getUniformBlockIndex(t.program,i);t.uniformBufferBindings[i]=this.shader.uniformBindCount,n.uniformBlockBinding(t.program,s,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(e,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=lS(e,this.shader.program.uniformData)),e.autoManage){const l=new Float32Array(a.size/4);e.buffer.update(l)}return t.uniformGroups[e.id]=a.syncFunc,t.uniformGroups[e.id]}getSignature(e,t,i){const n=e.uniforms,s=[`${i}-`];for(const o in n)s.push(o),t[o]&&s.push(t[o].type);return s.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(e){const t=this.gl,i=e.program,n=rS(t,i);return i.glPrograms[this.renderer.CONTEXT_UID]=n,n}reset(){this.program=null,this.shader=null}disposeShader(e){this.shader===e&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}M0.extension={type:ge.RendererSystem,name:"shader"},Ee.add(M0);class xh{constructor(e){this.renderer=e}run(e){const{renderer:t}=this;t.runners.init.emit(t.options),e.hello&&console.log(`PixiJS 7.4.3 - ${t.rendererLogId} - https://pixijs.com`),t.resize(t.screen.width,t.screen.height)}destroy(){}}xh.defaultOptions={hello:!1},xh.extension={type:[ge.RendererSystem,ge.CanvasRendererSystem],name:"startup"},Ee.add(xh);function uS(r,e=[]){return e[Ne.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.ADD]=[r.ONE,r.ONE],e[Ne.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.NONE]=[0,0],e[Ne.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],e[Ne.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e[Ne.SRC_IN]=[r.DST_ALPHA,r.ZERO],e[Ne.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],e[Ne.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],e[Ne.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],e[Ne.DST_IN]=[r.ZERO,r.SRC_ALPHA],e[Ne.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],e[Ne.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],e[Ne.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],e[Ne.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],e}const cS=0,dS=1,fS=2,pS=3,gS=4,mS=5,D0=class yf{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Ne.NONE,this._blendEq=!1,this.map=[],this.map[cS]=this.setBlend,this.map[dS]=this.setOffset,this.map[fS]=this.setCullFace,this.map[pS]=this.setDepthTest,this.map[gS]=this.setFrontFace,this.map[mS]=this.setDepthMask,this.checks=[],this.defaultState=new Or,this.defaultState.blend=!0}contextChange(e){this.gl=e,this.blendModes=uS(e),this.set(this.defaultState),this.reset()}set(e){if(e=e||this.defaultState,this.stateId!==e.data){let t=this.stateId^e.data,i=0;for(;t;)t&1&&this.map[i].call(this,!!(e.data&1<<i)),t=t>>1,i++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e=e||this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(e){this.updateCheck(yf.checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this.updateCheck(yf.checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this.gl[e?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(e){this.gl.frontFace(this.gl[e?"CW":"CCW"])}setBlendMode(e){if(e===this.blendMode)return;this.blendMode=e;const t=this.blendModes[e],i=this.gl;t.length===2?i.blendFunc(t[0],t[1]):i.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,i.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(e,t){const i=this.checks.indexOf(e);t&&i===-1?this.checks.push(e):!t&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null}};D0.extension={type:ge.RendererSystem,name:"state"};let vS=D0;Ee.add(vS);class yS extends oa{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(e){this.addRunners(...e.runners);const t=(e.priority??[]).filter(n=>e.systems[n]),i=[...t,...Object.keys(e.systems).filter(n=>!t.includes(n))];for(const n of i)this.addSystem(e.systems[n],n)}addRunners(...e){e.forEach(t=>{this.runners[t]=new dr(t)})}addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const n in this.runners)this.runners[n].add(i);return this}emitWithCustomOptions(e,t){const i=Object.keys(this._systemsHash);e.items.forEach(n=>{const s=i.find(o=>this._systemsHash[o]===n);n[e.name](t[s])})}destroy(){Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash={}}}const wa=class Jh{constructor(e){this.renderer=e,this.count=0,this.checkCount=0,this.maxIdle=Jh.defaultMaxIdle,this.checkCountMax=Jh.defaultCheckCountMax,this.mode=Jh.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Fc.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const e=this.renderer.texture,t=e.managedTextures;let i=!1;for(let n=0;n<t.length;n++){const s=t[n];s.resource&&this.count-s.touched>this.maxIdle&&(e.destroyTexture(s,!0),t[n]=null,i=!0)}if(i){let n=0;for(let s=0;s<t.length;s++)t[s]!==null&&(t[n++]=t[s]);t.length=n}}unload(e){const t=this.renderer.texture,i=e._texture;i&&!i.framebuffer&&t.destroyTexture(i);for(let n=e.children.length-1;n>=0;n--)this.unload(e.children[n])}destroy(){this.renderer=null}};wa.defaultMode=Fc.AUTO,wa.defaultMaxIdle=3600,wa.defaultCheckCountMax=600,wa.extension={type:ge.RendererSystem,name:"textureGC"};let ps=wa;Ee.add(ps);class Id{constructor(e){this.texture=e,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Re.UNSIGNED_BYTE,this.internalFormat=he.RGBA,this.samplerType=0}}function _S(r){let e;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?e={[r.RGB]:ve.FLOAT,[r.RGBA]:ve.FLOAT,[r.ALPHA]:ve.FLOAT,[r.LUMINANCE]:ve.FLOAT,[r.LUMINANCE_ALPHA]:ve.FLOAT,[r.R8]:ve.FLOAT,[r.R8_SNORM]:ve.FLOAT,[r.RG8]:ve.FLOAT,[r.RG8_SNORM]:ve.FLOAT,[r.RGB8]:ve.FLOAT,[r.RGB8_SNORM]:ve.FLOAT,[r.RGB565]:ve.FLOAT,[r.RGBA4]:ve.FLOAT,[r.RGB5_A1]:ve.FLOAT,[r.RGBA8]:ve.FLOAT,[r.RGBA8_SNORM]:ve.FLOAT,[r.RGB10_A2]:ve.FLOAT,[r.RGB10_A2UI]:ve.FLOAT,[r.SRGB8]:ve.FLOAT,[r.SRGB8_ALPHA8]:ve.FLOAT,[r.R16F]:ve.FLOAT,[r.RG16F]:ve.FLOAT,[r.RGB16F]:ve.FLOAT,[r.RGBA16F]:ve.FLOAT,[r.R32F]:ve.FLOAT,[r.RG32F]:ve.FLOAT,[r.RGB32F]:ve.FLOAT,[r.RGBA32F]:ve.FLOAT,[r.R11F_G11F_B10F]:ve.FLOAT,[r.RGB9_E5]:ve.FLOAT,[r.R8I]:ve.INT,[r.R8UI]:ve.UINT,[r.R16I]:ve.INT,[r.R16UI]:ve.UINT,[r.R32I]:ve.INT,[r.R32UI]:ve.UINT,[r.RG8I]:ve.INT,[r.RG8UI]:ve.UINT,[r.RG16I]:ve.INT,[r.RG16UI]:ve.UINT,[r.RG32I]:ve.INT,[r.RG32UI]:ve.UINT,[r.RGB8I]:ve.INT,[r.RGB8UI]:ve.UINT,[r.RGB16I]:ve.INT,[r.RGB16UI]:ve.UINT,[r.RGB32I]:ve.INT,[r.RGB32UI]:ve.UINT,[r.RGBA8I]:ve.INT,[r.RGBA8UI]:ve.UINT,[r.RGBA16I]:ve.INT,[r.RGBA16UI]:ve.UINT,[r.RGBA32I]:ve.INT,[r.RGBA32UI]:ve.UINT,[r.DEPTH_COMPONENT16]:ve.FLOAT,[r.DEPTH_COMPONENT24]:ve.FLOAT,[r.DEPTH_COMPONENT32F]:ve.FLOAT,[r.DEPTH_STENCIL]:ve.FLOAT,[r.DEPTH24_STENCIL8]:ve.FLOAT,[r.DEPTH32F_STENCIL8]:ve.FLOAT}:e={[r.RGB]:ve.FLOAT,[r.RGBA]:ve.FLOAT,[r.ALPHA]:ve.FLOAT,[r.LUMINANCE]:ve.FLOAT,[r.LUMINANCE_ALPHA]:ve.FLOAT,[r.DEPTH_STENCIL]:ve.FLOAT},e}function xS(r){let e;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?e={[Re.UNSIGNED_BYTE]:{[he.RGBA]:r.RGBA8,[he.RGB]:r.RGB8,[he.RG]:r.RG8,[he.RED]:r.R8,[he.RGBA_INTEGER]:r.RGBA8UI,[he.RGB_INTEGER]:r.RGB8UI,[he.RG_INTEGER]:r.RG8UI,[he.RED_INTEGER]:r.R8UI,[he.ALPHA]:r.ALPHA,[he.LUMINANCE]:r.LUMINANCE,[he.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[Re.BYTE]:{[he.RGBA]:r.RGBA8_SNORM,[he.RGB]:r.RGB8_SNORM,[he.RG]:r.RG8_SNORM,[he.RED]:r.R8_SNORM,[he.RGBA_INTEGER]:r.RGBA8I,[he.RGB_INTEGER]:r.RGB8I,[he.RG_INTEGER]:r.RG8I,[he.RED_INTEGER]:r.R8I},[Re.UNSIGNED_SHORT]:{[he.RGBA_INTEGER]:r.RGBA16UI,[he.RGB_INTEGER]:r.RGB16UI,[he.RG_INTEGER]:r.RG16UI,[he.RED_INTEGER]:r.R16UI,[he.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[Re.SHORT]:{[he.RGBA_INTEGER]:r.RGBA16I,[he.RGB_INTEGER]:r.RGB16I,[he.RG_INTEGER]:r.RG16I,[he.RED_INTEGER]:r.R16I},[Re.UNSIGNED_INT]:{[he.RGBA_INTEGER]:r.RGBA32UI,[he.RGB_INTEGER]:r.RGB32UI,[he.RG_INTEGER]:r.RG32UI,[he.RED_INTEGER]:r.R32UI,[he.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[Re.INT]:{[he.RGBA_INTEGER]:r.RGBA32I,[he.RGB_INTEGER]:r.RGB32I,[he.RG_INTEGER]:r.RG32I,[he.RED_INTEGER]:r.R32I},[Re.FLOAT]:{[he.RGBA]:r.RGBA32F,[he.RGB]:r.RGB32F,[he.RG]:r.RG32F,[he.RED]:r.R32F,[he.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[Re.HALF_FLOAT]:{[he.RGBA]:r.RGBA16F,[he.RGB]:r.RGB16F,[he.RG]:r.RG16F,[he.RED]:r.R16F},[Re.UNSIGNED_SHORT_5_6_5]:{[he.RGB]:r.RGB565},[Re.UNSIGNED_SHORT_4_4_4_4]:{[he.RGBA]:r.RGBA4},[Re.UNSIGNED_SHORT_5_5_5_1]:{[he.RGBA]:r.RGB5_A1},[Re.UNSIGNED_INT_2_10_10_10_REV]:{[he.RGBA]:r.RGB10_A2,[he.RGBA_INTEGER]:r.RGB10_A2UI},[Re.UNSIGNED_INT_10F_11F_11F_REV]:{[he.RGB]:r.R11F_G11F_B10F},[Re.UNSIGNED_INT_5_9_9_9_REV]:{[he.RGB]:r.RGB9_E5},[Re.UNSIGNED_INT_24_8]:{[he.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[Re.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[he.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:e={[Re.UNSIGNED_BYTE]:{[he.RGBA]:r.RGBA,[he.RGB]:r.RGB,[he.ALPHA]:r.ALPHA,[he.LUMINANCE]:r.LUMINANCE,[he.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[Re.UNSIGNED_SHORT_5_6_5]:{[he.RGB]:r.RGB},[Re.UNSIGNED_SHORT_4_4_4_4]:{[he.RGBA]:r.RGBA},[Re.UNSIGNED_SHORT_5_5_5_1]:{[he.RGBA]:r.RGBA}},e}class O0{constructor(e){this.renderer=e,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new ze,this.hasIntegerTextures=!1}contextChange(){const e=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=xS(e),this.samplerTypes=_S(e);const t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=t;for(let n=0;n<t;n++)this.boundTextures[n]=null;this.emptyTextures={};const i=new Id(e.createTexture());e.bindTexture(e.TEXTURE_2D,i.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[e.TEXTURE_2D]=i,this.emptyTextures[e.TEXTURE_CUBE_MAP]=new Id(e.createTexture()),e.bindTexture(e.TEXTURE_CUBE_MAP,this.emptyTextures[e.TEXTURE_CUBE_MAP].texture);for(let n=0;n<6;n++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR);for(let n=0;n<this.boundTextures.length;n++)this.bind(null,n)}bind(e,t=0){const{gl:i}=this;if(e=e==null?void 0:e.castToBaseTexture(),(e==null?void 0:e.valid)&&!e.parentTextureArray){e.touched=this.renderer.textureGC.count;const n=e._glTextures[this.CONTEXT_UID]||this.initTexture(e);this.boundTextures[t]!==e&&(this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),i.bindTexture(e.target,n.texture)),n.dirtyId!==e.dirtyId?(this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),this.updateTexture(e)):n.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(e),this.boundTextures[t]=e}else this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[t]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let e=0;e<this.boundTextures.length;e++)this.boundTextures[e]=this.unknownTexture}unbind(e){const{gl:t,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let n=0;n<i.length;n++)i[n]===this.unknownTexture&&this.bind(null,n)}for(let n=0;n<i.length;n++)i[n]===e&&(this.currentLocation!==n&&(t.activeTexture(t.TEXTURE0+n),this.currentLocation=n),t.bindTexture(e.target,this.emptyTextures[e.target].texture),i[n]=null)}ensureSamplerType(e){const{boundTextures:t,hasIntegerTextures:i,CONTEXT_UID:n}=this;if(i)for(let s=e-1;s>=0;--s){const o=t[s];o&&o._glTextures[n].samplerType!==ve.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(e){const t=new Id(this.gl.createTexture());return t.dirtyId=-1,e._glTextures[this.CONTEXT_UID]=t,this.managedTextures.push(e),e.on("dispose",this.destroyTexture,this),t}initTextureType(e,t){var i;t.internalFormat=((i=this.internalFormats[e.type])==null?void 0:i[e.format])??e.format,t.samplerType=this.samplerTypes[t.internalFormat]??ve.FLOAT,this.webGLVersion===2&&e.type===Re.HALF_FLOAT?t.type=this.gl.HALF_FLOAT:t.type=e.type}updateTexture(e){var t;const i=e._glTextures[this.CONTEXT_UID];if(!i)return;const n=this.renderer;if(this.initTextureType(e,i),(t=e.resource)==null?void 0:t.upload(n,e,i))i.samplerType!==ve.FLOAT&&(this.hasIntegerTextures=!0);else{const s=e.realWidth,o=e.realHeight,a=n.gl;(i.width!==s||i.height!==o||i.dirtyId<0)&&(i.width=s,i.height=o,a.texImage2D(e.target,0,i.internalFormat,s,o,0,e.format,i.type,null))}e.dirtyStyleId!==i.dirtyStyleId&&this.updateTextureStyle(e),i.dirtyId=e.dirtyId}destroyTexture(e,t){const{gl:i}=this;if(e=e.castToBaseTexture(),e._glTextures[this.CONTEXT_UID]&&(this.unbind(e),i.deleteTexture(e._glTextures[this.CONTEXT_UID].texture),e.off("dispose",this.destroyTexture,this),delete e._glTextures[this.CONTEXT_UID],!t)){const n=this.managedTextures.indexOf(e);n!==-1&&oo(this.managedTextures,n,1)}}updateTextureStyle(e){var t;const i=e._glTextures[this.CONTEXT_UID];i&&((e.mipmap===Cr.POW2||this.webGLVersion!==2)&&!e.isPowerOfTwo?i.mipmap=!1:i.mipmap=e.mipmap>=1,this.webGLVersion!==2&&!e.isPowerOfTwo?i.wrapMode=En.CLAMP:i.wrapMode=e.wrapMode,(t=e.resource)!=null&&t.style(this.renderer,e,i)||this.setStyle(e,i),i.dirtyStyleId=e.dirtyStyleId)}setStyle(e,t){const i=this.gl;if(t.mipmap&&e.mipmap!==Cr.ON_MANUAL&&i.generateMipmap(e.target),i.texParameteri(e.target,i.TEXTURE_WRAP_S,t.wrapMode),i.texParameteri(e.target,i.TEXTURE_WRAP_T,t.wrapMode),t.mipmap){i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===qr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const n=this.renderer.context.extensions.anisotropicFiltering;if(n&&e.anisotropicLevel>0&&e.scaleMode===qr.LINEAR){const s=Math.min(e.anisotropicLevel,i.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(e.target,n.TEXTURE_MAX_ANISOTROPY_EXT,s)}}else i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===qr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(e.target,i.TEXTURE_MAG_FILTER,e.scaleMode===qr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}O0.extension={type:ge.RendererSystem,name:"texture"},Ee.add(O0);class L0{constructor(e){this.renderer=e}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,n=e._glTransformFeedbacks[i]||this.createGLTransformFeedback(e);t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,n)}unbind(){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(e,t){const{gl:i,renderer:n}=this;t&&n.shader.bind(t),i.beginTransformFeedback(e)}endTransformFeedback(){const{gl:e}=this;e.endTransformFeedback()}createGLTransformFeedback(e){const{gl:t,renderer:i,CONTEXT_UID:n}=this,s=t.createTransformFeedback();e._glTransformFeedbacks[n]=s,t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,s);for(let o=0;o<e.buffers.length;o++){const a=e.buffers[o];a&&(i.buffer.update(a),a._glBuffers[n].refCount++,t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[n].buffer||null))}return t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),e.disposeRunner.add(this),s}disposeTransformFeedback(e,t){const i=e._glTransformFeedbacks[this.CONTEXT_UID],n=this.gl;e.disposeRunner.remove(this);const s=this.renderer.buffer;if(s)for(let o=0;o<e.buffers.length;o++){const a=e.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!t&&s.dispose(a,t))}i&&(t||n.deleteTransformFeedback(i),delete e._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}L0.extension={type:ge.RendererSystem,name:"transformFeedback"},Ee.add(L0);class wh{constructor(e){this.renderer=e}init(e){this.screen=new We(0,0,e.width,e.height),this.element=e.view||ye.ADAPTER.createCanvas(),this.resolution=e.resolution||ye.RESOLUTION,this.autoDensity=!!e.autoDensity}resizeView(e,t){this.element.width=Math.round(e*this.resolution),this.element.height=Math.round(t*this.resolution);const i=this.element.width/this.resolution,n=this.element.height/this.resolution;this.screen.width=i,this.screen.height=n,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${n}px`),this.renderer.emit("resize",i,n),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(e){var t;e&&((t=this.element.parentNode)==null||t.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}wh.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},wh.extension={type:[ge.RendererSystem,ge.CanvasRendererSystem],name:"_view"},Ee.add(wh),ye.PREFER_ENV=is.WEBGL2,ye.STRICT_TEXTURE_CACHE=!1,ye.RENDER_OPTIONS={...mh.defaultOptions,...gh.defaultOptions,...wh.defaultOptions,...xh.defaultOptions},Object.defineProperties(ye,{WRAP_MODE:{get(){return ze.defaultOptions.wrapMode},set(r){Je("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),ze.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return ze.defaultOptions.scaleMode},set(r){Je("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),ze.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return ze.defaultOptions.mipmap},set(r){Je("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),ze.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return ze.defaultOptions.anisotropicLevel},set(r){Je("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),ze.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return Je("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),mi.defaultResolution},set(r){mi.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return Je("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),mi.defaultMultisample},set(r){mi.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return cs.defaultMaxTextures},set(r){Je("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),cs.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return cs.defaultBatchSize},set(r){Je("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),cs.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return cs.canUploadSameBuffer},set(r){Je("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),cs.canUploadSameBuffer=r}},GC_MODE:{get(){return ps.defaultMode},set(r){Je("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),ps.defaultMode=r}},GC_MAX_IDLE:{get(){return ps.defaultMaxIdle},set(r){Je("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),ps.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return ps.defaultCheckCountMax},set(r){Je("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),ps.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return tn.defaultVertexPrecision},set(r){Je("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),tn.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return tn.defaultFragmentPrecision},set(r){Je("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),tn.defaultFragmentPrecision=r}}});var gs=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(gs||{});class Md{constructor(e,t=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=e,this.context=t,this.priority=i,this.once=n}match(e,t=null){return this.fn===e&&this.context===t}emit(e){this.fn&&(this.context?this.fn.call(this.context,e):this.fn(e));const t=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const t=this.next;return this.next=e?null:t,this.previous=null,t}}const N0=class Ui{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Md(null,null,1/0),this.deltaMS=1/Ui.targetFPMS,this.elapsedMS=1/Ui.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,i=gs.NORMAL){return this._addListener(new Md(e,t,i))}addOnce(e,t,i=gs.NORMAL){return this._addListener(new Md(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const s=e-this._lastFrame|0;if(s<this._minElapsedMS)return;this._lastFrame=e-s%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*Ui.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(this.maxFPS,e),i=Math.min(Math.max(0,t)/1e3,Ui.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){if(e===0)this._minElapsedMS=0;else{const t=Math.max(this.minFPS,e);this._minElapsedMS=1/(t/1e3)}}static get shared(){if(!Ui._shared){const e=Ui._shared=new Ui;e.autoStart=!0,e._protected=!0}return Ui._shared}static get system(){if(!Ui._system){const e=Ui._system=new Ui;e.autoStart=!0,e._protected=!0}return Ui._system}};N0.targetFPMS=.06;let Li=N0;Object.defineProperties(ye,{TARGET_FPMS:{get(){return Li.targetFPMS},set(r){Je("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Li.targetFPMS=r}}});class F0{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,gs.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Li.shared:new Li,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}F0.extension=ge.Application,Ee.add(F0);const B0=[];Ee.handleByList(ge.Renderer,B0);function k0(r){for(const e of B0)if(e.test(r))return new e(r);throw new Error("Unable to auto-detect a suitable renderer.")}var wS=`attribute vec2 aVertexPosition;
|
|
566
|
+
attribute vec2 aTextureCoord;
|
|
567
|
+
|
|
568
|
+
uniform mat3 projectionMatrix;
|
|
569
|
+
|
|
570
|
+
varying vec2 vTextureCoord;
|
|
571
|
+
|
|
572
|
+
void main(void)
|
|
573
|
+
{
|
|
574
|
+
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
575
|
+
vTextureCoord = aTextureCoord;
|
|
576
|
+
}`,ES=`attribute vec2 aVertexPosition;
|
|
577
|
+
|
|
578
|
+
uniform mat3 projectionMatrix;
|
|
579
|
+
|
|
580
|
+
varying vec2 vTextureCoord;
|
|
581
|
+
|
|
582
|
+
uniform vec4 inputSize;
|
|
583
|
+
uniform vec4 outputFrame;
|
|
584
|
+
|
|
585
|
+
vec4 filterVertexPosition( void )
|
|
586
|
+
{
|
|
587
|
+
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
|
588
|
+
|
|
589
|
+
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
vec2 filterTextureCoord( void )
|
|
593
|
+
{
|
|
594
|
+
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
void main(void)
|
|
598
|
+
{
|
|
599
|
+
gl_Position = filterVertexPosition();
|
|
600
|
+
vTextureCoord = filterTextureCoord();
|
|
601
|
+
}
|
|
602
|
+
`;const TS=wS,U0=ES;class H0{constructor(e){this.renderer=e}contextChange(e){let t;if(this.renderer.context.webGLVersion===1){const i=e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.FRAMEBUFFER,i)}else{const i=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,i)}t>=Bt.HIGH?this.multisample=Bt.HIGH:t>=Bt.MEDIUM?this.multisample=Bt.MEDIUM:t>=Bt.LOW?this.multisample=Bt.LOW:this.multisample=Bt.NONE}destroy(){}}H0.extension={type:ge.RendererSystem,name:"_multisample"},Ee.add(H0);class bS{constructor(e){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class G0{constructor(e){this.renderer=e,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,n=e._glBuffers[i]||this.createGLBuffer(e);t.bindBuffer(e.type,n.buffer)}unbind(e){const{gl:t}=this;t.bindBuffer(e,null)}bindBufferBase(e,t){const{gl:i,CONTEXT_UID:n}=this;if(this.boundBufferBases[t]!==e){const s=e._glBuffers[n]||this.createGLBuffer(e);this.boundBufferBases[t]=e,i.bindBufferBase(i.UNIFORM_BUFFER,t,s.buffer)}}bindBufferRange(e,t,i){const{gl:n,CONTEXT_UID:s}=this;i=i||0;const o=e._glBuffers[s]||this.createGLBuffer(e);n.bindBufferRange(n.UNIFORM_BUFFER,t||0,o.buffer,i*256,256)}update(e){const{gl:t,CONTEXT_UID:i}=this,n=e._glBuffers[i]||this.createGLBuffer(e);if(e._updateID!==n.updateID)if(n.updateID=e._updateID,t.bindBuffer(e.type,n.buffer),n.byteLength>=e.data.byteLength)t.bufferSubData(e.type,0,e.data);else{const s=e.static?t.STATIC_DRAW:t.DYNAMIC_DRAW;n.byteLength=e.data.byteLength,t.bufferData(e.type,e.data,s)}}dispose(e,t){if(!this.managedBuffers[e.id])return;delete this.managedBuffers[e.id];const i=e._glBuffers[this.CONTEXT_UID],n=this.gl;e.disposeRunner.remove(this),i&&(t||n.deleteBuffer(i.buffer),delete e._glBuffers[this.CONTEXT_UID])}disposeAll(e){const t=Object.keys(this.managedBuffers);for(let i=0;i<t.length;i++)this.dispose(this.managedBuffers[t[i]],e)}createGLBuffer(e){const{CONTEXT_UID:t,gl:i}=this;return e._glBuffers[t]=new bS(i.createBuffer()),this.managedBuffers[e.id]=e,e.disposeRunner.add(this),e._glBuffers[t]}}G0.extension={type:ge.RendererSystem,name:"buffer"},Ee.add(G0);class V0{constructor(e){this.renderer=e}render(e,t){const i=this.renderer;let n,s,o,a;if(t&&(n=t.renderTexture,s=t.clear,o=t.transform,a=t.skipUpdateTransform),this.renderingToScreen=!n,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(n||(this.lastObjectRendered=e),!a){const l=e.enableTempParent();e.updateTransform(),e.disableTempParent(l)}i.renderTexture.bind(n),i.batch.currentRenderer.start(),(s??i.background.clearBeforeRender)&&i.renderTexture.clear(),e.render(i),i.batch.currentRenderer.flush(),n&&(t.blit&&i.framebuffer.blit(),n.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}V0.extension={type:ge.RendererSystem,name:"objectRenderer"},Ee.add(V0);const Eh=class _f extends yS{constructor(e){super(),this.type=Dm.WEBGL,e=Object.assign({},ye.RENDER_OPTIONS,e),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new fr({projectionMatrix:new pt},!0);const t={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:_f.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(t),"useContextAlpha"in e&&(Je("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),e.premultipliedAlpha=e.useContextAlpha&&e.useContextAlpha!=="notMultiplied",e.backgroundAlpha=e.useContextAlpha===!1?1:e.backgroundAlpha),this._plugin.rendererPlugins=_f.__plugins,this.options=e,this.startup.run(this.options)}static test(e){return e!=null&&e.forceCanvas?!1:Z2()}render(e,t){this.objectRenderer.render(e,t)}resize(e,t){this._view.resizeView(e,t)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(e=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:e}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(e){this._view.resolution=e,this.runners.resolutionChange.emit(e)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return Je("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return Je("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return Je("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return Je("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(e){Je("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=e}get backgroundAlpha(){return Je("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(e){Je("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=e}get powerPreference(){return Je("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(e,t){return this.textureGenerator.generateTexture(e,t)}};Eh.extension={type:ge.Renderer,priority:1},Eh.__plugins={},Eh.__systems={};let Dd=Eh;Ee.handleByMap(ge.RendererPlugin,Dd.__plugins),Ee.handleByMap(ge.RendererSystem,Dd.__systems),Ee.add(Dd);class z0 extends ma{constructor(e,t){const{width:i,height:n}=t||{};super(i,n),this.items=[],this.itemDirtyIds=[];for(let s=0;s<e;s++){const o=new ze;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=e,this._load=null,this.baseTexture=null}initFromArray(e,t){for(let i=0;i<this.length;i++)e[i]&&(e[i].castToBaseTexture?this.addBaseTextureAt(e[i].castToBaseTexture(),i):e[i]instanceof ma?this.addResourceAt(e[i],i):this.addResourceAt(qv(e[i],t),i))}dispose(){for(let e=0,t=this.length;e<t;e++)this.items[e].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(e,t){if(!this.items[t])throw new Error(`Index ${t} is out of bounds`);return e.valid&&!this.valid&&this.resize(e.width,e.height),this.items[t].setResource(e),this}bind(e){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(e);for(let t=0;t<this.length;t++)this.items[t].parentTextureArray=e,this.items[t].on("update",e.update,e)}unbind(e){super.unbind(e);for(let t=0;t<this.length;t++)this.items[t].parentTextureArray=null,this.items[t].off("update",e.update,e)}load(){if(this._load)return this._load;const e=this.items.map(t=>t.resource).filter(t=>t).map(t=>t.load());return this._load=Promise.all(e).then(()=>{const{realWidth:t,realHeight:i}=this.items[0];return this.resize(t,i),this.update(),Promise.resolve(this)}),this._load}}class AS extends z0{constructor(e,t){const{width:i,height:n}=t||{};let s,o;Array.isArray(e)?(s=e,o=e.length):o=e,super(o,{width:i,height:n}),s&&this.initFromArray(s,t)}addBaseTextureAt(e,t){if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(e){super.bind(e),e.target=Js.TEXTURE_2D_ARRAY}upload(e,t,i){const{length:n,itemDirtyIds:s,items:o}=this,{gl:a}=e;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,n,0,t.format,i.type,null);for(let l=0;l<n;l++){const h=o[l];s[l]<h.dirtyId&&(s[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,t.format,i.type,h.resource.source))}return!0}}class SS extends rn{constructor(e){super(e)}static test(e){const{OffscreenCanvas:t}=globalThis;return t&&e instanceof t?!0:globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement}}const j0=class qa extends z0{constructor(e,t){const{width:i,height:n,autoLoad:s,linkBaseTexture:o}=t||{};if(e&&e.length!==qa.SIDES)throw new Error(`Invalid length. Got ${e.length}, expected 6`);super(6,{width:i,height:n});for(let a=0;a<qa.SIDES;a++)this.items[a].target=Js.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,e&&this.initFromArray(e,t),s!==!1&&this.load()}bind(e){super.bind(e),e.target=Js.TEXTURE_CUBE_MAP}addBaseTextureAt(e,t,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[t])throw new Error(`Index ${t} is out of bounds`);if(!this.linkBaseTexture||e.parentTextureArray||Object.keys(e._glTextures).length>0)if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("CubeResource does not support copying of renderTexture.");else e.target=Js.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.parentTextureArray=this.baseTexture,this.items[t]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[t]=e,this}upload(e,t,i){const n=this.itemDirtyIds;for(let s=0;s<qa.SIDES;s++){const o=this.items[s];(n[s]<o.dirtyId||i.dirtyId<t.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(e,o,i),n[s]=o.dirtyId):n[s]<-1&&(e.gl.texImage2D(o.target,0,i.internalFormat,t.realWidth,t.realHeight,0,t.format,i.type,null),n[s]=-1))}return!0}static test(e){return Array.isArray(e)&&e.length===qa.SIDES}};j0.SIDES=6;let RS=j0;class lo extends rn{constructor(e,t){t=t||{};let i,n,s;typeof e=="string"?(i=lo.EMPTY,n=e,s=!0):(i=e,n=null,s=!1),super(i),this.url=n,this.crossOrigin=t.crossOrigin??!0,this.alphaMode=typeof t.alphaMode=="number"?t.alphaMode:null,this.ownsImageBitmap=t.ownsImageBitmap??s,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(e,t)=>{if(this.url===null){e(this);return}try{const i=await ye.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const n=await i.blob();if(this.destroyed)return;const s=await createImageBitmap(n,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===bi.UNPACK?"premultiply":"none"});if(this.destroyed){s.close();return}this.source=s,this.update(),e(this)}catch(i){if(this.destroyed)return;t(i),this.onError.emit(i)}}),this._load)}upload(e,t,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),super.upload(e,t,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof e=="string"||e instanceof ImageBitmap)}static get EMPTY(){return lo._EMPTY=lo._EMPTY??ye.ADAPTER.createCanvas(0,0),lo._EMPTY}}const Od=class $h extends rn{constructor(e,t){t=t||{},super(ye.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=e,this.scale=t.scale||1,this._overrideWidth=t.width,this._overrideHeight=t.height,this._resolve=null,this._crossorigin=t.crossorigin,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(e=>{if(this._resolve=()=>{this.update(),e(this)},$h.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const e=new Image;rn.crossOrigin(e,this.svg,this._crossorigin),e.src=this.svg,e.onerror=t=>{this._resolve&&(e.onerror=null,this.onError.emit(t))},e.onload=()=>{if(!this._resolve)return;const t=e.width,i=e.height;if(!t||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let n=t*this.scale,s=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(n=this._overrideWidth||this._overrideHeight/i*t,s=this._overrideHeight||this._overrideWidth/t*i),n=Math.round(n),s=Math.round(s);const o=this.source;o.width=n,o.height=s,o._pixiId=`canvas_${ss()}`,o.getContext("2d").drawImage(e,0,0,t,i,0,0,n,s),this._resolve(),this._resolve=null}}static getSize(e){const t=$h.SVG_SIZE.exec(e),i={};return t&&(i[t[1]]=Math.round(parseFloat(t[3])),i[t[5]]=Math.round(parseFloat(t[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(e,t){return t==="svg"||typeof e=="string"&&e.startsWith("data:image/svg+xml")||typeof e=="string"&&$h.SVG_XML.test(e)}};Od.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Od.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Ld=Od;class CS extends rn{constructor(e){super(e)}static test(e){return!!globalThis.VideoFrame&&e instanceof globalThis.VideoFrame}}const Nd=class xf extends rn{constructor(e,t){if(t=t||{},!(e instanceof HTMLVideoElement)){const i=document.createElement("video");t.autoLoad!==!1&&i.setAttribute("preload","auto"),t.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),t.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),t.loop===!0&&i.setAttribute("loop",""),t.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof e=="string"&&(e=[e]);const n=e[0].src||e[0];rn.crossOrigin(i,n,t.crossorigin);for(let s=0;s<e.length;++s){const o=document.createElement("source");let{src:a,mime:l}=e[s];if(a=a||e[s],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||xf.MIME_TYPES[u]||`video/${u}`}o.src=a,l&&(o.type=l),i.appendChild(o)}e=i}super(e),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}update(e=0){if(!this.destroyed){if(this._updateFPS){const t=Li.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const e=this.source;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._load=new Promise((t,i)=>{this.valid?t(this):(this._resolve=t,this._reject=i,e.load())}),this._load}_onError(e){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.source;return!e.paused&&!e.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!t&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()}dispose(){this._configureAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Li.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Li.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Li.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e,t){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||xf.TYPES.includes(t)}};Nd.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Nd.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let W0=Nd;md.push(lo,u0,SS,W0,CS,Ld,rh,RS,AS);class Th{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(e){return this.minX>this.maxX||this.minY>this.maxY?We.EMPTY:(e=e||new We(0,0,1,1),e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)}addPoint(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)}addPointMatrix(e,t){const{a:i,b:n,c:s,d:o,tx:a,ty:l}=e,h=i*t.x+s*t.y+a,u=n*t.x+o*t.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(e){let t=this.minX,i=this.minY,n=this.maxX,s=this.maxY,o=e[0],a=e[1];t=o<t?o:t,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=e[2],a=e[3],t=o<t?o:t,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=e[4],a=e[5],t=o<t?o:t,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=e[6],a=e[7],t=o<t?o:t,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,this.minX=t,this.minY=i,this.maxX=n,this.maxY=s}addFrame(e,t,i,n,s){this.addFrameMatrix(e.worldTransform,t,i,n,s)}addFrameMatrix(e,t,i,n,s){const o=e.a,a=e.b,l=e.c,h=e.d,u=e.tx,c=e.ty;let d=this.minX,f=this.minY,g=this.maxX,p=this.maxY,m=o*t+l*i+u,v=a*t+h*i+c;d=m<d?m:d,f=v<f?v:f,g=m>g?m:g,p=v>p?v:p,m=o*n+l*i+u,v=a*n+h*i+c,d=m<d?m:d,f=v<f?v:f,g=m>g?m:g,p=v>p?v:p,m=o*t+l*s+u,v=a*t+h*s+c,d=m<d?m:d,f=v<f?v:f,g=m>g?m:g,p=v>p?v:p,m=o*n+l*s+u,v=a*n+h*s+c,d=m<d?m:d,f=v<f?v:f,g=m>g?m:g,p=v>p?v:p,this.minX=d,this.minY=f,this.maxX=g,this.maxY=p}addVertexData(e,t,i){let n=this.minX,s=this.minY,o=this.maxX,a=this.maxY;for(let l=t;l<i;l+=2){const h=e[l],u=e[l+1];n=h<n?h:n,s=u<s?u:s,o=h>o?h:o,a=u>a?u:a}this.minX=n,this.minY=s,this.maxX=o,this.maxY=a}addVertices(e,t,i,n){this.addVerticesMatrix(e.worldTransform,t,i,n)}addVerticesMatrix(e,t,i,n,s=0,o=s){const a=e.a,l=e.b,h=e.c,u=e.d,c=e.tx,d=e.ty;let f=this.minX,g=this.minY,p=this.maxX,m=this.maxY;for(let v=i;v<n;v+=2){const y=t[v],_=t[v+1],w=a*y+h*_+c,A=u*_+l*y+d;f=Math.min(f,w-s),p=Math.max(p,w+s),g=Math.min(g,A-o),m=Math.max(m,A+o)}this.minX=f,this.minY=g,this.maxX=p,this.maxY=m}addBounds(e){const t=this.minX,i=this.minY,n=this.maxX,s=this.maxY;this.minX=e.minX<t?e.minX:t,this.minY=e.minY<i?e.minY:i,this.maxX=e.maxX>n?e.maxX:n,this.maxY=e.maxY>s?e.maxY:s}addBoundsMask(e,t){const i=e.minX>t.minX?e.minX:t.minX,n=e.minY>t.minY?e.minY:t.minY,s=e.maxX<t.maxX?e.maxX:t.maxX,o=e.maxY<t.maxY?e.maxY:t.maxY;if(i<=s&&n<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=n<l?n:l,this.maxX=s>h?s:h,this.maxY=o>u?o:u}}addBoundsMatrix(e,t){this.addFrameMatrix(t,e.minX,e.minY,e.maxX,e.maxY)}addBoundsArea(e,t){const i=e.minX>t.x?e.minX:t.x,n=e.minY>t.y?e.minY:t.y,s=e.maxX<t.x+t.width?e.maxX:t.x+t.width,o=e.maxY<t.y+t.height?e.maxY:t.y+t.height;if(i<=s&&n<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=n<l?n:l,this.maxX=s>h?s:h,this.maxY=o>u?o:u}}pad(e=0,t=e){this.isEmpty()||(this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t)}addFramePad(e,t,i,n,s,o){e-=s,t-=o,i+=s,n+=o,this.minX=this.minX<e?this.minX:e,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<t?this.minY:t,this.maxY=this.maxY>n?this.maxY:n}}class Ct extends oa{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new wd,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Th,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(e){const t=Object.keys(e);for(let i=0;i<t.length;++i){const n=t[i];Object.defineProperty(Ct.prototype,n,Object.getOwnPropertyDescriptor(e,n))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(e,t){return e||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),t||(this._boundsRect||(this._boundsRect=new We),t=this._boundsRect),this._bounds.getRectangle(t)}getLocalBounds(e){e||(this._localBoundsRect||(this._localBoundsRect=new We),e=this._localBoundsRect),this._localBounds||(this._localBounds=new Th);const t=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const n=this._bounds,s=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,e);return this.parent=i,this.transform=t,this._bounds=n,this._bounds.updateID+=this._boundsID-s,o}toGlobal(e,t,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(e,t)}toLocal(e,t,i,n){return t&&(e=t.toGlobal(e,i,n)),n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(e,i)}setParent(e){if(!e||!e.addChild)throw new Error("setParent: Argument must be a Container");return e.addChild(this),e}removeFromParent(){var e;(e=this.parent)==null||e.removeChild(this)}setTransform(e=0,t=0,i=1,n=1,s=0,o=0,a=0,l=0,h=0){return this.position.x=e,this.position.y=t,this.scale.x=i||1,this.scale.y=n||1,this.rotation=s,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(e){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new PS),this.tempDisplayObjectParent}enableTempParent(){const e=this.parent;return this.parent=this._tempDisplayObjectParent,e}disableTempParent(e){this.parent=e}get x(){return this.position.x}set x(e){this.transform.position.x=e}get y(){return this.position.y}set y(e){this.transform.position.y=e}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*EA}set angle(e){this.transform.rotation=e*TA}get zIndex(){return this._zIndex}set zIndex(e){this._zIndex!==e&&(this._zIndex=e,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let e=this;do{if(!e.visible)return!1;e=e.parent}while(e);return!0}get mask(){return this._mask}set mask(e){if(this._mask!==e){if(this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount--,t._maskRefCount===0&&(t.renderable=!0,t.isMask=!1))}if(this._mask=e,this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount===0&&(t.renderable=!1,t.isMask=!0),t._maskRefCount++)}}}}class PS extends Ct{constructor(){super(...arguments),this.sortDirty=null}}Ct.prototype.displayObjectUpdateTransform=Ct.prototype.updateTransform;const IS=new pt;function MS(r,e){return r.zIndex===e.zIndex?r._lastSortedIndex-e._lastSortedIndex:r.zIndex-e.zIndex}const X0=class wf extends Ct{constructor(){super(),this.children=[],this.sortableChildren=wf.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(e){}addChild(...e){if(e.length>1)for(let t=0;t<e.length;t++)this.addChild(e[t]);else{const t=e[0];t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.push(t),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this)}return e[0]}addChildAt(e,t){if(t<0||t>this.children.length)throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${this.children.length}`);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit("added",this),this.emit("childAdded",e,this,t),e}swapChildren(e,t){if(e===t)return;const i=this.getChildIndex(e),n=this.getChildIndex(t);this.children[i]=t,this.children[n]=e,this.onChildrenChange(i<n?i:n)}getChildIndex(e){const t=this.children.indexOf(e);if(t===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return t}setChildIndex(e,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(e);oo(this.children,i,1),this.children.splice(t,0,e),this.onChildrenChange(t)}getChildAt(e){if(e<0||e>=this.children.length)throw new Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]}removeChild(...e){if(e.length>1)for(let t=0;t<e.length;t++)this.removeChild(e[t]);else{const t=e[0],i=this.children.indexOf(t);if(i===-1)return null;t.parent=null,t.transform._parentID=-1,oo(this.children,i,1),this._boundsID++,this.onChildrenChange(i),t.emit("removed",this),this.emit("childRemoved",t,this,i)}return e[0]}removeChildAt(e){const t=this.getChildAt(e);return t.parent=null,t.transform._parentID=-1,oo(this.children,e,1),this._boundsID++,this.onChildrenChange(e),t.emit("removed",this),this.emit("childRemoved",t,this,e),t}removeChildren(e=0,t=this.children.length){const i=e,n=t,s=n-i;let o;if(s>0&&s<=n){o=this.children.splice(i,s);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(e);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(s===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let e=!1;for(let t=0,i=this.children.length;t<i;++t){const n=this.children[t];n._lastSortedIndex=t,!e&&n.zIndex!==0&&(e=!0)}e&&this.children.length>1&&this.children.sort(MS),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let e=0,t=this.children.length;e<t;++e){const i=this.children[e];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let e=0;e<this.children.length;e++){const t=this.children[e];if(!(!t.visible||!t.renderable))if(t.calculateBounds(),t._mask){const i=t._mask.isMaskData?t._mask.maskObject:t._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(t._bounds,i._bounds)):this._bounds.addBounds(t._bounds)}else t.filterArea?this._bounds.addBoundsArea(t._bounds,t.filterArea):this._bounds.addBounds(t._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(e,t=!1){const i=super.getLocalBounds(e);if(!t)for(let n=0,s=this.children.length;n<s;++n){const o=this.children[n];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(e){const t=e.renderTexture.sourceFrame;if(!(t.width>0&&t.height>0))return;let i,n;this.cullArea?(i=this.cullArea,n=this.worldTransform):this._render!==wf.prototype._render&&(i=this.getBounds(!0));const s=e.projection.transform;if(s&&(n?(n=IS.copyFrom(n),n.prepend(s)):n=s),i&&t.intersects(i,n))this._render(e);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(e),l.cullable=h}}render(e){var t;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(t=this.filters)!=null&&t.length)this.renderAdvanced(e);else if(this.cullable)this._renderWithCulling(e);else{this._render(e);for(let i=0,n=this.children.length;i<n;++i)this.children[i].render(e)}}renderAdvanced(e){var t,i,n;const s=this.filters,o=this._mask;if(s){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<s.length;l++)s[l].enabled&&this._enabledFilters.push(s[l])}const a=s&&((t=this._enabledFilters)==null?void 0:t.length)||o&&(!o.isMaskData||o.enabled&&(o.autoDetect||o.type!==Gt.NONE));if(a&&e.batch.flush(),s&&(i=this._enabledFilters)!=null&&i.length&&e.filter.push(this,this._enabledFilters),o&&e.mask.push(this,this._mask),this.cullable)this._renderWithCulling(e);else{this._render(e);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(e)}a&&e.batch.flush(),o&&e.mask.pop(this),s&&(n=this._enabledFilters)!=null&&n.length&&e.filter.pop()}_render(e){}destroy(e){super.destroy(),this.sortDirty=!1;const t=typeof e=="boolean"?e:e==null?void 0:e.children,i=this.removeChildren(0,this.children.length);if(t)for(let n=0;n<i.length;++n)i[n].destroy(e)}get width(){return this.scale.x*this.getLocalBounds().width}set width(e){const t=this.getLocalBounds().width;t!==0?this.scale.x=e/t:this.scale.x=1,this._width=e}get height(){return this.scale.y*this.getLocalBounds().height}set height(e){const t=this.getLocalBounds().height;t!==0?this.scale.y=e/t:this.scale.y=1,this._height=e}};X0.defaultSortableChildren=!1;let pr=X0;pr.prototype.containerUpdateTransform=pr.prototype.updateTransform,Object.defineProperties(ye,{SORTABLE_CHILDREN:{get(){return pr.defaultSortableChildren},set(r){Je("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),pr.defaultSortableChildren=r}}});const Ea=new nt,DS=new Uint16Array([0,1,2,0,2,3]);class ho extends pr{constructor(e){super(),this._anchor=new en(this._onAnchorUpdate,this,e?e.defaultAnchor.x:0,e?e.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new ut(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Ne.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=e||Te.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=DS,this.pluginName="batch",this.isSprite=!0,this._roundPixels=ye.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Tn(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Tn(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const e=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===e._updateID)return;this._textureID!==e._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=e._updateID;const t=this.transform.worldTransform,i=t.a,n=t.b,s=t.c,o=t.d,a=t.tx,l=t.ty,h=this.vertexData,u=e.trim,c=e.orig,d=this._anchor;let f=0,g=0,p=0,m=0;if(u?(g=u.x-d._x*c.width,f=g+u.width,m=u.y-d._y*c.height,p=m+u.height):(g=-d._x*c.width,f=g+c.width,m=-d._y*c.height,p=m+c.height),h[0]=i*g+s*m+a,h[1]=o*m+n*g+l,h[2]=i*f+s*m+a,h[3]=o*m+n*f+l,h[4]=i*f+s*p+a,h[5]=o*p+n*f+l,h[6]=i*g+s*p+a,h[7]=o*p+n*g+l,this._roundPixels){const v=ye.RESOLUTION;for(let y=0;y<h.length;++y)h[y]=Math.round(h[y]*v)/v}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const e=this._texture,t=this.vertexTrimmedData,i=e.orig,n=this._anchor,s=this.transform.worldTransform,o=s.a,a=s.b,l=s.c,h=s.d,u=s.tx,c=s.ty,d=-n._x*i.width,f=d+i.width,g=-n._y*i.height,p=g+i.height;if(t[0]=o*d+l*g+u,t[1]=h*g+a*d+c,t[2]=o*f+l*g+u,t[3]=h*g+a*f+c,t[4]=o*f+l*p+u,t[5]=h*p+a*f+c,t[6]=o*d+l*p+u,t[7]=h*p+a*d+c,this._roundPixels){const m=ye.RESOLUTION;for(let v=0;v<t.length;++v)t[v]=Math.round(t[v]*m)/m}}_render(e){this.calculateVertices(),e.batch.setObjectRenderer(e.plugins[this.pluginName]),e.plugins[this.pluginName].render(this)}_calculateBounds(){const e=this._texture.trim,t=this._texture.orig;!e||e.width===t.width&&e.height===t.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(e){return this.children.length===0?(this._localBounds||(this._localBounds=new Th),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),e||(this._localBoundsRect||(this._localBoundsRect=new We),e=this._localBoundsRect),this._localBounds.getRectangle(e)):super.getLocalBounds.call(this,e)}containsPoint(e){this.worldTransform.applyInverse(e,Ea);const t=this._texture.orig.width,i=this._texture.orig.height,n=-t*this.anchor.x;let s=0;return Ea.x>=n&&Ea.x<n+t&&(s=-i*this.anchor.y,Ea.y>=s&&Ea.y<s+i)}destroy(e){if(super.destroy(e),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof e=="boolean"?e:e==null?void 0:e.texture){const t=typeof e=="boolean"?e:e==null?void 0:e.baseTexture;this._texture.destroy(!!t)}this._texture=null}static from(e,t){const i=e instanceof Te?e:Te.from(e,t);return new ho(i)}set roundPixels(e){this._roundPixels!==e&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=e}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){const t=Tn(this.scale.x)||1;this.scale.x=t*e/this._texture.orig.width,this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){const t=Tn(this.scale.y)||1;this.scale.y=t*e/this._texture.orig.height,this._height=e}get anchor(){return this._anchor}set anchor(e){this._anchor.copyFrom(e)}get tint(){return this._tintColor.value}set tint(e){this._tintColor.setValue(e),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=e||Te.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,e&&(e.baseTexture.valid?this._onTextureUpdate():e.once("update",this._onTextureUpdate,this)))}}const Y0=new pt;Ct.prototype._cacheAsBitmap=!1,Ct.prototype._cacheData=null,Ct.prototype._cacheAsBitmapResolution=null,Ct.prototype._cacheAsBitmapMultisample=null;class OS{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(Ct.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(r){r!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(r){r!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(r){if(this._cacheAsBitmap===r)return;this._cacheAsBitmap=r;let e;r?(this._cacheData||(this._cacheData=new OS),e=this._cacheData,e.originalRender=this.render,e.originalRenderCanvas=this.renderCanvas,e.originalUpdateTransform=this.updateTransform,e.originalCalculateBounds=this.calculateBounds,e.originalGetLocalBounds=this.getLocalBounds,e.originalDestroy=this.destroy,e.originalContainsPoint=this.containsPoint,e.originalMask=this._mask,e.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(e=this._cacheData,e.sprite&&this._destroyCachedDisplayObject(),this.render=e.originalRender,this.renderCanvas=e.originalRenderCanvas,this.calculateBounds=e.originalCalculateBounds,this.getLocalBounds=e.originalGetLocalBounds,this.destroy=e.originalDestroy,this.updateTransform=e.originalUpdateTransform,this.containsPoint=e.originalContainsPoint,this._mask=e.originalMask,this.filterArea=e.originalFilterArea)}}}),Ct.prototype._renderCached=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(r),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(r))},Ct.prototype._initCachedDisplayObject=function(r){var e,t;if((e=this._cacheData)!=null&&e.sprite)return;const i=this.alpha;this.alpha=1,r.batch.flush();const n=this.getLocalBounds(new We,!0);if((t=this.filters)!=null&&t.length){const g=this.filters[0].padding;n.pad(g)}const s=this.cacheAsBitmapResolution||r.resolution;n.ceil(s),n.width=Math.max(n.width,1/s),n.height=Math.max(n.height,1/s);const o=r.renderTexture.current,a=r.renderTexture.sourceFrame.clone(),l=r.renderTexture.destinationFrame.clone(),h=r.projection.transform,u=ds.create({width:n.width,height:n.height,resolution:s,multisample:this.cacheAsBitmapMultisample??r.multisample}),c=`cacheAsBitmap_${ss()}`;this._cacheData.textureCacheId=c,ze.addToCache(u.baseTexture,c),Te.addToCache(u,c);const d=this.transform.localTransform.copyTo(Y0).invert().translate(-n.x,-n.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:u,clear:!0,transform:d,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=h,r.renderTexture.bind(o,a,l),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=i;const f=new ho(u);f.transform.worldTransform=this.transform.worldTransform,f.anchor.x=-(n.x/n.width),f.anchor.y=-(n.y/n.height),f.alpha=i,f._bounds=this._bounds,this._cacheData.sprite=f,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=f.containsPoint.bind(f)},Ct.prototype._renderCachedCanvas=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(r),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(r))},Ct.prototype._initCachedDisplayObjectCanvas=function(r){var e;if((e=this._cacheData)!=null&&e.sprite)return;const t=this.getLocalBounds(new We,!0),i=this.alpha;this.alpha=1;const n=r.canvasContext.activeContext,s=r._projTransform,o=this.cacheAsBitmapResolution||r.resolution;t.ceil(o),t.width=Math.max(t.width,1/o),t.height=Math.max(t.height,1/o);const a=ds.create({width:t.width,height:t.height,resolution:o}),l=`cacheAsBitmap_${ss()}`;this._cacheData.textureCacheId=l,ze.addToCache(a.baseTexture,l),Te.addToCache(a,l);const h=Y0;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),r.canvasContext.activeContext=n,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=i;const u=new ho(a);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(t.x/t.width),u.anchor.y=-(t.y/t.height),u.alpha=i,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=u.containsPoint.bind(u)},Ct.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Ct.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Ct.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,ze.removeFromCache(this._cacheData.textureCacheId),Te.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Ct.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Ct.prototype.name=null,pr.prototype.getChildByName=function(r,e){for(let t=0,i=this.children.length;t<i;t++)if(this.children[t].name===r)return this.children[t];if(e)for(let t=0,i=this.children.length;t<i;t++){const n=this.children[t];if(!n.getChildByName)continue;const s=n.getChildByName(r,!0);if(s)return s}return null},Ct.prototype.getGlobalPosition=function(r=new nt,e=!1){return this.parent?this.parent.toGlobal(this.position,r,e):(r.x=this.position.x,r.y=this.position.y),r};var LS=`varying vec2 vTextureCoord;
|
|
603
|
+
|
|
604
|
+
uniform sampler2D uSampler;
|
|
605
|
+
uniform float uAlpha;
|
|
606
|
+
|
|
607
|
+
void main(void)
|
|
608
|
+
{
|
|
609
|
+
gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
|
|
610
|
+
}
|
|
611
|
+
`;class NS extends mi{constructor(e=1){super(TS,LS,{uAlpha:1}),this.alpha=e}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}}const FS={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},BS=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
|
|
612
|
+
`);function kS(r){const e=FS[r],t=e.length;let i=BS,n="";const s="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=s.replace("%index%",a.toString());o=a,a>=t&&(o=r-a-1),l=l.replace("%value%",e[o].toString()),n+=l,n+=`
|
|
613
|
+
`}return i=i.replace("%blur%",n),i=i.replace("%size%",r.toString()),i}const US=`
|
|
614
|
+
attribute vec2 aVertexPosition;
|
|
615
|
+
|
|
616
|
+
uniform mat3 projectionMatrix;
|
|
617
|
+
|
|
618
|
+
uniform float strength;
|
|
619
|
+
|
|
620
|
+
varying vec2 vBlurTexCoords[%size%];
|
|
621
|
+
|
|
622
|
+
uniform vec4 inputSize;
|
|
623
|
+
uniform vec4 outputFrame;
|
|
624
|
+
|
|
625
|
+
vec4 filterVertexPosition( void )
|
|
626
|
+
{
|
|
627
|
+
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
|
628
|
+
|
|
629
|
+
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
vec2 filterTextureCoord( void )
|
|
633
|
+
{
|
|
634
|
+
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
void main(void)
|
|
638
|
+
{
|
|
639
|
+
gl_Position = filterVertexPosition();
|
|
640
|
+
|
|
641
|
+
vec2 textureCoord = filterTextureCoord();
|
|
642
|
+
%blur%
|
|
643
|
+
}`;function HS(r,e){const t=Math.ceil(r/2);let i=US,n="",s;e?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=s.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(t-1)}.0`),n+=a,n+=`
|
|
644
|
+
`}return i=i.replace("%blur%",n),i=i.replace("%size%",r.toString()),i}class Fd extends mi{constructor(e,t=8,i=4,n=mi.defaultResolution,s=5){const o=HS(s,e),a=kS(s);super(o,a),this.horizontal=e,this.resolution=n,this._quality=0,this.quality=i,this.blur=t}apply(e,t,i,n){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/t.width):this.uniforms.strength=1/i.height*(i.height/t.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/t.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/t.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,t,i,n);else{const s=e.getFilterTexture(),o=e.renderer;let a=t,l=s;this.state.blend=!1,e.applyFilter(this,a,l,Pr.CLEAR);for(let h=1;h<this.passes-1;h++){e.bindAndClear(a,Pr.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,e.applyFilter(this,l,i,n),e.returnFilterTexture(s)}}get blur(){return this.strength}set blur(e){this.padding=1+Math.abs(e)*2,this.strength=e}get quality(){return this._quality}set quality(e){this._quality=e,this.passes=e}}class GS extends mi{constructor(e=8,t=4,i=mi.defaultResolution,n=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Fd(!0,e,t,i,n),this.blurYFilter=new Fd(!1,e,t,i,n),this.resolution=i,this.quality=t,this.blur=e,this.repeatEdgePixels=!1}apply(e,t,i,n){const s=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(s&&o){const a=e.getFilterTexture();this.blurXFilter.apply(e,t,a,Pr.CLEAR),this.blurYFilter.apply(e,a,i,n),e.returnFilterTexture(a)}else o?this.blurYFilter.apply(e,t,i,n):this.blurXFilter.apply(e,t,i,n)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(e){this.blurXFilter.blur=this.blurYFilter.blur=e,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(e){this.blurXFilter.quality=this.blurYFilter.quality=e}get blurX(){return this.blurXFilter.blur}set blurX(e){this.blurXFilter.blur=e,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(e){this.blurYFilter.blur=e,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(e){this.blurYFilter.blendMode=e}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(e){this._repeatEdgePixels=e,this.updatePadding()}}var VS=`varying vec2 vTextureCoord;
|
|
645
|
+
uniform sampler2D uSampler;
|
|
646
|
+
uniform float m[20];
|
|
647
|
+
uniform float uAlpha;
|
|
648
|
+
|
|
649
|
+
void main(void)
|
|
650
|
+
{
|
|
651
|
+
vec4 c = texture2D(uSampler, vTextureCoord);
|
|
652
|
+
|
|
653
|
+
if (uAlpha == 0.0) {
|
|
654
|
+
gl_FragColor = c;
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
|
659
|
+
if (c.a > 0.0) {
|
|
660
|
+
c.rgb /= c.a;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
vec4 result;
|
|
664
|
+
|
|
665
|
+
result.r = (m[0] * c.r);
|
|
666
|
+
result.r += (m[1] * c.g);
|
|
667
|
+
result.r += (m[2] * c.b);
|
|
668
|
+
result.r += (m[3] * c.a);
|
|
669
|
+
result.r += m[4];
|
|
670
|
+
|
|
671
|
+
result.g = (m[5] * c.r);
|
|
672
|
+
result.g += (m[6] * c.g);
|
|
673
|
+
result.g += (m[7] * c.b);
|
|
674
|
+
result.g += (m[8] * c.a);
|
|
675
|
+
result.g += m[9];
|
|
676
|
+
|
|
677
|
+
result.b = (m[10] * c.r);
|
|
678
|
+
result.b += (m[11] * c.g);
|
|
679
|
+
result.b += (m[12] * c.b);
|
|
680
|
+
result.b += (m[13] * c.a);
|
|
681
|
+
result.b += m[14];
|
|
682
|
+
|
|
683
|
+
result.a = (m[15] * c.r);
|
|
684
|
+
result.a += (m[16] * c.g);
|
|
685
|
+
result.a += (m[17] * c.b);
|
|
686
|
+
result.a += (m[18] * c.a);
|
|
687
|
+
result.a += m[19];
|
|
688
|
+
|
|
689
|
+
vec3 rgb = mix(c.rgb, result.rgb, uAlpha);
|
|
690
|
+
|
|
691
|
+
// Premultiply alpha again.
|
|
692
|
+
rgb *= result.a;
|
|
693
|
+
|
|
694
|
+
gl_FragColor = vec4(rgb, result.a);
|
|
695
|
+
}
|
|
696
|
+
`;class Bd extends mi{constructor(){const e={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(U0,VS,e),this.alpha=1}_loadMatrix(e,t=!1){let i=e;t&&(this._multiply(i,this.uniforms.m,e),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(e,t,i){return e[0]=t[0]*i[0]+t[1]*i[5]+t[2]*i[10]+t[3]*i[15],e[1]=t[0]*i[1]+t[1]*i[6]+t[2]*i[11]+t[3]*i[16],e[2]=t[0]*i[2]+t[1]*i[7]+t[2]*i[12]+t[3]*i[17],e[3]=t[0]*i[3]+t[1]*i[8]+t[2]*i[13]+t[3]*i[18],e[4]=t[0]*i[4]+t[1]*i[9]+t[2]*i[14]+t[3]*i[19]+t[4],e[5]=t[5]*i[0]+t[6]*i[5]+t[7]*i[10]+t[8]*i[15],e[6]=t[5]*i[1]+t[6]*i[6]+t[7]*i[11]+t[8]*i[16],e[7]=t[5]*i[2]+t[6]*i[7]+t[7]*i[12]+t[8]*i[17],e[8]=t[5]*i[3]+t[6]*i[8]+t[7]*i[13]+t[8]*i[18],e[9]=t[5]*i[4]+t[6]*i[9]+t[7]*i[14]+t[8]*i[19]+t[9],e[10]=t[10]*i[0]+t[11]*i[5]+t[12]*i[10]+t[13]*i[15],e[11]=t[10]*i[1]+t[11]*i[6]+t[12]*i[11]+t[13]*i[16],e[12]=t[10]*i[2]+t[11]*i[7]+t[12]*i[12]+t[13]*i[17],e[13]=t[10]*i[3]+t[11]*i[8]+t[12]*i[13]+t[13]*i[18],e[14]=t[10]*i[4]+t[11]*i[9]+t[12]*i[14]+t[13]*i[19]+t[14],e[15]=t[15]*i[0]+t[16]*i[5]+t[17]*i[10]+t[18]*i[15],e[16]=t[15]*i[1]+t[16]*i[6]+t[17]*i[11]+t[18]*i[16],e[17]=t[15]*i[2]+t[16]*i[7]+t[17]*i[12]+t[18]*i[17],e[18]=t[15]*i[3]+t[16]*i[8]+t[17]*i[13]+t[18]*i[18],e[19]=t[15]*i[4]+t[16]*i[9]+t[17]*i[14]+t[18]*i[19]+t[19],e}_colorMatrix(e){const t=new Float32Array(e);return t[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,t}brightness(e,t){const i=[e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0];this._loadMatrix(i,t)}tint(e,t){const[i,n,s]=ut.shared.setValue(e).toArray(),o=[i,0,0,0,0,0,n,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(o,t)}greyscale(e,t){const i=[e,e,e,0,0,e,e,e,0,0,e,e,e,0,0,0,0,0,1,0];this._loadMatrix(i,t)}blackAndWhite(e){const t=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(t,e)}hue(e,t){e=(e||0)/180*Math.PI;const i=Math.cos(e),n=Math.sin(e),s=Math.sqrt,o=1/3,a=s(o),l=i+(1-i)*o,h=o*(1-i)-a*n,u=o*(1-i)+a*n,c=o*(1-i)+a*n,d=i+o*(1-i),f=o*(1-i)-a*n,g=o*(1-i)-a*n,p=o*(1-i)+a*n,m=i+o*(1-i),v=[l,h,u,0,0,c,d,f,0,0,g,p,m,0,0,0,0,0,1,0];this._loadMatrix(v,t)}contrast(e,t){const i=(e||0)+1,n=-.5*(i-1),s=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(s,t)}saturate(e=0,t){const i=e*2/3+1,n=(i-1)*-.5,s=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(s,t)}desaturate(){this.saturate(-1)}negative(e){const t=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(t,e)}sepia(e){const t=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(t,e)}technicolor(e){const t=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(t,e)}polaroid(e){const t=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(t,e)}toBGR(e){const t=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(t,e)}kodachrome(e){const t=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(t,e)}browni(e){const t=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(t,e)}vintage(e){const t=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(t,e)}colorTone(e,t,i,n,s){e=e||.2,t=t||.15,i=i||16770432,n=n||3375104;const o=ut.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(n).toArray(),f=[.3,.59,.11,0,0,a,l,h,e,0,u,c,d,t,0,a-u,l-c,h-d,0,0];this._loadMatrix(f,s)}night(e,t){e=e||.1;const i=[e*-2,-e,0,0,0,-e,0,e,0,0,0,e,e*2,0,0,0,0,0,1,0];this._loadMatrix(i,t)}predator(e,t){const i=[11.224130630493164*e,-4.794486999511719*e,-2.8746118545532227*e,0*e,.40342438220977783*e,-3.6330697536468506*e,9.193157196044922*e,-2.951810836791992*e,0*e,-1.316135048866272*e,-3.2184197902679443*e,-4.2375030517578125*e,7.476448059082031*e,0*e,.8044459223747253*e,0,0,0,1,0];this._loadMatrix(i,t)}lsd(e){const t=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(t,e)}reset(){const e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(e,!1)}get matrix(){return this.uniforms.m}set matrix(e){this.uniforms.m=e}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}}Bd.prototype.grayscale=Bd.prototype.greyscale;var zS=`varying vec2 vFilterCoord;
|
|
697
|
+
varying vec2 vTextureCoord;
|
|
698
|
+
|
|
699
|
+
uniform vec2 scale;
|
|
700
|
+
uniform mat2 rotation;
|
|
701
|
+
uniform sampler2D uSampler;
|
|
702
|
+
uniform sampler2D mapSampler;
|
|
703
|
+
|
|
704
|
+
uniform highp vec4 inputSize;
|
|
705
|
+
uniform vec4 inputClamp;
|
|
706
|
+
|
|
707
|
+
void main(void)
|
|
708
|
+
{
|
|
709
|
+
vec4 map = texture2D(mapSampler, vFilterCoord);
|
|
710
|
+
|
|
711
|
+
map -= 0.5;
|
|
712
|
+
map.xy = scale * inputSize.zw * (rotation * map.xy);
|
|
713
|
+
|
|
714
|
+
gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
|
|
715
|
+
}
|
|
716
|
+
`,jS=`attribute vec2 aVertexPosition;
|
|
717
|
+
|
|
718
|
+
uniform mat3 projectionMatrix;
|
|
719
|
+
uniform mat3 filterMatrix;
|
|
720
|
+
|
|
721
|
+
varying vec2 vTextureCoord;
|
|
722
|
+
varying vec2 vFilterCoord;
|
|
723
|
+
|
|
724
|
+
uniform vec4 inputSize;
|
|
725
|
+
uniform vec4 outputFrame;
|
|
726
|
+
|
|
727
|
+
vec4 filterVertexPosition( void )
|
|
728
|
+
{
|
|
729
|
+
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
|
730
|
+
|
|
731
|
+
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
vec2 filterTextureCoord( void )
|
|
735
|
+
{
|
|
736
|
+
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
void main(void)
|
|
740
|
+
{
|
|
741
|
+
gl_Position = filterVertexPosition();
|
|
742
|
+
vTextureCoord = filterTextureCoord();
|
|
743
|
+
vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
|
|
744
|
+
}
|
|
745
|
+
`;class WS extends mi{constructor(e,t){const i=new pt;e.renderable=!1,super(jS,zS,{mapSampler:e._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=e,this.maskMatrix=i,t==null&&(t=20),this.scale=new nt(t,t)}apply(e,t,i,n){this.uniforms.filterMatrix=e.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const s=this.maskSprite.worldTransform,o=Math.sqrt(s.a*s.a+s.b*s.b),a=Math.sqrt(s.c*s.c+s.d*s.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=s.a/o,this.uniforms.rotation[1]=s.b/o,this.uniforms.rotation[2]=s.c/a,this.uniforms.rotation[3]=s.d/a),e.applyFilter(this,t,i,n)}get map(){return this.uniforms.mapSampler}set map(e){this.uniforms.mapSampler=e}}var XS=`varying vec2 v_rgbNW;
|
|
746
|
+
varying vec2 v_rgbNE;
|
|
747
|
+
varying vec2 v_rgbSW;
|
|
748
|
+
varying vec2 v_rgbSE;
|
|
749
|
+
varying vec2 v_rgbM;
|
|
750
|
+
|
|
751
|
+
varying vec2 vFragCoord;
|
|
752
|
+
uniform sampler2D uSampler;
|
|
753
|
+
uniform highp vec4 inputSize;
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
Basic FXAA implementation based on the code on geeks3d.com with the
|
|
758
|
+
modification that the texture2DLod stuff was removed since it's
|
|
759
|
+
unsupported by WebGL.
|
|
760
|
+
|
|
761
|
+
--
|
|
762
|
+
|
|
763
|
+
From:
|
|
764
|
+
https://github.com/mitsuhiko/webgl-meincraft
|
|
765
|
+
|
|
766
|
+
Copyright (c) 2011 by Armin Ronacher.
|
|
767
|
+
|
|
768
|
+
Some rights reserved.
|
|
769
|
+
|
|
770
|
+
Redistribution and use in source and binary forms, with or without
|
|
771
|
+
modification, are permitted provided that the following conditions are
|
|
772
|
+
met:
|
|
773
|
+
|
|
774
|
+
* Redistributions of source code must retain the above copyright
|
|
775
|
+
notice, this list of conditions and the following disclaimer.
|
|
776
|
+
|
|
777
|
+
* Redistributions in binary form must reproduce the above
|
|
778
|
+
copyright notice, this list of conditions and the following
|
|
779
|
+
disclaimer in the documentation and/or other materials provided
|
|
780
|
+
with the distribution.
|
|
781
|
+
|
|
782
|
+
* The names of the contributors may not be used to endorse or
|
|
783
|
+
promote products derived from this software without specific
|
|
784
|
+
prior written permission.
|
|
785
|
+
|
|
786
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
787
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
788
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
789
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
790
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
791
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
792
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
793
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
794
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
795
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
796
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
797
|
+
*/
|
|
798
|
+
|
|
799
|
+
#ifndef FXAA_REDUCE_MIN
|
|
800
|
+
#define FXAA_REDUCE_MIN (1.0/ 128.0)
|
|
801
|
+
#endif
|
|
802
|
+
#ifndef FXAA_REDUCE_MUL
|
|
803
|
+
#define FXAA_REDUCE_MUL (1.0 / 8.0)
|
|
804
|
+
#endif
|
|
805
|
+
#ifndef FXAA_SPAN_MAX
|
|
806
|
+
#define FXAA_SPAN_MAX 8.0
|
|
807
|
+
#endif
|
|
808
|
+
|
|
809
|
+
//optimized version for mobile, where dependent
|
|
810
|
+
//texture reads can be a bottleneck
|
|
811
|
+
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,
|
|
812
|
+
vec2 v_rgbNW, vec2 v_rgbNE,
|
|
813
|
+
vec2 v_rgbSW, vec2 v_rgbSE,
|
|
814
|
+
vec2 v_rgbM) {
|
|
815
|
+
vec4 color;
|
|
816
|
+
vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
|
|
817
|
+
vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
|
|
818
|
+
vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
|
|
819
|
+
vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
|
|
820
|
+
vec4 texColor = texture2D(tex, v_rgbM);
|
|
821
|
+
vec3 rgbM = texColor.xyz;
|
|
822
|
+
vec3 luma = vec3(0.299, 0.587, 0.114);
|
|
823
|
+
float lumaNW = dot(rgbNW, luma);
|
|
824
|
+
float lumaNE = dot(rgbNE, luma);
|
|
825
|
+
float lumaSW = dot(rgbSW, luma);
|
|
826
|
+
float lumaSE = dot(rgbSE, luma);
|
|
827
|
+
float lumaM = dot(rgbM, luma);
|
|
828
|
+
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
|
829
|
+
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
|
830
|
+
|
|
831
|
+
mediump vec2 dir;
|
|
832
|
+
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
|
833
|
+
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
|
834
|
+
|
|
835
|
+
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
|
|
836
|
+
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
|
837
|
+
|
|
838
|
+
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
|
839
|
+
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
|
840
|
+
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
|
|
841
|
+
dir * rcpDirMin)) * inverseVP;
|
|
842
|
+
|
|
843
|
+
vec3 rgbA = 0.5 * (
|
|
844
|
+
texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
|
|
845
|
+
texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
|
|
846
|
+
vec3 rgbB = rgbA * 0.5 + 0.25 * (
|
|
847
|
+
texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
|
|
848
|
+
texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
|
|
849
|
+
|
|
850
|
+
float lumaB = dot(rgbB, luma);
|
|
851
|
+
if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
|
852
|
+
color = vec4(rgbA, texColor.a);
|
|
853
|
+
else
|
|
854
|
+
color = vec4(rgbB, texColor.a);
|
|
855
|
+
return color;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
void main() {
|
|
859
|
+
|
|
860
|
+
vec4 color;
|
|
861
|
+
|
|
862
|
+
color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
|
|
863
|
+
|
|
864
|
+
gl_FragColor = color;
|
|
865
|
+
}
|
|
866
|
+
`,YS=`
|
|
867
|
+
attribute vec2 aVertexPosition;
|
|
868
|
+
|
|
869
|
+
uniform mat3 projectionMatrix;
|
|
870
|
+
|
|
871
|
+
varying vec2 v_rgbNW;
|
|
872
|
+
varying vec2 v_rgbNE;
|
|
873
|
+
varying vec2 v_rgbSW;
|
|
874
|
+
varying vec2 v_rgbSE;
|
|
875
|
+
varying vec2 v_rgbM;
|
|
876
|
+
|
|
877
|
+
varying vec2 vFragCoord;
|
|
878
|
+
|
|
879
|
+
uniform vec4 inputSize;
|
|
880
|
+
uniform vec4 outputFrame;
|
|
881
|
+
|
|
882
|
+
vec4 filterVertexPosition( void )
|
|
883
|
+
{
|
|
884
|
+
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
|
885
|
+
|
|
886
|
+
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
void texcoords(vec2 fragCoord, vec2 inverseVP,
|
|
890
|
+
out vec2 v_rgbNW, out vec2 v_rgbNE,
|
|
891
|
+
out vec2 v_rgbSW, out vec2 v_rgbSE,
|
|
892
|
+
out vec2 v_rgbM) {
|
|
893
|
+
v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
|
|
894
|
+
v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
|
|
895
|
+
v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
|
|
896
|
+
v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
|
|
897
|
+
v_rgbM = vec2(fragCoord * inverseVP);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
void main(void) {
|
|
901
|
+
|
|
902
|
+
gl_Position = filterVertexPosition();
|
|
903
|
+
|
|
904
|
+
vFragCoord = aVertexPosition * outputFrame.zw;
|
|
905
|
+
|
|
906
|
+
texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
|
|
907
|
+
}
|
|
908
|
+
`;class ZS extends mi{constructor(){super(YS,XS)}}var qS=`precision highp float;
|
|
909
|
+
|
|
910
|
+
varying vec2 vTextureCoord;
|
|
911
|
+
varying vec4 vColor;
|
|
912
|
+
|
|
913
|
+
uniform float uNoise;
|
|
914
|
+
uniform float uSeed;
|
|
915
|
+
uniform sampler2D uSampler;
|
|
916
|
+
|
|
917
|
+
float rand(vec2 co)
|
|
918
|
+
{
|
|
919
|
+
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
void main()
|
|
923
|
+
{
|
|
924
|
+
vec4 color = texture2D(uSampler, vTextureCoord);
|
|
925
|
+
float randomValue = rand(gl_FragCoord.xy * uSeed);
|
|
926
|
+
float diff = (randomValue - 0.5) * uNoise;
|
|
927
|
+
|
|
928
|
+
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
|
929
|
+
if (color.a > 0.0) {
|
|
930
|
+
color.rgb /= color.a;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
color.r += diff;
|
|
934
|
+
color.g += diff;
|
|
935
|
+
color.b += diff;
|
|
936
|
+
|
|
937
|
+
// Premultiply alpha again.
|
|
938
|
+
color.rgb *= color.a;
|
|
939
|
+
|
|
940
|
+
gl_FragColor = color;
|
|
941
|
+
}
|
|
942
|
+
`;class KS extends mi{constructor(e=.5,t=Math.random()){super(U0,qS,{uNoise:0,uSeed:0}),this.noise=e,this.seed=t}get noise(){return this.uniforms.uNoise}set noise(e){this.uniforms.uNoise=e}get seed(){return this.uniforms.uSeed}set seed(e){this.uniforms.uSeed=e}}const Z0={AlphaFilter:NS,BlurFilter:GS,BlurFilterPass:Fd,ColorMatrixFilter:Bd,DisplacementFilter:WS,FXAAFilter:ZS,NoiseFilter:KS};Object.entries(Z0).forEach(([r,e])=>{Object.defineProperty(Z0,r,{get(){return Je("7.1.0",`filters.${r} has moved to ${r}`),e}})});class QS{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this.tickerAdded||!this.domElement||(Li.system.add(this.tickerUpdate,this,gs.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Li.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events.rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY}))}tickerUpdate(e){this._deltaTime+=e,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Sn=new QS;class Ta{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ta.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new nt,this.page=new nt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,n,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class bh extends Ta{constructor(){super(...arguments),this.client=new nt,this.movement=new nt,this.offset=new nt,this.global=new nt,this.screen=new nt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,i){return e.worldTransform.applyInverse(i||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,i,n,s,o,a,l,h,u,c,d,f,g,p){throw new Error("Method not implemented.")}}class gr extends bh{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class uo extends bh{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}uo.DOM_DELTA_PIXEL=0,uo.DOM_DELTA_LINE=1,uo.DOM_DELTA_PAGE=2;const JS=2048,$S=new nt,kd=new nt;class eR{constructor(e){this.dispatch=new oa,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((i,n)=>i.priority-n.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,n=t.length;i<n;i++)t[i].fn(e);else console.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Sn.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,$S.set(e,t),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(e,t){if(!e.target)return;const i=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let n=0,s=i.length-1;n<s;n++)if(e.currentTarget=i[n],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let n=i.length-2;n>=0;n--)if(e.currentTarget=i[n],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const n=Array.isArray(t)?t:[t];for(let s=i.length-1;s>=0;s--)n.forEach(o=>{e.currentTarget=i[s],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let i=0;i<JS&&e!==this.rootTarget;i++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,i,n,s,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Sn.pauseUpdate=!1),e.interactiveChildren&&e.children){const u=e.children;for(let c=u.length-1;c>=0;c--){const d=u[c],f=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,i,n,s,o||s(e,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const g=e.isInteractive();(f.length>0||g)&&(g&&this._allInteractiveElements.push(e),f.push(e)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(t),h=e.isInteractive();return l&&h&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:l&&!s(e,i)&&n(e,i)?h?[e]:[]:null}hitTestRecursive(e,t,i,n,s){if(this._interactivePrune(e)||s(e,i))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Sn.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,i,n,s);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=e.isInteractive();return(c.length>0||d)&&c.push(e),c}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&n(e,i)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!!(!e||e.isMask||!e.visible||!e.renderable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren||e.isMask)}hitPruneFn(e,t){var i;if(e.hitArea&&(e.worldTransform.applyInverse(t,kd),!e.hitArea.contains(kd.x,kd.y)))return!0;if(e._mask){const n=e._mask.isMaskData?e._mask.maskObject:e._mask;if(n&&!((i=n.containsPoint)!=null&&i.call(n,t)))return!0}return!1}hitTestFn(e,t){return e.eventMode==="passive"?!1:e.hitArea?!0:e.containsPoint?e.containsPoint(t):!1}notifyTarget(e,t){var i,n;t=t??e.type;const s=`on${t}`;(n=(i=e.currentTarget)[s])==null||n.call(i,e);const o=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this.notifyListeners(e,o),e.eventPhase===e.AT_TARGET&&this.notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof gr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const n=t.button===2;this.dispatchEvent(t,n?"rightdown":"mousedown")}const i=this.trackingData(e.pointerId);i.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){var t,i;if(!(e instanceof gr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const n=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const s=n.pointerType==="mouse"||n.pointerType==="pen",o=this.trackingData(e.pointerId),a=this.findMountedTarget(o.overTargets);if(((t=o.overTargets)==null?void 0:t.length)>0&&a!==n.target){const u=e.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(e,u,a);if(this.dispatchEvent(c,"pointerout"),s&&this.dispatchEvent(c,"mouseout"),!n.composedPath().includes(a)){const d=this.createPointerEvent(e,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!n.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(a!==n.target){const u=e.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(n,u);this.dispatchEvent(c,"pointerover"),s&&this.dispatchEvent(c,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==n.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(n,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),s&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(c)}const l=[],h=this.enableGlobalMoveEvents??!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(n,"pointermove"),h&&l.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),h&&l.push("globaltouchmove")),s&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),h&&l.push("globalmousemove"),this.cursor=(i=n.target)==null?void 0:i.cursor),l.length>0&&this.all(n,l),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(e){var t;if(!(e instanceof gr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const i=this.trackingData(e.pointerId),n=this.createPointerEvent(e),s=n.pointerType==="mouse"||n.pointerType==="pen";this.dispatchEvent(n,"pointerover"),s&&this.dispatchEvent(n,"mouseover"),n.pointerType==="mouse"&&(this.cursor=(t=n.target)==null?void 0:t.cursor);const o=this.clonePointerEvent(n,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;i.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(o)}mapPointerOut(e){if(!(e instanceof gr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",n=this.findMountedTarget(t.overTargets),s=this.createPointerEvent(e,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(e,"pointerleave",n);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof gr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),i=this.createPointerEvent(e);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const n=this.trackingData(e.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[e.button]);let o=s;if(s&&!i.composedPath().includes(s)){let a=s;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete n.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,n.clicksByButton[e.button]||(n.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const l=n.clicksByButton[e.button];if(l.target===a.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=t,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(e){if(!(e instanceof gr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),n=this.createPointerEvent(e);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(n)}mapWheel(e){if(!(e instanceof uo)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i<e.length&&e[i].parent===t;i++)t=e[i];return t}createPointerEvent(e,t,i){const n=this.allocateEvent(gr);return this.copyPointerData(e,n),this.copyMouseData(e,n),this.copyData(e,n),n.nativeEvent=e.nativeEvent,n.originalEvent=e,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],typeof t=="string"&&(n.type=t),n}createWheelEvent(e){const t=this.allocateEvent(uo);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const i=this.allocateEvent(gr);return i.nativeEvent=e.nativeEvent,i.originalEvent=e.originalEvent,this.copyPointerData(e,i),this.copyMouseData(e,i),this.copyData(e,i),i.target=e.target,i.path=e.composedPath().slice(),i.type=t??i.type,i}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof gr&&t instanceof gr&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist)}copyMouseData(e,t){e instanceof bh&&t instanceof bh&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}notifyListeners(e,t){const i=e.currentTarget._events[t];if(i&&e.currentTarget.isInteractive())if("fn"in i)i.once&&e.currentTarget.removeListener(t,i.fn,void 0,!0),i.fn.call(i.context,e);else for(let n=0,s=i.length;n<s&&!e.propagationImmediatelyStopped;n++)i[n].once&&e.currentTarget.removeListener(t,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,e)}}const tR=1,iR={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ud=class Ef{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new eR(null),Sn.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new gr(null),this.rootWheelEvent=new uo(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ef.defaultEventFeatures},{set:(t,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),t[i]=n,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{view:t,resolution:i}=this.renderer;this.setTargetElement(t),this.resolution=i,Ef._defaultEventMode=e.eventMode??"auto",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(e){e=e||"default";let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this.currentCursor===e)return;this.currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this.rootPointerEvent}onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let i=0,n=t.length;i<n;i++){const s=t[i],o=this.bootstrapEvent(this.rootPointerEvent,s);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Sn.pointerMoved();const t=this.normalizeToPointerData(e);for(let i=0,n=t.length;i<n;i++){const s=this.bootstrapEvent(this.rootPointerEvent,t[i]);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",n=this.normalizeToPointerData(e);for(let s=0,o=n.length;s<o;s++){const a=this.bootstrapEvent(this.rootPointerEvent,n[s]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);for(let i=0,n=t.length;i<n;i++){const s=this.bootstrapEvent(this.rootPointerEvent,t[i]);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this.removeEvents(),this.domElement=e,Sn.domElement=e,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Sn.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;Sn.removeTickerListener();const e=this.domElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(e,t,i){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;e.x=(t-n.left)*(this.domElement.width/n.width)*s,e.y=(i-n.top)*(this.domElement.height/n.height)*s}normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let i=0,n=e.changedTouches.length;i<n;i++){const s=e.changedTouches[i];typeof s.button>"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=e.type,t.push(s)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=tR),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}else t.push(e);return t}normalizeWheelEvent(e){const t=this.rootWheelEvent;return this.transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this.transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=iR[e.type]||e.type),e}transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};Ud.extension={name:"events",type:[ge.RendererSystem,ge.CanvasRendererSystem]},Ud.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Hd=Ud;Ee.add(Hd);function q0(r){return r==="dynamic"||r==="static"}const rR={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??q0(Hd.defaultEventMode)},set interactive(r){Je("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Hd.defaultEventMode},set eventMode(r){this._internalInteractive=q0(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,n=typeof t=="object"?t.signal:void 0,s=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;r=i?`${r}capture`:r;const a=typeof e=="function"?e:e.handleEvent,l=this;n&&n.addEventListener("abort",()=>{l.off(r,a,o)}),s?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,n=typeof e=="function"?void 0:e;r=i?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.off(r,e,n)},dispatchEvent(r){if(!(r instanceof Ta))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};Ct.mixin(rR);const nR={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Ct.mixin(nR);const sR=9,Ah=100,oR=0,aR=0,K0=2,Q0=1,lR=-1e3,hR=-1e3,uR=2;class J0{constructor(e){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(Qr.tablet||Qr.phone)&&this.createTouchHook();const t=document.createElement("div");t.style.width=`${Ah}px`,t.style.height=`${Ah}px`,t.style.position="absolute",t.style.top=`${oR}px`,t.style.left=`${aR}px`,t.style.zIndex=K0.toString(),this.div=t,this.renderer=e,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const e=document.createElement("button");e.style.width=`${Q0}px`,e.style.height=`${Q0}px`,e.style.position="absolute",e.style.top=`${lR}px`,e.style.left=`${hR}px`,e.style.zIndex=uR.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var e;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(e=this.renderer.view.parentNode)==null||e.appendChild(this.div))}deactivate(){var e;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(e=this.div.parentNode)==null||e.removeChild(this.div))}updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this.addChild(e),e.renderId=this.renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this.updateAccessibleObjects(t[i])}update(){const e=performance.now();if(Qr.android.device&&e<this.androidUpdateCount||(this.androidUpdateCount=e+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:t,y:i,width:n,height:s}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=n/o*l,u=s/a*l;let c=this.div;c.style.left=`${t}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,oo(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{c=f._accessibleDiv;let g=f.hitArea;const p=f.worldTransform;f.hitArea?(c.style.left=`${(p.tx+g.x*p.a)*h}px`,c.style.top=`${(p.ty+g.y*p.d)*u}px`,c.style.width=`${g.width*p.a*h}px`,c.style.height=`${g.height*p.d*u}px`):(g=f.getBounds(),this.capHitArea(g),c.style.left=`${g.x*h}px`,c.style.top=`${g.y*u}px`,c.style.width=`${g.width*h}px`,c.style.height=`${g.height*u}px`,c.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(c.title=f.accessibleTitle),c.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&c.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==c.title||f.tabIndex!==c.tabIndex)&&(c.title=f.accessibleTitle,c.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this.renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}addChild(e){let t=this.pool.pop();t||(t=document.createElement("button"),t.style.width=`${Ah}px`,t.style.height=`${Ah}px`,t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=K0.toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`displayObject ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute("aria-label",e.accessibleHint),this.debug&&this.updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.displayObject=e,this.children.push(e),this.div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){const{displayObject:i}=e.target,n=this.renderer.events.rootBoundary,s=Object.assign(new Ta(n),{target:i});n.rootTarget=this.renderer.lastObjectRendered,t.forEach(o=>n.dispatchEvent(s,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode===sR&&this.activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}J0.extension={name:"accessibility",type:[ge.RendererPlugin,ge.CanvasRendererPlugin]},Ee.add(J0);const $0=class Tf{constructor(e){this.stage=new pr,e=Object.assign({forceCanvas:!1},e),this.renderer=k0(e),Tf._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render(this.stage)}get view(){var e;return(e=this.renderer)==null?void 0:e.view}get screen(){var e;return(e=this.renderer)==null?void 0:e.screen}destroy(e,t){const i=Tf._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};$0._plugins=[];let cR=$0;Ee.handleByList(ge.Application,cR._plugins);class ey{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let t,i;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:s}=this._resizeTo;t=n,i=s}this.renderer.resize(t,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}ey.extension=ge.Application,Ee.add(ey);const ty={loader:ge.LoadParser,resolver:ge.ResolveParser,cache:ge.CacheParser,detection:ge.DetectionParser};Ee.handle(ge.Asset,r=>{const e=r.ref;Object.entries(ty).filter(([t])=>!!e[t]).forEach(([t,i])=>Ee.add(Object.assign(e[t],{extension:e[t].extension??i})))},r=>{const e=r.ref;Object.keys(ty).filter(t=>!!e[t]).forEach(t=>Ee.remove(e[t]))});class dR{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<t;i++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}function co(r,e){if(Array.isArray(e)){for(const t of e)if(r.startsWith(`data:${t}`))return!0;return!1}return r.startsWith(`data:${e}`)}function Rn(r,e){const t=r.split("?")[0],i=Zt.extname(t).toLowerCase();return Array.isArray(e)?e.includes(i):i===e}const mr=(r,e,t=!1)=>(Array.isArray(r)||(r=[r]),e?r.map(i=>typeof i=="string"||t?e(i):i):r),Gd=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r};function iy(r,e,t,i,n){const s=e[t];for(let o=0;o<s.length;o++){const a=s[o];t<e.length-1?iy(r.replace(i[t],a),e,t+1,i,n):n.push(r.replace(i[t],a))}}function fR(r){const e=/\{(.*?)\}/g,t=r.match(e),i=[];if(t){const n=[];t.forEach(s=>{const o=s.substring(1,s.length-1).split(",");n.push(o)}),iy(r,n,0,t,i)}else i.push(r);return i}const Sh=r=>!Array.isArray(r);class pR{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||console.warn(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=mr(e);let n;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(t)){n=l.getCacheableAssets(i,t);break}}n||(n={},i.forEach(a=>{n[a]=t}));const s=Object.keys(n),o={cacheKeys:s,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),s.forEach(a=>{const l=n?n[a]:t;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,n[a])}),t instanceof Te){const a=t;i.forEach(l=>{a.baseTexture!==Te.EMPTY.baseTexture&&ze.addToCache(a.baseTexture,l),Te.addToCache(a,l)})}}remove(e){if(!this._cacheMap.has(e)){console.warn(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(i=>{this._cache.delete(i)}),t.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const ms=new pR;class gR{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{var n,s;let o=null,a=null;if(t.loadParser&&(a=this._parserHash[t.loadParser],a||console.warn(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)),!a){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&(n=h.test)!=null&&n.call(h,e,t,this)){a=h;break}}if(!a)return console.warn(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}o=await a.load(e,t,this),i.parser=a;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((s=h.testParse)==null?void 0:s.call(h,o,t,this))&&(o=await h.parse(o,t,this)||o,i.parser=h)}return o})(),i}async load(e,t){this._parsersValidated||this._validateParsers();let i=0;const n={},s=Sh(e),o=mr(e,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=Zt.toAbsolute(h.src);if(!n[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),n[h.src]=await this.promiseCache[u].promise,t&&t(++i/a)}catch(c){throw delete this.promiseCache[u],delete n[h.src],new Error(`[Loader.load] Failed to load ${u}.
|
|
943
|
+
${c}`)}});return await Promise.all(l),s?n[o[0].src]:n}async unload(e){const t=mr(e,i=>({alias:[i],src:i})).map(async i=>{var n,s;const o=Zt.toAbsolute(i.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],(s=(n=a.parser)==null?void 0:n.unload)==null||s.call(n,l,i,this)}});await Promise.all(t)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name).reduce((e,t)=>(e[t.name]&&console.warn(`[Assets] loadParser name conflict "${t.name}"`),{...e,[t.name]:t}),{})}}var vr=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(vr||{});const mR=".json",vR="application/json",yR={extension:{type:ge.LoadParser,priority:vr.Low},name:"loadJson",test(r){return co(r,vR)||Rn(r,mR)},async load(r){return await(await ye.ADAPTER.fetch(r)).json()}};Ee.add(yR);const _R=".txt",xR="text/plain",wR={name:"loadTxt",extension:{type:ge.LoadParser,priority:vr.Low},test(r){return co(r,xR)||Rn(r,_R)},async load(r){return await(await ye.ADAPTER.fetch(r)).text()}};Ee.add(wR);const ER=["normal","bold","100","200","300","400","500","600","700","800","900"],TR=[".ttf",".otf",".woff",".woff2"],bR=["font/ttf","font/otf","font/woff","font/woff2"],AR=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function SR(r){const e=Zt.extname(r),t=Zt.basename(r,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=t.length>0;for(const s of t)if(!s.match(AR)){i=!1;break}let n=t.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const RR=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function CR(r){return RR.test(r)?r:encodeURI(r)}const PR={extension:{type:ge.LoadParser,priority:vr.Low},name:"loadWebFont",test(r){return co(r,bR)||Rn(r,TR)},async load(r,e){var t,i,n;const s=ye.ADAPTER.getFontFaceSet();if(s){const o=[],a=((t=e.data)==null?void 0:t.family)??SR(r),l=((n=(i=e.data)==null?void 0:i.weights)==null?void 0:n.filter(u=>ER.includes(u)))??["normal"],h=e.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${CR(r)})`,{...h,weight:c});await d.load(),s.add(d),o.push(d)}return o.length===1?o[0]:o}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(e=>ye.ADAPTER.getFontFaceSet().delete(e))}};Ee.add(PR);const IR=`(function() {
|
|
944
|
+
"use strict";
|
|
945
|
+
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
|
|
946
|
+
async function checkImageBitmap() {
|
|
947
|
+
try {
|
|
948
|
+
if (typeof createImageBitmap != "function")
|
|
949
|
+
return !1;
|
|
950
|
+
const imageBlob = await (await fetch(WHITE_PNG)).blob(), imageBitmap = await createImageBitmap(imageBlob);
|
|
951
|
+
return imageBitmap.width === 1 && imageBitmap.height === 1;
|
|
952
|
+
} catch {
|
|
953
|
+
return !1;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
checkImageBitmap().then((result) => {
|
|
957
|
+
self.postMessage(result);
|
|
958
|
+
});
|
|
959
|
+
})();
|
|
960
|
+
`;let fo=null,Vd=class{constructor(){fo||(fo=URL.createObjectURL(new Blob([IR],{type:"application/javascript"}))),this.worker=new Worker(fo)}};Vd.revokeObjectURL=function(){fo&&(URL.revokeObjectURL(fo),fo=null)};const MR=`(function() {
|
|
961
|
+
"use strict";
|
|
962
|
+
async function loadImageBitmap(url) {
|
|
963
|
+
const response = await fetch(url);
|
|
964
|
+
if (!response.ok)
|
|
965
|
+
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
|
|
966
|
+
const imageBlob = await response.blob();
|
|
967
|
+
return await createImageBitmap(imageBlob);
|
|
968
|
+
}
|
|
969
|
+
self.onmessage = async (event) => {
|
|
970
|
+
try {
|
|
971
|
+
const imageBitmap = await loadImageBitmap(event.data.data[0]);
|
|
972
|
+
self.postMessage({
|
|
973
|
+
data: imageBitmap,
|
|
974
|
+
uuid: event.data.uuid,
|
|
975
|
+
id: event.data.id
|
|
976
|
+
}, [imageBitmap]);
|
|
977
|
+
} catch (e) {
|
|
978
|
+
self.postMessage({
|
|
979
|
+
error: e,
|
|
980
|
+
uuid: event.data.uuid,
|
|
981
|
+
id: event.data.id
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
})();
|
|
986
|
+
`;let po=null;class ry{constructor(){po||(po=URL.createObjectURL(new Blob([MR],{type:"application/javascript"}))),this.worker=new Worker(po)}}ry.revokeObjectURL=function(){po&&(URL.revokeObjectURL(po),po=null)};let ny=0,zd;class DR{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(e=>{const{worker:t}=new Vd;t.addEventListener("message",i=>{t.terminate(),Vd.revokeObjectURL(),e(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e){return this._run("loadImageBitmap",[e])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){zd===void 0&&(zd=navigator.hardwareConcurrency||4);let e=this.workerPool.pop();return!e&&this._createdWorkers<zd&&(this._createdWorkers++,e=new ry().worker,e.addEventListener("message",t=>{this.complete(t.data),this.returnWorker(t.target),this.next()})),e}returnWorker(e){this.workerPool.push(e)}complete(e){e.error!==void 0?this.resolveHash[e.uuid].reject(e.error):this.resolveHash[e.uuid].resolve(e.data),this.resolveHash[e.uuid]=null}async _run(e,t){await this._initWorkers();const i=new Promise((n,s)=>{this.queue.push({id:e,arguments:t,resolve:n,reject:s})});return this.next(),i}next(){if(!this.queue.length)return;const e=this.getWorker();if(!e)return;const t=this.queue.pop(),i=t.id;this.resolveHash[ny]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:ny++,id:i})}}const sy=new DR;function ba(r,e,t){r.resource.internal=!0;const i=new Te(r),n=()=>{delete e.promiseCache[t],ms.has(t)&&ms.remove(t)};return i.baseTexture.once("destroyed",()=>{t in e.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),n())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),i}const OR=[".jpeg",".jpg",".png",".webp",".avif"],LR=["image/jpeg","image/png","image/webp","image/avif"];async function NR(r){const e=await ye.ADAPTER.fetch(r);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${e.status} ${e.statusText}`);const t=await e.blob();return await createImageBitmap(t)}const Rh={name:"loadTextures",extension:{type:ge.LoadParser,priority:vr.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return co(r,LR)||Rn(r,OR)},async load(r,e,t){var i;const n=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;n?this.config.preferWorkers&&await sy.isImageBitmapSupported()?s=await sy.loadImageBitmap(r):s=await NR(r):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const o={...e.data};o.resolution??(o.resolution=$r(r)),n&&((i=o.resourceOptions)==null?void 0:i.ownsImageBitmap)===void 0&&(o.resourceOptions={...o.resourceOptions},o.resourceOptions.ownsImageBitmap=!0);const a=new ze(s,o);return a.resource.src=r,ba(a,t,r)},unload(r){r.destroy(!0)}};Ee.add(Rh);const FR=".svg",BR="image/svg+xml",kR={extension:{type:ge.LoadParser,priority:vr.High},name:"loadSVG",test(r){return co(r,BR)||Rn(r,FR)},async testParse(r){return Ld.test(r)},async parse(r,e,t){var i;const n=new Ld(r,(i=e==null?void 0:e.data)==null?void 0:i.resourceOptions);await n.load();const s=new ze(n,{resolution:$r(r),...e==null?void 0:e.data});return s.resource.src=e.src,ba(s,t,e.src)},async load(r,e){return(await ye.ADAPTER.fetch(r)).text()},unload:Rh.unload};Ee.add(kR);const UR=[".mp4",".m4v",".webm",".ogv"],HR=["video/mp4","video/webm","video/ogg"],GR={name:"loadVideo",extension:{type:ge.LoadParser,priority:vr.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return co(r,HR)||Rn(r,UR)},async load(r,e,t){var i;let n;const s=await(await ye.ADAPTER.fetch(r)).blob(),o=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(i=e==null?void 0:e.data)==null?void 0:i.resourceOptions,autoLoad:!0},l=new W0(o,a);await l.load();const h=new ze(l,{alphaMode:await Y2(),resolution:$r(r),...e==null?void 0:e.data});h.resource.src=r,n=ba(h,t,r),n.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(o)})}catch(a){throw URL.revokeObjectURL(o),a}return n},unload(r){r.destroy(!0)}};Ee.add(GR);class VR{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,name:i,src:n,srcs:s}=e;return mr(t||i||n||s,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>(a==null?void 0:a.src)??(a==null?void 0:a.srcs)??a):o!=null&&o.src||o!=null&&o.srcs?o.src??o.srcs:o,!0)}addManifest(e){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];Array.isArray(t)?t.forEach(n=>{const s=n.src??n.srcs,o=n.alias??n.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(e,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(e,h));i.push(...l),a=[...o,...l]}this.add({...n,alias:a,src:s})}):Object.keys(t).forEach(n=>{const s=[n,this._createBundleAssetId(e,n)];if(typeof t[n]=="string")this.add({alias:s,src:t[n]});else if(Array.isArray(t[n]))this.add({alias:s,src:t[n]});else{const o=t[n],a=o.src??o.srcs;this.add({...o,alias:s,src:Array.isArray(a)?a:[a]})}i.push(...s)}),this._bundles[e]=i}add(e,t,i,n,s){const o=[];typeof e=="string"||Array.isArray(e)&&typeof e[0]=="string"?(Je("7.2.0",`Assets.add now uses an object instead of individual parameters.
|
|
987
|
+
Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:e,src:t,data:i,format:n,loadParser:s})):Array.isArray(e)?o.push(...e):o.push(e);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},mr(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:f}=l;const g=mr(h||u).map(v=>typeof v=="string"?fR(v):Array.isArray(v)?v:[v]),p=this.getAlias(l);Array.isArray(p)?p.forEach(a):a(p);const m=[];g.forEach(v=>{v.forEach(y=>{let _={};if(typeof y!="object"){_.src=y;for(let w=0;w<this._parsers.length;w++){const A=this._parsers[w];if(A.test(y)){_=A.parse(y);break}}}else c=y.data??c,d=y.format??d,f=y.loadParser??f,_={..._,...y};if(!p)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this.buildResolvedAsset(_,{aliases:p,data:c,format:d,loadParser:f}),m.push(_)})}),p.forEach(v=>{this._assetMap[v]=m})})}resolveBundle(e){const t=Sh(e);e=mr(e);const i={};return e.forEach(n=>{const s=this._bundles[n];if(s){const o=this.resolve(s),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(n,l)]=h}i[n]=a}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const n in t)i[n]=t[n].src;return i}return t.src}resolve(e){const t=Sh(e);e=mr(e);const i={};return e.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let s=this._assetMap[n];const o=s[0],a=this._getPreferredOrder(s);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const u=s.filter(c=>c[l]?c[l]===h:!1);u.length&&(s=u)})}),this._resolverHash[n]=s[0]??o}else this._resolverHash[n]=this.buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const i=e[0],n=this._preferredOrder.find(s=>s.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}buildResolvedAsset(e,t){const{aliases:i,data:n,loadParser:s,format:o}=t;return(this._basePath||this._rootPath)&&(e.src=Zt.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...n||{},...e.data},e.loadParser=s??e.loadParser,e.format=o??e.format??Zt.extname(e.src).slice(1),e.srcs=e.src,e.name=e.alias,e}}class zR{constructor(){this._detections=[],this._initialized=!1,this.resolver=new VR,this.loader=new gR,this.cache=ms,this._backgroundLoader=new dR(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){var t,i;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let a=e.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const n=((t=e.texturePreference)==null?void 0:t.resolution)??1,s=typeof n=="number"?[n]:n,o=await this._detectFormats({preferredFormats:(i=e.texturePreference)==null?void 0:i.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:s}}),e.preferences&&this.setPreferences(e.preferences)}add(e,t,i,n,s){this.resolver.add(e,t,i,n,s)}async load(e,t){this._initialized||await this.init();const i=Sh(e),n=mr(e).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),s=this.resolver.resolve(n),o=await this._mapLoadToResolve(s,t);return i?o[n[0]]:o}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const n=this.resolver.resolveBundle(e),s={},o=Object.keys(n);let a=0,l=0;const h=()=>{t==null||t(++a/l)},u=o.map(c=>{const d=n[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{s[c]=f})});return await Promise.all(u),i?s[e[0]]:s}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return ms.get(e);const t={};for(let i=0;i<e.length;i++)t[i]=ms.get(e[i]);return t}async _mapLoadToResolve(e,t){const i=Object.values(e),n=Object.keys(e);this._backgroundLoader.active=!1;const s=await this.loader.load(i,t);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=s[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[n[l]]=h,ms.set(u,h)}),o}async unload(e){this._initialized||await this.init();const t=mr(e).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=mr(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(n=>this._unloadFromResolved(t[n]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{ms.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,n)=>t.indexOf(i)===n),t}get detections(){return this._detections}get preferWorkers(){return Rh.config.preferWorkers}set preferWorkers(e){Je("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:e})}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const Ch=new zR;Ee.handleByList(ge.LoadParser,Ch.loader.parsers).handleByList(ge.ResolveParser,Ch.resolver.parsers).handleByList(ge.CacheParser,Ch.cache.parsers).handleByList(ge.DetectionParser,Ch.detections);const jR={extension:ge.CacheParser,test:r=>Array.isArray(r)&&r.every(e=>e instanceof Te),getCacheableAssets:(r,e)=>{const t={};return r.forEach(i=>{e.forEach((n,s)=>{t[i+(s===0?"":s+1)]=n})}),t}};Ee.add(jR);async function oy(r){if("Image"in globalThis)return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(r)).blob();await createImageBitmap(e)}catch{return!1}return!0}return!1}const WR={extension:{type:ge.DetectionParser,priority:1},test:async()=>oy("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(e=>e!=="avif")};Ee.add(WR);const XR={extension:{type:ge.DetectionParser,priority:0},test:async()=>oy("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(e=>e!=="webp")};Ee.add(XR);const ay=["png","jpg","jpeg"],YR={extension:{type:ge.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...ay],remove:async r=>r.filter(e=>!ay.includes(e))};Ee.add(YR);const ZR="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function jd(r){return ZR?!1:document.createElement("video").canPlayType(r)!==""}const qR={extension:{type:ge.DetectionParser,priority:0},test:async()=>jd("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(e=>e!=="webm")};Ee.add(qR);const KR={extension:{type:ge.DetectionParser,priority:0},test:async()=>jd("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(e=>e!=="mp4"&&e!=="m4v")};Ee.add(KR);const QR={extension:{type:ge.DetectionParser,priority:0},test:async()=>jd("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(e=>e!=="ogv")};Ee.add(QR);const JR={extension:ge.ResolveParser,test:Rh.test,parse:r=>{var e;return{resolution:parseFloat(((e=ye.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:Zt.extname(r).slice(1),src:r}}};Ee.add(JR);var ii=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(ii||{});const Ph={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Nr,go;function ly(){go={bptc:Nr.getExtension("EXT_texture_compression_bptc"),astc:Nr.getExtension("WEBGL_compressed_texture_astc"),etc:Nr.getExtension("WEBGL_compressed_texture_etc"),s3tc:Nr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Nr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Nr.getExtension("WEBGL_compressed_texture_pvrtc")||Nr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Nr.getExtension("WEBGL_compressed_texture_etc1"),atc:Nr.getExtension("WEBGL_compressed_texture_atc")}}const $R={extension:{type:ge.DetectionParser,priority:2},test:async()=>{const r=ye.ADAPTER.createCanvas().getContext("webgl");return r?(Nr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{go||ly();const e=[];for(const t in go)go[t]&&e.push(t);return[...e,...r]},remove:async r=>(go||ly(),r.filter(e=>!(e in go)))};Ee.add($R);class eC extends rh{constructor(e,t={width:1,height:1,autoLoad:!0}){let i,n;typeof e=="string"?(i=e,n=new Uint8Array):(i=null,n=e),super(n,t),this.origin=i,this.buffer=n?new hd(n):null,this._load=null,this.loaded=!1,this.origin!==null&&t.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(e){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(e=>e.blob()).then(e=>e.arrayBuffer()).then(e=>(this.data=new Uint32Array(e),this.buffer=new hd(e),this.loaded=!0,this.onBlobLoaded(e),this.update(),this)),this._load)}}class vs extends eC{constructor(e,t){super(e,t),this.format=t.format,this.levels=t.levels||1,this._width=t.width,this._height=t.height,this._extension=vs._formatToExtension(this.format),(t.levelBuffers||this.buffer)&&(this._levelBuffers=t.levelBuffers||vs._createLevelBuffers(e instanceof Uint8Array?e:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(e,t,i){const n=e.gl;if(!e.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;n.pixelStorei(n.UNPACK_ALIGNMENT,4);for(let s=0,o=this.levels;s<o;s++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:u}=this._levelBuffers[s];n.compressedTexImage2D(n.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=vs._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(e){if(e>=33776&&e<=33779)return"s3tc";if(e>=35916&&e<=35919)return"s3tc_sRGB";if(e>=37488&&e<=37497)return"etc";if(e>=35840&&e<=35843)return"pvrtc";if(e===36196)return"etc1";if(e===35986||e===35987||e===34798)return"atc";if(e>=36492&&e<=36495)return"bptc";if(e===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${e}`)}static _createLevelBuffers(e,t,i,n,s,o,a){const l=new Array(i);let h=e.byteOffset,u=o,c=a,d=u+n-1&~(n-1),f=c+s-1&~(s-1),g=d*f*Ph[t];for(let p=0;p<i;p++)l[p]={levelID:p,levelWidth:i>1?u:d,levelHeight:i>1?c:f,levelBuffer:new Uint8Array(e.buffer,h,g)},h+=g,u=u>>1||1,c=c>>1||1,d=u+n-1&~(n-1),f=c+s-1&~(s-1),g=d*f*Ph[t];return l}}const Wd=4,Ih=124,tC=32,hy=20,iC=542327876,Mh={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},rC={FOURCC:2},Dh={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},nC=1,sC=2,oC=4,aC=64,lC=512,hC=131072,uC=827611204,cC=861165636,dC=894720068,fC=808540228,pC=4,gC={[uC]:ii.COMPRESSED_RGBA_S3TC_DXT1_EXT,[cC]:ii.COMPRESSED_RGBA_S3TC_DXT3_EXT,[dC]:ii.COMPRESSED_RGBA_S3TC_DXT5_EXT},mC={70:ii.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:ii.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:ii.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:ii.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:ii.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:ii.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:ii.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:ii.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:ii.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:ii.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:ii.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:ii.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:ii.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function vC(r){const e=new Uint32Array(r);if(e[0]!==iC)throw new Error("Invalid DDS file magic word");const t=new Uint32Array(r,0,Ih/Uint32Array.BYTES_PER_ELEMENT),i=t[Mh.HEIGHT],n=t[Mh.WIDTH],s=t[Mh.MIPMAP_COUNT],o=new Uint32Array(r,Mh.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,tC/Uint32Array.BYTES_PER_ELEMENT),a=o[nC];if(a&oC){const l=o[rC.FOURCC];if(l!==fC){const y=gC[l],_=Wd+Ih,w=new Uint8Array(r,_);return[new vs(w,{format:y,width:n,height:i,levels:s})]}const h=Wd+Ih,u=new Uint32Array(e.buffer,h,hy/Uint32Array.BYTES_PER_ELEMENT),c=u[Dh.DXGI_FORMAT],d=u[Dh.RESOURCE_DIMENSION],f=u[Dh.MISC_FLAG],g=u[Dh.ARRAY_SIZE],p=mC[c];if(p===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===pC)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const m=new Array,v=Wd+Ih+hy;if(g===1)m.push(new Uint8Array(r,v));else{const y=Ph[p];let _=0,w=n,A=i;for(let C=0;C<s;C++){const R=Math.max(1,w+3&-4),M=Math.max(1,A+3&-4),k=R*M*y;_+=k,w=w>>>1,A=A>>>1}let F=v;for(let C=0;C<g;C++)m.push(new Uint8Array(r,F,_)),F+=_}return m.map(y=>new vs(y,{format:p,width:n,height:i,levels:s}))}throw a&aC?new Error("DDSParser does not support uncompressed texture data."):a&lC?new Error("DDSParser does not supported YUV uncompressed texture data."):a&hC?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&sC?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const uy=[171,75,84,88,32,49,49,187,13,10,26,10],yC=67305985,yr={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},Xd=64,cy={[Re.UNSIGNED_BYTE]:1,[Re.UNSIGNED_SHORT]:2,[Re.INT]:4,[Re.UNSIGNED_INT]:4,[Re.FLOAT]:4,[Re.HALF_FLOAT]:8},_C={[he.RGBA]:4,[he.RGB]:3,[he.RG]:2,[he.RED]:1,[he.LUMINANCE]:1,[he.LUMINANCE_ALPHA]:2,[he.ALPHA]:1},xC={[Re.UNSIGNED_SHORT_4_4_4_4]:2,[Re.UNSIGNED_SHORT_5_5_5_1]:2,[Re.UNSIGNED_SHORT_5_6_5]:2};function wC(r,e,t=!1){const i=new DataView(e);if(!EC(r,i))return null;const n=i.getUint32(yr.ENDIANNESS,!0)===yC,s=i.getUint32(yr.GL_TYPE,n),o=i.getUint32(yr.GL_FORMAT,n),a=i.getUint32(yr.GL_INTERNAL_FORMAT,n),l=i.getUint32(yr.PIXEL_WIDTH,n),h=i.getUint32(yr.PIXEL_HEIGHT,n)||1,u=i.getUint32(yr.PIXEL_DEPTH,n)||1,c=i.getUint32(yr.NUMBER_OF_ARRAY_ELEMENTS,n)||1,d=i.getUint32(yr.NUMBER_OF_FACES,n),f=i.getUint32(yr.NUMBER_OF_MIPMAP_LEVELS,n),g=i.getUint32(yr.BYTES_OF_KEY_VALUE_DATA,n);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const p=4,m=4,v=l+3&-4,y=h+3&-4,_=new Array(c);let w=l*h;s===0&&(w=v*y);let A;if(s!==0?cy[s]?A=cy[s]*_C[o]:A=xC[s]:A=Ph[a],A===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const F=t?bC(i,g,n):null;let C=w*A,R=l,M=h,k=v,z=y,D=Xd+g;for(let S=0;S<f;S++){const b=i.getUint32(D,n);let O=D+4;for(let j=0;j<c;j++){let V=_[j];V||(V=_[j]=new Array(f)),V[S]={levelID:S,levelWidth:f>1||s!==0?R:k,levelHeight:f>1||s!==0?M:z,levelBuffer:new Uint8Array(e,O,C)},O+=C}D+=b+4,D=D%4!==0?D+4-D%4:D,R=R>>1||1,M=M>>1||1,k=R+p-1&-4,z=M+m-1&-4,C=k*z*A}return s!==0?{uncompressed:_.map(S=>{let b=S[0].levelBuffer,O=!1;return s===Re.FLOAT?b=new Float32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4):s===Re.UNSIGNED_INT?(O=!0,b=new Uint32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)):s===Re.INT&&(O=!0,b=new Int32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)),{resource:new rh(b,{width:S[0].levelWidth,height:S[0].levelHeight}),type:s,format:O?TC(o):o}}),kvData:F}:{compressed:_.map(S=>new vs(null,{format:a,width:l,height:h,levels:f,levelBuffers:S})),kvData:F}}function EC(r,e){for(let t=0;t<uy.length;t++)if(e.getUint8(t)!==uy[t])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function TC(r){switch(r){case he.RGBA:return he.RGBA_INTEGER;case he.RGB:return he.RGB_INTEGER;case he.RG:return he.RG_INTEGER;case he.RED:return he.RED_INTEGER;default:return r}}function bC(r,e,t){const i=new Map;let n=0;for(;n<e;){const s=r.getUint32(Xd+n,t),o=Xd+n+4,a=3-(s+3)%4;if(s===0||s>e-n){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<s&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),u=new DataView(r.buffer,o+l+1,s-l-1);i.set(h,u),n+=4+s+a}return i}const AC={extension:{type:ge.LoadParser,priority:vr.High},name:"loadDDS",test(r){return Rn(r,".dds")},async load(r,e,t){const i=await(await ye.ADAPTER.fetch(r)).arrayBuffer(),n=vC(i).map(s=>{const o=new ze(s,{mipmap:Cr.OFF,alphaMode:bi.NO_PREMULTIPLIED_ALPHA,resolution:$r(r),...e.data});return ba(o,t,r)});return n.length===1?n[0]:n},unload(r){Array.isArray(r)?r.forEach(e=>e.destroy(!0)):r.destroy(!0)}};Ee.add(AC);const SC={extension:{type:ge.LoadParser,priority:vr.High},name:"loadKTX",test(r){return Rn(r,".ktx")},async load(r,e,t){const i=await(await ye.ADAPTER.fetch(r)).arrayBuffer(),{compressed:n,uncompressed:s,kvData:o}=wC(r,i),a=n??s,l={mipmap:Cr.OFF,alphaMode:bi.NO_PREMULTIPLIED_ALPHA,resolution:$r(r),...e.data},h=a.map(u=>{a===s&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new ze(c,l);return d.ktxKeyValueData=o,ba(d,t,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(e=>e.destroy(!0)):r.destroy(!0)}};Ee.add(SC);const RC=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],CC={extension:ge.ResolveParser,test:r=>{const e=Zt.extname(r).slice(1);return["basis","ktx","dds"].includes(e)},parse:r=>{var e,t;const i=r.split("."),n=i.pop();if(["ktx","dds"].includes(n)){const s=i.pop();if(RC.includes(s))return{resolution:parseFloat(((e=ye.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:s,src:r}}return{resolution:parseFloat(((t=ye.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:n,src:r}}};Ee.add(CC);const Oh=new We,PC=4,dy=class Ka{constructor(e){this.renderer=e,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(e,t,i,n){const s=new Image;return s.src=await this.base64(e,t,i,n),s}async base64(e,t,i,n){const s=this.canvas(e,n);if(s.toBlob!==void 0)return new Promise((o,a)=>{s.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},t,i)});if(s.toDataURL!==void 0)return s.toDataURL(t,i);if(s.convertToBlob!==void 0){const o=await s.convertToBlob({type:t,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e,t){const{pixels:i,width:n,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(e,t);o&&Ka._flipY(i,n,s),a&&Ka._unpremultiplyAlpha(i);const l=new hA(n,s,1),h=new ImageData(new Uint8ClampedArray(i.buffer),n,s);return l.context.putImageData(h,0,0),l.canvas}pixels(e,t){const{pixels:i,width:n,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(e,t);return o&&Ka._flipY(i,n,s),a&&Ka._unpremultiplyAlpha(i),i}_rawPixels(e,t){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let n,s=!1,o=!1,a,l=!1;e&&(e instanceof ds?a=e:(a=i.generateTexture(e,{region:t,resolution:i.resolution,multisample:i.multisample}),l=!0,t&&(Oh.width=t.width,Oh.height=t.height,t=Oh)));const h=i.gl;if(a){if(n=a.baseTexture.resolution,t=t??a.frame,s=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===he.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else n=i.resolution,t||(t=Oh,t.width=i.width/n,t.height=i.height/n),s=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(t.width*n),1),c=Math.max(Math.round(t.height*n),1),d=new Uint8Array(PC*u*c);return h.readPixels(Math.round(t.x*n),Math.round(t.y*n),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,flipY:s,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(e,t,i){const n=t<<2,s=i>>1,o=new Uint8Array(n);for(let a=0;a<s;a++){const l=a*n,h=(i-a-1)*n;o.set(e.subarray(l,l+n)),e.copyWithin(l,h,h+n),e.set(o,h)}}static _unpremultiplyAlpha(e){e instanceof Uint8ClampedArray&&(e=new Uint8Array(e.buffer));const t=e.length;for(let i=0;i<t;i+=4){const n=e[i+3];if(n!==0){const s=255.001/n;e[i]=e[i]*s+.5,e[i+1]=e[i+1]*s+.5,e[i+2]=e[i+2]*s+.5}}}};dy.extension={name:"extract",type:ge.RendererSystem};let IC=dy;Ee.add(IC);const Lh={build(r){const e=r.points;let t,i,n,s,o,a;if(r.type===ti.CIRC){const g=r.shape;t=g.x,i=g.y,o=a=g.radius,n=s=0}else if(r.type===ti.ELIP){const g=r.shape;t=g.x,i=g.y,o=g.width,a=g.height,n=s=0}else{const g=r.shape,p=g.width/2,m=g.height/2;t=g.x+p,i=g.y+m,o=a=Math.max(0,Math.min(g.radius,Math.min(p,m))),n=p-o,s=m-a}if(!(o>=0&&a>=0&&n>=0&&s>=0)){e.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(n?4:0)+(s?4:0);if(e.length=h,h===0)return;if(l===0){e.length=8,e[0]=e[6]=t+n,e[1]=e[3]=i+s,e[2]=e[4]=t-n,e[5]=e[7]=i-s;return}let u=0,c=l*4+(n?2:0)+2,d=c,f=h;{const g=n+o,p=s,m=t+g,v=t-g,y=i+p;if(e[u++]=m,e[u++]=y,e[--c]=y,e[--c]=v,s){const _=i-p;e[d++]=v,e[d++]=_,e[--f]=_,e[--f]=m}}for(let g=1;g<l;g++){const p=Math.PI/2*(g/l),m=n+Math.cos(p)*o,v=s+Math.sin(p)*a,y=t+m,_=t-m,w=i+v,A=i-v;e[u++]=y,e[u++]=w,e[--c]=w,e[--c]=_,e[d++]=_,e[d++]=A,e[--f]=A,e[--f]=y}{const g=n,p=s+a,m=t+g,v=t-g,y=i+p,_=i-p;e[u++]=m,e[u++]=y,e[--f]=_,e[--f]=m,n&&(e[u++]=v,e[u++]=y,e[--f]=_,e[--f]=v)}},triangulate(r,e){const t=r.points,i=e.points,n=e.indices;if(t.length===0)return;let s=i.length/2;const o=s;let a,l;if(r.type!==ti.RREC){const u=r.shape;a=u.x,l=u.y}else{const u=r.shape;a=u.x+u.width/2,l=u.y+u.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),s++,i.push(t[0],t[1]);for(let u=2;u<t.length;u+=2)i.push(t[u],t[u+1]),n.push(s++,o,s);n.push(o+1,o,s)}};function fy(r,e=!1){const t=r.length;if(t<6)return;let i=0;for(let n=0,s=r[t-2],o=r[t-1];n<t;n+=2){const a=r[n],l=r[n+1];i+=(a-s)*(l+o),s=a,o=l}if(!e&&i>0||e&&i<=0){const n=t/2;for(let s=n+n%2;s<t;s+=2){const o=t-s-2,a=t-s-1,l=s,h=s+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const py={build(r){r.points=r.shape.points.slice()},triangulate(r,e){let t=r.points;const i=r.holes,n=e.points,s=e.indices;if(t.length>=6){fy(t,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];fy(u.points,!0),o.push(t.length/2),t=t.concat(u.points)}const a=wb(t,o,2);if(!a)return;const l=n.length/2;for(let h=0;h<a.length;h+=3)s.push(a[h]+l),s.push(a[h+1]+l),s.push(a[h+2]+l);for(let h=0;h<t.length;h++)n.push(t[h])}}},MC={build(r){const e=r.shape,t=e.x,i=e.y,n=e.width,s=e.height,o=r.points;o.length=0,n>=0&&s>=0&&o.push(t,i,t+n,i,t+n,i+s,t,i+s)},triangulate(r,e){const t=r.points,i=e.points;if(t.length===0)return;const n=i.length/2;i.push(t[0],t[1],t[2],t[3],t[6],t[7],t[4],t[5]),e.indices.push(n,n+1,n+2,n+1,n+2,n+3)}},DC={build(r){Lh.build(r)},triangulate(r,e){Lh.triangulate(r,e)}};var Ji=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Ji||{}),Cn=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Cn||{});const mo={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,e=20){if(!this.adaptive||!r||isNaN(r))return e;let t=Math.ceil(r/this.maxLength);return t<this.minSegments?t=this.minSegments:t>this.maxSegments&&(t=this.maxSegments),t}};class gy{static curveTo(e,t,i,n,s,o){const a=o[o.length-2],l=o[o.length-1]-t,h=a-e,u=n-t,c=i-e,d=Math.abs(l*c-h*u);if(d<1e-8||s===0)return(o[o.length-2]!==e||o[o.length-1]!==t)&&o.push(e,t),null;const f=l*l+h*h,g=u*u+c*c,p=l*u+h*c,m=s*Math.sqrt(f)/d,v=s*Math.sqrt(g)/d,y=m*p/f,_=v*p/g,w=m*c+v*h,A=m*u+v*l,F=h*(v+y),C=l*(v+y),R=c*(m+_),M=u*(m+_),k=Math.atan2(C-A,F-w),z=Math.atan2(M-A,R-w);return{cx:w+e,cy:A+t,radius:s,startAngle:k,endAngle:z,anticlockwise:h*u>c*l}}static arc(e,t,i,n,s,o,a,l,h){const u=a-o,c=mo._segmentsCount(Math.abs(u)*s,Math.ceil(Math.abs(u)/sh)*40),d=u/(c*2),f=d*2,g=Math.cos(d),p=Math.sin(d),m=c-1,v=m%1/m;for(let y=0;y<=m;++y){const _=y+v*y,w=d+o+f*_,A=Math.cos(w),F=-Math.sin(w);h.push((g*A+p*F)*s+i,(g*-F+p*A)*s+n)}}}class OC{constructor(){this.reset()}begin(e,t,i){this.reset(),this.style=e,this.start=t,this.attribStart=i}end(e,t){this.attribSize=t-this.attribStart,this.size=e-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class Yd{static curveLength(e,t,i,n,s,o,a,l){let h=0,u=0,c=0,d=0,f=0,g=0,p=0,m=0,v=0,y=0,_=0,w=e,A=t;for(let F=1;F<=10;++F)u=F/10,c=u*u,d=c*u,f=1-u,g=f*f,p=g*f,m=p*e+3*g*u*i+3*f*c*s+d*a,v=p*t+3*g*u*n+3*f*c*o+d*l,y=w-m,_=A-v,w=m,A=v,h+=Math.sqrt(y*y+_*_);return h}static curveTo(e,t,i,n,s,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const u=mo._segmentsCount(Yd.curveLength(l,h,e,t,i,n,s,o));let c=0,d=0,f=0,g=0,p=0;a.push(l,h);for(let m=1,v=0;m<=u;++m)v=m/u,c=1-v,d=c*c,f=d*c,g=v*v,p=g*v,a.push(f*l+3*d*v*e+3*c*g*i+p*s,f*h+3*d*v*t+3*c*g*n+p*o)}}function my(r,e,t,i,n,s,o,a){const l=r-t*n,h=e-i*n,u=r+t*s,c=e+i*s;let d,f;o?(d=i,f=-t):(d=-i,f=t);const g=l+d,p=h+f,m=u+d,v=c+f;return a.push(g,p,m,v),2}function ys(r,e,t,i,n,s,o,a){const l=t-r,h=i-e;let u=Math.atan2(l,h),c=Math.atan2(n-r,s-e);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const f=c-u,g=Math.abs(f),p=Math.sqrt(l*l+h*h),m=(15*g*Math.sqrt(p)/Math.PI>>0)+1,v=f/m;if(d+=v,a){o.push(r,e,t,i);for(let y=1,_=d;y<m;y++,_+=v)o.push(r,e,r+Math.sin(_)*p,e+Math.cos(_)*p);o.push(r,e,n,s)}else{o.push(t,i,r,e);for(let y=1,_=d;y<m;y++,_+=v)o.push(r+Math.sin(_)*p,e+Math.cos(_)*p,r,e);o.push(n,s,r,e)}return m*2}function LC(r,e){const t=r.shape;let i=r.points||t.points.slice();const n=e.closePointEps;if(i.length===0)return;const s=r.lineStyle,o=new nt(i[0],i[1]),a=new nt(i[i.length-2],i[i.length-1]),l=t.type!==ti.POLY||t.closeStroke,h=Math.abs(o.x-a.x)<n&&Math.abs(o.y-a.y)<n;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const V=(o.x+a.x)*.5,Y=(a.y+o.y)*.5;i.unshift(V,Y),i.push(V,Y)}const u=e.points,c=i.length/2;let d=i.length;const f=u.length/2,g=s.width/2,p=g*g,m=s.miterLimit*s.miterLimit;let v=i[0],y=i[1],_=i[2],w=i[3],A=0,F=0,C=-(y-w),R=v-_,M=0,k=0,z=Math.sqrt(C*C+R*R);C/=z,R/=z,C*=g,R*=g;const D=s.alignment,S=(1-D)*2,b=D*2;l||(s.cap===Cn.ROUND?d+=ys(v-C*(S-b)*.5,y-R*(S-b)*.5,v-C*S,y-R*S,v+C*b,y+R*b,u,!0)+2:s.cap===Cn.SQUARE&&(d+=my(v,y,C,R,S,b,!0,u))),u.push(v-C*S,y-R*S,v+C*b,y+R*b);for(let V=1;V<c-1;++V){v=i[(V-1)*2],y=i[(V-1)*2+1],_=i[V*2],w=i[V*2+1],A=i[(V+1)*2],F=i[(V+1)*2+1],C=-(y-w),R=v-_,z=Math.sqrt(C*C+R*R),C/=z,R/=z,C*=g,R*=g,M=-(w-F),k=_-A,z=Math.sqrt(M*M+k*k),M/=z,k/=z,M*=g,k*=g;const Y=_-v,G=y-w,H=_-A,X=F-w,K=Y*H+G*X,Q=G*H-X*Y,W=Q<0;if(Math.abs(Q)<.001*Math.abs(K)){u.push(_-C*S,w-R*S,_+C*b,w+R*b),K>=0&&(s.join===Ji.ROUND?d+=ys(_,w,_-C*S,w-R*S,_-M*S,w-k*S,u,!1)+4:d+=2,u.push(_-M*b,w-k*b,_+M*S,w+k*S));continue}const $=(-C+v)*(-R+w)-(-C+_)*(-R+y),ne=(-M+A)*(-k+w)-(-M+_)*(-k+F),_e=(Y*ne-H*$)/Q,pe=(X*$-G*ne)/Q,Ce=(_e-_)*(_e-_)+(pe-w)*(pe-w),Pe=_+(_e-_)*S,Be=w+(pe-w)*S,ke=_-(_e-_)*b,Ge=w-(pe-w)*b,$e=Math.min(Y*Y+G*G,H*H+X*X),ft=W?S:b,Pt=$e+ft*ft*p,x=Ce<=Pt;let L=s.join;if(L===Ji.MITER&&Ce/p>m&&(L=Ji.BEVEL),x)switch(L){case Ji.MITER:{u.push(Pe,Be,ke,Ge);break}case Ji.BEVEL:{W?u.push(Pe,Be,_+C*b,w+R*b,Pe,Be,_+M*b,w+k*b):u.push(_-C*S,w-R*S,ke,Ge,_-M*S,w-k*S,ke,Ge),d+=2;break}case Ji.ROUND:{W?(u.push(Pe,Be,_+C*b,w+R*b),d+=ys(_,w,_+C*b,w+R*b,_+M*b,w+k*b,u,!0)+4,u.push(Pe,Be,_+M*b,w+k*b)):(u.push(_-C*S,w-R*S,ke,Ge),d+=ys(_,w,_-C*S,w-R*S,_-M*S,w-k*S,u,!1)+4,u.push(_-M*S,w-k*S,ke,Ge));break}}else{switch(u.push(_-C*S,w-R*S,_+C*b,w+R*b),L){case Ji.MITER:{W?u.push(ke,Ge,ke,Ge):u.push(Pe,Be,Pe,Be),d+=2;break}case Ji.ROUND:{W?d+=ys(_,w,_+C*b,w+R*b,_+M*b,w+k*b,u,!0)+2:d+=ys(_,w,_-C*S,w-R*S,_-M*S,w-k*S,u,!1)+2;break}}u.push(_-M*S,w-k*S,_+M*b,w+k*b),d+=2}}v=i[(c-2)*2],y=i[(c-2)*2+1],_=i[(c-1)*2],w=i[(c-1)*2+1],C=-(y-w),R=v-_,z=Math.sqrt(C*C+R*R),C/=z,R/=z,C*=g,R*=g,u.push(_-C*S,w-R*S,_+C*b,w+R*b),l||(s.cap===Cn.ROUND?d+=ys(_-C*(S-b)*.5,w-R*(S-b)*.5,_-C*S,w-R*S,_+C*b,w+R*b,u,!1)+2:s.cap===Cn.SQUARE&&(d+=my(_,w,C,R,S,b,!1,u)));const O=e.indices,j=mo.epsilon*mo.epsilon;for(let V=f;V<d+f-2;++V)v=u[V*2],y=u[V*2+1],_=u[(V+1)*2],w=u[(V+1)*2+1],A=u[(V+2)*2],F=u[(V+2)*2+1],!(Math.abs(v*(w-F)+_*(F-y)+A*(y-w))<j)&&O.push(V,V+1,V+2)}function NC(r,e){let t=0;const i=r.shape,n=r.points||i.points,s=i.type!==ti.POLY||i.closeStroke;if(n.length===0)return;const o=e.points,a=e.indices,l=n.length/2,h=o.length/2;let u=h;for(o.push(n[0],n[1]),t=1;t<l;t++)o.push(n[t*2],n[t*2+1]),a.push(u,u+1),u++;s&&a.push(u,h)}function vy(r,e){r.lineStyle.native?NC(r,e):LC(r,e)}class Zd{static curveLength(e,t,i,n,s,o){const a=e-2*i+s,l=t-2*n+o,h=2*i-2*e,u=2*n-2*t,c=4*(a*a+l*l),d=4*(a*h+l*u),f=h*h+u*u,g=2*Math.sqrt(c+d+f),p=Math.sqrt(c),m=2*c*p,v=2*Math.sqrt(f),y=d/p;return(m*g+p*d*(g-v)+(4*f*c-d*d)*Math.log((2*p+y+g)/(y+v)))/(4*m)}static curveTo(e,t,i,n,s){const o=s[s.length-2],a=s[s.length-1],l=mo._segmentsCount(Zd.curveLength(o,a,e,t,i,n));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(e-o)*d,u=a+(t-a)*d,s.push(h+(e+(i-e)*d-h)*d,u+(t+(n-t)*d-u)*d)}}}const qd={[ti.POLY]:py,[ti.CIRC]:Lh,[ti.ELIP]:Lh,[ti.RECT]:MC,[ti.RREC]:DC},yy=[],Nh=[];class Fh{constructor(e,t=null,i=null,n=null){this.points=[],this.holes=[],this.shape=e,this.lineStyle=i,this.fillStyle=t,this.matrix=n,this.type=e.type}clone(){return new Fh(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const vo=new nt,_y=class S_ extends Qv{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Th,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let e=0;e<this.drawCalls.length;e++)this.drawCalls[e].texArray.clear(),Nh.push(this.drawCalls[e]);this.drawCalls.length=0;for(let e=0;e<this.batches.length;e++){const t=this.batches[e];t.reset(),yy.push(t)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(e,t=null,i=null,n=null){const s=new Fh(e,t,i,n);return this.graphicsData.push(s),this.dirty++,this}drawHole(e,t=null){if(!this.graphicsData.length)return null;const i=new Fh(e,null,null,t),n=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=n.lineStyle,n.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let e=0;e<this.graphicsData.length;++e)this.graphicsData[e].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(e){const t=this.graphicsData;for(let i=0;i<t.length;++i){const n=t[i];if(n.fillStyle.visible&&n.shape&&(n.matrix?n.matrix.applyInverse(e,vo):vo.copyFrom(e),n.shape.contains(vo.x,vo.y))){let s=!1;if(n.holes){for(let o=0;o<n.holes.length;o++)if(n.holes[o].shape.contains(vo.x,vo.y)){s=!0;break}}if(!s)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const e=this.uvs,t=this.graphicsData;let i=null,n=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],n=i.style);for(let l=this.shapeIndex;l<t.length;l++){this.shapeIndex++;const h=t[l],u=h.fillStyle,c=h.lineStyle;qd[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?u:c;if(!f.visible)continue;const g=f.texture.baseTexture,p=this.indices.length,m=this.points.length/2;g.wrapMode=En.REPEAT,d===0?this.processFill(h):this.processLine(h);const v=this.points.length/2-m;v!==0&&(i&&!this._compareStyles(n,f)&&(i.end(p,m),i=null),i||(i=yy.pop()||new OC,i.begin(f,p,m),this.batches.push(i),n=f),this.addUvs(this.points,e,f.texture,m,v,f.matrix))}}const s=this.indices.length,o=this.points.length/2;if(i&&i.end(s,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(e,t){return!(!e||!t||e.texture.baseTexture!==t.texture.baseTexture||e.color+e.alpha!==t.color+t.alpha||!!e.native!=!!t.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let e=0,t=this.graphicsData.length;e<t;e++){const i=this.graphicsData[e],n=i.fillStyle,s=i.lineStyle;if(n&&!n.texture.baseTexture.valid||s&&!s.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const e=this.batches;for(let t=0,i=e.length;t<i;t++){const n=e[t];for(let s=0;s<n.size;s++){const o=n.start+s;this.indicesUint16[o]=this.indicesUint16[o]-n.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const e=this.batches;for(let t=0;t<e.length;t++)if(e[t].style.native)return!1;return this.points.length<S_.BATCHABLE_SIZE*2}buildDrawCalls(){let e=++ze._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Nh.push(this.drawCalls[c]);this.drawCalls.length=0;const t=this.colors,i=this.textureIds;let n=Nh.pop();n||(n=new yd,n.texArray=new bd),n.texArray.count=0,n.start=0,n.size=0,n.type=Rr.TRIANGLES;let s=0,o=null,a=0,l=!1,h=Rr.TRIANGLES,u=0;this.drawCalls.push(n);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],f=8,g=d.style,p=g.texture.baseTexture;l!==!!g.native&&(l=!!g.native,h=l?Rr.LINES:Rr.TRIANGLES,o=null,s=f,e++),o!==p&&(o=p,p._batchEnabled!==e&&(s===f&&(e++,s=0,n.size>0&&(n=Nh.pop(),n||(n=new yd,n.texArray=new bd),this.drawCalls.push(n)),n.start=u,n.size=0,n.texArray.count=0,n.type=h),p.touched=1,p._batchEnabled=e,p._batchLocation=s,p.wrapMode=En.REPEAT,n.texArray.elements[n.texArray.count++]=p,s++)),n.size+=d.size,u+=d.size,a=p._batchLocation,this.addColors(t,g.color,g.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}ze._globalBatch=e,this.packAttributes()}packAttributes(){const e=this.points,t=this.uvs,i=this.colors,n=this.textureIds,s=new ArrayBuffer(e.length*3*4),o=new Float32Array(s),a=new Uint32Array(s);let l=0;for(let h=0;h<e.length/2;h++)o[l++]=e[h*2],o[l++]=e[h*2+1],o[l++]=t[h*2],o[l++]=t[h*2+1],a[l++]=i[h],o[l++]=n[h];this._buffer.update(s),this._indexBuffer.update(this.indicesUint16)}processFill(e){e.holes.length?py.triangulate(e,this):qd[e.type].triangulate(e,this)}processLine(e){vy(e,this);for(let t=0;t<e.holes.length;t++)vy(e.holes[t],this)}processHoles(e){for(let t=0;t<e.length;t++){const i=e[t];qd[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const e=this._bounds;e.clear(),e.addVertexData(this.points,0,this.points.length),e.pad(this.boundsPadding,this.boundsPadding)}transformPoints(e,t){for(let i=0;i<e.length/2;i++){const n=e[i*2],s=e[i*2+1];e[i*2]=t.a*n+t.c*s+t.tx,e[i*2+1]=t.b*n+t.d*s+t.ty}}addColors(e,t,i,n,s=0){const o=ut.shared.setValue(t).toLittleEndianNumber(),a=ut.shared.setValue(o).toPremultiplied(i);e.length=Math.max(e.length,s+n);for(let l=0;l<n;l++)e[s+l]=a}addTextureIds(e,t,i,n=0){e.length=Math.max(e.length,n+i);for(let s=0;s<i;s++)e[n+s]=t}addUvs(e,t,i,n,s,o=null){let a=0;const l=t.length,h=i.frame;for(;a<s;){let c=e[(n+a)*2],d=e[(n+a)*2+1];if(o){const f=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=f}a++,t.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.height)&&this.adjustUvs(t,i,l,s)}adjustUvs(e,t,i,n){const s=t.baseTexture,o=1e-6,a=i+n*2,l=t.frame,h=l.width/s.width,u=l.height/s.height;let c=l.x/l.width,d=l.y/l.height,f=Math.floor(e[i]+o),g=Math.floor(e[i+1]+o);for(let p=i+2;p<a;p+=2)f=Math.min(f,Math.floor(e[p]+o)),g=Math.min(g,Math.floor(e[p+1]+o));c-=f,d-=g;for(let p=i;p<a;p+=2)e[p]=(e[p]+c)*h,e[p+1]=(e[p+1]+d)*u}};_y.BATCHABLE_SIZE=100;let FC=_y;class Bh{constructor(){this.color=16777215,this.alpha=1,this.texture=Te.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const e=new Bh;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e}reset(){this.color=16777215,this.alpha=1,this.texture=Te.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Kd extends Bh{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Cn.BUTT,this.join=Ji.MITER,this.miterLimit=10}clone(){const e=new Kd;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e.width=this.width,e.alignment=this.alignment,e.native=this.native,e.cap=this.cap,e.join=this.join,e.miterLimit=this.miterLimit,e}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Cn.BUTT,this.join=Ji.MITER,this.miterLimit=10}}const Qd={},Jd=class eu extends pr{constructor(e=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Bh,this._lineStyle=new Kd,this._matrix=null,this._holeMode=!1,this.state=Or.for2d(),this._geometry=e||new FC,this._geometry.refCount++,this._transformID=-1,this._tintColor=new ut(16777215),this.blendMode=Ne.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new eu(this._geometry)}set blendMode(e){this.state.blendMode=e}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(e){this._tintColor.setValue(e)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(e=null,t=0,i,n=.5,s=!1){return typeof e=="number"&&(e={width:e,color:t,alpha:i,alignment:n,native:s}),this.lineTextureStyle(e)}lineTextureStyle(e){const t={width:0,texture:Te.WHITE,color:e!=null&&e.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Cn.BUTT,join:Ji.MITER,miterLimit:10};e=Object.assign(t,e),this.normalizeColor(e),this.currentPath&&this.startPoly();const i=e.width>0&&e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._lineStyle,{visible:i},e)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const e=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new os,this.currentPath.closeStroke=!1,this.currentPath.points.push(e[t-2],e[t-1]))}else this.currentPath=new os,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(e,t){return this.startPoly(),this.currentPath.points[0]=e,this.currentPath.points[1]=t,this}lineTo(e,t){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,n=i[i.length-2],s=i[i.length-1];return(n!==e||s!==t)&&i.push(e,t),this}_initCurve(e=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[e,t]):this.moveTo(e,t)}quadraticCurveTo(e,t,i,n){this._initCurve();const s=this.currentPath.points;return s.length===0&&this.moveTo(0,0),Zd.curveTo(e,t,i,n,s),this}bezierCurveTo(e,t,i,n,s,o){return this._initCurve(),Yd.curveTo(e,t,i,n,s,o,this.currentPath.points),this}arcTo(e,t,i,n,s){this._initCurve(e,t);const o=this.currentPath.points,a=gy.curveTo(e,t,i,n,s,o);if(a){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:f}=a;this.arc(l,h,u,c,d,f)}return this}arc(e,t,i,n,s,o=!1){if(n===s)return this;if(!o&&s<=n?s+=sh:o&&n<=s&&(n+=sh),s-n===0)return this;const a=e+Math.cos(n)*i,l=t+Math.sin(n)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(a,l)}else this.moveTo(a,l),u=this.currentPath.points;return gy.arc(a,l,e,t,i,n,s,o,u),this}beginFill(e=0,t){return this.beginTextureFill({texture:Te.WHITE,color:e,alpha:t})}normalizeColor(e){const t=ut.shared.setValue(e.color??0);e.color=t.toNumber(),e.alpha??(e.alpha=t.alpha)}beginTextureFill(e){const t={texture:Te.WHITE,color:16777215,matrix:null};e=Object.assign(t,e),this.normalizeColor(e),this.currentPath&&this.startPoly();const i=e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._fillStyle,{visible:i},e)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(e,t,i,n){return this.drawShape(new We(e,t,i,n))}drawRoundedRect(e,t,i,n,s){return this.drawShape(new hh(e,t,i,n,s))}drawCircle(e,t,i){return this.drawShape(new ah(e,t,i))}drawEllipse(e,t,i,n){return this.drawShape(new lh(e,t,i,n))}drawPolygon(...e){let t,i=!0;const n=e[0];n.points?(i=n.closeStroke,t=n.points):Array.isArray(e[0])?t=e[0]:t=e;const s=new os(t);return s.closeStroke=i,this.drawShape(s),this}drawShape(e){return this._holeMode?this._geometry.drawHole(e,this._matrix):this._geometry.drawShape(e,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const e=this._geometry.graphicsData;return e.length===1&&e[0].shape.type===ti.RECT&&!e[0].matrix&&!e[0].holes.length&&!(e[0].lineStyle.visible&&e[0].lineStyle.width)}_render(e){this.finishPoly();const t=this._geometry;t.updateBatches(),t.batchable?(this.batchDirty!==t.batchDirty&&this._populateBatches(),this._renderBatched(e)):(e.batch.flush(),this._renderDirect(e))}_populateBatches(){const e=this._geometry,t=this.blendMode,i=e.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=e.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(e.points);for(let n=0;n<i;n++){const s=e.batches[n],o=s.style.color,a=new Float32Array(this.vertexData.buffer,s.attribStart*4*2,s.attribSize*2),l=new Float32Array(e.uvsFloat32.buffer,s.attribStart*4*2,s.attribSize*2),h=new Uint16Array(e.indicesUint16.buffer,s.start*2,s.size),u={vertexData:a,blendMode:t,indices:h,uvs:l,_batchRGB:ut.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:s.style.texture,alpha:s.style.alpha,worldAlpha:1};this.batches[n]=u}}_renderBatched(e){if(this.batches.length){e.batch.setObjectRenderer(e.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let t=0,i=this.batches.length;t<i;t++){const n=this.batches[t];n.worldAlpha=this.worldAlpha*n.alpha,e.plugins[this.pluginName].render(n)}}}_renderDirect(e){const t=this._resolveDirectShader(e),i=this._geometry,n=this.worldAlpha,s=t.uniforms,o=i.drawCalls;s.translationMatrix=this.transform.worldTransform,ut.shared.setValue(this._tintColor).premultiply(n).toArray(s.tint),e.shader.bind(t),e.geometry.bind(i,t),e.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(e,i.drawCalls[a])}_renderDrawCallDirect(e,t){const{texArray:i,type:n,size:s,start:o}=t,a=i.count;for(let l=0;l<a;l++)e.texture.bind(i.elements[l],l);e.geometry.draw(n,s,o)}_resolveDirectShader(e){let t=this.shader;const i=this.pluginName;if(!t){if(!Qd[i]){const{maxTextures:n}=e.plugins[i],s=new Int32Array(n);for(let l=0;l<n;l++)s[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new pt,default:fr.from({uSamplers:s},!0)},a=e.plugins[i]._shader.program;Qd[i]=new Lr(a,o)}t=Qd[i]}return t}_calculateBounds(){this.finishPoly();const e=this._geometry;if(!e.graphicsData.length)return;const{minX:t,minY:i,maxX:n,maxY:s}=e.bounds;this._bounds.addFrame(this.transform,t,i,n,s)}containsPoint(e){return this.worldTransform.applyInverse(e,eu._TEMP_POINT),this._geometry.containsPoint(eu._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let e=0;e<this.batches.length;e++){const t=this.batches[e];t._tintRGB=ut.shared.setValue(this._tintColor).multiply(t._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const e=this.transform._worldID;if(this._transformID===e)return;this._transformID=e;const t=this.transform.worldTransform,i=t.a,n=t.b,s=t.c,o=t.d,a=t.tx,l=t.ty,h=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const f=h[d],g=h[d+1];u[c++]=i*f+s*g+a,u[c++]=o*g+n*f+l}}closePath(){const e=this.currentPath;return e&&(e.closeStroke=!0,this.finishPoly()),this}setMatrix(e){return this._matrix=e,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(e){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(e)}};Jd.curves=mo,Jd._TEMP_POINT=new nt;let Aa=Jd;class BC{constructor(e,t){this.uvBuffer=e,this.uvMatrix=t,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(e){if(!e&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const t=this.uvBuffer.data;(!this.data||this.data.length!==t.length)&&(this.data=new Float32Array(t.length)),this.uvMatrix.multiplyUvs(t,this.data),this._updateID++}}const $d=new nt,xy=new os,wy=class R_ extends pr{constructor(e,t,i,n=Rr.TRIANGLES){super(),this.geometry=e,this.shader=t,this.state=i||Or.for2d(),this.drawMode=n,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=ye.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(e){this._geometry!==e&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=e,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(e){this.shader=e}get material(){return this.shader}set blendMode(e){this.state.blendMode=e}get blendMode(){return this.state.blendMode}set roundPixels(e){this._roundPixels!==e&&(this._transformID=-1),this._roundPixels=e}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(e){this.shader.tint=e}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(e){this.shader.texture=e}_render(e){const t=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Rr.TRIANGLES&&t.length<R_.BATCHABLE_SIZE*2?this._renderToBatch(e):this._renderDefault(e)}_renderDefault(e){const t=this.shader;t.alpha=this.worldAlpha,t.update&&t.update(),e.batch.flush(),t.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),e.shader.bind(t),e.state.set(this.state),e.geometry.bind(this.geometry,t),e.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(e){const t=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=t.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const n=this.material.pluginName;e.batch.setObjectRenderer(e.plugins[n]),e.plugins[n].render(this)}calculateVertices(){const e=this.geometry.buffers[0],t=e.data,i=e._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==t.length&&(this.vertexData=new Float32Array(t.length));const n=this.transform.worldTransform,s=n.a,o=n.b,a=n.c,l=n.d,h=n.tx,u=n.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const f=t[d*2],g=t[d*2+1];c[d*2]=s*f+a*g+h,c[d*2+1]=o*f+l*g+u}if(this._roundPixels){const d=ye.RESOLUTION;for(let f=0;f<c.length;++f)c[f]=Math.round(c[f]*d)/d}this.vertexDirty=i}calculateUvs(){const e=this.geometry.buffers[1],t=this.shader;t.uvMatrix.isSimple?this.uvs=e.data:(this.batchUvs||(this.batchUvs=new BC(e,t.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(e){if(!this.getBounds().contains(e.x,e.y))return!1;this.worldTransform.applyInverse(e,$d);const t=this.geometry.getBuffer("aVertexPosition").data,i=xy.points,n=this.geometry.getIndex().data,s=n.length,o=this.drawMode===4?3:1;for(let a=0;a+2<s;a+=o){const l=n[a]*2,h=n[a+1]*2,u=n[a+2]*2;if(i[0]=t[l],i[1]=t[l+1],i[2]=t[h],i[3]=t[h+1],i[4]=t[u],i[5]=t[u+1],xy.contains($d.x,$d.y))return!0}return!1}destroy(e){super.destroy(e),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};wy.BATCHABLE_SIZE=100;let Ey=wy;class kC extends An{constructor(e,t,i){super();const n=new Mt(e),s=new Mt(t,!0),o=new Mt(i,!0,!0);this.addAttribute("aVertexPosition",n,2,!1,Re.FLOAT).addAttribute("aTextureCoord",s,2,!1,Re.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var UC=`varying vec2 vTextureCoord;
|
|
988
|
+
uniform vec4 uColor;
|
|
989
|
+
|
|
990
|
+
uniform sampler2D uSampler;
|
|
991
|
+
|
|
992
|
+
void main(void)
|
|
993
|
+
{
|
|
994
|
+
gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
|
|
995
|
+
}
|
|
996
|
+
`,HC=`attribute vec2 aVertexPosition;
|
|
997
|
+
attribute vec2 aTextureCoord;
|
|
998
|
+
|
|
999
|
+
uniform mat3 projectionMatrix;
|
|
1000
|
+
uniform mat3 translationMatrix;
|
|
1001
|
+
uniform mat3 uTextureMatrix;
|
|
1002
|
+
|
|
1003
|
+
varying vec2 vTextureCoord;
|
|
1004
|
+
|
|
1005
|
+
void main(void)
|
|
1006
|
+
{
|
|
1007
|
+
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
1008
|
+
|
|
1009
|
+
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
|
|
1010
|
+
}
|
|
1011
|
+
`;class Ty extends Lr{constructor(e,t){const i={uSampler:e,alpha:1,uTextureMatrix:pt.IDENTITY,uColor:new Float32Array([1,1,1,1])};t=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},t),t.uniforms&&Object.assign(i,t.uniforms),super(t.program||tn.from(HC,UC),i),this._colorDirty=!1,this.uvMatrix=new y0(e),this.batchable=t.program===void 0,this.pluginName=t.pluginName,this._tintColor=new ut(t.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=t.alpha}get texture(){return this.uniforms.uSampler}set texture(e){this.uniforms.uSampler!==e&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!e.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=e,this.uvMatrix.texture=e)}set alpha(e){e!==this._alpha&&(this._alpha=e,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(e){e!==this.tint&&(this._tintColor.setValue(e),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const e=this.texture.baseTexture.alphaMode;ut.shared.setValue(this._tintColor).premultiply(this._alpha,e).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class by{constructor(e,t,i){this.geometry=new An,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let n=0;n<e.length;++n){let s=e[n];s={attributeName:s.attributeName,size:s.size,uploadFunction:s.uploadFunction,type:s.type||Re.FLOAT,offset:s.offset},t[n]?this.dynamicProperties.push(s):this.staticProperties.push(s)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const e=this.geometry;let t=0;this.indexBuffer=new Mt(aA(this.size),!0,!0),e.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=t,t+=a.size,this.dynamicStride+=a.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new Mt(this.dynamicData,!1,!1);let n=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=n,n+=a.size,this.staticStride+=a.size}const s=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(s),this.staticDataUint32=new Uint32Array(s),this.staticBuffer=new Mt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];e.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===Re.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];e.addAttribute(a.attributeName,this.staticBuffer,0,a.type===Re.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(e,t,i){for(let n=0;n<this.dynamicProperties.length;n++){const s=this.dynamicProperties[n];s.uploadFunction(e,t,i,s.type===Re.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,s.offset)}this.dynamicBuffer._updateID++}uploadStatic(e,t,i){for(let n=0;n<this.staticProperties.length;n++){const s=this.staticProperties[n];s.uploadFunction(e,t,i,s.type===Re.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,s.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var GC=`varying vec2 vTextureCoord;
|
|
1012
|
+
varying vec4 vColor;
|
|
1013
|
+
|
|
1014
|
+
uniform sampler2D uSampler;
|
|
1015
|
+
|
|
1016
|
+
void main(void){
|
|
1017
|
+
vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
|
|
1018
|
+
gl_FragColor = color;
|
|
1019
|
+
}`,VC=`attribute vec2 aVertexPosition;
|
|
1020
|
+
attribute vec2 aTextureCoord;
|
|
1021
|
+
attribute vec4 aColor;
|
|
1022
|
+
|
|
1023
|
+
attribute vec2 aPositionCoord;
|
|
1024
|
+
attribute float aRotation;
|
|
1025
|
+
|
|
1026
|
+
uniform mat3 translationMatrix;
|
|
1027
|
+
uniform vec4 uColor;
|
|
1028
|
+
|
|
1029
|
+
varying vec2 vTextureCoord;
|
|
1030
|
+
varying vec4 vColor;
|
|
1031
|
+
|
|
1032
|
+
void main(void){
|
|
1033
|
+
float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
|
|
1034
|
+
float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
|
|
1035
|
+
|
|
1036
|
+
vec2 v = vec2(x, y);
|
|
1037
|
+
v = v + aPositionCoord;
|
|
1038
|
+
|
|
1039
|
+
gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
|
1040
|
+
|
|
1041
|
+
vTextureCoord = aTextureCoord;
|
|
1042
|
+
vColor = aColor * uColor;
|
|
1043
|
+
}
|
|
1044
|
+
`;class Ay extends ph{constructor(e){super(e),this.shader=null,this.properties=null,this.tempMatrix=new pt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:Re.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Lr.from(VC,GC,{}),this.state=Or.for2d()}render(e){const t=e.children,i=e._maxSize,n=e._batchSize,s=this.renderer;let o=t.length;if(o===0)return;o>i&&!e.autoResize&&(o=i);let a=e._buffers;a||(a=e._buffers=this.generateBuffers(e));const l=t[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=Hv(e.blendMode,h),s.state.set(this.state);const u=s.gl,c=e.worldTransform.copyTo(this.tempMatrix);c.prepend(s.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=ut.shared.setValue(e.tintRgb).premultiply(e.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,g=0;f<o;f+=n,g+=1){let p=o-f;p>n&&(p=n),g>=a.length&&a.push(this._generateOneMoreBuffer(e));const m=a[g];m.uploadDynamic(t,f,p);const v=e._bufferUpdateIDs[g]||0;d=d||m._updateID<v,d&&(m._updateID=e._updateID,m.uploadStatic(t,f,p)),s.geometry.bind(m.geometry),u.drawElements(u.TRIANGLES,p*6,u.UNSIGNED_SHORT,0)}}generateBuffers(e){const t=[],i=e._maxSize,n=e._batchSize,s=e._properties;for(let o=0;o<i;o+=n)t.push(new by(this.properties,s,n));return t}_generateOneMoreBuffer(e){const t=e._batchSize,i=e._properties;return new by(this.properties,i,t)}uploadVertices(e,t,i,n,s,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=e[t+c],f=d._texture,g=d.scale.x,p=d.scale.y,m=f.trim,v=f.orig;m?(l=m.x-d.anchor.x*v.width,a=l+m.width,u=m.y-d.anchor.y*v.height,h=u+m.height):(a=v.width*(1-d.anchor.x),l=v.width*-d.anchor.x,h=v.height*(1-d.anchor.y),u=v.height*-d.anchor.y),n[o]=l*g,n[o+1]=u*p,n[o+s]=a*g,n[o+s+1]=u*p,n[o+s*2]=a*g,n[o+s*2+1]=h*p,n[o+s*3]=l*g,n[o+s*3+1]=h*p,o+=s*4}}uploadPosition(e,t,i,n,s,o){for(let a=0;a<i;a++){const l=e[t+a].position;n[o]=l.x,n[o+1]=l.y,n[o+s]=l.x,n[o+s+1]=l.y,n[o+s*2]=l.x,n[o+s*2+1]=l.y,n[o+s*3]=l.x,n[o+s*3+1]=l.y,o+=s*4}}uploadRotation(e,t,i,n,s,o){for(let a=0;a<i;a++){const l=e[t+a].rotation;n[o]=l,n[o+s]=l,n[o+s*2]=l,n[o+s*3]=l,o+=s*4}}uploadUvs(e,t,i,n,s,o){for(let a=0;a<i;++a){const l=e[t+a]._texture._uvs;l?(n[o]=l.x0,n[o+1]=l.y0,n[o+s]=l.x1,n[o+s+1]=l.y1,n[o+s*2]=l.x2,n[o+s*2+1]=l.y2,n[o+s*3]=l.x3,n[o+s*3+1]=l.y3,o+=s*4):(n[o]=0,n[o+1]=0,n[o+s]=0,n[o+s+1]=0,n[o+s*2]=0,n[o+s*2+1]=0,n[o+s*3]=0,n[o+s*3+1]=0,o+=s*4)}}uploadTint(e,t,i,n,s,o){for(let a=0;a<i;++a){const l=e[t+a],h=ut.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);n[o]=h,n[o+s]=h,n[o+s*2]=h,n[o+s*3]=h,o+=s*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Ay.extension={name:"particle",type:ge.RendererPlugin},Ee.add(Ay);var kh=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(kh||{});const Uh={willReadFrequently:!0},Fr=class Ae{static get experimentalLetterSpacingSupported(){let e=Ae._experimentalLetterSpacingSupported;if(e!==void 0){const t=ye.ADAPTER.getCanvasRenderingContext2D().prototype;e=Ae._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,i,n,s,o,a,l,h){this.text=e,this.style=t,this.width=i,this.height=n,this.lines=s,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(e,t,i,n=Ae._canvas){i=i??t.wordWrap;const s=t.toFontString(),o=Ae.measureFont(s);o.fontSize===0&&(o.fontSize=t.fontSize,o.ascent=t.fontSize);const a=n.getContext("2d",Uh);a.font=s;const l=(i?Ae.wordWrap(e,t,n):e).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let g=0;g<l.length;g++){const p=Ae._measureText(l[g],t.letterSpacing,a);h[g]=p,u=Math.max(u,p)}let c=u+t.strokeThickness;t.dropShadow&&(c+=t.dropShadowDistance);const d=t.lineHeight||o.fontSize+t.strokeThickness;let f=Math.max(d,o.fontSize+t.strokeThickness*2)+t.leading+(l.length-1)*(d+t.leading);return t.dropShadow&&(f+=t.dropShadowDistance),new Ae(e,t,c,f,l,h,d+t.leading,u,o)}static _measureText(e,t,i){let n=!1;Ae.experimentalLetterSpacingSupported&&(Ae.experimentalLetterSpacing?(i.letterSpacing=`${t}px`,i.textLetterSpacing=`${t}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let s=i.measureText(e).width;return s>0&&(n?s-=t:s+=(Ae.graphemeSegmenter(e).length-1)*t),s}static wordWrap(e,t,i=Ae._canvas){const n=i.getContext("2d",Uh);let s=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=t,c=Ae.collapseSpaces(u),d=Ae.collapseNewlines(u);let f=!c;const g=t.wordWrapWidth+h,p=Ae.tokenize(e);for(let m=0;m<p.length;m++){let v=p[m];if(Ae.isNewline(v)){if(!d){a+=Ae.addLine(o),f=!c,o="",s=0;continue}v=" "}if(c){const _=Ae.isBreakingSpace(v),w=Ae.isBreakingSpace(o[o.length-1]);if(_&&w)continue}const y=Ae.getFromCache(v,h,l,n);if(y>g)if(o!==""&&(a+=Ae.addLine(o),o="",s=0),Ae.canBreakWords(v,t.breakWords)){const _=Ae.wordWrapSplit(v);for(let w=0;w<_.length;w++){let A=_[w],F=A,C=1;for(;_[w+C];){const M=_[w+C];if(!Ae.canBreakChars(F,M,v,w,t.breakWords))A+=M;else break;F=M,C++}w+=C-1;const R=Ae.getFromCache(A,h,l,n);R+s>g&&(a+=Ae.addLine(o),f=!1,o="",s=0),o+=A,s+=R}}else{o.length>0&&(a+=Ae.addLine(o),o="",s=0);const _=m===p.length-1;a+=Ae.addLine(v,!_),f=!1,o="",s=0}else y+s>g&&(f=!1,a+=Ae.addLine(o),o="",s=0),(o.length>0||!Ae.isBreakingSpace(v)||f)&&(o+=v,s+=y)}return a+=Ae.addLine(o,!1),a}static addLine(e,t=!0){return e=Ae.trimRight(e),e=t?`${e}
|
|
1045
|
+
`:e,e}static getFromCache(e,t,i,n){let s=i[e];return typeof s!="number"&&(s=Ae._measureText(e,t,n)+t,i[e]=s),s}static collapseSpaces(e){return e==="normal"||e==="pre-line"}static collapseNewlines(e){return e==="normal"}static trimRight(e){if(typeof e!="string")return"";for(let t=e.length-1;t>=0;t--){const i=e[t];if(!Ae.isBreakingSpace(i))break;e=e.slice(0,-1)}return e}static isNewline(e){return typeof e!="string"?!1:Ae._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,t){return typeof e!="string"?!1:Ae._breakingSpaces.includes(e.charCodeAt(0))}static tokenize(e){const t=[];let i="";if(typeof e!="string")return t;for(let n=0;n<e.length;n++){const s=e[n],o=e[n+1];if(Ae.isBreakingSpace(s,o)||Ae.isNewline(s)){i!==""&&(t.push(i),i=""),t.push(s);continue}i+=s}return i!==""&&t.push(i),t}static canBreakWords(e,t){return t}static canBreakChars(e,t,i,n,s){return!0}static wordWrapSplit(e){return Ae.graphemeSegmenter(e)}static measureFont(e){if(Ae._fonts[e])return Ae._fonts[e];const t={ascent:0,descent:0,fontSize:0},i=Ae._canvas,n=Ae._context;n.font=e;const s=Ae.METRICS_STRING+Ae.BASELINE_SYMBOL,o=Math.ceil(n.measureText(s).width);let a=Math.ceil(n.measureText(Ae.BASELINE_SYMBOL).width);const l=Math.ceil(Ae.HEIGHT_MULTIPLIER*a);if(a=a*Ae.BASELINE_MULTIPLIER|0,o===0||l===0)return Ae._fonts[e]=t,t;i.width=o,i.height=l,n.fillStyle="#f00",n.fillRect(0,0,o,l),n.font=e,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(s,0,a);const h=n.getImageData(0,0,o,l).data,u=h.length,c=o*4;let d=0,f=0,g=!1;for(d=0;d<a;++d){for(let p=0;p<c;p+=4)if(h[f+p]!==255){g=!0;break}if(!g)f+=c;else break}for(t.ascent=a-d,f=u-c,g=!1,d=l;d>a;--d){for(let p=0;p<c;p+=4)if(h[f+p]!==255){g=!0;break}if(!g)f-=c;else break}return t.descent=d-a,t.fontSize=t.ascent+t.descent,Ae._fonts[e]=t,t}static clearMetrics(e=""){e?delete Ae._fonts[e]:Ae._fonts={}}static get _canvas(){var e;if(!Ae.__canvas){let t;try{const i=new OffscreenCanvas(0,0);if((e=i.getContext("2d",Uh))!=null&&e.measureText)return Ae.__canvas=i,i;t=ye.ADAPTER.createCanvas()}catch{t=ye.ADAPTER.createCanvas()}t.width=t.height=10,Ae.__canvas=t}return Ae.__canvas}static get _context(){return Ae.__context||(Ae.__context=Ae._canvas.getContext("2d",Uh)),Ae.__context}};Fr.METRICS_STRING="|ÉqÅ",Fr.BASELINE_SYMBOL="M",Fr.BASELINE_MULTIPLIER=1.4,Fr.HEIGHT_MULTIPLIER=2,Fr.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return e=>[...r.segment(e)].map(t=>t.segment)}return r=>[...r]})(),Fr.experimentalLetterSpacing=!1,Fr._fonts={},Fr._newlines=[10,13],Fr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Pn=Fr;const zC=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Sy=class Qa{constructor(e){this.styleID=0,this.reset(),tf(this,e,e)}clone(){const e={};return tf(e,this,Qa.defaultStyle),new Qa(e)}reset(){tf(this,Qa.defaultStyle,Qa.defaultStyle)}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(this._dropShadow=e,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(e){this._dropShadowAlpha!==e&&(this._dropShadowAlpha=e,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(e){this._dropShadowAngle!==e&&(this._dropShadowAngle=e,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(e){this._dropShadowBlur!==e&&(this._dropShadowBlur=e,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(e){const t=ef(e);this._dropShadowColor!==t&&(this._dropShadowColor=t,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(e){this._dropShadowDistance!==e&&(this._dropShadowDistance=e,this.styleID++)}get fill(){return this._fill}set fill(e){const t=ef(e);this._fill!==t&&(this._fill=t,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(e){this._fillGradientType!==e&&(this._fillGradientType=e,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(e){jC(this._fillGradientStops,e)||(this._fillGradientStops=e,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(e){this.fontFamily!==e&&(this._fontFamily=e,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.styleID++)}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(e){this._lineJoin!==e&&(this._lineJoin=e,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(e){this._miterLimit!==e&&(this._miterLimit=e,this.styleID++)}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.styleID++)}get stroke(){return this._stroke}set stroke(e){const t=ef(e);this._stroke!==t&&(this._stroke=t,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(e){this._strokeThickness!==e&&(this._strokeThickness=e,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.styleID++)}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.styleID++)}toFontString(){const e=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let t=this.fontFamily;Array.isArray(this.fontFamily)||(t=this.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let n=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!zC.includes(n)&&(n=`"${n}"`),t[i]=n}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${e} ${t.join(",")}`}};Sy.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:kh.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let In=Sy;function ef(r){const e=ut.shared,t=i=>{const n=e.setValue(i);return n.alpha===1?n.toHex():n.toRgbaString()};return Array.isArray(r)?r.map(t):t(r)}function jC(r,e){if(!Array.isArray(r)||!Array.isArray(e)||r.length!==e.length)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}function tf(r,e,t){for(const i in t)Array.isArray(e[i])?r[i]=e[i].slice():r[i]=e[i]}const WC={texture:!0,children:!1,baseTexture:!0},Ry=class bf extends ho{constructor(e,t,i){let n=!1;i||(i=ye.ADAPTER.createCanvas(),n=!0),i.width=3,i.height=3;const s=Te.from(i);s.orig=new We,s.trim=new We,super(s),this._ownCanvas=n,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=bf.defaultResolution??ye.RESOLUTION,this._autoResolution=bf.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=e,this.style=t,this.localStyleID=-1}static get experimentalLetterSpacing(){return Pn.experimentalLetterSpacing}static set experimentalLetterSpacing(e){Je("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Pn.experimentalLetterSpacing=e}updateText(e){const t=this._style;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;this._font=this._style.toFontString();const i=this.context,n=Pn.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),s=n.width,o=n.height,a=n.lines,l=n.lineHeight,h=n.lineWidths,u=n.maxLineWidth,c=n.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,s)+t.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+t.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=t.strokeThickness,i.textBaseline=t.textBaseline,i.lineJoin=t.lineJoin,i.miterLimit=t.miterLimit;let d,f;const g=t.dropShadow?2:1;for(let p=0;p<g;++p){const m=t.dropShadow&&p===0,v=m?Math.ceil(Math.max(1,o)+t.padding*2):0,y=v*this._resolution;if(m){i.fillStyle="black",i.strokeStyle="black";const w=t.dropShadowColor,A=t.dropShadowBlur*this._resolution,F=t.dropShadowDistance*this._resolution;i.shadowColor=ut.shared.setValue(w).setAlpha(t.dropShadowAlpha).toRgbaString(),i.shadowBlur=A,i.shadowOffsetX=Math.cos(t.dropShadowAngle)*F,i.shadowOffsetY=Math.sin(t.dropShadowAngle)*F+y}else i.fillStyle=this._generateFillStyle(t,a,n),i.strokeStyle=t.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let _=(l-c.fontSize)/2;l-c.fontSize<0&&(_=0);for(let w=0;w<a.length;w++)d=t.strokeThickness/2,f=t.strokeThickness/2+w*l+c.ascent+_,t.align==="right"?d+=u-h[w]:t.align==="center"&&(d+=(u-h[w])/2),t.stroke&&t.strokeThickness&&this.drawLetterSpacing(a[w],d+t.padding,f+t.padding-v,!0),t.fill&&this.drawLetterSpacing(a[w],d+t.padding,f+t.padding-v)}this.updateTexture()}drawLetterSpacing(e,t,i,n=!1){const s=this._style.letterSpacing;let o=!1;if(Pn.experimentalLetterSpacingSupported&&(Pn.experimentalLetterSpacing?(this.context.letterSpacing=`${s}px`,this.context.textLetterSpacing=`${s}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),s===0||o){n?this.context.strokeText(e,t,i):this.context.fillText(e,t,i);return}let a=t;const l=Pn.graphemeSegmenter(e);let h=this.context.measureText(e).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];n?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let g=c+1;g<l.length;++g)f+=l[g];u=this.context.measureText(f).width,a+=h-u+s,h=u}}updateTexture(){const e=this.canvas;if(this._style.trim){const o=cA(e);o.data&&(e.width=o.width,e.height=o.height,this.context.putImageData(o.data,0,0))}const t=this._texture,i=this._style,n=i.trim?0:i.padding,s=t.baseTexture;t.trim.width=t._frame.width=e.width/this._resolution,t.trim.height=t._frame.height=e.height/this._resolution,t.trim.x=-n,t.trim.y=-n,t.orig.width=t._frame.width-n*2,t.orig.height=t._frame.height-n*2,this._onTextureUpdate(),s.setRealSize(e.width,e.height,this._resolution),t.updateUvs(),this.dirty=!1}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._render(e)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(e,t){return this.updateText(!0),this._textureID===-1&&(e=!1),super.getBounds(e,t)}getLocalBounds(e){return this.updateText(!0),super.getLocalBounds.call(this,e)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(e,t,i){const n=e.fill;if(Array.isArray(n)){if(n.length===1)return n[0]}else return n;let s;const o=e.dropShadow?e.dropShadowDistance:0,a=e.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,u=n.slice(),c=e.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let f=1;f<d;++f)c.push(f/d)}if(u.unshift(n[0]),c.unshift(0),u.push(n[n.length-1]),c.push(1),e.fillGradientType===kh.LINEAR_VERTICAL){s=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+e.strokeThickness;for(let f=0;f<t.length;f++){const g=i.lineHeight*(f-1)+d,p=i.lineHeight*f;let m=p;f>0&&g>p&&(m=(p+g)/2);const v=p+d,y=i.lineHeight*(f+1);let _=v;f+1<t.length&&y<v&&(_=(v+y)/2);const w=(_-m)/h;for(let A=0;A<u.length;A++){let F=0;typeof c[A]=="number"?F=c[A]:F=A/u.length;let C=Math.min(1,Math.max(0,m/h+F*w));C=Number(C.toFixed(5)),s.addColorStop(C,u[A])}}}else{s=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let f=1;for(let g=0;g<u.length;g++){let p;typeof c[g]=="number"?p=c[g]:p=f/d,s.addColorStop(p,u[g]),f++}}return s}destroy(e){typeof e=="boolean"&&(e={children:e}),e=Object.assign({},WC,e),super.destroy(e),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this.updateText(!0);const t=Tn(this.scale.x)||1;this.scale.x=t*e/this._texture.orig.width,this._width=e}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this.updateText(!0);const t=Tn(this.scale.y)||1;this.scale.y=t*e/this._texture.orig.height,this._height=e}get style(){return this._style}set style(e){e=e||{},e instanceof In?this._style=e:this._style=new In(e),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}};Ry.defaultAutoResolution=!0;let Cy=Ry;class XC{constructor(e){this.maxItemsPerFrame=e,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function YC(r,e){var t;let i=!1;if((t=r==null?void 0:r._textures)!=null&&t.length){for(let n=0;n<r._textures.length;n++)if(r._textures[n]instanceof Te){const s=r._textures[n].baseTexture;e.includes(s)||(e.push(s),i=!0)}}return i}function ZC(r,e){if(r.baseTexture instanceof ze){const t=r.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function qC(r,e){if(r._texture&&r._texture instanceof Te){const t=r._texture.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function KC(r,e){return e instanceof Cy?(e.updateText(!0),!0):!1}function QC(r,e){if(e instanceof In){const t=e.toFontString();return Pn.measureFont(t),!0}return!1}function JC(r,e){if(r instanceof Cy){e.includes(r.style)||e.push(r.style),e.includes(r)||e.push(r);const t=r._texture.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function $C(r,e){return r instanceof In?(e.includes(r)||e.push(r),!0):!1}const Py=class C_{constructor(e){this.limiter=new XC(C_.uploadsPerFrame),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(JC),this.registerFindHook($C),this.registerFindHook(YC),this.registerFindHook(ZC),this.registerFindHook(qC),this.registerUploadHook(KC),this.registerUploadHook(QC)}upload(e){return new Promise(t=>{e&&this.add(e),this.queue.length?(this.completes.push(t),this.ticking||(this.ticking=!0,Li.system.addOnce(this.tick,this,gs.UTILITY))):t()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const e=this.queue[0];let t=!1;if(e&&!e._destroyed){for(let i=0,n=this.uploadHooks.length;i<n;i++)if(this.uploadHooks[i](this.uploadHookHelper,e)){this.queue.shift(),t=!0;break}}t||this.queue.shift()}if(this.queue.length)Li.system.addOnce(this.tick,this,gs.UTILITY);else{this.ticking=!1;const e=this.completes.slice(0);this.completes.length=0;for(let t=0,i=e.length;t<i;t++)e[t]()}}registerFindHook(e){return e&&this.addHooks.push(e),this}registerUploadHook(e){return e&&this.uploadHooks.push(e),this}add(e){for(let t=0,i=this.addHooks.length;t<i&&!this.addHooks[t](e,this.queue);t++);if(e instanceof pr)for(let t=e.children.length-1;t>=0;t--)this.add(e.children[t]);return this}destroy(){this.ticking&&Li.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Py.uploadsPerFrame=4;let rf=Py;Object.defineProperties(ye,{UPLOADS_PER_FRAME:{get(){return rf.uploadsPerFrame},set(r){Je("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),rf.uploadsPerFrame=r}}});function Iy(r,e){return e instanceof ze?(e._glTextures[r.CONTEXT_UID]||r.texture.bind(e),!0):!1}function eP(r,e){if(!(e instanceof Aa))return!1;const{geometry:t}=e;e.finishPoly(),t.updateBatches();const{batches:i}=t;for(let n=0;n<i.length;n++){const{texture:s}=i[n].style;s&&Iy(r,s.baseTexture)}return t.batchable||r.geometry.bind(t,e._resolveDirectShader(r)),!0}function tP(r,e){return r instanceof Aa?(e.push(r),!0):!1}class My extends rf{constructor(e){super(e),this.uploadHookHelper=this.renderer,this.registerFindHook(tP),this.registerUploadHook(Iy),this.registerUploadHook(eP)}}My.extension={name:"prepare",type:ge.RendererSystem},Ee.add(My);var iP=`#version 300 es
|
|
1046
|
+
#define SHADER_NAME Tiling-Sprite-100
|
|
1047
|
+
|
|
1048
|
+
precision lowp float;
|
|
1049
|
+
|
|
1050
|
+
in vec2 vTextureCoord;
|
|
1051
|
+
|
|
1052
|
+
out vec4 fragmentColor;
|
|
1053
|
+
|
|
1054
|
+
uniform sampler2D uSampler;
|
|
1055
|
+
uniform vec4 uColor;
|
|
1056
|
+
uniform mat3 uMapCoord;
|
|
1057
|
+
uniform vec4 uClampFrame;
|
|
1058
|
+
uniform vec2 uClampOffset;
|
|
1059
|
+
|
|
1060
|
+
void main(void)
|
|
1061
|
+
{
|
|
1062
|
+
vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
|
|
1063
|
+
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
1064
|
+
vec2 unclamped = coord;
|
|
1065
|
+
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
1066
|
+
|
|
1067
|
+
vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
|
|
1068
|
+
|
|
1069
|
+
fragmentColor = texSample * uColor;
|
|
1070
|
+
}
|
|
1071
|
+
`,rP=`#version 300 es
|
|
1072
|
+
#define SHADER_NAME Tiling-Sprite-300
|
|
1073
|
+
|
|
1074
|
+
precision lowp float;
|
|
1075
|
+
|
|
1076
|
+
in vec2 aVertexPosition;
|
|
1077
|
+
in vec2 aTextureCoord;
|
|
1078
|
+
|
|
1079
|
+
uniform mat3 projectionMatrix;
|
|
1080
|
+
uniform mat3 translationMatrix;
|
|
1081
|
+
uniform mat3 uTransform;
|
|
1082
|
+
|
|
1083
|
+
out vec2 vTextureCoord;
|
|
1084
|
+
|
|
1085
|
+
void main(void)
|
|
1086
|
+
{
|
|
1087
|
+
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
1088
|
+
|
|
1089
|
+
vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
|
|
1090
|
+
}
|
|
1091
|
+
`,nP=`#version 100
|
|
1092
|
+
#ifdef GL_EXT_shader_texture_lod
|
|
1093
|
+
#extension GL_EXT_shader_texture_lod : enable
|
|
1094
|
+
#endif
|
|
1095
|
+
#define SHADER_NAME Tiling-Sprite-100
|
|
1096
|
+
|
|
1097
|
+
precision lowp float;
|
|
1098
|
+
|
|
1099
|
+
varying vec2 vTextureCoord;
|
|
1100
|
+
|
|
1101
|
+
uniform sampler2D uSampler;
|
|
1102
|
+
uniform vec4 uColor;
|
|
1103
|
+
uniform mat3 uMapCoord;
|
|
1104
|
+
uniform vec4 uClampFrame;
|
|
1105
|
+
uniform vec2 uClampOffset;
|
|
1106
|
+
|
|
1107
|
+
void main(void)
|
|
1108
|
+
{
|
|
1109
|
+
vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
|
|
1110
|
+
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
1111
|
+
vec2 unclamped = coord;
|
|
1112
|
+
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
1113
|
+
|
|
1114
|
+
#ifdef GL_EXT_shader_texture_lod
|
|
1115
|
+
vec4 texSample = unclamped == coord
|
|
1116
|
+
? texture2D(uSampler, coord)
|
|
1117
|
+
: texture2DLodEXT(uSampler, coord, 0);
|
|
1118
|
+
#else
|
|
1119
|
+
vec4 texSample = texture2D(uSampler, coord);
|
|
1120
|
+
#endif
|
|
1121
|
+
|
|
1122
|
+
gl_FragColor = texSample * uColor;
|
|
1123
|
+
}
|
|
1124
|
+
`,Dy=`#version 100
|
|
1125
|
+
#define SHADER_NAME Tiling-Sprite-100
|
|
1126
|
+
|
|
1127
|
+
precision lowp float;
|
|
1128
|
+
|
|
1129
|
+
attribute vec2 aVertexPosition;
|
|
1130
|
+
attribute vec2 aTextureCoord;
|
|
1131
|
+
|
|
1132
|
+
uniform mat3 projectionMatrix;
|
|
1133
|
+
uniform mat3 translationMatrix;
|
|
1134
|
+
uniform mat3 uTransform;
|
|
1135
|
+
|
|
1136
|
+
varying vec2 vTextureCoord;
|
|
1137
|
+
|
|
1138
|
+
void main(void)
|
|
1139
|
+
{
|
|
1140
|
+
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
1141
|
+
|
|
1142
|
+
vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
|
|
1143
|
+
}
|
|
1144
|
+
`,sP=`#version 100
|
|
1145
|
+
#define SHADER_NAME Tiling-Sprite-Simple-100
|
|
1146
|
+
|
|
1147
|
+
precision lowp float;
|
|
1148
|
+
|
|
1149
|
+
varying vec2 vTextureCoord;
|
|
1150
|
+
|
|
1151
|
+
uniform sampler2D uSampler;
|
|
1152
|
+
uniform vec4 uColor;
|
|
1153
|
+
|
|
1154
|
+
void main(void)
|
|
1155
|
+
{
|
|
1156
|
+
vec4 texSample = texture2D(uSampler, vTextureCoord);
|
|
1157
|
+
gl_FragColor = texSample * uColor;
|
|
1158
|
+
}
|
|
1159
|
+
`;const Hh=new pt;class Oy extends ph{constructor(e){super(e),e.runners.contextChange.add(this),this.quad=new f0,this.state=Or.for2d()}contextChange(){const e=this.renderer,t={globals:e.globalUniforms};this.simpleShader=Lr.from(Dy,sP,t),this.shader=e.context.webGLVersion>1?Lr.from(rP,iP,t):Lr.from(Dy,nP,t)}render(e){const t=this.renderer,i=this.quad;let n=i.vertices;n[0]=n[6]=e._width*-e.anchor.x,n[1]=n[3]=e._height*-e.anchor.y,n[2]=n[4]=e._width*(1-e.anchor.x),n[5]=n[7]=e._height*(1-e.anchor.y);const s=e.uvRespectAnchor?e.anchor.x:0,o=e.uvRespectAnchor?e.anchor.y:0;n=i.uvs,n[0]=n[6]=-s,n[1]=n[3]=-o,n[2]=n[4]=1-s,n[5]=n[7]=1-o,i.invalidate();const a=e._texture,l=a.baseTexture,h=l.alphaMode>0,u=e.tileTransform.localTransform,c=e.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[t.CONTEXT_UID]?d=l.wrapMode!==En.CLAMP:l.wrapMode===En.CLAMP&&(l.wrapMode=En.REPEAT));const f=d?this.simpleShader:this.shader,g=a.width,p=a.height,m=e._width,v=e._height;Hh.set(u.a*g/m,u.b*g/v,u.c*p/m,u.d*p/v,u.tx/m,u.ty/v),Hh.invert(),d?Hh.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=Hh.toArray(!0),f.uniforms.uColor=ut.shared.setValue(e.tint).premultiply(e.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=e.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,t.shader.bind(f),t.geometry.bind(i),this.state.blendMode=Hv(e.blendMode,h),t.state.set(this.state),t.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Oy.extension={name:"tilingSprite",type:ge.RendererPlugin},Ee.add(Oy);const Ly=class Ja{constructor(e,t,i){this.linkedSheets=[],(e instanceof ze||e instanceof Te)&&(e={texture:e,data:t,resolutionFilename:i});const{texture:n,data:s,resolutionFilename:o=null,cachePrefix:a=""}=e;this.cachePrefix=a,this._texture=n instanceof Te?n:null,this.baseTexture=n instanceof ze?n:this._texture.baseTexture,this.textures={},this.animations={},this.data=s;const l=this.baseTexture.resource;this.resolution=this._updateResolution(o||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(e=null){const{scale:t}=this.data.meta;let i=$r(e,null);return i===null&&(i=typeof t=="number"?t:parseFloat(t??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Ja.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let t=e;const i=Ja.BATCH_SIZE;for(;t-e<i&&t<this._frameKeys.length;){const n=this._frameKeys[t],s=this._frames[n],o=s.frame;if(o){let a=null,l=null;const h=s.trimmed!==!1&&s.sourceSize?s.sourceSize:s.frame,u=new We(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);s.rotated?a=new We(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new We(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),s.trimmed!==!1&&s.spriteSourceSize&&(l=new We(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[n]=new Te(this.baseTexture,a,u,l,s.rotated?2:0,s.anchor,s.borders),Te.addToCache(this.textures[n],this.cachePrefix+n.toString())}t++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let i=0;i<e[t].length;i++){const n=e[t][i];this.animations[t].push(this.textures[n])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Ja.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ja.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((t=this._texture)==null||t.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};Ly.BATCH_SIZE=1e3;let Ny=Ly;const oP=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function Fy(r,e,t){const i={};if(r.forEach(n=>{i[n]=e}),Object.keys(e.textures).forEach(n=>{i[`${e.cachePrefix}${n}`]=e.textures[n]}),!t){const n=Zt.dirname(r[0]);e.linkedSheets.forEach((s,o)=>{Object.assign(i,Fy([`${n}/${e.data.meta.related_multi_packs[o]}`],s,!0))})}return i}const aP={extension:ge.Asset,cache:{test:r=>r instanceof Ny,getCacheableAssets:(r,e)=>Fy(r,e,!1)},resolver:{test:r=>{const e=r.split("?")[0].split("."),t=e.pop(),i=e.pop();return t==="json"&&oP.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=ye.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:ge.LoadParser,priority:vr.Normal},async testParse(r,e){return Zt.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){var i,n;const{texture:s,imageFilename:o,cachePrefix:a}=(e==null?void 0:e.data)??{};let l=Zt.dirname(e.src);l&&l.lastIndexOf("/")!==l.length-1&&(l+="/");let h;if(s&&s.baseTexture)h=s;else{const d=Gd(l+(o??r.meta.image),e.src);h=(await t.load([d]))[d]}const u=new Ny({texture:h.baseTexture,data:r,resolutionFilename:e.src,cachePrefix:a});await u.parse();const c=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(c)){const d=[];for(const g of c){if(typeof g!="string")continue;let p=l+g;(n=e.data)!=null&&n.ignoreMultiPack||(p=Gd(p,e.src),d.push(t.load({src:p,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);u.linkedSheets=f,f.forEach(g=>{g.linkedSheets=[u].concat(u.linkedSheets.filter(p=>p!==g))})}return u},unload(r){r.destroy(!0)}}};Ee.add(aP);class Gh{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Vh{static test(e){return typeof e=="string"&&e.startsWith("info face=")}static parse(e){const t=e.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const s in t){const o=t[s].match(/^[a-z]+/gm)[0],a=t[s].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const u=a[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),f=parseFloat(d),g=isNaN(f)?d:f;l[c]=g}i[o].push(l)}const n=new Gh;return i.info.forEach(s=>n.info.push({face:s.face,size:parseInt(s.size,10)})),i.common.forEach(s=>n.common.push({lineHeight:parseInt(s.lineHeight,10)})),i.page.forEach(s=>n.page.push({id:parseInt(s.id,10),file:s.file})),i.char.forEach(s=>n.char.push({id:parseInt(s.id,10),page:parseInt(s.page,10),x:parseInt(s.x,10),y:parseInt(s.y,10),width:parseInt(s.width,10),height:parseInt(s.height,10),xoffset:parseInt(s.xoffset,10),yoffset:parseInt(s.yoffset,10),xadvance:parseInt(s.xadvance,10)})),i.kerning.forEach(s=>n.kerning.push({first:parseInt(s.first,10),second:parseInt(s.second,10),amount:parseInt(s.amount,10)})),i.distanceField.forEach(s=>n.distanceField.push({distanceRange:parseInt(s.distanceRange,10),fieldType:s.fieldType})),n}}class nf{static test(e){const t=e;return typeof e!="string"&&"getElementsByTagName"in e&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(e){const t=new Gh,i=e.getElementsByTagName("info"),n=e.getElementsByTagName("common"),s=e.getElementsByTagName("page"),o=e.getElementsByTagName("char"),a=e.getElementsByTagName("kerning"),l=e.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)t.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<n.length;h++)t.common.push({lineHeight:parseInt(n[h].getAttribute("lineHeight"),10)});for(let h=0;h<s.length;h++)t.page.push({id:parseInt(s[h].getAttribute("id"),10)||0,file:s[h].getAttribute("file")});for(let h=0;h<o.length;h++){const u=o[h];t.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)t.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)t.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return t}}class sf{static test(e){return typeof e=="string"&&e.includes("<font>")?nf.test(ye.ADAPTER.parseXML(e)):!1}static parse(e){return nf.parse(ye.ADAPTER.parseXML(e))}}const of=[Vh,nf,sf];function lP(r){for(let e=0;e<of.length;e++)if(of[e].test(r))return of[e];return null}function hP(r,e,t,i,n,s){const o=t.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=t.dropShadow?t.dropShadowDistance:0,h=t.padding||0,u=r.width/i-l-h*2,c=r.height/i-l-h*2,d=o.slice(),f=t.fillGradientStops.slice();if(!f.length){const g=d.length+1;for(let p=1;p<g;++p)f.push(p/g)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),t.fillGradientType===kh.LINEAR_VERTICAL){a=e.createLinearGradient(u/2,h,u/2,c+h);let g=0;const p=(s.fontProperties.fontSize+t.strokeThickness)/c;for(let m=0;m<n.length;m++){const v=s.lineHeight*m;for(let y=0;y<d.length;y++){let _=0;typeof f[y]=="number"?_=f[y]:_=y/d.length;const w=v/c+_*p;let A=Math.max(g,w);A=Math.min(A,1),a.addColorStop(A,d[y]),g=A}}}else{a=e.createLinearGradient(h,c/2,u+h,c/2);const g=d.length+1;let p=1;for(let m=0;m<d.length;m++){let v;typeof f[m]=="number"?v=f[m]:v=p/g,a.addColorStop(v,d[m]),p++}}return a}function uP(r,e,t,i,n,s,o){const a=t.text,l=t.fontProperties;e.translate(i,n),e.scale(s,s);const h=o.strokeThickness/2,u=-(o.strokeThickness/2);if(e.font=o.toFontString(),e.lineWidth=o.strokeThickness,e.textBaseline=o.textBaseline,e.lineJoin=o.lineJoin,e.miterLimit=o.miterLimit,e.fillStyle=hP(r,e,o,s,[a],t),e.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*s,f=o.dropShadowDistance*s;e.shadowColor=ut.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),e.shadowBlur=d,e.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,e.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0;o.stroke&&o.strokeThickness&&e.strokeText(a,h,u+t.lineHeight-l.descent),o.fill&&e.fillText(a,h,u+t.lineHeight-l.descent),e.setTransform(1,0,0,1,0,0),e.fillStyle="rgba(0, 0, 0, 0)"}function zh(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function By(r){return Array.from?Array.from(r):r.split("")}function cP(r){typeof r=="string"&&(r=[r]);const e=[];for(let t=0,i=r.length;t<i;t++){const n=r[t];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);const s=n[0].charCodeAt(0),o=n[1].charCodeAt(0);if(o<s)throw new Error("[BitmapFont]: Invalid character range.");for(let a=s,l=o;a<=l;a++)e.push(String.fromCharCode(a))}else e.push(...By(n))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}const Mn=class Gr{constructor(e,t,i){var n;const[s]=e.info,[o]=e.common,[a]=e.page,[l]=e.distanceField,h=$r(a.file),u={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=o.lineHeight/h,this.chars={},this.pageTextures=u;for(let c=0;c<e.page.length;c++){const{id:d,file:f}=e.page[c];u[d]=t instanceof Array?t[c]:t[f],l!=null&&l.fieldType&&l.fieldType!=="none"&&(u[d].baseTexture.alphaMode=bi.NO_PREMULTIPLIED_ALPHA,u[d].baseTexture.mipmap=Cr.OFF)}for(let c=0;c<e.char.length;c++){const{id:d,page:f}=e.char[c];let{x:g,y:p,width:m,height:v,xoffset:y,yoffset:_,xadvance:w}=e.char[c];g/=h,p/=h,m/=h,v/=h,y/=h,_/=h,w/=h;const A=new We(g+u[f].frame.x/h,p+u[f].frame.y/h,m,v);this.chars[d]={xOffset:y,yOffset:_,xAdvance:w,kerning:{},texture:new Te(u[f].baseTexture,A),page:f}}for(let c=0;c<e.kerning.length;c++){let{first:d,second:f,amount:g}=e.kerning[c];d/=h,f/=h,g/=h,this.chars[f]&&(this.chars[f].kerning[d]=g)}this.distanceFieldRange=l==null?void 0:l.distanceRange,this.distanceFieldType=((n=l==null?void 0:l.fieldType)==null?void 0:n.toLowerCase())??"none"}destroy(){for(const e in this.chars)this.chars[e].texture.destroy(),this.chars[e].texture=null;for(const e in this.pageTextures)this._ownsTextures&&this.pageTextures[e].destroy(!0),this.pageTextures[e]=null;this.chars=null,this.pageTextures=null}static install(e,t,i){let n;if(e instanceof Gh)n=e;else{const o=lP(e);if(!o)throw new Error("Unrecognized data format for font.");n=o.parse(e)}t instanceof Te&&(t=[t]);const s=new Gr(n,t,i);return Gr.available[s.font]=s,s}static uninstall(e){const t=Gr.available[e];if(!t)throw new Error(`No font found named '${e}'`);t.destroy(),delete Gr.available[e]}static from(e,t,i){if(!e)throw new Error("[BitmapFont] Property `name` is required.");const{chars:n,padding:s,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},Gr.defaultOptions,i),u=cP(n),c=t instanceof In?t:new In(t),d=a,f=new Gh;f.info[0]={face:c.fontFamily,size:c.fontSize},f.common[0]={lineHeight:c.fontSize};let g=0,p=0,m,v,y,_=0;const w=[];for(let F=0;F<u.length;F++){m||(m=ye.ADAPTER.createCanvas(),m.width=a,m.height=l,v=m.getContext("2d"),y=new ze(m,{resolution:o,...h}),w.push(new Te(y)),f.page.push({id:w.length-1,file:""}));const C=u[F],R=Pn.measureText(C,c,!1,m),M=R.width,k=Math.ceil(R.height),z=Math.ceil((c.fontStyle==="italic"?2:1)*M);if(p>=l-k*o){if(p===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${C}')`);--F,m=null,v=null,y=null,p=0,g=0,_=0;continue}if(_=Math.max(k+R.fontProperties.descent,_),z*o+g>=d){if(g===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${C}')`);--F,p+=_*o,p=Math.ceil(p),g=0,_=0;continue}uP(m,v,R,g,p,o,c);const D=zh(R.text);f.char.push({id:D,page:w.length-1,x:g/o,y:p/o,width:z,height:k,xoffset:0,yoffset:0,xadvance:M-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),g+=(z+2*s)*o,g=Math.ceil(g)}if(!(i!=null&&i.skipKerning))for(let F=0,C=u.length;F<C;F++){const R=u[F];for(let M=0;M<C;M++){const k=u[M],z=v.measureText(R).width,D=v.measureText(k).width,S=v.measureText(R+k).width-(z+D);S&&f.kerning.push({first:zh(R),second:zh(k),amount:S})}}const A=new Gr(f,w,!0);return Gr.available[e]!==void 0&&Gr.uninstall(e),Gr.available[e]=A,A}};Mn.ALPHA=[["a","z"],["A","Z"]," "],Mn.NUMERIC=[["0","9"]],Mn.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Mn.ASCII=[[" ","~"]],Mn.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Mn.ALPHANUMERIC},Mn.available={};let Dn=Mn;var dP=`// Pixi texture info\r
|
|
1160
|
+
varying vec2 vTextureCoord;\r
|
|
1161
|
+
uniform sampler2D uSampler;\r
|
|
1162
|
+
\r
|
|
1163
|
+
// Tint\r
|
|
1164
|
+
uniform vec4 uColor;\r
|
|
1165
|
+
\r
|
|
1166
|
+
// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
|
|
1167
|
+
uniform float uFWidth;\r
|
|
1168
|
+
\r
|
|
1169
|
+
void main(void) {\r
|
|
1170
|
+
\r
|
|
1171
|
+
// To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
|
|
1172
|
+
vec4 texColor = texture2D(uSampler, vTextureCoord);\r
|
|
1173
|
+
\r
|
|
1174
|
+
// MSDF\r
|
|
1175
|
+
float median = texColor.r + texColor.g + texColor.b -\r
|
|
1176
|
+
min(texColor.r, min(texColor.g, texColor.b)) -\r
|
|
1177
|
+
max(texColor.r, max(texColor.g, texColor.b));\r
|
|
1178
|
+
// SDF\r
|
|
1179
|
+
median = min(median, texColor.a);\r
|
|
1180
|
+
\r
|
|
1181
|
+
float screenPxDistance = uFWidth * (median - 0.5);\r
|
|
1182
|
+
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
|
|
1183
|
+
if (median < 0.01) {\r
|
|
1184
|
+
alpha = 0.0;\r
|
|
1185
|
+
} else if (median > 0.99) {\r
|
|
1186
|
+
alpha = 1.0;\r
|
|
1187
|
+
}\r
|
|
1188
|
+
\r
|
|
1189
|
+
// Gamma correction for coverage-like alpha\r
|
|
1190
|
+
float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r
|
|
1191
|
+
float gamma = mix(1.0, 1.0 / 2.2, luma);\r
|
|
1192
|
+
float coverage = pow(uColor.a * alpha, gamma); \r
|
|
1193
|
+
\r
|
|
1194
|
+
// NPM Textures, NPM outputs\r
|
|
1195
|
+
gl_FragColor = vec4(uColor.rgb, coverage);\r
|
|
1196
|
+
}\r
|
|
1197
|
+
`,fP=`// Mesh material default fragment\r
|
|
1198
|
+
attribute vec2 aVertexPosition;\r
|
|
1199
|
+
attribute vec2 aTextureCoord;\r
|
|
1200
|
+
\r
|
|
1201
|
+
uniform mat3 projectionMatrix;\r
|
|
1202
|
+
uniform mat3 translationMatrix;\r
|
|
1203
|
+
uniform mat3 uTextureMatrix;\r
|
|
1204
|
+
\r
|
|
1205
|
+
varying vec2 vTextureCoord;\r
|
|
1206
|
+
\r
|
|
1207
|
+
void main(void)\r
|
|
1208
|
+
{\r
|
|
1209
|
+
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
|
|
1210
|
+
\r
|
|
1211
|
+
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
|
|
1212
|
+
}\r
|
|
1213
|
+
`;const ky=[],Uy=[],Hy=[],pP=class P_ extends pr{constructor(e,t={}){super();const{align:i,tint:n,maxWidth:s,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},P_.styleDefaults,t);if(!Dn.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new ut(n),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=e,this._maxWidth=s,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new en(()=>{this.dirty=!0},this,0,0),this._roundPixels=ye.ROUND_PIXELS,this.dirty=!0,this._resolution=ye.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var e;const t=Dn.available[this._fontName],i=this.fontSize,n=i/t.size,s=new nt,o=[],a=[],l=[],h=this._text.replace(/(?:\r\n|\r)/g,`
|
|
1214
|
+
`)||" ",u=By(h),c=this._maxWidth*t.size/i,d=t.distanceFieldType==="none"?ky:Uy;let f=null,g=0,p=0,m=0,v=-1,y=0,_=0,w=0,A=0;for(let D=0;D<u.length;D++){const S=u[D],b=zh(S);if(/(?:\s)/.test(S)&&(v=D,y=g,A++),S==="\r"||S===`
|
|
1215
|
+
`){a.push(g),l.push(-1),p=Math.max(p,g),++m,++_,s.x=0,s.y+=t.lineHeight,f=null,A=0;continue}const O=t.chars[b];if(!O)continue;f&&O.kerning[f]&&(s.x+=O.kerning[f]);const j=Hy.pop()||{texture:Te.EMPTY,line:0,charCode:0,prevSpaces:0,position:new nt};j.texture=O.texture,j.line=m,j.charCode=b,j.position.x=Math.round(s.x+O.xOffset+this._letterSpacing/2),j.position.y=Math.round(s.y+O.yOffset),j.prevSpaces=A,o.push(j),g=j.position.x+Math.max(O.xAdvance-O.xOffset,O.texture.orig.width),s.x+=O.xAdvance+this._letterSpacing,w=Math.max(w,O.yOffset+O.texture.height),f=b,v!==-1&&c>0&&s.x>c&&(++_,oo(o,1+v-_,1+D-v),D=v,v=-1,a.push(y),l.push(o.length>0?o[o.length-1].prevSpaces:0),p=Math.max(p,y),m++,s.x=0,s.y+=t.lineHeight,f=null,A=0)}const F=u[u.length-1];F!=="\r"&&F!==`
|
|
1216
|
+
`&&(/(?:\s)/.test(F)&&(g=y),a.push(g),p=Math.max(p,g),l.push(-1));const C=[];for(let D=0;D<=m;D++){let S=0;this._align==="right"?S=p-a[D]:this._align==="center"?S=(p-a[D])/2:this._align==="justify"&&(S=l[D]<0?0:(p-a[D])/l[D]),C.push(S)}const R=o.length,M={},k=[],z=this._activePagesMeshData;d.push(...z);for(let D=0;D<R;D++){const S=o[D].texture,b=S.baseTexture.uid;if(!M[b]){let O=d.pop();if(!O){const V=new kC;let Y,G;t.distanceFieldType==="none"?(Y=new Ty(Te.EMPTY),G=Ne.NORMAL):(Y=new Ty(Te.EMPTY,{program:tn.from(fP,dP),uniforms:{uFWidth:0}}),G=Ne.NORMAL_NPM);const H=new Ey(V,Y);H.blendMode=G,O={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:H,vertices:null,uvs:null,indices:null}}O.index=0,O.indexCount=0,O.vertexCount=0,O.uvsCount=0,O.total=0;const{_textureCache:j}=this;j[b]=j[b]||new Te(S.baseTexture),O.mesh.texture=j[b],O.mesh.tint=this._tintColor.value,k.push(O),M[b]=O}M[b].total++}for(let D=0;D<z.length;D++)k.includes(z[D])||this.removeChild(z[D].mesh);for(let D=0;D<k.length;D++)k[D].mesh.parent!==this&&this.addChild(k[D].mesh);this._activePagesMeshData=k;for(const D in M){const S=M[D],b=S.total;if(!(((e=S.indices)==null?void 0:e.length)>6*b)||S.vertices.length<Ey.BATCHABLE_SIZE*2)S.vertices=new Float32Array(8*b),S.uvs=new Float32Array(8*b),S.indices=new Uint16Array(6*b);else{const O=S.total,j=S.vertices;for(let V=O*4*2;V<j.length;V++)j[V]=0}S.mesh.size=6*b}for(let D=0;D<R;D++){const S=o[D];let b=S.position.x+C[S.line]*(this._align==="justify"?S.prevSpaces:1);this._roundPixels&&(b=Math.round(b));const O=b*n,j=S.position.y*n,V=S.texture,Y=M[V.baseTexture.uid],G=V.frame,H=V._uvs,X=Y.index++;Y.indices[X*6+0]=0+X*4,Y.indices[X*6+1]=1+X*4,Y.indices[X*6+2]=2+X*4,Y.indices[X*6+3]=0+X*4,Y.indices[X*6+4]=2+X*4,Y.indices[X*6+5]=3+X*4,Y.vertices[X*8+0]=O,Y.vertices[X*8+1]=j,Y.vertices[X*8+2]=O+G.width*n,Y.vertices[X*8+3]=j,Y.vertices[X*8+4]=O+G.width*n,Y.vertices[X*8+5]=j+G.height*n,Y.vertices[X*8+6]=O,Y.vertices[X*8+7]=j+G.height*n,Y.uvs[X*8+0]=H.x0,Y.uvs[X*8+1]=H.y0,Y.uvs[X*8+2]=H.x1,Y.uvs[X*8+3]=H.y1,Y.uvs[X*8+4]=H.x2,Y.uvs[X*8+5]=H.y2,Y.uvs[X*8+6]=H.x3,Y.uvs[X*8+7]=H.y3}this._textWidth=p*n,this._textHeight=(s.y+t.lineHeight)*n;for(const D in M){const S=M[D];if(this.anchor.x!==0||this.anchor.y!==0){let V=0;const Y=this._textWidth*this.anchor.x,G=this._textHeight*this.anchor.y;for(let H=0;H<S.total;H++)S.vertices[V++]-=Y,S.vertices[V++]-=G,S.vertices[V++]-=Y,S.vertices[V++]-=G,S.vertices[V++]-=Y,S.vertices[V++]-=G,S.vertices[V++]-=Y,S.vertices[V++]-=G}this._maxLineHeight=w*n;const b=S.mesh.geometry.getBuffer("aVertexPosition"),O=S.mesh.geometry.getBuffer("aTextureCoord"),j=S.mesh.geometry.getIndex();b.data=S.vertices,O.data=S.uvs,j.data=S.indices,b.update(),O.update(),j.update()}for(let D=0;D<o.length;D++)Hy.push(o[D]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0);const{distanceFieldRange:t,distanceFieldType:i,size:n}=Dn.available[this._fontName];if(i!=="none"){const{a:s,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(s*s+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/n,f=e._view.resolution;for(const g of this._activePagesMeshData)g.mesh.shader.uniforms.uFWidth=c*t*d*f}super._render(e)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const e=Dn.available[this._fontName];if(!e)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==e&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(e){if(this.tint!==e){this._tintColor.setValue(e);for(let t=0;t<this._activePagesMeshData.length;t++)this._activePagesMeshData[t].mesh.tint=e}}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.dirty=!0)}get fontName(){return this._fontName}set fontName(e){if(!Dn.available[e])throw new Error(`Missing BitmapFont "${e}"`);this._fontName!==e&&(this._fontName=e,this.dirty=!0)}get fontSize(){return this._fontSize??Dn.available[this._fontName].size}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.dirty=!0)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get text(){return this._text}set text(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(e){this._maxWidth!==e&&(this._maxWidth=e,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(e){e!==this._roundPixels&&(this._roundPixels=e,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}destroy(e){const{_textureCache:t}=this,i=Dn.available[this._fontName].distanceFieldType==="none"?ky:Uy;i.push(...this._activePagesMeshData);for(const n of this._activePagesMeshData)this.removeChild(n.mesh);this._activePagesMeshData=[],i.filter(n=>t[n.mesh.texture.baseTexture.uid]).forEach(n=>{n.mesh.texture=Te.EMPTY});for(const n in t)t[n].destroy(),delete t[n];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(e)}};pP.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const gP=[".xml",".fnt"],mP={extension:{type:ge.LoadParser,priority:vr.Normal},name:"loadBitmapFont",test(r){return gP.includes(Zt.extname(r).toLowerCase())},async testParse(r){return Vh.test(r)||sf.test(r)},async parse(r,e,t){const i=Vh.test(r)?Vh.parse(r):sf.parse(r),{src:n}=e,{page:s}=i,o=[];for(let h=0;h<s.length;++h){const u=s[h].file;let c=Zt.join(Zt.dirname(n),u);c=Gd(c,n),o.push(c)}const a=await t.load(o),l=o.map(h=>a[h]);return Dn.install(i,l,!0)},async load(r,e){return(await ye.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};Ee.add(mP);const af=class Ro extends In{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(e){return new Ro(Object.keys(Ro.defaultOptions).reduce((t,i)=>({...t,[i]:e[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(e=>{URL.revokeObjectURL(e.src),e.refs--,e.refs===0&&(e.fontFace&&document.fonts.delete(e.fontFace),delete Ro.availableFonts[e.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(e,t={}){const{availableFonts:i}=Ro;if(i[e]){const n=i[e];return this._fonts.push(n),n.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return ye.ADAPTER.fetch(e).then(n=>n.blob()).then(async n=>new Promise((s,o)=>{const a=URL.createObjectURL(n),l=new FileReader;l.onload=()=>s([a,l.result]),l.onerror=o,l.readAsDataURL(n)})).then(async([n,s])=>{const o=Object.assign({family:Zt.basename(e,Zt.extname(e)),weight:"normal",style:"normal",display:"auto",src:n,dataSrc:s,refs:1,originalUrl:e,fontFace:null},t);i[e]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...e){const t=e.filter(i=>!this._overrides.includes(i));t.length>0&&(this._overrides.push(...t),this.styleID++)}removeOverride(...e){const t=e.filter(i=>this._overrides.includes(i));t.length>0&&(this._overrides=this._overrides.filter(i=>!t.includes(i)),this.styleID++)}toCSS(e){return[`transform: scale(${e})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((e,t)=>`${e}
|
|
1217
|
+
@font-face {
|
|
1218
|
+
font-family: "${t.family}";
|
|
1219
|
+
src: url('${t.dataSrc}');
|
|
1220
|
+
font-weight: ${t.weight};
|
|
1221
|
+
font-style: ${t.style};
|
|
1222
|
+
font-display: ${t.display};
|
|
1223
|
+
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(e){this._stylesheet!==e&&(this._stylesheet=e,this.styleID++)}normalizeColor(e){return Array.isArray(e)&&(e=sA(e)),typeof e=="number"?nA(e):e}dropShadowToCSS(){let e=this.normalizeColor(this.dropShadowColor);const t=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);e.startsWith("#")&&t<1&&(e+=(t*255|0).toString(16).padStart(2,"0"));const s=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${s} ${this.dropShadowBlur}px ${e}`:`text-shadow: ${s} ${e}`}reset(){Object.assign(this,Ro.defaultOptions)}onBeforeDraw(){const{fontsDirty:e}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&e?new Promise(t=>setTimeout(t,100)):Promise.resolve()}get isSafari(){const{userAgent:e}=ye.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}set fillGradientStops(e){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(e){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(e){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(e){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(e){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(e){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(e){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};af.availableFonts={},af.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let lf=af;const jh=class Co extends ho{constructor(e="",t={}){super(Te.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,n=Te.from(i,{scaleMode:ye.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new We,n.trim=new We,this.texture=n;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Co.defaultMaxWidth,this.maxHeight=Co.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Co.defaultAutoResolution,this._resolution=Co.defaultResolution??ye.RESOLUTION,this.text=e,this.style=t}measureText(e){var t,i;const{text:n,style:s,resolution:o}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},e);Object.assign(this._domElement,{innerHTML:n,style:s.toCSS(o)}),this._styleElement.textContent=s.toGlobalCSS(),document.body.appendChild(this._svgRoot);const a=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:l,height:h}=a;(l>this.maxWidth||h>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const u=Math.min(this.maxWidth,Math.ceil(l)),c=Math.min(this.maxHeight,Math.ceil(h));return this._svgRoot.setAttribute("width",u.toString()),this._svgRoot.setAttribute("height",c.toString()),n!==this._text&&(this._domElement.innerHTML=this._text),s!==this._style&&(Object.assign(this._domElement,{style:(t=this._style)==null?void 0:t.toCSS(o)}),this._styleElement.textContent=(i=this._style)==null?void 0:i.toGlobalCSS()),{width:u+s.padding*2,height:c+s.padding*2}}async updateText(e=!0){const{style:t,_image:i,_loadImage:n}=this;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;const{width:s,height:o}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,s)),i.height=n.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{n.onload=async()=>{if(a<this._updateID){l();return}await t.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:e,texture:t,_image:i,resolution:n}=this,{padding:s}=e,{baseTexture:o}=t;t.trim.width=t._frame.width=i.width/n,t.trim.height=t._frame.height=i.height/n,t.trim.x=-s,t.trim.y=-s,t.orig.width=t._frame.width-s*2,t.orig.height=t._frame.height-s*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,n),this.dirty=!1}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._render(e)}_renderCanvas(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(e)}getLocalBounds(e){return this.updateText(!0),super.getLocalBounds(e)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(e){var t,i,n,s,o;typeof e=="boolean"&&(e={children:e}),e=Object.assign({},Co.defaultDestroyOptions,e),super.destroy(e);const a=null;this.ownsStyle&&((t=this._style)==null||t.cleanFonts()),this._style=a,(i=this._svgRoot)==null||i.remove(),this._svgRoot=a,(n=this._domElement)==null||n.remove(),this._domElement=a,(s=this._foreignObject)==null||s.remove(),this._foreignObject=a,(o=this._styleElement)==null||o.remove(),this._styleElement=a,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=a,this._image.src="",this._image=a}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(e){this.updateText(!0);const t=Tn(this.scale.x)||1;this.scale.x=t*e/this._image.width/this.resolution,this._width=e}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(e){this.updateText(!0);const t=Tn(this.scale.y)||1;this.scale.y=t*e/this._image.height/this.resolution,this._height=e}get style(){return this._style}set style(e){this._style!==e&&(e=e||{},e instanceof lf?(this.ownsStyle=!1,this._style=e):e instanceof In?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=lf.from(e)):(this.ownsStyle=!0,this._style=new lf(e)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(e){e=String(e===""||e===null||e===void 0?" ":e),e=this.sanitiseText(e),this._text!==e&&(this._text=e,this.dirty=!0)}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}sanitiseText(e){return e.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};jh.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},jh.defaultMaxWidth=2024,jh.defaultMaxHeight=2024,jh.defaultAutoResolution=!0;const vP=16777215,yP=.25,_P=16777215,xP=1,wP=1.5;let On=!1,yo;const hf=r=>{const e={tint:r!=null&&r.fill?new ut(r.fill).toNumber():vP,alpha:(r==null?void 0:r.fillOpacity)!==void 0?Math.min(r.fillOpacity,1):String(r==null?void 0:r.fill).toLowerCase().startsWith("rgba(")?new ut(r==null?void 0:r.fill).alpha:yP},t={tint:r!=null&&r.stroke?new ut(r.stroke).toNumber():_P,alpha:(r==null?void 0:r.strokeOpacity)!==void 0?Math.min(r.strokeOpacity,1):String(r==null?void 0:r.stroke).toLowerCase().startsWith("rgba(")?new ut(r==null?void 0:r.stroke).alpha:xP,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?wP:r.strokeWidth};return{fillStyle:e,strokeStyle:t}},_o=r=>(e,t,i,n={})=>{const{fillStyle:s,strokeStyle:o}=hf(i),a=new Aa;n.strokeOnly||(a.beginFill(16777215),r(t,a),a.endFill(),a.tint=s.tint,a.alpha=s.alpha),e.addChild(a);const l=new Aa,h=o.lineWidth===1?1:o.lineWidth/yo;return l.lineStyle(h,16777215,1,.5,o.lineWidth===1),r(t,l),l.tint=o.tint||16777215,l.alpha=o.alpha,e.addChild(l),{fill:a,stroke:l,strokeWidth:o.lineWidth}},EP=_o((r,e)=>{const{x:t,y:i,w:n,h:s}=r.geometry;e.drawRect(t,i,n,s)}),TP=_o((r,e)=>{const{cx:t,cy:i,rx:n,ry:s}=r.geometry;e.drawEllipse(t,i,n,s)}),bP=_o((r,e)=>{const[[t,i],[n,s]]=r.geometry.points;e.moveTo(t,i),e.lineTo(n,s),e.closePath()}),AP=_o((r,e)=>{const t=r.geometry.points.reduce((i,n)=>[...i,...n],[]);e.drawPolygon(t)}),SP=_o((r,e)=>{const{points:t,closed:i}=r.geometry;if(t.length===0)return;i||e.beginFill(0,0);const n=(o,a)=>{const[l,h]=o.point,[u,c]=a.point;if(o.type==="CURVE"||a.type==="CURVE"){const d=o.type==="CURVE"&&o.outHandle?o.outHandle[0]:l,f=o.type==="CURVE"&&o.outHandle?o.outHandle[1]:h,g=a.type==="CURVE"&&a.inHandle?a.inHandle[0]:u,p=a.type==="CURVE"&&a.inHandle?a.inHandle[1]:c;e.bezierCurveTo(d,f,g,p,u,c)}else e.lineTo(u,c)},s=t[0];e.moveTo(s.point[0],s.point[1]);for(let o=1;o<t.length;o++){const a=t[o-1],l=t[o];n(a,l)}if(i&&t.length>2){const o=t[t.length-1],a=t[0];n(o,a),e.closePath()}else e.endFill()}),RP=_o((r,e)=>{const t=i=>i.points.reduce((n,s)=>[...n,...s],[]);r.geometry.polygons.forEach(i=>{const[n,...s]=i.rings;e.drawPolygon(t(n)),s.forEach(o=>{e.beginHole(),e.drawPolygon(t(o)),e.endHole()})})}),Gy=r=>{const e=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*e/r.world.getContentFactor()},Vy=(r,e,t,i)=>()=>{const n=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),s=Gy(r);(s!==yo||!On)&&(On=!0,t.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:g}=d.geometry.graphicsData[0];f>1?(On=s===yo,g.width=f/s,g.native=!1,d.geometry.invalidate()):f===1&&!g.native&&(g.width=1,g.native=!0,d.geometry.invalidate())})),yo=s;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+n.x*s:-n.x*s,h=-n.y*s;let u,c;a>0&&a<=Math.PI/2?(u=n.height*s,c=0):a>Math.PI/2&&a<=Math.PI?(u=n.width*s,c=n.height*s):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=n.width*s):(u=0,c=0),e.position.x=u+l*Math.cos(a)-h*Math.sin(a),e.position.y=c+l*Math.sin(a)+h*Math.cos(a),e.scale.set(o?-s:s,s),e.rotation=a,i.render(e)},CP=(r,e)=>{const t=new Aa,i=k0({width:e.width,height:e.height,backgroundAlpha:0,view:e,antialias:!0,resolution:2}),n=new Map;let s=new Set,o,a;yo=Gy(r);const l=(y,_)=>{On=!1;const w=n.get(y.id);w&&(w.fill.destroy(),w.stroke.destroy());const{selector:A}=y.target,F=typeof a=="function"?a(y,_):a;let C;if(A.type===ht.RECTANGLE)C=EP(t,A,F);else if(A.type===ht.POLYGON)C=AP(t,A,F);else if(A.type===ht.ELLIPSE)C=TP(t,A,F);else if(A.type===ht.MULTIPOLYGON)C=RP(t,A,F);else if(A.type===ht.POLYLINE){const R=A;C=SP(t,R,F,{strokeOnly:!R.geometry.closed})}else A.type===ht.LINE?C=bP(t,A,F):console.warn(`Unsupported shape type: ${A.type}`);C&&n.set(y.id,{annotation:y,...C})},h=y=>{const _=n.get(y.id);_&&(n.delete(y.id),_.fill.destroy(),_.stroke.destroy())},u=(y,_,w)=>{On=!1;const A=n.get(y.id);if(A&&(n.delete(y.id),A.fill.destroy(),A.stroke.destroy(),l(_,w),s.has(_.id))){const{fill:F,stroke:C}=n.get(_.id);t.removeChild(F),t.removeChild(C)}},c=(y,_)=>{const w=n.get(y);w&&(n.delete(y),w.fill.destroy(),w.stroke.destroy(),l(w.annotation,_))},d=(y,_)=>{i.resize(y,_),i.render(t)},f=y=>{On=!1;const{children:_}=t;n.forEach(({fill:w,stroke:A,annotation:F})=>{const C=y?s.has(F.id)||y(F):!0;C&&!_.includes(w)?(t.addChild(w),t.addChild(A)):!C&&_.includes(w)&&(t.removeChild(w),t.removeChild(A))}),i.render(t)},g=y=>{const _=new Set(y.selected.map(F=>F.id)),w=y.selected.filter(({id:F})=>!s.has(F)),A=[...s].filter(F=>!_.has(F));w.forEach(({id:F,editable:C})=>{if(C){const R=n.get(F);R&&cm(R.annotation.target.selector)&&(t.removeChild(R.fill),t.removeChild(R.stroke))}else c(F,{selected:!0,hovered:F===o})}),A.forEach(F=>c(F,{hovered:F===o})),s=_,i.render(t)},p=y=>{o!==y&&(y&&s.has(y)||(o&&!s.has(o)&&c(o,{selected:s.has(o)}),y&&c(y,{selected:s.has(y),hovered:!0}),o=y,i.render(t)))},m=y=>{if(typeof y=="function")n.forEach(({annotation:_,fill:w,stroke:A,strokeWidth:F},C)=>{F>1&&(On=!1);const R={selected:s.has(_.id),hovered:o===_.id},{fillStyle:M,strokeStyle:k}=hf(y(_,R));w.tint=M.tint,w.alpha=M.alpha,A.tint=k.tint||16777215,A.alpha=k.alpha,n.set(_.id,{annotation:_,fill:w,stroke:A,strokeWidth:k.lineWidth})});else{const{fillStyle:_,strokeStyle:w}=hf(y);w.lineWidth>1&&(On=!1),n.forEach(({annotation:A,fill:F,stroke:C,strokeWidth:R},M)=>{F.tint=_.tint,F.alpha=_.alpha,C.tint=w.tint||16777215,C.alpha=w.alpha,n.set(A.id,{annotation:A,fill:F,stroke:C,strokeWidth:w.lineWidth})})}a=y,i.render(t),Vy(r,t,n,i)()},v=y=>{y?e.classList.remove("hidden"):e.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>yo,redraw:Vy(r,t,n,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:p,setSelected:g,setStyle:m,setVisible:v,updateAnnotation:u}};function PP(r,e,t){let i,n,{filter:s}=e,{state:o}=e,{style:a}=e,{viewer:l}=e,{visible:h=!0}=e;const{store:u,hover:c,selection:d,viewport:f}=o;ia(r,c,R=>t(11,i=R)),ia(r,d,R=>t(8,n=R));const g=Rc(),p=ur?10:2;let m,v;const y=R=>{const M=new Jn.Point(R.x,R.y),{x:k,y:z}=l.viewport.pointFromPixel(M);return l.viewport.viewportToImageCoordinates(k,z)},_=()=>p/m.getScale(),w=R=>{const{x:M,y:k}=R.position;v={x:M,y:k}},A=R=>M=>{const{x:k,y:z}=y(new Jn.Point(M.offsetX,M.offsetY)),D=_(),S=u.getAt(k,z,s,D);S?(R.classList.add("hover"),i!==S.id&&(c.set(S.id),m.setHovered(S.id))):(R.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},F=R=>{if(!v)return;const M=R.originalEvent,{x:k,y:z}=R.position,D=k-v.x,S=z-v.y;if(Math.sqrt(D*D+S*S)<5){const{x:b,y:O}=y(R.position),j=_(),V=u.getAt(b,O,s,j);V?g("click",{originalEvent:M,annotation:V}):g("click",{originalEvent:M})}v=void 0};let C;return sa(()=>{var R;const{offsetWidth:M,offsetHeight:k}=l.canvas,z=document.createElement("canvas");z.width=M,z.height=k,z.className="a9s-gl-canvas",(R=l.element.querySelector(".openseadragon-canvas"))==null||R.appendChild(z),t(7,m=CP(l,z));const D=A(z);z.addEventListener("pointermove",D);const S=new ResizeObserver(G=>{try{const{width:H,height:X}=G[0].contentRect;z.width=H,z.height=X,m.resize(H,X)}catch{console.warn("WebGL canvas already disposed")}});S.observe(z);const b=()=>{const G=l.viewport.getBounds();C=l.viewport.viewportToImageRectangle(G);const{x:H,y:X,width:K,height:Q}=C,W=u.getIntersecting(H,X,K,Q);f.set(W.map($=>$.id))};l.addHandler("canvas-press",w),l.addHandler("canvas-release",F),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",b);const O=G=>G.filter(H=>_n(H)),j=G=>_n(G.oldValue)&&_n(G.newValue),V=G=>{const{selector:H}=G.target;if(H.type===ht.POLYGON){const X=VT(H);return{...G,target:{...G.target,selector:{...X}}}}else if(H.type===ht.MULTIPOLYGON){const X=HT(H);return{...G,target:{...G.target,selector:{...X}}}}else return G},Y=G=>{const{created:H,updated:X,deleted:K}=G.changes,Q=(H||[]).filter(W=>_n(W)).map(V);if(O(K||[]).forEach(W=>m.removeAnnotation(W)),Q.forEach(W=>m.addAnnotation(W)),(X||[]).filter(W=>j(W)).map(({oldValue:W,newValue:$})=>({oldValue:W,newValue:V($)})).forEach(({oldValue:W,newValue:$})=>m.updateAnnotation(W,$)),C){const{x:W,y:$,width:ne,height:_e}=C,pe=u.getIntersecting(W,$,ne,_e);f.set(pe.map(Ce=>Ce.id))}else f.set(u.all().map(W=>W.id));m.redraw()};return u.observe(Y),()=>{var G;z.removeEventListener("pointermove",D),S.disconnect(),l.removeHandler("canvas-press",w),l.removeHandler("canvas-release",F),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",b),u.unobserve(Y),m.destroy(),(G=z.parentNode)==null||G.removeChild(z)}}),r.$$set=R=>{"filter"in R&&t(2,s=R.filter),"state"in R&&t(3,o=R.state),"style"in R&&t(4,a=R.style),"viewer"in R&&t(5,l=R.viewer),"visible"in R&&t(6,h=R.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(s)),r.$$.dirty&384&&(m==null||m.setSelected(n)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[c,d,s,o,a,l,h,m,n]}class IP extends ci{constructor(e){super(),ui(this,e,PP,null,Xt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const zy=(r,e,t,i)=>{if(!i)return r;if(e.shiftKey||e.ctrlKey||e.metaKey){const n=(t.selected||[]).map(s=>s.id);return n.includes(r)?n.filter(s=>s!==r):[...n,r]}else return r},MP=r=>({transform:r&2,scale:r&1}),jy=r=>({transform:r[1],scale:r[0]});function DP(r){let e;const t=r[4].default,i=vT(t,r,r[3],jy);return{c(){i&&i.c()},m(n,s){i&&i.m(n,s),e=!0},p(n,[s]){i&&i.p&&(!e||s&11)&&_T(i,t,n,n[3],e?yT(t,n[3],s,MP):xT(n[3]),jy)},i(n){e||(He(i,n),e=!0)},o(n){Ye(i,n),e=!1},d(n){i&&i.d(n)}}}function OP(r,e,t){let{$$slots:i={},$$scope:n}=e,{viewer:s}=e,o=1,a;const l=()=>{const h=s.viewport.getContainerSize().x,u=s.viewport.getZoom(!0),c=s.viewport.getFlip(),d=s.viewport.pixelFromPoint(new Jn.Point(0,0),!0);c&&(d.x=h-d.x);const f=u*h/s.world.getContentFactor(),g=c?-f:f,p=s.viewport.getRotation(!0);t(1,a=`translate(${d.x}, ${d.y}) scale(${g}, ${f}) rotate(${p})`),t(0,o=u*h/s.world.getContentFactor())};return sa(()=>(s.addHandler("update-viewport",l),()=>{s.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&t(2,s=h.viewer),"$$scope"in h&&t(3,n=h.$$scope)},[o,a,s,n,i]}class uf extends ci{constructor(e){super(),ui(this,e,OP,DP,Xt,{viewer:2})}}function LP(r,e,t){const i=Rc();let{drawingMode:n}=e,{opts:s}=e,{target:o}=e,{tool:a}=e,{transform:l}=e,{viewer:h}=e,{viewportScale:u}=e,c;return sa(()=>{const d=o.closest("svg"),f=[],g=(p,m,v)=>{if(d==null||d.addEventListener(p,m,v),f.push(()=>d==null?void 0:d.removeEventListener(p,m,v)),p==="pointerup"||p==="dblclick"){const y=w=>{const{originalEvent:A}=w;m(A)},_=p==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(_,y),f.push(()=>h.removeHandler(_,y))}else if(p==="pointermove"){const y=_=>{const{originalEvent:w}=_;m(w)};h.addHandler("canvas-drag",y),f.push(()=>h.removeHandler("canvas-drag",y))}};return t(7,c=new a({target:o,props:{addEventListener:g,drawingMode:n,opts:s,transform:l,viewportScale:u,svgEl:d}})),c.$on("create",p=>i("create",p.detail)),()=>{f.forEach(p=>p()),c.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&t(0,n=d.drawingMode),"opts"in d&&t(1,s=d.opts),"target"in d&&t(2,o=d.target),"tool"in d&&t(3,a=d.tool),"transform"in d&&t(4,l=d.transform),"viewer"in d&&t(5,h=d.viewer),"viewportScale"in d&&t(6,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&c&&c.$set({transform:l}),r.$$.dirty&192&&c&&c.$set({viewportScale:u})},[n,s,o,a,l,h,u,c]}class NP extends ci{constructor(e){super(),ui(this,e,LP,null,Xt,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:FP}=Ac;function Wy(r,e,t){const i=r.slice();i[41]=e[t];const n=i[19](i[41].target.selector);return i[42]=n,i}function BP(r){let e=`${r[2]}-${r[7]}`,t,i,n=Xy(r);return{c(){n.c(),t=Zr()},m(s,o){n.m(s,o),bt(s,t,o),i=!0},p(s,o){o[0]&132&&Xt(e,e=`${s[2]}-${s[7]}`)?(Zi(),Ye(n,1,1,It),qi(),n=Xy(s),n.c(),He(n,1),n.m(t.parentNode,t)):n.p(s,o)},i(s){i||(He(n),i=!0)},o(s){Ye(n),i=!1},d(s){s&&xt(t),n.d(s)}}}function kP(r){let e,t,i=wn(r[9].filter(r[29])),n=[];for(let o=0;o<i.length;o+=1)n[o]=qy(Wy(r,i,o));const s=o=>Ye(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();e=Zr()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);bt(o,e,a),t=!0},p(o,a){if(a[0]&713474|a[1]&512){i=wn(o[9].filter(o[29]));let l;for(l=0;l<i.length;l+=1){const h=Wy(o,i,l);n[l]?(n[l].p(h,a),He(n[l],1)):(n[l]=qy(h),n[l].c(),He(n[l],1),n[l].m(e.parentNode,e))}for(Zi(),l=i.length;l<n.length;l+=1)s(l);qi()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)He(n[a]);t=!0}},o(o){n=n.filter(FP);for(let a=0;a<n.length;a+=1)Ye(n[a]);t=!1},d(o){o&&xt(e),kl(n,o)}}}function Xy(r){let e,t;return e=new NP({props:{target:r[8],tool:r[10],drawingMode:r[4],transform:{elementToImage:r[13]},viewer:r[3],viewportScale:r[40],opts:r[5]}}),e.$on("create",r[18]),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n[0]&256&&(s.target=i[8]),n[0]&1024&&(s.tool=i[10]),n[0]&16&&(s.drawingMode=i[4]),n[0]&8&&(s.viewer=i[3]),n[1]&512&&(s.viewportScale=i[40]),n[0]&32&&(s.opts=i[5]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function Yy(r){let e=r[41].id,t,i,n=Zy(r);return{c(){n.c(),t=Zr()},m(s,o){n.m(s,o),bt(s,t,o),i=!0},p(s,o){o[0]&512&&Xt(e,e=s[41].id)?(Zi(),Ye(n,1,1,It),qi(),n=Zy(s),n.c(),He(n,1),n.m(t.parentNode,t)):n.p(s,o)},i(s){i||(He(n),i=!0)},o(s){Ye(n),i=!1},d(s){s&&xt(t),n.d(s)}}}function Zy(r){let e,t;return e=new eb({props:{target:r[8],editor:r[19](r[41].target.selector),annotation:r[41],style:r[1],transform:{elementToImage:r[13]},viewportScale:r[40]}}),e.$on("grab",r[14]),e.$on("change",function(){bc(r[17](r[41]))&&r[17](r[41]).apply(this,arguments)}),e.$on("release",r[15]),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){r=i;const s={};n[0]&256&&(s.target=r[8]),n[0]&512&&(s.editor=r[19](r[41].target.selector)),n[0]&512&&(s.annotation=r[41]),n[0]&2&&(s.style=r[1]),n[1]&512&&(s.viewportScale=r[40]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function qy(r){let e,t,i=r[42]&&Yy(r);return{c(){i&&i.c(),e=Zr()},m(n,s){i&&i.m(n,s),bt(n,e,s),t=!0},p(n,s){n[42]?i?(i.p(n,s),s[0]&512&&He(i,1)):(i=Yy(n),i.c(),He(i,1),i.m(e.parentNode,e)):i&&(Zi(),Ye(i,1,1,()=>{i=null}),qi())},i(n){t||(He(i),t=!0)},o(n){Ye(i),t=!1},d(n){n&&xt(e),i&&i.d(n)}}}function UP(r){let e,t,i,n,s,o,a,l;const h=[kP,BP],u=[];function c(d,f){var g;return d[8]&&((g=d[9])==null?void 0:g.length)===1?0:d[8]&&d[10]&&d[0]?1:-1}return~(i=c(r))&&(n=u[i]=h[i](r)),{c(){e=At("svg"),t=At("g"),n&&n.c(),se(t,"transform",s=r[39]),se(t,"class","svelte-g4ws1v"),se(e,"tabindex",0),se(e,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),Ys(e,"drawing",r[0]),Ys(e,"editing",r[9]),Ys(e,"hover",r[6])},m(d,f){bt(d,e,f),Ar(e,t),~i&&u[i].m(t,null),r[30](t),o=!0,a||(l=wT(e,"pointermove",r[16]),a=!0)},p(d,f){let g=i;i=c(d),i===g?~i&&u[i].p(d,f):(n&&(Zi(),Ye(u[g],1,1,()=>{u[g]=null}),qi()),~i?(n=u[i],n?n.p(d,f):(n=u[i]=h[i](d),n.c()),He(n,1),n.m(t,null)):n=null),(!o||f[1]&256&&s!==(s=d[39]))&&se(t,"transform",s),(!o||f[0]&1)&&Ys(e,"drawing",d[0]),(!o||f[0]&512)&&Ys(e,"editing",d[9]),(!o||f[0]&64)&&Ys(e,"hover",d[6])},i(d){o||(He(n),o=!0)},o(d){Ye(n),o=!1},d(d){d&&xt(e),~i&&u[i].d(),r[30](null),a=!1,l()}}}function HP(r){let e,t;return e=new uf({props:{viewer:r[3],$$slots:{default:[UP,({transform:i,scale:n})=>({39:i,40:n}),({transform:i,scale:n})=>[0,(i?256:0)|(n?512:0)]]},$$scope:{ctx:r}}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n[0]&8&&(s.viewer=i[3]),n[0]&2047|n[1]&17152&&(s.$$scope={dirty:n,ctx:i}),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function GP(r,e,t){let i,n,s,o,a,{drawingEnabled:l}=e,{filter:h}=e,{multiSelect:u}=e,{preferredDrawingMode:c}=e,{state:d}=e,{style:f=void 0}=e,{toolName:g=gm()[0]}=e,{user:p}=e,{viewer:m}=e;const v=ur?10:2;let y=!1,_=0;const w=()=>t(7,_+=1),A=()=>g,F=()=>l;let C;const{store:R,selection:M,hover:k}=d;ia(r,M,ne=>t(28,o=ne)),ia(r,k,ne=>t(33,a=ne));let z,D,S;const b=ne=>{R.unobserve(z);const _e=ne.filter(({editable:pe})=>pe).map(({id:pe})=>pe);_e.length>0?(t(9,D=_e.map(pe=>R.getAnnotation(pe))),z=pe=>{const{updated:Ce}=pe.changes;t(9,D=(Ce||[]).map(Pe=>Pe.newValue))},R.observe(z,{annotations:_e}),m.forceRedraw()):t(9,D=void 0)},O=(ne,_e)=>{const{x:pe,y:Ce}=m.viewport.viewerElementToImageCoordinates(new Jn.Point(ne,_e));return[pe,Ce]},j=()=>{const ne=m.viewport.getContainerSize().x;return m.viewport.getZoom(!0)*ne/m.world.getContentFactor()},V=()=>v/j(),Y=ne=>{m.setMouseNavEnabled(!1),S=ne.timeStamp},G=ne=>{if(m.setMouseNavEnabled(!0),performance.now()-(S||0)<300){const{offsetX:_e,offsetY:pe}=ne.detail,[Ce,Pe]=O(_e,pe),Be=V(),ke=R.getAt(Ce,Pe,void 0,Be);if(ke&&(!h||h(ke))&&!D.find(Ge=>Ge.id===ke.id)){k.set(ke.id);const Ge=zy(ke.id,ne.detail,M,u);M.userSelect(Ge)}}},H=ne=>{const _e=new Jn.Point(ne.offsetX,ne.offsetY),pe=m.viewport.pointFromPixel(_e),{x:Ce,y:Pe}=m.viewport.viewportToImageCoordinates(pe.x,pe.y),Be=V(),ke=R.getAt(Ce,Pe,h,Be);ke?a!==ke.id&&k.set(ke.id):a&&k.set(void 0)},X=ne=>_e=>{var pe;const{target:Ce}=ne,Pe=600*1e3,Be=((pe=Ce.creator)==null?void 0:pe.id)!==p.id||!Ce.created||new Date().getTime()-Ce.created.getTime()>Pe;R.updateTarget({...Ce,selector:_e.detail,created:Be?Ce.created:new Date,updated:Be?new Date:void 0,updatedBy:Be?p:void 0})},K=ne=>{const _e=QT(),pe={id:_e,bodies:[],target:{annotation:_e,selector:ne.detail,creator:p,created:new Date}};R.addAnnotation(pe),M.setSelected(pe.id),m.setMouseNavEnabled(!0)},Q=ne=>cm(ne);sa(()=>{const ne=_e=>{if(o.selected.length===0)return;const{offsetX:pe,offsetY:Ce}=_e,Pe=m.viewport.pointFromPixel(new Jn.Point(pe,Ce)),{x:Be,y:ke}=m.viewport.viewportToImageCoordinates(Pe.x,Pe.y),Ge=V();t(6,y=!!R.getAt(Be,ke,h,Ge))};return m.element.addEventListener("pointermove",ne),()=>{var _e;(_e=m.element)==null||_e.removeEventListener("pointermove",ne)}});const W=ne=>_n(ne);function $(ne){Ul[ne?"unshift":"push"](()=>{C=ne,t(8,C)})}return r.$$set=ne=>{"drawingEnabled"in ne&&t(0,l=ne.drawingEnabled),"filter"in ne&&t(20,h=ne.filter),"multiSelect"in ne&&t(21,u=ne.multiSelect),"preferredDrawingMode"in ne&&t(22,c=ne.preferredDrawingMode),"state"in ne&&t(23,d=ne.state),"style"in ne&&t(1,f=ne.style),"toolName"in ne&&t(2,g=ne.toolName),"user"in ne&&t(24,p=ne.user),"viewer"in ne&&t(3,m=ne.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&t(10,{tool:i,opts:n}=mm(g)||{tool:void 0,opts:void 0},i,(t(5,n),t(2,g))),r.$$.dirty[0]&4194336&&t(4,s=(n==null?void 0:n.drawingMode)||c),r.$$.dirty[0]&25&&(l&&s==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&l&&M.clear(),r.$$.dirty[0]&268435481&&o.selected.length===0&&s==="drag"&&l&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&268435456&&b(o.selected)},[l,f,g,m,s,n,y,_,C,D,i,M,k,O,Y,G,H,X,K,Q,h,u,c,d,p,w,A,F,o,W,$]}class VP extends ci{constructor(e){super(),ui(this,e,GP,HP,Xt,{drawingEnabled:0,filter:20,multiSelect:21,preferredDrawingMode:22,state:23,style:1,toolName:2,user:24,viewer:3,cancelDrawing:25,getDrawingTool:26,isDrawingEnabled:27},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[25]}get getDrawingTool(){return this.$$.ctx[26]}get isDrawingEnabled(){return this.$$.ctx[27]}}function zP(r){let e,t,i,n,s,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){e=At("g"),t=At("rect"),a=At("text"),h=Tm(l),se(t,"class","a9s-presence-label-bg svelte-1rehw2p"),se(t,"x",r[0]),se(t,"y",i=r[1]-18/r[3]),se(t,"height",n=18/r[3]),se(t,"fill",s=r[2].appearance.color),se(t,"stroke",o=r[2].appearance.color),se(a,"font-size",u=12/r[3]),se(a,"x",c=r[0]+Math.round(5/r[3])),se(a,"y",d=r[1]-5/r[3]),se(a,"class","svelte-1rehw2p"),se(e,"class","a9s-presence-label")},m(f,g){bt(f,e,g),Ar(e,t),Ar(e,a),Ar(a,h),r[6](e)},p(f,[g]){g&1&&se(t,"x",f[0]),g&10&&i!==(i=f[1]-18/f[3])&&se(t,"y",i),g&8&&n!==(n=18/f[3])&&se(t,"height",n),g&4&&s!==(s=f[2].appearance.color)&&se(t,"fill",s),g&4&&o!==(o=f[2].appearance.color)&&se(t,"stroke",o),g&4&&l!==(l=f[2].appearance.label+"")&&TT(h,l),g&8&&u!==(u=12/f[3])&&se(a,"font-size",u),g&9&&c!==(c=f[0]+Math.round(5/f[3]))&&se(a,"x",c),g&10&&d!==(d=f[1]-5/f[3])&&se(a,"y",d)},i:It,o:It,d(f){f&&xt(e),r[6](null)}}}function jP(r,e,t){let{x:i}=e,{y:n}=e,{user:s}=e,{scale:o}=e,{hAlign:a=null}=e,l;const h=c=>{const d=l.querySelector("text"),f=l.querySelector("rect"),g=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${g/2}px)`),f.setAttribute("width",`${g}`)};function u(c){Ul[c?"unshift":"push"](()=>{l=c,t(4,l)})}return r.$$set=c=>{"x"in c&&t(0,i=c.x),"y"in c&&t(1,n=c.y),"user"in c&&t(2,s=c.user),"scale"in c&&t(3,o=c.scale),"hAlign"in c&&t(5,a=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,n,s,o,l,a,u]}class Ky extends ci{constructor(e){super(),ui(this,e,jP,zP,Xt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function WP(r){let e,t,i,n,s,o;return t=new Ky({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){e=At("g"),gi(t.$$.fragment),i=At("polygon"),se(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),se(i,"stroke",n=r[0].appearance.color),se(i,"fill","transparent"),se(i,"points",s=r[2].points.map(Qy).join(" ")),se(e,"class","a9s-presence-overlay")},m(a,l){bt(a,e,l),li(t,e,null),Ar(e,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),t.$set(h),(!o||l&1&&n!==(n=a[0].appearance.color))&&se(i,"stroke",n),(!o||l&4&&s!==(s=a[2].points.map(Qy).join(" ")))&&se(i,"points",s)},i(a){o||(He(t.$$.fragment,a),o=!0)},o(a){Ye(t.$$.fragment,a),o=!1},d(a){a&&xt(e),hi(t)}}}const Qy=r=>r.join(",");function XP(r,e,t){let i,n,{annotation:s}=e,{user:o}=e,{scale:a}=e;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,f])=>{f<u[1]&&(u=[d,f])}),u};return r.$$set=h=>{"annotation"in h&&t(4,s=h.annotation),"user"in h&&t(0,o=h.user),"scale"in h&&t(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&t(2,i=s.target.selector.geometry),r.$$.dirty&4&&t(3,n=l(i))},[o,a,i,n,s]}class YP extends ci{constructor(e){super(),ui(this,e,XP,WP,Xt,{annotation:4,user:0,scale:1})}}function ZP(r){let e,t,i,n,s,o,a,l,h;return t=new Ky({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){e=At("g"),gi(t.$$.fragment),i=At("rect"),se(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),se(i,"stroke",n=r[0].appearance.color),se(i,"fill","transparent"),se(i,"x",s=r[2].x),se(i,"y",o=r[2].y),se(i,"width",a=r[2].w),se(i,"height",l=r[2].h),se(e,"class","a9s-presence-overlay")},m(u,c){bt(u,e,c),li(t,e,null),Ar(e,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),t.$set(d),(!h||c&1&&n!==(n=u[0].appearance.color))&&se(i,"stroke",n),(!h||c&4&&s!==(s=u[2].x))&&se(i,"x",s),(!h||c&4&&o!==(o=u[2].y))&&se(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&se(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&se(i,"height",l)},i(u){h||(He(t.$$.fragment,u),h=!0)},o(u){Ye(t.$$.fragment,u),h=!1},d(u){u&&xt(e),hi(t)}}}function qP(r,e,t){let i,{annotation:n}=e,{user:s}=e,{scale:o}=e;return r.$$set=a=>{"annotation"in a&&t(3,n=a.annotation),"user"in a&&t(0,s=a.user),"scale"in a&&t(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&t(2,i=n.target.selector.geometry)},[s,o,i,n]}class KP extends ci{constructor(e){super(),ui(this,e,qP,ZP,Xt,{annotation:3,user:0,scale:1})}}const{Boolean:QP}=Ac;function Jy(r,e,t){const i=r.slice();return i[8]=e[t],i}function $y(r){let e,t;return e=new uf({props:{viewer:r[0],$$slots:{default:[eI,({transform:i,scale:n})=>({6:i,7:n}),({transform:i,scale:n})=>(i?64:0)|(n?128:0)]},$$scope:{ctx:r}}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&2244&&(s.$$scope={dirty:n,ctx:i}),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function e_(r){let e,t,i=wn(r[2]),n=[];for(let o=0;o<i.length;o+=1)n[o]=t_(Jy(r,i,o));const s=o=>Ye(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();e=Zr()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);bt(o,e,a),t=!0},p(o,a){if(a&132){i=wn(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Jy(o,i,l);n[l]?(n[l].p(h,a),He(n[l],1)):(n[l]=t_(h),n[l].c(),He(n[l],1),n[l].m(e.parentNode,e))}for(Zi(),l=i.length;l<n.length;l+=1)s(l);qi()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)He(n[a]);t=!0}},o(o){n=n.filter(QP);for(let a=0;a<n.length;a+=1)Ye(n[a]);t=!1},d(o){o&&xt(e),kl(n,o)}}}function JP(r){let e,t;return e=new YP({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function $P(r){let e,t;return e=new KP({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function t_(r){let e,t,i,n;const s=[$P,JP],o=[];function a(l,h){return l[8].annotation.target.selector.type===ht.RECTANGLE?0:l[8].annotation.target.selector.type===ht.POLYGON?1:-1}return~(e=a(r))&&(t=o[e]=s[e](r)),{c(){t&&t.c(),i=Zr()},m(l,h){~e&&o[e].m(l,h),bt(l,i,h),n=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&(Zi(),Ye(o[u],1,1,()=>{o[u]=null}),qi()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),He(t,1),t.m(i.parentNode,i)):t=null)},i(l){n||(He(t),n=!0)},o(l){Ye(t),n=!1},d(l){l&&xt(i),~e&&o[e].d(l)}}}function eI(r){let e,t,i,n,s=r[2].length>0&&e_(r);return{c(){e=At("svg"),t=At("g"),s&&s.c(),se(t,"transform",i=r[6]),se(e,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){bt(o,e,a),Ar(e,t),s&&s.m(t,null),n=!0},p(o,a){o[2].length>0?s?(s.p(o,a),a&4&&He(s,1)):(s=e_(o),s.c(),He(s,1),s.m(t,null)):s&&(Zi(),Ye(s,1,1,()=>{s=null}),qi()),(!n||a&64&&i!==(i=o[6]))&&se(t,"transform",i)},i(o){n||(He(s),n=!0)},o(o){Ye(s),n=!1},d(o){o&&xt(e),s&&s.d()}}}function tI(r){let e=!!r[1],t,i,n=e&&$y(r);return{c(){n&&n.c(),t=Zr()},m(s,o){n&&n.m(s,o),bt(s,t,o),i=!0},p(s,[o]){o&2&&(e=!!s[1]),e?n?(n.p(s,o),o&2&&He(n,1)):(n=$y(s),n.c(),He(n,1),n.m(t.parentNode,t)):n&&(Zi(),Ye(n,1,1,()=>{n=null}),qi())},i(s){i||(He(n),i=!0)},o(s){Ye(n),i=!1},d(s){s&&xt(t),n&&n.d(s)}}}function iI(r,e,t){let{store:i}=e,{viewer:n}=e,{provider:s}=e,o=[],a;const l=(h,u)=>{t(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:f}=c.changes,g=new Set((d||[]).map(m=>m.id)),p=o.filter(({annotation:m})=>!g.has(m.id)).map(m=>{const v=(f||[]).find(y=>y.oldValue.id===m.annotation.id);return v?{selectedBy:m.selectedBy,annotation:v.newValue}:m});t(2,o=p)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return AT(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&t(3,i=h.store),"viewer"in h&&t(0,n=h.viewer),"provider"in h&&t(1,s=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&s&&s.on("selectionChange",l)},[n,s,o,i]}class rI extends ci{constructor(e){super(),ui(this,e,iI,tI,Xt,{store:3,viewer:0,provider:1})}}function nI(r){let e,t,i,n,s;return{c(){e=At("ellipse"),se(e,"cx",t=r[0].cx),se(e,"cy",i=r[0].cy),se(e,"rx",n=r[0].rx),se(e,"ry",s=r[0].ry)},m(o,a){bt(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].cx)&&se(e,"cx",t),a&1&&i!==(i=o[0].cy)&&se(e,"cy",i),a&1&&n!==(n=o[0].rx)&&se(e,"rx",n),a&1&&s!==(s=o[0].ry)&&se(e,"ry",s)},i:It,o:It,d(o){o&&xt(e)}}}function sI(r,e,t){let i,{annotation:n}=e;return r.$$set=s=>{"annotation"in s&&t(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&t(0,i=n.target.selector.geometry)},[i,n]}class oI extends ci{constructor(e){super(),ui(this,e,sI,nI,Xt,{annotation:1})}}function aI(r){let e,t,i,n,s;return{c(){e=At("line"),se(e,"x1",t=r[0].points[0][0]),se(e,"y1",i=r[0].points[0][1]),se(e,"x2",n=r[0].points[1][0]),se(e,"y2",s=r[0].points[1][1])},m(o,a){bt(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].points[0][0])&&se(e,"x1",t),a&1&&i!==(i=o[0].points[0][1])&&se(e,"y1",i),a&1&&n!==(n=o[0].points[1][0])&&se(e,"x2",n),a&1&&s!==(s=o[0].points[1][1])&&se(e,"y2",s)},i:It,o:It,d(o){o&&xt(e)}}}function lI(r,e,t){let i,{annotation:n}=e;return r.$$set=s=>{"annotation"in s&&t(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&t(0,i=n.target.selector.geometry)},[i,n]}class hI extends ci{constructor(e){super(),ui(this,e,lI,aI,Xt,{annotation:1})}}function i_(r,e,t){const i=r.slice();return i[2]=e[t],i}function r_(r){let e,t;return{c(){e=At("path"),t=At("path"),se(e,"fill-rule","evenodd"),se(e,"d",yn(r[2])),se(t,"class","a9s-inner"),se(t,"fill-rule","evenodd"),se(t,"d",yn(r[2]))},m(i,n){bt(i,e,n),bt(i,t,n)},p:It,d(i){i&&(xt(e),xt(t))}}}function uI(r){let e,t=wn(r[0]),i=[];for(let n=0;n<t.length;n+=1)i[n]=r_(i_(r,t,n));return{c(){e=At("g");for(let n=0;n<i.length;n+=1)i[n].c()},m(n,s){bt(n,e,s);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(e,null)},p(n,[s]){if(s&1){t=wn(n[0]);let o;for(o=0;o<t.length;o+=1){const a=i_(n,t,o);i[o]?i[o].p(a,s):(i[o]=r_(a),i[o].c(),i[o].m(e,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=t.length}},i:It,o:It,d(n){n&&xt(e),kl(i,n)}}}function cI(r,e,t){let{annotation:i}=e;const{polygons:n}=i.target.selector.geometry;return r.$$set=s=>{"annotation"in s&&t(1,i=s.annotation)},[n,i]}class dI extends ci{constructor(e){super(),ui(this,e,cI,uI,Xt,{annotation:1})}}function fI(r){let e,t;return{c(){e=At("polygon"),se(e,"points",t=r[0].points.map(n_).join(" "))},m(i,n){bt(i,e,n)},p(i,[n]){n&1&&t!==(t=i[0].points.map(n_).join(" "))&&se(e,"points",t)},i:It,o:It,d(i){i&&xt(e)}}}const n_=r=>r.join(",");function pI(r,e,t){let i,{annotation:n}=e;return r.$$set=s=>{"annotation"in s&&t(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&t(0,i=n.target.selector.geometry)},[i,n]}class gI extends ci{constructor(e){super(),ui(this,e,pI,fI,Xt,{annotation:1})}}function mI(r){let e;return{c(){e=At("path"),se(e,"d",r[0])},m(t,i){bt(t,e,i)},p(t,[i]){i&1&&se(e,"d",t[0])},i:It,o:It,d(t){t&&xt(e)}}}function vI(r,e,t){let i,n,{annotation:s}=e;return r.$$set=o=>{"annotation"in o&&t(1,s=o.annotation)},r.$$.update=()=>{r.$$.dirty&2&&t(2,i=s.target.selector.geometry),r.$$.dirty&4&&t(0,n=Xw(i))},[n,s,i]}class yI extends ci{constructor(e){super(),ui(this,e,vI,mI,Xt,{annotation:1})}}function _I(r){let e,t,i,n,s;return{c(){e=At("rect"),se(e,"x",t=r[0].x),se(e,"y",i=r[0].y),se(e,"width",n=r[0].w),se(e,"height",s=r[0].h)},m(o,a){bt(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].x)&&se(e,"x",t),a&1&&i!==(i=o[0].y)&&se(e,"y",i),a&1&&n!==(n=o[0].w)&&se(e,"width",n),a&1&&s!==(s=o[0].h)&&se(e,"height",s)},i:It,o:It,d(o){o&&xt(e)}}}function xI(r,e,t){let i,{annotation:n}=e;return r.$$set=s=>{"annotation"in s&&t(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&t(0,i=n.target.selector.geometry)},[i,n]}class wI extends ci{constructor(e){super(),ui(this,e,xI,_I,Xt,{annotation:1})}}const{Boolean:EI}=Ac;function s_(r,e,t){const i=r.slice();return i[10]=e[t],i}function o_(r){let e,t;return e=new uf({props:{viewer:r[0],$$slots:{default:[PI,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&8710&&(s.$$scope={dirty:n,ctx:i}),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function TI(r){let e,t;return e=new hI({props:{annotation:r[10]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function bI(r){let e,t;return e=new oI({props:{annotation:r[10]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function AI(r){let e,t;return e=new yI({props:{annotation:r[10]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function SI(r){let e,t;return e=new dI({props:{annotation:r[10]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function RI(r){let e,t;return e=new gI({props:{annotation:r[10]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function CI(r){let e,t;return e=new wI({props:{annotation:r[10]}}),{c(){gi(e.$$.fragment)},m(i,n){li(e,i,n),t=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(He(e.$$.fragment,i),t=!0)},o(i){Ye(e.$$.fragment,i),t=!1},d(i){hi(e,i)}}}function a_(r){let e,t,i,n;const s=[CI,RI,SI,AI,bI,TI],o=[];function a(l,h){return l[10].target.selector.type===ht.RECTANGLE?0:l[10].target.selector.type===ht.POLYGON?1:l[10].target.selector.type===ht.MULTIPOLYGON?2:l[10].target.selector.type===ht.POLYLINE?3:l[10].target.selector.type===ht.ELLIPSE?4:l[10].target.selector.type===ht.LINE?5:-1}return~(e=a(r))&&(t=o[e]=s[e](r)),{c(){t&&t.c(),i=Zr()},m(l,h){~e&&o[e].m(l,h),bt(l,i,h),n=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&(Zi(),Ye(o[u],1,1,()=>{o[u]=null}),qi()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),He(t,1),t.m(i.parentNode,i)):t=null)},i(l){n||(He(t),n=!0)},o(l){Ye(t),n=!1},d(l){l&&xt(i),~e&&o[e].d(l)}}}function PI(r){let e,t,i,n,s,o,a,l,h,u,c,d,f,g,p=wn(r[1].filter(r[6])),m=[];for(let y=0;y<p.length;y+=1)m[y]=a_(s_(r,p,y));const v=y=>Ye(m[y],1,1,()=>{m[y]=null});return{c(){var y,_,w,A;e=At("svg"),t=At("g"),i=At("rect"),l=At("rect");for(let F=0;F<m.length;F+=1)m[F].c();se(i,"class","a9s-union-bg svelte-jwrce3"),se(i,"x",n=(y=r[2])==null?void 0:y.minX),se(i,"y",s=(_=r[2])==null?void 0:_.minY),se(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),se(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),se(l,"class","a9s-union-fg svelte-jwrce3"),se(l,"x",h=(w=r[2])==null?void 0:w.minX),se(l,"y",u=(A=r[2])==null?void 0:A.minY),se(l,"width",c=r[2]?r[2].maxX-r[2].minX:0),se(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),se(t,"transform",f=r[9]),se(e,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(y,_){bt(y,e,_),Ar(e,t),Ar(t,i),Ar(t,l);for(let w=0;w<m.length;w+=1)m[w]&&m[w].m(t,null);g=!0},p(y,_){var w,A,F,C;if((!g||_&4&&n!==(n=(w=y[2])==null?void 0:w.minX))&&se(i,"x",n),(!g||_&4&&s!==(s=(A=y[2])==null?void 0:A.minY))&&se(i,"y",s),(!g||_&4&&o!==(o=y[2]?y[2].maxX-y[2].minX:0))&&se(i,"width",o),(!g||_&4&&a!==(a=y[2]?y[2].maxY-y[2].minY:0))&&se(i,"height",a),(!g||_&4&&h!==(h=(F=y[2])==null?void 0:F.minX))&&se(l,"x",h),(!g||_&4&&u!==(u=(C=y[2])==null?void 0:C.minY))&&se(l,"y",u),(!g||_&4&&c!==(c=y[2]?y[2].maxX-y[2].minX:0))&&se(l,"width",c),(!g||_&4&&d!==(d=y[2]?y[2].maxY-y[2].minY:0))&&se(l,"height",d),_&2){p=wn(y[1].filter(y[6]));let R;for(R=0;R<p.length;R+=1){const M=s_(y,p,R);m[R]?(m[R].p(M,_),He(m[R],1)):(m[R]=a_(M),m[R].c(),He(m[R],1),m[R].m(t,null))}for(Zi(),R=p.length;R<m.length;R+=1)v(R);qi()}(!g||_&512&&f!==(f=y[9]))&&se(t,"transform",f)},i(y){if(!g){for(let _=0;_<p.length;_+=1)He(m[_]);g=!0}},o(y){m=m.filter(EI);for(let _=0;_<m.length;_+=1)Ye(m[_]);g=!1},d(y){y&&xt(e),kl(m,y)}}}function II(r){let e=!!r[2],t,i,n=e&&o_(r);return{c(){n&&n.c(),t=Zr()},m(s,o){n&&n.m(s,o),bt(s,t,o),i=!0},p(s,[o]){o&4&&(e=!!s[2]),e?n?(n.p(s,o),o&4&&He(n,1)):(n=o_(s),n.c(),He(n,1),n.m(t.parentNode,t)):n&&(Zi(),Ye(n,1,1,()=>{n=null}),qi())},i(s){i||(He(n),i=!0)},o(s){Ye(n),i=!1},d(s){s&&xt(t),n&&n.d(s)}}}function MI(r,e,t){let i,n,s,{state:o}=e,{viewer:a}=e;const{store:l}=o,{selection:h}=o;ia(r,h,d=>t(5,s=d));const u=d=>{let f=-1/0,g=-1/0,p=1/0,m=1/0;for(let v of d.filter(y=>_n(y))){const{bounds:y}=v.target.selector.geometry;y.maxX>f&&(f=y.maxX),y.maxY>g&&(g=y.maxY),y.minX<p&&(p=y.minX),y.minY<m&&(m=y.minY)}return a.forceRedraw(),{maxX:f,maxY:g,minX:p,minY:m}},c=d=>_n(d);return r.$$set=d=>{"state"in d&&t(4,o=d.state),"viewer"in d&&t(0,a=d.viewer)},r.$$.update=()=>{r.$$.dirty&32&&t(1,i=s.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&t(2,n=i.length>1?u(i):void 0)},[a,i,n,h,o,s,c]}class DI extends ci{constructor(e){super(),ui(this,e,MI,II,Xt,{state:4,viewer:0})}}const l_=(r,e)=>{e==="auto"?r.addHandler("open",t=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:s}=n;if(s){const o=r.canvas.querySelector("canvas"),a=cT(o);r.element.setAttribute("data-theme",a)}})}):r.element.setAttribute("data-theme",e)},h_=(r,e,t)=>(i,n={})=>{const s=typeof i=="string"?i:i.id,o=e.getAnnotation(s);if(!o||!_n(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=n;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:f,minY:g,maxX:p,maxY:m}=o.target.selector.geometry.bounds,v=p-f,y=m-g,_=f-d*v,w=g-h*y,A=v+(u+d)*v,F=y+(h+c)*y,C=r.viewport.imageToViewportRectangle(_,w,A,F);r.viewport[t](C,n.immediately)},OI=(r,e)=>h_(r,e,"fitBounds"),LI=(r,e)=>h_(r,e,"fitBoundsWithConstraints"),NI=(r,e={})=>{const t=dT(e,{drawingEnabled:!1,drawingMode:ur?"drag":"click",userSelectAction:Eg.EDIT,theme:"light"}),i=hT(t),{hover:n,selection:s,store:o}=i,a=fw(o,t.initialHistory),l=pw(i,a,t.adapter,t.autoSave);let h=Ew(),u=t.drawingEnabled,c=t.drawingMode,d=t.modalSelect;const f=fT(a,r.element),g=new IP({target:r.element,props:{state:i,viewer:r,style:t.style,filter:void 0}}),p=new rI({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),m=new VP({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:t.multiSelect,preferredDrawingMode:c,state:i,style:t.style,user:h,viewer:r}}),v=e.multiSelect?new DI({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}}):void 0;g.$on("click",K=>{const{originalEvent:Q,annotation:W}=K.detail,$=ne=>zy(ne.id,Q,s,t.multiSelect);d?s.isEmpty()&&W&&s.userSelect($(W),Q):W&&!(c==="click"&&u)?s.userSelect($(W),Q):s.isEmpty()||(t.multiSelect?Q.metaKey||Q.shiftKey||Q.ctrlKey||s.userSelect([],Q):s.userSelect([],Q))}),r.element.addEventListener("pointerdown",K=>{if(n.current){const Q=o.getAnnotation(n.current);l.emit("clickAnnotation",Q,K)}}),l_(r,t.theme);const y=mw(i,a,t.adapter),_=()=>m.cancelDrawing(),w=()=>{g.$destroy(),p.$destroy(),m.$destroy(),v==null||v.$destroy(),f.destroy(),a.destroy()},A=OI(r,o),F=LI(r,o),C=()=>m.getDrawingTool(),R=()=>h,M=()=>m.isDrawingEnabled(),k=(K,Q,W)=>eT(K,Q,W),z=(K,Q)=>WE(K,Q),D=K=>{if(!mm(K))throw`No drawing tool named ${K}`;m.$set({toolName:K})},S=K=>{u=K,m.$set({drawingEnabled:K})},b=K=>{c=K,m.$set({preferredDrawingMode:K})},O=K=>{g.$set({filter:K}),m.$set({filter:K})},j=K=>d=K,V=K=>{g.$set({style:K}),m.$set({style:K})},Y=K=>p.$set({provider:K}),G=K=>l_(r,K),H=K=>{h=K,m.$set({user:K})},X=K=>g.$set({visible:K});return{...y,cancelDrawing:_,destroy:w,fitBounds:A,fitBoundsWithConstraints:F,getDrawingTool:C,getUser:R,isDrawingEnabled:M,listDrawingTools:gm,on:l.on,off:l.off,registerDrawingTool:k,registerShapeEditor:z,setDrawingEnabled:S,setDrawingMode:b,setDrawingTool:D,setFilter:O,setModalSelect:j,setPresenceProvider:Y,setStyle:V,setTheme:G,setUser:H,setVisible:X,state:i,viewer:r}};function u_(r){return r.id||r["@id"]||(typeof r.getId=="function"?r.getId():"")}function cf(r){if(!r)return null;const e=r.match(/xywh=(\d+),(\d+),(\d+),(\d+)/);return e?{x:parseInt(e[1],10),y:parseInt(e[2],10),w:parseInt(e[3],10),h:parseInt(e[4],10)}:null}function FI(r){const e=BI(r);if(e)return kI(e);const t=VI(r);return t?{type:"RECTANGLE",geometry:{x:t.x,y:t.y,w:t.w,h:t.h,bounds:{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h}}}:null}function BI(r){var t,i;if(typeof r.getTarget=="function"){const n=((t=r.__jsonld)==null?void 0:t.on)||((i=r.__jsonld)==null?void 0:i.target);if(n)return c_(n)}const e=r.target||r.on;return e?c_(e):null}function c_(r){if(!r)return null;if(Array.isArray(r))for(const e of r){const t=d_(e);if(t)return t}else return d_(r);return null}function d_(r){var t;if(!r)return null;const e=r.selector||r;return(e==null?void 0:e.type)==="SvgSelector"&&e.value?e.value:((t=e==null?void 0:e.item)==null?void 0:t.type)==="SvgSelector"&&e.item.value?e.item.value:null}function kI(r){try{const t=new DOMParser().parseFromString(r,"image/svg+xml");if(t.documentElement.nodeName==="parsererror")return console.warn("Failed to parse SVG selector:",r),null;const i=[];let n={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};const s=t.querySelectorAll("polygon");for(const l of s){const h=l.getAttribute("points");if(h){const u=UI(h);i.push(...u)}}const o=t.querySelectorAll("path");for(const l of o){const h=l.getAttribute("d");if(h){const u=HI(h);i.push(...u)}}const a=t.querySelectorAll("circle");for(const l of a){const h=parseFloat(l.getAttribute("cx")||"0"),u=parseFloat(l.getAttribute("cy")||"0"),c=parseFloat(l.getAttribute("r")||"0"),d=GI(h,u,c);i.push(...d)}for(const[l,h]of i)n.minX=Math.min(n.minX,l),n.minY=Math.min(n.minY,h),n.maxX=Math.max(n.maxX,l),n.maxY=Math.max(n.maxY,h);return i.length===0?null:{type:"POLYGON",geometry:{points:i,bounds:n}}}catch(e){return console.warn("Failed to convert SVG to polygon:",e),null}}function UI(r){const e=[],t=r.trim().split(/\s+/);for(const i of t){const[n,s]=i.split(",").map(o=>parseFloat(o));!isNaN(n)&&!isNaN(s)&&e.push([n,s])}return e}function HI(r){const e=[],t=/[ML]\s*([\d.]+)[,\s]+([\d.]+)/g;let i;for(;(i=t.exec(r))!==null;){const n=parseFloat(i[1]),s=parseFloat(i[2]);!isNaN(n)&&!isNaN(s)&&e.push([n,s])}return e}function GI(r,e,t,i=8){const n=[];for(let s=0;s<i;s++){const o=s/i*Math.PI*2,a=r+t*Math.cos(o),l=e+t*Math.sin(o);n.push([a,l])}return n}function VI(r){var t;if(typeof r.getTarget=="function"){const i=r.getTarget();if(typeof i=="string"&&i.includes("xywh="))return cf(i);const n=(t=r.__jsonld)==null?void 0:t.on;if(n){const s=df(n);if(s)return s}}const e=r.target||r.on;return e?df(e):null}function df(r){if(!r)return null;if(Array.isArray(r))for(const e of r){const t=df(e);if(t)return t}if(typeof r=="string"&&r.includes("xywh="))return cf(r);if(r.selector){const e=r.selector,t=e.item||e;if(t.value&&typeof t.value=="string"&&t.value.includes("xywh="))return cf(t.value)}return null}function zI(r){const e=[];if(typeof r.getBody=="function"){const t=r.getBody();if(t&&Array.isArray(t))for(const i of t){const n=i.getValue?i.getValue():"";i.getFormat&&i.getFormat(),n&&e.push({purpose:"commenting",value:n})}}else{const t=i=>i&&(i.chars||i.value||i["cnt:chars"])||"";if(r.resource){const i=Array.isArray(r.resource)?r.resource:[r.resource];for(const n of i){const s=t(n);s&&e.push({purpose:"commenting",value:s})}}else if(r.body){const i=Array.isArray(r.body)?r.body:[r.body];for(const n of i){const s=t(n);s&&e.push({purpose:"commenting",value:s})}}}if(e.length===0){let t="";typeof r.getLabel=="function"?t=r.getLabel():r.label&&(t=Array.isArray(r.label)?r.label.join(" "):r.label),t&&e.push({purpose:"commenting",value:t})}return e}function jI(r,e,t=!1){const i=u_(r)||`anno-${e}`,n=FI(r);if(!n)return null;const s=zI(r);return t&&s.push({purpose:"search-hit",value:"search-hit"}),{id:i,target:{selector:n},bodies:s}}function WI(r,e=new Set){return r.map((t,i)=>{const n=e.has(u_(t));return jI(t,i,n)}).filter(t=>t!==null)}var XI=rt('<div class="absolute bg-base-200 text-base-content px-3 py-2 rounded-lg shadow-lg text-sm max-w-xs pointer-events-none z-1000"> </div>'),YI=rt('<div class="w-full h-full relative"><div class="w-full h-full osd-background bg-base-100"></div> <!></div>');function ZI(r,e){wt(e,!0);let t=qe(void 0),i=qe(void 0),n=qe(void 0),s=qe(null),o=qe(_i({x:0,y:0})),a=me(()=>{if(!e.viewerState.manifestId||!e.viewerState.canvasId)return[];const p=Ns.getAnnotations(e.viewerState.manifestId,e.viewerState.canvasId),m=e.viewerState.currentCanvasSearchAnnotations,v=e.viewerState.createdAnnotations[e.viewerState.canvasId]||[];return[...p,...m,...v]}),l=me(()=>{const p=new Set;return e.viewerState.currentCanvasSearchAnnotations.forEach(m=>{const v=m.id||m["@id"];v&&p.add(v)}),p}),h=me(()=>WI(P(a),P(l)));U1(()=>{if(P(t))return Me(i,Jn({element:P(t),tileSources:null,prefixUrl:"",showNavigationControl:!1,showHomeControl:!1,showFullPageControl:!1,showSequenceControl:!1,showZoomControl:!1,showRotationControl:!1,animationTime:.5,springStiffness:7,zoomPerClick:2}),!0),Me(n,NI(P(i),{drawingEnabled:!1,readOnly:!0,disableSelect:!0}),!0),P(n).on("createAnnotation",p=>{const m={...p,id:p.id||crypto.randomUUID(),motivation:"commenting",target:{...p.target,source:e.viewerState.canvasId}};e.viewerState.addAnnotation(m,e.viewerState.canvasId)}),e.viewerState.canvasId&&e.viewerState.loadAnnotationsFromStorage(e.viewerState.canvasId),P(n).on("selectionChanged",p=>{p&&p.length>0&&P(n)&&P(n).cancelSelected()}),P(n).on("mouseEnterAnnotation",p=>{Me(s,p,!0)}),P(n).on("mouseLeaveAnnotation",()=>{Me(s,null)}),P(t)&&P(t).addEventListener("pointermove",p=>{const m=P(t).getBoundingClientRect();Me(o,{x:p.clientX-m.left,y:p.clientY-m.top},!0)}),()=>{var p,m;(p=P(n))==null||p.destroy(),(m=P(i))==null||m.destroy()}}),Ri(()=>{!P(i)||!e.tileSources||P(i).open(e.tileSources)}),Ri(()=>{P(n)&&P(n).setAnnotations(P(h))}),Ri(()=>{P(n)&&P(n).setStyle(p=>{var v;const m=(v=p.bodies)==null?void 0:v.some(y=>y.purpose==="search-hit");return{fill:m?"#facc15":"#ef4444",fillOpacity:m?.4:.2,stroke:m?"#facc15":"#ef4444",strokeWidth:m?1:2}})}),Ri(()=>{P(n)&&(P(n).setDrawingEnabled(e.viewerState.isCreatingAnnotation),e.viewerState.isCreatingAnnotation&&P(n).setDrawingTool("rect"))}),Ri(()=>{e.viewerState.canvasId&&e.viewerState.loadAnnotationsFromStorage(e.viewerState.canvasId)}),Ri(()=>{if(!P(n))return;const p=e.viewerState.showAnnotations,m=e.viewerState.visibleAnnotationIds;P(n).setFilter(v=>{var y;return(y=v.bodies)!=null&&y.some(_=>_.purpose==="search-hit")?!0:p?m.has(v.id):!1})});function u(p){if(!p.bodies||p.bodies.length===0)return"Annotation";const m=p.bodies.find(v=>v.purpose==="commenting");return(m==null?void 0:m.value)||"Annotation"}var c=YI(),d=ce(c);Vp(d,p=>Me(t,p),()=>P(t));var f=we(d,2);{var g=p=>{var m=XI(),v=ce(m,!0);ue(m),Lt(y=>{yl(m,`left: ${P(o).x+15}px; top: ${P(o).y+15}px;`),ai(v,y)},[()=>u(P(s))]),U(p,m)};ie(f,p=>{P(s)&&e.viewerState.showAnnotations&&p(g)})}ue(c),U(r,c),Et()}let f_=Symbol("phosphor-svelte");function Ni(){return r1(f_)?Ps(f_):{}}var qI=le('<path d="M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z"></path>'),KI=le('<path d="M160,48V208L80,128Z" opacity="0.2"></path><path d="M163.06,40.61a8,8,0,0,0-8.72,1.73l-80,80a8,8,0,0,0,0,11.32l80,80A8,8,0,0,0,168,208V48A8,8,0,0,0,163.06,40.61ZM152,188.69,91.31,128,152,67.31Z"></path>',1),QI=le('<path d="M168,48V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,168,48Z"></path>'),JI=le('<path d="M164.24,203.76a6,6,0,1,1-8.48,8.48l-80-80a6,6,0,0,1,0-8.48l80-80a6,6,0,0,1,8.48,8.48L88.49,128Z"></path>'),$I=le('<path d="M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z"></path>'),eM=le('<path d="M162.83,205.17a4,4,0,0,1-5.66,5.66l-80-80a4,4,0,0,1,0-5.66l80-80a4,4,0,1,1,5.66,5.66L85.66,128Z"></path>'),tM=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function iM(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=tM();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=qI();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=KI();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=QI();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=JI();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=$I();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=eM();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var rM=le('<path d="M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"></path>'),nM=le('<path d="M176,128,96,208V48Z" opacity="0.2"></path><path d="M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z"></path>',1),sM=le('<path d="M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z"></path>'),oM=le('<path d="M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z"></path>'),aM=le('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"></path>'),lM=le('<path d="M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z"></path>'),hM=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function uM(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=hM();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=rM();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=nM();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=sM();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=oM();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=aM();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=lM();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var cM=rt('<div><button class="btn btn-circle btn-sm btn-ghost" aria-label="Previous Canvas"><!></button> <span class="text-sm font-mono tabular-nums"> </span> <button class="btn btn-circle btn-sm btn-ghost" aria-label="Next Canvas"><!></button></div>');function dM(r,e){wt(e,!0);var t=cM(),i=ce(t);i.__click=()=>e.viewerState.previousCanvas();var n=ce(i);iM(n,{size:20,weight:"bold"}),ue(i);var s=we(i,2),o=ce(s);ue(s);var a=we(s,2);a.__click=()=>e.viewerState.nextCanvas();var l=ce(a);uM(l,{size:20,weight:"bold"}),ue(a),ue(t),Lt(()=>{Nt(t,1,`absolute left-1/2 -translate-x-1/2 bg-base-200/90 backdrop-blur rounded-full shadow-lg px-4 py-2 flex items-center gap-4 z-10 border border-base-300 transition-all duration-200 ${e.viewerState.showThumbnailGallery&&e.viewerState.isGalleryDockedBottom?"bottom-40":"bottom-4"}`),i.disabled=!e.viewerState.hasPrevious,ai(o,`${e.viewerState.currentCanvasIndex+1} / ${e.viewerState.canvases.length??""}`),a.disabled=!e.viewerState.hasNext}),U(r,t),Et()}Kn(["click"]);var fM=le('<path d="M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z"></path>'),pM=le('<path d="M208,96l-80,80L48,96Z" opacity="0.2"></path><path d="M215.39,92.94A8,8,0,0,0,208,88H48a8,8,0,0,0-5.66,13.66l80,80a8,8,0,0,0,11.32,0l80-80A8,8,0,0,0,215.39,92.94ZM128,164.69,67.31,104H188.69Z"></path>',1),gM=le('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z"></path>'),mM=le('<path d="M212.24,100.24l-80,80a6,6,0,0,1-8.48,0l-80-80a6,6,0,0,1,8.48-8.48L128,167.51l75.76-75.75a6,6,0,0,1,8.48,8.48Z"></path>'),vM=le('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path>'),yM=le('<path d="M210.83,98.83l-80,80a4,4,0,0,1-5.66,0l-80-80a4,4,0,0,1,5.66-5.66L128,170.34l77.17-77.17a4,4,0,1,1,5.66,5.66Z"></path>'),_M=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function xM(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=_M();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=fM();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=pM();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=gM();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=mM();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=vM();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=yM();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var wM=le('<path d="M251,123.13c-.37-.81-9.13-20.26-28.48-39.61C196.63,57.67,164,44,128,44S59.37,57.67,33.51,83.52C14.16,102.87,5.4,122.32,5,123.13a12.08,12.08,0,0,0,0,9.75c.37.82,9.13,20.26,28.49,39.61C59.37,198.34,92,212,128,212s68.63-13.66,94.48-39.51c19.36-19.35,28.12-38.79,28.49-39.61A12.08,12.08,0,0,0,251,123.13Zm-46.06,33C183.47,177.27,157.59,188,128,188s-55.47-10.73-76.91-31.88A130.36,130.36,0,0,1,29.52,128,130.45,130.45,0,0,1,51.09,99.89C72.54,78.73,98.41,68,128,68s55.46,10.73,76.91,31.89A130.36,130.36,0,0,1,226.48,128,130.45,130.45,0,0,1,204.91,156.12ZM128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,64a20,20,0,1,1,20-20A20,20,0,0,1,128,148Z"></path>'),EM=le('<path d="M128,56C48,56,16,128,16,128s32,72,112,72,112-72,112-72S208,56,128,56Zm0,112a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z" opacity="0.2"></path><path d="M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"></path>',1),TM=le('<path d="M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,168a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z"></path>'),bM=le('<path d="M245.48,125.57c-.34-.78-8.66-19.23-27.24-37.81C201,70.54,171.38,50,128,50S55,70.54,37.76,87.76c-18.58,18.58-26.9,37-27.24,37.81a6,6,0,0,0,0,4.88c.34.77,8.66,19.22,27.24,37.8C55,185.47,84.62,206,128,206s73-20.53,90.24-37.75c18.58-18.58,26.9-37,27.24-37.8A6,6,0,0,0,245.48,125.57ZM128,194c-31.38,0-58.78-11.42-81.45-33.93A134.77,134.77,0,0,1,22.69,128,134.56,134.56,0,0,1,46.55,95.94C69.22,73.42,96.62,62,128,62s58.78,11.42,81.45,33.94A134.56,134.56,0,0,1,233.31,128C226.94,140.21,195,194,128,194Zm0-112a46,46,0,1,0,46,46A46.06,46.06,0,0,0,128,82Zm0,80a34,34,0,1,1,34-34A34,34,0,0,1,128,162Z"></path>'),AM=le('<path d="M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"></path>'),SM=le('<path d="M243.66,126.38c-.34-.76-8.52-18.89-26.83-37.2C199.87,72.22,170.7,52,128,52S56.13,72.22,39.17,89.18c-18.31,18.31-26.49,36.44-26.83,37.2a4.08,4.08,0,0,0,0,3.25c.34.77,8.52,18.89,26.83,37.2,17,17,46.14,37.17,88.83,37.17s71.87-20.21,88.83-37.17c18.31-18.31,26.49-36.43,26.83-37.2A4.08,4.08,0,0,0,243.66,126.38Zm-32.7,35c-23.07,23-51,34.62-83,34.62s-59.89-11.65-83-34.62A135.71,135.71,0,0,1,20.44,128,135.69,135.69,0,0,1,45,94.62C68.11,71.65,96,60,128,60s59.89,11.65,83,34.62A135.79,135.79,0,0,1,235.56,128,135.71,135.71,0,0,1,211,161.38ZM128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,80a36,36,0,1,1,36-36A36,36,0,0,1,128,164Z"></path>'),RM=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function p_(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=RM();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=wM();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=EM();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=TM();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=bM();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=AM();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=SM();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var CM=le('<path d="M56.88,31.93A12,12,0,1,0,39.12,48.07l16,17.65C20.67,88.66,5.72,121.58,5,123.13a12.08,12.08,0,0,0,0,9.75c.37.82,9.13,20.26,28.49,39.61C59.37,198.34,92,212,128,212a131.34,131.34,0,0,0,51-10l20.09,22.1a12,12,0,0,0,17.76-16.14ZM128,188c-29.59,0-55.47-10.73-76.91-31.88A130.69,130.69,0,0,1,29.52,128c5.27-9.31,18.79-29.9,42-44.29l90.09,99.11A109.33,109.33,0,0,1,128,188Zm123-55.12c-.36.81-9,20-28,39.16a12,12,0,1,1-17-16.9A130.48,130.48,0,0,0,226.48,128a130.36,130.36,0,0,0-21.57-28.12C183.46,78.73,157.59,68,128,68c-3.35,0-6.7.14-10,.42a12,12,0,1,1-2-23.91c3.93-.34,8-.51,12-.51,36,0,68.63,13.67,94.49,39.52,19.35,19.35,28.11,38.8,28.48,39.61A12.08,12.08,0,0,1,251,132.88Z"></path>'),PM=le('<path d="M128,56C48,56,16,128,16,128s32,72,112,72,112-72,112-72S208,56,128,56Zm0,112a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z" opacity="0.2"></path><path d="M53.92,34.62A8,8,0,1,0,42.08,45.38L61.32,66.55C25,88.84,9.38,123.2,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208a127.11,127.11,0,0,0,52.07-10.83l22,24.21a8,8,0,1,0,11.84-10.76Zm47.33,75.84,41.67,45.85a32,32,0,0,1-41.67-45.85ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.16,133.16,0,0,1,25,128c4.69-8.79,19.66-33.39,47.35-49.38l18,19.75a48,48,0,0,0,63.66,70l14.73,16.2A112,112,0,0,1,128,192Zm6-95.43a8,8,0,0,1,3-15.72,48.16,48.16,0,0,1,38.77,42.64,8,8,0,0,1-7.22,8.71,6.39,6.39,0,0,1-.75,0,8,8,0,0,1-8-7.26A32.09,32.09,0,0,0,134,96.57Zm113.28,34.69c-.42.94-10.55,23.37-33.36,43.8a8,8,0,1,1-10.67-11.92A132.77,132.77,0,0,0,231.05,128a133.15,133.15,0,0,0-23.12-30.77C185.67,75.19,158.78,64,128,64a118.37,118.37,0,0,0-19.36,1.57A8,8,0,1,1,106,49.79,134,134,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41A8,8,0,0,1,247.31,131.26Z"></path>',1),IM=le('<path d="M96.68,57.87a4,4,0,0,1,2.08-6.6A130.13,130.13,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41a8,8,0,0,1,0,6.5c-.35.79-8.82,19.57-27.65,38.4q-4.28,4.26-8.79,8.07a4,4,0,0,1-5.55-.36ZM213.92,210.62a8,8,0,1,1-11.84,10.76L180,197.13A127.21,127.21,0,0,1,128,208c-34.88,0-66.57-13.26-91.66-38.34C17.51,150.83,9,132.05,8.69,131.26a8,8,0,0,1,0-6.5C9,124,17.51,105.18,36.34,86.35a135,135,0,0,1,25-19.78L42.08,45.38A8,8,0,1,1,53.92,34.62Zm-65.49-48.25-52.69-58a40,40,0,0,0,52.69,58Z"></path>'),MM=le('<path d="M52.44,36A6,6,0,0,0,43.56,44L64.44,67c-37.28,21.9-53.23,57-53.92,58.57a6,6,0,0,0,0,4.88c.34.77,8.66,19.22,27.24,37.8C55,185.47,84.62,206,128,206a124.91,124.91,0,0,0,52.57-11.25l23,25.29a6,6,0,0,0,8.88-8.08Zm48.62,71.32,45,49.52a34,34,0,0,1-45-49.52ZM128,194c-31.38,0-58.78-11.42-81.45-33.93A134.57,134.57,0,0,1,22.69,128c4.29-8.2,20.1-35.18,50-51.91L92.89,98.3a46,46,0,0,0,61.35,67.48l17.81,19.6A113.47,113.47,0,0,1,128,194Zm6.4-99.4a6,6,0,0,1,2.25-11.79,46.17,46.17,0,0,1,37.15,40.87,6,6,0,0,1-5.42,6.53l-.56,0a6,6,0,0,1-6-5.45A34.1,34.1,0,0,0,134.4,94.6Zm111.08,35.85c-.41.92-10.37,23-32.86,43.12a6,6,0,1,1-8-8.94A134.07,134.07,0,0,0,233.31,128a134.67,134.67,0,0,0-23.86-32.07C186.78,73.42,159.38,62,128,62a120.19,120.19,0,0,0-19.69,1.6,6,6,0,1,1-2-11.83A131.12,131.12,0,0,1,128,50c43.38,0,73,20.54,90.24,37.76,18.58,18.58,26.9,37,27.24,37.81A6,6,0,0,1,245.48,130.45Z"></path>'),DM=le('<path d="M53.92,34.62A8,8,0,1,0,42.08,45.38L61.32,66.55C25,88.84,9.38,123.2,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208a127.11,127.11,0,0,0,52.07-10.83l22,24.21a8,8,0,1,0,11.84-10.76Zm47.33,75.84,41.67,45.85a32,32,0,0,1-41.67-45.85ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.16,133.16,0,0,1,25,128c4.69-8.79,19.66-33.39,47.35-49.38l18,19.75a48,48,0,0,0,63.66,70l14.73,16.2A112,112,0,0,1,128,192Zm6-95.43a8,8,0,0,1,3-15.72,48.16,48.16,0,0,1,38.77,42.64,8,8,0,0,1-7.22,8.71,6.39,6.39,0,0,1-.75,0,8,8,0,0,1-8-7.26A32.09,32.09,0,0,0,134,96.57Zm113.28,34.69c-.42.94-10.55,23.37-33.36,43.8a8,8,0,1,1-10.67-11.92A132.77,132.77,0,0,0,231.05,128a133.15,133.15,0,0,0-23.12-30.77C185.67,75.19,158.78,64,128,64a118.37,118.37,0,0,0-19.36,1.57A8,8,0,1,1,106,49.79,134,134,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41A8,8,0,0,1,247.31,131.26Z"></path>'),OM=le('<path d="M51,37.31A4,4,0,0,0,45,42.69L67.59,67.5C29.34,89,13,124.81,12.34,126.38a4.08,4.08,0,0,0,0,3.25c.34.77,8.52,18.89,26.83,37.2,17,17,46.14,37.17,88.83,37.17a122.59,122.59,0,0,0,53.06-11.69l24,26.38a4,4,0,1,0,5.92-5.38ZM149.1,157.16A36,36,0,0,1,101,104.22ZM128,196c-32,0-59.89-11.65-83-34.62A135.81,135.81,0,0,1,20.44,128c3.65-7.23,20.09-36.81,52.68-54.43l22.45,24.7a44,44,0,0,0,59,64.83l20.89,23A114.94,114.94,0,0,1,128,196Zm6.78-103.36a4,4,0,0,1,1.49-7.86,44.15,44.15,0,0,1,35.54,39.09,4,4,0,0,1-3.61,4.35l-.38,0a4,4,0,0,1-4-3.63A36.1,36.1,0,0,0,134.78,92.64Zm108.88,37c-.41.91-10.2,22.58-32.38,42.45a4,4,0,0,1-2.67,1,4,4,0,0,1-2.67-7A136.71,136.71,0,0,0,235.56,128,136.07,136.07,0,0,0,211,94.62C187.89,71.65,160,60,128,60a122,122,0,0,0-20,1.63,4,4,0,0,1-1.32-7.89A129.3,129.3,0,0,1,128,52c42.7,0,71.87,20.22,88.83,37.18,18.31,18.31,26.49,36.44,26.83,37.2A4.08,4.08,0,0,1,243.66,129.63Z"></path>'),LM=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function g_(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=LM();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=CM();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=PM();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=IM();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=MM();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=DM();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=OM();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var NM=rt('<span class="text-xs opacity-50 truncate max-w-[150px]"> </span>'),FM=rt('<button class="w-full text-left p-3 hover:bg-base-300 transition-colors cursor-pointer flex gap-3 group/item items-start focus:outline-none focus:bg-base-300"><div class="btn btn-xs btn-circle btn-ghost mt-0.5 shrink-0 pointer-events-none"><!></div> <div class="flex-1 min-w-0"><div class="flex items-start justify-between"><span class="font-bold text-sm text-primary"></span> <!></div> <div><!></div></div></button>'),BM=rt('<div class="p-4 text-center opacity-50 text-sm">No annotations yet. Click the pencil to draw.</div>'),kM=rt('<div class="absolute top-4 right-4 z-500 pointer-events-auto"><details class="group relative"><summary class="flex items-center gap-2 bg-base-200/90 backdrop-blur shadow-lg rounded-full px-4 py-2 cursor-pointer list-none hover:bg-base-200 transition-all select-none border border-base-300 pointer-events-auto"><button class="btn btn-xs btn-circle btn-ghost"><!></button> <span class="text-sm font-medium"> <span class="opacity-50 text-xs font-normal ml-1"> </span></span> <!></summary> <div class="absolute right-0 mt-2 w-96 bg-base-200/95 backdrop-blur shadow-xl rounded-box p-0 max-h-[60vh] overflow-y-auto border border-base-300 flex flex-col divide-y divide-base-300"></div></details></div>');function UM(r,e){wt(e,!0);const t=Ps(Fs);let i=me(()=>{if(!t.manifestId||!t.canvasId)return[];const d=Ns.getAnnotations(t.manifestId,t.canvasId),f=t.currentCanvasSearchAnnotations;return[...d,...f]});function n(d){return d.id||d["@id"]||(typeof d.getId=="function"?d.getId():"")||""}Ri(()=>{if(P(i).length>0){const d=new Set;P(i).forEach(f=>{const g=n(f);g&&d.add(g)}),t.visibleAnnotationIds=d}else t.visibleAnnotationIds=new Set});let s=me(()=>P(i).length===0?!1:P(i).every(d=>{const f=n(d);return!f||t.visibleAnnotationIds.has(f)}));function o(d){t.visibleAnnotationIds.has(d)?t.visibleAnnotationIds.delete(d):t.visibleAnnotationIds.add(d),t.visibleAnnotationIds=new Set(t.visibleAnnotationIds)}function a(){if(P(s))t.visibleAnnotationIds=new Set;else{const d=new Set;P(i).forEach(f=>{const g=n(f);g&&d.add(g)}),t.visibleAnnotationIds=d}}let l=me(()=>P(i).length?P(i).map(d=>{let f="",g=!1;if(typeof d.getBody=="function"){const p=d.getBody();if(p&&p.length){const m=v=>{const y=v.getValue?v.getValue():null;return y||""};f=p.map(v=>m(v)).filter(Boolean).join(" "),g=p.some(v=>{const y=v.getFormat?v.getFormat():"";return y==="text/html"||y==="application/html"})}if(!f&&typeof d.getLabel=="function"){const m=d.getLabel();m&&(f=m)}}else{const p=v=>v&&(v.chars||v.value||v["cnt:chars"])||"",m=v=>v?v.format==="text/html"||v.type==="TextualBody":!1;if(d.resource?Array.isArray(d.resource)?(f=d.resource.map(v=>p(v)).join(" "),d.resource.some(v=>m(v))&&(g=!0)):(f=p(d.resource),m(d.resource)&&(g=!0)):d.body&&(Array.isArray(d.body)?(f=d.body.map(v=>p(v)).join(" "),d.body.some(v=>m(v))&&(g=!0)):(f=p(d.body),m(d.body)&&(g=!0))),!f){const v=d.label||d.name||d.title;v&&(f=Array.isArray(v)?v.join(" "):v)}}return{id:n(d),content:f,isHtml:g,label:(typeof d.getLabel=="function"?d.getLabel():d.label)||""}}):[]);var h=de(),u=oe(h);{var c=d=>{var f=kM(),g=ce(f),p=ce(g),m=ce(p);m.__click=k=>{k.preventDefault(),a()};var v=ce(m);{var y=k=>{p_(k,{size:16,weight:"bold"})},_=k=>{g_(k,{size:16,weight:"bold"})};ie(v,k=>{P(s)?k(y):k(_,!1)})}ue(m);var w=we(m,2),A=ce(w),F=we(A),C=ce(F);ue(F),ue(w);var R=we(w,2);xM(R,{size:16,weight:"bold",class:"group-open:rotate-180 transition-transform opacity-80"}),ue(p);var M=we(p,2);vl(M,21,()=>P(l),ml,(k,z,D)=>{const S=me(()=>t.visibleAnnotationIds.has(P(z).id));var b=FM();b.__click=pe=>{pe.preventDefault(),o(P(z).id)};var O=ce(b),j=ce(O);{var V=pe=>{p_(pe,{size:16,weight:"bold"})},Y=pe=>{g_(pe,{size:16,weight:"bold"})};ie(j,pe=>{P(S)?pe(V):pe(Y,!1)})}ue(O);var G=we(O,2),H=ce(G),X=ce(H);X.textContent=`#${D+1}`;var K=we(X,2);{var Q=pe=>{var Ce=NM(),Pe=ce(Ce,!0);ue(Ce),Lt(()=>ai(Pe,P(z).label)),U(pe,Ce)};ie(K,pe=>{P(z).label&&P(z).label!==P(z).content&&pe(Q)})}ue(H);var W=we(H,2),$=ce(W);{var ne=pe=>{var Ce=de(),Pe=oe(Ce);Qn(Pe,()=>P(z).content),U(pe,Ce)},_e=pe=>{var Ce=Ti();Lt(()=>ai(Ce,P(z).content||"(No content)")),U(pe,Ce)};ie($,pe=>{P(z).isHtml?pe(ne):pe(_e,!1)})}ue(W),ue(G),ue(b),Lt(()=>Nt(W,1,`text-sm prose prose-sm max-w-none prose-p:my-0 prose-a:text-blue-500 wrap-break-word text-left ${P(S)?"":"opacity-50"}`)),U(k,b)},k=>{var z=BM();U(k,z)}),ue(M),ue(g),ue(f),Lt(()=>{Mi(m,"title",P(s)?"Hide All Annotations":"Show All Annotations"),ai(A,`${P(i).length??""} Annotations `),ai(C,`(${t.visibleAnnotationIds.size??""} visible)`)}),U(d,f)};ie(u,d=>{t.showAnnotations&&d(c)})}U(r,h),Et()}Kn(["click"]);var HM=le('<path d="M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"></path>'),GM=le('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z" opacity="0.2"></path><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>',1),VM=le('<path d="M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>'),zM=le('<path d="M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"></path>'),jM=le('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>'),WM=le('<path d="M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"></path>'),XM=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function YM(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=XM();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=HM();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=GM();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=VM();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=zM();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=jM();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=WM();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var ZM=rt('<img class="object-contain w-full h-full" loading="lazy"/>'),qM=rt('<span class="opacity-20 text-4xl">?</span>'),KM=rt('<button><div class="aspect-4/3 bg-base-300 rounded overflow-hidden relative w-full flex items-center justify-center"><!></div> <div class="text-xs font-medium truncate w-full opacity-70 group-hover:opacity-100"><span class="font-bold mr-1"> </span> </div></button>'),QM=rt('<div class="absolute bottom-0 right-0 w-6 h-6 cursor-se-resize resize-handle bg-accent hover:bg-accent-focus transition-colors z-50" style="clip-path: polygon(100% 0, 0 100%, 100% 100%);" role="button" tabindex="0" aria-label="Resize"></div>'),JM=rt('<div role="group"><span class="font-bold text-primary opacity-50">Dock Top</span></div> <div role="group"><span class="font-bold text-primary opacity-50">Dock Bottom</span></div> <div role="group"><span class="font-bold text-primary opacity-50 vertical-rl rotate-180" style="writing-mode: vertical-rl;">Dock Left</span></div> <div role="group"><span class="font-bold text-primary opacity-50 vertical-rl rotate-180" style="writing-mode: vertical-rl;">Dock Right</span></div>',1),$M=rt('<div><button class="absolute top-1 right-1 btn btn-error btn-xs btn-circle z-20" aria-label="Close Gallery"><!></button> <div><div role="button" tabindex="0" aria-label="Drag Gallery"><div></div></div></div> <div><div></div></div> <!></div> <!>',1);function eD(r,e){wt(e,!0);const t=Ps(Fs);let i=qe(_i({x:20,y:100})),n=qe(_i({width:300,height:400})),s=qe(!1),o=qe(!1),a={x:0,y:0},l={x:0,y:0,w:0,h:0},h=qe(void 0),u=me(()=>e.canvases?e.canvases.map((R,M)=>{let k="";try{if(R.getCanonicalImageUri)k=R.getCanonicalImageUri(200);else if(R.getThumbnail){const z=R.getThumbnail();z&&(k=typeof z=="string"?z:z.id||z["@id"])}}catch(z){console.warn("Error getting thumbnail",z)}if(!k){const z=R.getImages();if(z&&z.length>0){const D=z[0].getResource();D&&D.getServices().length>0?k=`${D.getServices()[0].id}/full/200,/0/default.jpg`:D&&D.id&&(k=D.id)}}return{id:R.id,label:R.getLabel().length?R.getLabel()[0].value:`Canvas ${M+1}`,src:k,index:M}}):[]);function c(R){if(!P(s))return;let M=R.clientX-a.x,k=R.clientY-a.y;if(P(h)&&P(h).parentElement){const z=P(h).parentElement,D=Math.max(0,z.clientWidth-P(n).width),S=Math.max(0,z.clientHeight-P(n).height);M=Math.max(0,Math.min(M,D)),k=Math.max(0,Math.min(k,S))}P(i).x=M,P(i).y=k}function d(){const R=P(y);Me(s,!1),Me(y,null),window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",d),R&&Me(v,R,!0)}function f(R){R.stopPropagation(),Me(o,!0),l={x:R.clientX,y:R.clientY,w:P(n).width,h:P(n).height},window.addEventListener("mousemove",g),window.addEventListener("mouseup",p)}function g(R){if(!P(o))return;const M=R.clientX-l.x,k=R.clientY-l.y;P(n).width=Math.max(200,l.w+M),P(n).height=Math.max(200,l.h+k)}function p(){Me(o,!1),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",p)}function m(R){t.canvasId=R}let v=qe("bottom"),y=qe(null);Ri(()=>{t.dockSide=P(v),t.isGalleryDockedBottom=P(v)==="bottom",t.isGalleryDockedRight=P(v)==="right"});let _=me(()=>P(v)==="top"||P(v)==="bottom"||P(v)==="none"&&P(n).height<320);function w(R){var M,k;if(!R.target.closest(".resize-handle")){if(P(v)!=="none"){Me(v,"none");const z=((k=(M=P(h))==null?void 0:M.parentElement)==null?void 0:k.getBoundingClientRect())||{left:0,top:0};Me(n,{width:300,height:400},!0),Me(i,{x:R.clientX-z.left-150,y:R.clientY-z.top-20},!0)}Me(s,!0),a={x:R.clientX-P(i).x,y:R.clientY-P(i).y},window.addEventListener("mousemove",c),window.addEventListener("mouseup",d)}}var A=de(),F=oe(A);{var C=R=>{var M=$M(),k=oe(M),z=ce(k);z.__click=()=>t.toggleThumbnailGallery();var D=ce(z);YM(D,{size:16,weight:"bold"}),ue(z);var S=we(z,2),b=ce(S);b.__mousedown=w;var O=ce(b);ue(b),ue(S);var j=we(S,2),V=ce(j);vl(V,21,()=>P(u),ml,(K,Q)=>{var W=KM();W.__click=()=>m(P(Q).id);var $=ce(W),ne=ce($);{var _e=Ge=>{var $e=ZM();Lt(()=>{Mi($e,"src",P(Q).src),Mi($e,"alt",P(Q).label)}),U(Ge,$e)},pe=Ge=>{var $e=qM();U(Ge,$e)};ie(ne,Ge=>{P(Q).src?Ge(_e):Ge(pe,!1)})}ue($);var Ce=we($,2),Pe=ce(Ce),Be=ce(Pe);ue(Pe);var ke=we(Pe);ue(Ce),ue(W),Lt(()=>{Nt(W,1,`group flex flex-col gap-1 p-1 rounded hover:bg-base-200 transition-colors text-left relative shrink-0 ${P(_)?"w-[140px]":""} ${t.canvasId===P(Q).id?"ring-2 ring-primary bg-primary/5":""}`),Mi(W,"aria-label",`Select canvas ${P(Q).label??""}`),ai(Be,`${P(Q).index+1}.`),ai(ke,` ${P(Q).label??""}`)}),U(K,W)}),ue(V),ue(j);var Y=we(j,2);{var G=K=>{var Q=QM();Q.__mousedown=f,U(K,Q)};ie(Y,K=>{P(v)==="none"&&K(G)})}ue(k),Vp(k,K=>Me(h,K),()=>P(h));var H=we(k,2);{var X=K=>{var Q=JM(),W=oe(Q),$=we(W,2),ne=we($,2),_e=we(ne,2);Lt(()=>{Nt(W,1,`absolute top-2 left-2 right-2 h-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-200 ${P(y)==="top"?"bg-primary/20 scale-105":"bg-base-100/50"}`),Nt($,1,`absolute bottom-2 left-2 right-2 h-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-200 ${P(y)==="bottom"?"bg-primary/20 scale-105":"bg-base-100/50"}`),Nt(ne,1,`absolute top-2 bottom-2 left-2 w-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-200 ${P(y)==="left"?"bg-primary/20 scale-105":"bg-base-100/50"}`),Nt(_e,1,`absolute top-2 bottom-2 w-16 rounded-xl border-4 border-dashed border-primary/40 z-950 flex items-center justify-center transition-all duration-300 ${t.showSearchPanel?"right-[328px]":"right-2"} ${P(y)==="right"?"bg-primary/20 scale-105":"bg-base-100/50"}`)}),cn("mouseenter",W,()=>Me(y,"top")),cn("mouseleave",W,()=>Me(y,null)),cn("mouseenter",$,()=>Me(y,"bottom")),cn("mouseleave",$,()=>Me(y,null)),cn("mouseenter",ne,()=>Me(y,"left")),cn("mouseleave",ne,()=>Me(y,null)),cn("mouseenter",_e,()=>Me(y,"right")),cn("mouseleave",_e,()=>Me(y,null)),U(K,Q)};ie(H,K=>{P(s)&&K(X)})}Lt(()=>{Nt(k,1,(P(v)!=="none"?`absolute z-900 bg-base-100 shadow-xl border-base-300 flex transition-all duration-200
|
|
1224
|
+
${P(v)==="bottom"?"flex-row bottom-0 left-0 right-0 h-[140px] border-t":""}
|
|
1225
|
+
${P(v)==="top"?"flex-row top-0 left-0 right-0 h-[140px] border-b":""}
|
|
1226
|
+
${P(v)==="left"?"flex-col left-0 top-0 bottom-0 w-[200px] border-r":""}
|
|
1227
|
+
${P(v)==="right"?`flex-col top-0 bottom-0 w-[200px] border-l ${t.showSearchPanel?"right-80":"right-0"}`:""}`:"absolute z-900 bg-base-100 shadow-2xl rounded-lg flex flex-col border border-base-300 overflow-hidden")+(P(s)?" pointer-events-none opacity-80":"")),yl(k,P(v)!=="none"?"":`left: ${P(i).x}px; top: ${P(i).y}px; width: ${P(n).width}px; height: ${P(n).height}px;`),Nt(S,1,"bg-base-100 flex shrink-0 select-none relative "+(P(v)==="bottom"||P(v)==="top"?"flex-row h-full items-center border-r border-base-200":"flex-col w-full border-b border-base-200")),Nt(b,1,"cursor-move flex items-center justify-center hover:bg-base-200/50 active:bg-base-200 transition-colors "+(P(v)==="bottom"||P(v)==="top"?"w-8 h-full":"h-6 w-full")),Nt(O,1,"bg-base-300 rounded-full "+(P(v)==="bottom"||P(v)==="top"?"w-1.5 h-12":"w-12 h-1.5")),Nt(j,1,`flex-1 p-1 bg-base-100 ${P(_)?"overflow-x-auto overflow-y-hidden":"overflow-y-auto overflow-x-hidden"}`),Nt(V,1,bu(P(_)?"flex flex-row gap-2 h-full items-center":"grid gap-2")),yl(V,P(_)?"":"grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));")}),U(R,M)};ie(F,R=>{t.showThumbnailGallery&&R(C)})}U(r,A),Et()}Kn(["click","mousedown"]),t1();var tD=le('<path d="M84,100A12,12,0,0,1,96,88h64a12,12,0,0,1,0,24H96A12,12,0,0,1,84,100Zm12,52h64a12,12,0,0,0,0-24H96a12,12,0,0,0,0,24ZM236,56V184a20,20,0,0,1-20,20H157.89l-12.52,21.92a20,20,0,0,1-34.74,0L98.11,204H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56Zm-24,4H44V180h61.07a12,12,0,0,1,10.42,6.05L128,207.94l12.51-21.89A12,12,0,0,1,150.93,180H212Z"></path>'),iD=le('<path d="M224,56V184a8,8,0,0,1-8,8H150.93l-16,28a8,8,0,0,1-13.9,0l-16-28H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z" opacity="0.2"></path><path d="M88,104a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,104Zm8,40h64a8,8,0,0,0,0-16H96a8,8,0,0,0,0,16ZM232,56V184a16,16,0,0,1-16,16H155.57l-13.68,23.94a16,16,0,0,1-27.78,0L100.43,200H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Zm-16,0H40V184h65.07a8,8,0,0,1,7,4l16,28,16-28a8,8,0,0,1,7-4H216Z"></path>',1),rD=le('<path d="M216,40H40A16,16,0,0,0,24,56V184a16,16,0,0,0,16,16h60.43l13.68,23.94a16,16,0,0,0,27.78,0L155.57,200H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM160,144H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"></path>'),nD=le('<path d="M166,104a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,104Zm-6,26H96a6,6,0,0,0,0,12h64a6,6,0,0,0,0-12Zm70-74V184a14,14,0,0,1-14,14H154.41L140.16,223a14,14,0,0,1-24.32,0L101.59,198H40a14,14,0,0,1-14-14V56A14,14,0,0,1,40,42H216A14,14,0,0,1,230,56Zm-12,0a2,2,0,0,0-2-2H40a2,2,0,0,0-2,2V184a2,2,0,0,0,2,2h65.07a6,6,0,0,1,5.21,3l16,28a2,2,0,0,0,3.48,0l16-28a6,6,0,0,1,5.21-3H216a2,2,0,0,0,2-2Z"></path>'),sD=le('<path d="M88,104a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,104Zm8,40h64a8,8,0,0,0,0-16H96a8,8,0,0,0,0,16ZM232,56V184a16,16,0,0,1-16,16H155.57l-13.68,23.94a16,16,0,0,1-27.78,0L100.43,200H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Zm-16,0H40V184h65.07a8,8,0,0,1,7,4l16,28,16-28a8,8,0,0,1,7-4H216Z"></path>'),oD=le('<path d="M164,104a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,104Zm-4,28H96a4,4,0,0,0,0,8h64a4,4,0,0,0,0-8Zm68-76V184a12,12,0,0,1-12,12H153.25L138.42,222a12,12,0,0,1-20.84,0L102.75,196H40a12,12,0,0,1-12-12V56A12,12,0,0,1,40,44H216A12,12,0,0,1,228,56Zm-8,0a4,4,0,0,0-4-4H40a4,4,0,0,0-4,4V184a4,4,0,0,0,4,4h65.07a4,4,0,0,1,3.47,2l16,28a4,4,0,0,0,6.94,0l16-28a4,4,0,0,1,3.47-2H216a4,4,0,0,0,4-4Z"></path>'),aD=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function lD(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=aD();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=tD();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=iD();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=rD();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=nD();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=sD();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=oD();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var hD=le('<path d="M148,96V48a12,12,0,0,1,24,0V84h36a12,12,0,0,1,0,24H160A12,12,0,0,1,148,96ZM96,148H48a12,12,0,0,0,0,24H84v36a12,12,0,0,0,24,0V160A12,12,0,0,0,96,148Zm112,0H160a12,12,0,0,0-12,12v48a12,12,0,0,0,24,0V172h36a12,12,0,0,0,0-24ZM96,36A12,12,0,0,0,84,48V84H48a12,12,0,0,0,0,24H96a12,12,0,0,0,12-12V48A12,12,0,0,0,96,36Z"></path>'),uD=le('<path d="M208,64V192a16,16,0,0,1-16,16H64a16,16,0,0,1-16-16V64A16,16,0,0,1,64,48H192A16,16,0,0,1,208,64Z" opacity="0.2"></path><path d="M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z"></path>',1),cD=le('<path d="M152,96V48a8,8,0,0,1,13.66-5.66l48,48A8,8,0,0,1,208,104H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0-5.66,13.66l48,48A8,8,0,0,0,104,208V160A8,8,0,0,0,96,152ZM99.06,40.61a8,8,0,0,0-8.72,1.73l-48,48A8,8,0,0,0,48,104H96a8,8,0,0,0,8-8V48A8,8,0,0,0,99.06,40.61ZM208,152H160a8,8,0,0,0-8,8v48a8,8,0,0,0,13.66,5.66l48-48A8,8,0,0,0,208,152Z"></path>'),dD=le('<path d="M154,96V48a6,6,0,0,1,12,0V90h42a6,6,0,0,1,0,12H160A6,6,0,0,1,154,96ZM96,154H48a6,6,0,0,0,0,12H90v42a6,6,0,0,0,12,0V160A6,6,0,0,0,96,154Zm112,0H160a6,6,0,0,0-6,6v48a6,6,0,0,0,12,0V166h42a6,6,0,0,0,0-12ZM96,42a6,6,0,0,0-6,6V90H48a6,6,0,0,0,0,12H96a6,6,0,0,0,6-6V48A6,6,0,0,0,96,42Z"></path>'),fD=le('<path d="M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z"></path>'),pD=le('<path d="M156,96V48a4,4,0,0,1,8,0V92h44a4,4,0,0,1,0,8H160A4,4,0,0,1,156,96ZM96,156H48a4,4,0,0,0,0,8H92v44a4,4,0,0,0,8,0V160A4,4,0,0,0,96,156Zm112,0H160a4,4,0,0,0-4,4v48a4,4,0,0,0,8,0V164h44a4,4,0,0,0,0-8ZM96,44a4,4,0,0,0-4,4V92H48a4,4,0,0,0,0,8H96a4,4,0,0,0,4-4V48A4,4,0,0,0,96,44Z"></path>'),gD=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function mD(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=gD();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=hD();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=uD();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=cD();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=dD();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=fD();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=pD();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var vD=le('<path d="M220,48V88a12,12,0,0,1-24,0V60H168a12,12,0,0,1,0-24h40A12,12,0,0,1,220,48ZM88,196H60V168a12,12,0,0,0-24,0v40a12,12,0,0,0,12,12H88a12,12,0,0,0,0-24Zm120-40a12,12,0,0,0-12,12v28H168a12,12,0,0,0,0,24h40a12,12,0,0,0,12-12V168A12,12,0,0,0,208,156ZM88,36H48A12,12,0,0,0,36,48V88a12,12,0,0,0,24,0V60H88a12,12,0,0,0,0-24Z"></path>'),yD=le('<path d="M208,48V208H48V48Z" opacity="0.2"></path><path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"></path>',1),_D=le('<path d="M93.66,202.34A8,8,0,0,1,88,216H48a8,8,0,0,1-8-8V168a8,8,0,0,1,13.66-5.66ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,13.66,5.66l40-40A8,8,0,0,0,88,40ZM211.06,160.61a8,8,0,0,0-8.72,1.73l-40,40A8,8,0,0,0,168,216h40a8,8,0,0,0,8-8V168A8,8,0,0,0,211.06,160.61ZM208,40H168a8,8,0,0,0-5.66,13.66l40,40A8,8,0,0,0,216,88V48A8,8,0,0,0,208,40Z"></path>'),xD=le('<path d="M214,48V88a6,6,0,0,1-12,0V54H168a6,6,0,0,1,0-12h40A6,6,0,0,1,214,48ZM88,202H54V168a6,6,0,0,0-12,0v40a6,6,0,0,0,6,6H88a6,6,0,0,0,0-12Zm120-40a6,6,0,0,0-6,6v34H168a6,6,0,0,0,0,12h40a6,6,0,0,0,6-6V168A6,6,0,0,0,208,162ZM88,42H48a6,6,0,0,0-6,6V88a6,6,0,0,0,12,0V54H88a6,6,0,0,0,0-12Z"></path>'),wD=le('<path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"></path>'),ED=le('<path d="M212,48V88a4,4,0,0,1-8,0V52H168a4,4,0,0,1,0-8h40A4,4,0,0,1,212,48ZM88,204H52V168a4,4,0,0,0-8,0v40a4,4,0,0,0,4,4H88a4,4,0,0,0,0-8Zm120-40a4,4,0,0,0-4,4v36H168a4,4,0,0,0,0,8h40a4,4,0,0,0,4-4V168A4,4,0,0,0,208,164ZM88,44H48a4,4,0,0,0-4,4V88a4,4,0,0,0,8,0V52H88a4,4,0,0,0,0-8Z"></path>'),TD=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function bD(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=TD();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=vD();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=yD();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=_D();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=xD();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=wD();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=ED();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var AD=le('<path d="M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z"></path>'),SD=le('<path d="M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z" opacity="0.2"></path><path d="M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z"></path>',1),RD=le('<path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z"></path>'),CD=le('<path d="M142,176a6,6,0,0,1-6,6,14,14,0,0,1-14-14V128a2,2,0,0,0-2-2,6,6,0,0,1,0-12,14,14,0,0,1,14,14v40a2,2,0,0,0,2,2A6,6,0,0,1,142,176ZM124,94a10,10,0,1,0-10-10A10,10,0,0,0,124,94Zm106,34A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z"></path>'),PD=le('<path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"></path>'),ID=le('<path d="M140,176a4,4,0,0,1-4,4,12,12,0,0,1-12-12V128a4,4,0,0,0-4-4,4,4,0,0,1,0-8,12,12,0,0,1,12,12v40a4,4,0,0,0,4,4A4,4,0,0,1,140,176ZM124,92a8,8,0,1,0-8-8A8,8,0,0,0,124,92Zm104,36A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z"></path>'),MD=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function DD(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=MD();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=AD();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=SD();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=RD();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=CD();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=PD();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=ID();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var OD=le('<path d="M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z"></path>'),LD=le('<path d="M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z" opacity="0.2"></path><path d="M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"></path>',1),ND=le('<path d="M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z"></path>'),FD=le('<path d="M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z"></path>'),BD=le('<path d="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"></path>'),kD=le('<path d="M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z"></path>'),UD=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function m_(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=UD();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=OD();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=LD();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=ND();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=FD();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=BD();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=kD();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var HD=le('<path d="M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"></path>'),GD=le('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z" opacity="0.2"></path><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"></path>',1),VD=le('<path d="M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"></path>'),zD=le('<path d="M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"></path>'),jD=le('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"></path>'),WD=le('<path d="M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"></path>'),XD=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function YD(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=XD();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=HD();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=GD();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=VD();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=zD();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=jD();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=WD();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var ZD=le('<path d="M184,44H72A20,20,0,0,0,52,64V192a20,20,0,0,0,20,20H184a20,20,0,0,0,20-20V64A20,20,0,0,0,184,44Zm-4,144H76V68H180ZM244,56V200a12,12,0,0,1-24,0V56a12,12,0,0,1,24,0ZM36,56V200a12,12,0,0,1-24,0V56a12,12,0,0,1,24,0Z"></path>'),qD=le('<path d="M200,64V192a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H192A8,8,0,0,1,200,64Z" opacity="0.2"></path><path d="M192,48H64A16,16,0,0,0,48,64V192a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64A16,16,0,0,0,192,48Zm0,144H64V64H192V192ZM240,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0ZM32,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0Z"></path>',1),KD=le('<path d="M208,64V192a16,16,0,0,1-16,16H64a16,16,0,0,1-16-16V64A16,16,0,0,1,64,48H192A16,16,0,0,1,208,64Zm24-16a8,8,0,0,0-8,8V200a8,8,0,0,0,16,0V56A8,8,0,0,0,232,48ZM24,48a8,8,0,0,0-8,8V200a8,8,0,0,0,16,0V56A8,8,0,0,0,24,48Z"></path>'),QD=le('<path d="M192,50H64A14,14,0,0,0,50,64V192a14,14,0,0,0,14,14H192a14,14,0,0,0,14-14V64A14,14,0,0,0,192,50Zm2,142a2,2,0,0,1-2,2H64a2,2,0,0,1-2-2V64a2,2,0,0,1,2-2H192a2,2,0,0,1,2,2ZM238,56V200a6,6,0,0,1-12,0V56a6,6,0,0,1,12,0ZM30,56V200a6,6,0,0,1-12,0V56a6,6,0,0,1,12,0Z"></path>'),JD=le('<path d="M192,48H64A16,16,0,0,0,48,64V192a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64A16,16,0,0,0,192,48Zm0,144H64V64H192V192ZM240,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0ZM32,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0Z"></path>'),$D=le('<path d="M192,52H64A12,12,0,0,0,52,64V192a12,12,0,0,0,12,12H192a12,12,0,0,0,12-12V64A12,12,0,0,0,192,52Zm4,140a4,4,0,0,1-4,4H64a4,4,0,0,1-4-4V64a4,4,0,0,1,4-4H192a4,4,0,0,1,4,4ZM236,56V200a4,4,0,0,1-8,0V56a4,4,0,0,1,8,0ZM28,56V200a4,4,0,0,1-8,0V56a4,4,0,0,1,8,0Z"></path>'),eO=le('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');function tO(r,e){wt(e,!0);const t=Ni();let i=Oi(e,["$$slots","$$events","$$legacy","children"]),n=me(()=>e.weight??t.weight??"regular"),s=me(()=>e.color??t.color??"currentColor"),o=me(()=>e.size??t.size??"1em"),a=me(()=>e.mirrored??t.mirrored??!1);function l(p){let{weight:m,color:v,size:y,mirrored:_,...w}=p;return w}var h=eO();Di(h,(p,m)=>({xmlns:"http://www.w3.org/2000/svg",role:"img",width:P(o),height:P(o),fill:P(s),transform:P(a)?"scale(-1, 1)":void 0,viewBox:"0 0 256 256",...p,...m}),[()=>l(t),()=>l(i)]);var u=ce(h);{var c=p=>{var m=de(),v=oe(m);Ii(v,()=>e.children),U(p,m)};ie(u,p=>{e.children&&p(c)})}var d=we(u,2);{var f=p=>{var m=ZD();U(p,m)},g=p=>{var m=de(),v=oe(m);{var y=w=>{var A=qD();yi(),U(w,A)},_=w=>{var A=de(),F=oe(A);{var C=M=>{var k=KD();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=QD();U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=JD();U(G,H)},Y=G=>{var H=de(),X=oe(H);{var K=W=>{var $=$D();U(W,$)},Q=W=>{var $=Ti();$.nodeValue=(console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'),""),U(W,$)};ie(X,W=>{P(n)==="thin"?W(K):W(Q,!1)},!0)}U(G,H)};ie(j,G=>{P(n)==="regular"?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{P(n)==="light"?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{P(n)==="fill"?M(C):M(R,!1)},!0)}U(w,A)};ie(v,w=>{P(n)==="duotone"?w(y):w(_,!1)},!0)}U(p,m)};ie(d,p=>{P(n)==="bold"?p(f):p(g,!1)})}ue(h),U(r,h),Et()}var iO=rt('<div data-tip="Menu"><div tabindex="0" role="button" class="btn btn-lg btn-primary btn-circle shadow-xl"><!></div> <div class="fab-close tooltip tooltip-top" data-tip="Search"><button aria-label="Toggle Search"><!></button></div> <div class="tooltip tooltip-left"><button><!></button></div> <div class="tooltip tooltip-left"><button><!></button></div> <div class="tooltip tooltip-top"><button aria-label="Toggle Annotations"><!></button></div> <div class="tooltip tooltip-top" data-tip="Metadata"><button aria-label="Toggle Metadata"><!></button></div></div>');function rO(r,e){wt(e,!1);const t=Ps(Fs);$1();var i=iO(),n=ce(i),s=ce(n);YD(s,{size:32,weight:"bold"}),ue(n);var o=we(n,2),a=ce(o);a.__click=()=>t.toggleSearchPanel();var l=ce(a);m_(l,{size:28,weight:"bold"}),ue(a),ue(o);var h=we(o,2),u=ce(h);u.__click=()=>t.toggleThumbnailGallery();var c=ce(u);tO(c,{size:28,weight:"bold"}),ue(u),ue(h);var d=we(h,2),f=ce(d);f.__click=()=>t.toggleFullScreen();var g=ce(f);{var p=C=>{mD(C,{size:28,weight:"bold"})},m=C=>{bD(C,{size:28,weight:"bold"})};ie(g,C=>{t.isFullScreen?C(p):C(m,!1)})}ue(f),ue(d);var v=we(d,2),y=ce(v);y.__click=()=>t.toggleAnnotations();var _=ce(y);lD(_,{size:28,weight:"bold"}),ue(y),ue(v);var w=we(v,2),A=ce(w);A.__click=()=>t.toggleMetadataDialog();var F=ce(A);DD(F,{size:28,weight:"bold"}),ue(A),ue(w),ue(i),Lt(()=>{Nt(i,1,`fab fab-flower fab-top-left absolute z-600 pointer-events-auto flex-col items-end transition-all duration-300 ${t.showSearchPanel?t.showThumbnailGallery&&t.isGalleryDockedRight?"right-[540px]":"right-[344px]":t.showThumbnailGallery&&t.isGalleryDockedRight?"right-[220px]":"right-6"} ${t.showThumbnailGallery&&t.dockSide==="bottom"?"bottom-40":"bottom-6"}`),Nt(a,1,bu(["btn btn-circle btn-lg shadow-lg",t.showSearchPanel&&"btn-primary",!t.showSearchPanel&&"btn-neutral"])),Mi(h,"data-tip",t.showThumbnailGallery?"Hide Gallery":"Show Gallery"),Mi(u,"aria-label",t.showThumbnailGallery?"Hide Gallery":"Show Gallery"),Nt(u,1,`btn btn-lg btn-circle shadow-lg ${t.showThumbnailGallery?"btn-info":"btn-neutral"}`),Mi(d,"data-tip",t.isFullScreen?"Exit Full Screen":"Enter Full Screen"),Nt(f,1,`btn btn-circle btn-lg shadow-lg transition-all duration-300 ease-out ${t.isFullScreen?"btn-warning":"btn-neutral"}`),Mi(v,"data-tip",t.showAnnotations?"Hide Annotations":"Show Annotations"),Nt(y,1,`btn btn-lg btn-circle shadow-lg ${t.showAnnotations?"btn-error":"btn-neutral"}`),Nt(A,1,`btn btn-lg btn-circle shadow-lg ${t.showMetadataDialog?"btn-info":"btn-neutral"}`)}),U(r,i),Et()}Kn(["click"]);var nO=rt('<div class="mb-6 prose"><p><!></p></div>'),sO=rt('<dt class="font-bold text-lg opacity-70 mt-6">Attribution</dt> <dd class="text-sm ps-2"><!></dd>',1),oO=rt('<dt class="font-bold text-lg opacity-70 mt-6">License</dt> <dd class="text-sm ps-2"><a target="_blank" rel="noreferrer" class="link link-primary break-all"> </a></dd>',1),aO=rt('<dt class="font-bold text-lg opacity-70 mt-6"> </dt> <dd class="text-sm ps-2"><!></dd>',1),lO=rt('<dialog class="modal absolute" style="position: absolute;"><div class="modal-box w-11/12 max-w-5xl"><form method="dialog"><button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button></form> <h3 class="font-bold text-lg mb-4"> </h3> <div class="py-4 overflow-y-auto max-h-[70vh]"><!> <dl class="grid grid-cols-1 md:grid-cols-[200px_1fr]"><!> <!> <!></dl></div> <div class="modal-action"><form method="dialog"><button class="btn">Close</button></form></div></div> <form method="dialog" class="modal-backdrop"><button>close</button></form></dialog>');function hO(r,e){wt(e,!0);const t=Ps(Fs);let i=me(()=>t.manifest),n=me(()=>{if(!P(i))return[];const D=P(i).getMetadata();return D?D.map(S=>{let b="",O="";if(S.getLabel){const j=S.getLabel();Array.isArray(j)?b=j.map(V=>V.value).join(" "):b=j}else S.label&&(typeof S.label=="string"?b=S.label:Array.isArray(S.label)?b=S.label.map(j=>j.value).join(" "):b=String(S.label));if(S.getValue){const j=S.getValue();Array.isArray(j)?O=j.map(V=>V.value).join(" "):O=j}else S.value&&(typeof S.value=="string"?O=S.value:Array.isArray(S.value)?O=S.value.map(j=>j.value).join(" "):O=String(S.value));return{label:b,value:O}}):[]}),s=me(()=>P(i)?P(i).getDescription():""),o=me(()=>{var D;return P(i)?(D=P(i).getRequiredStatement())==null?void 0:D.getValue():""}),a=me(()=>P(i)?P(i).getLicense():"");var l=lO(),h=ce(l),u=ce(h),c=ce(u);c.__click=()=>t.toggleMetadataDialog(),ue(u);var d=we(u,2),f=ce(d,!0);ue(d);var g=we(d,2),p=ce(g);{var m=D=>{var S=nO(),b=ce(S),O=ce(b);Qn(O,()=>P(s)),ue(b),ue(S),U(D,S)};ie(p,D=>{P(s)&&D(m)})}var v=we(p,2),y=ce(v);{var _=D=>{var S=sO(),b=we(oe(S),2),O=ce(b);Qn(O,()=>P(o)),ue(b),U(D,S)};ie(y,D=>{P(o)&&D(_)})}var w=we(y,2);{var A=D=>{var S=oO(),b=we(oe(S),2),O=ce(b),j=ce(O,!0);ue(O),ue(b),Lt(()=>{Mi(O,"href",P(a)),ai(j,P(a))}),U(D,S)};ie(w,D=>{P(a)&&D(A)})}var F=we(w,2);vl(F,17,()=>P(n),ml,(D,S)=>{var b=aO(),O=oe(b),j=ce(O,!0);ue(O);var V=we(O,2),Y=ce(V);Qn(Y,()=>P(S).value),ue(V),Lt(()=>ai(j,P(S).label)),U(D,b)}),ue(v),ue(g);var C=we(g,2),R=ce(C),M=ce(R);M.__click=()=>t.toggleMetadataDialog(),ue(R),ue(C),ue(h);var k=we(h,2),z=ce(k);z.__click=()=>t.toggleMetadataDialog(),ue(k),ue(l),Lt(D=>{l.open=t.showMetadataDialog,ai(f,D)},[()=>P(i)?P(i).getLabel().length?P(i).getLabel()[0].value:"Manifest Metadata":"Loading..."]),U(r,l),Et()}Kn(["click"]);var uO=rt('<span class="loading loading-spinner loading-xs"></span>'),cO=rt('<div class="flex justify-center p-8"><span class="loading loading-spinner loading-lg text-primary"></span></div>'),dO=rt('<div class="text-center opacity-50 p-4"> </div>'),fO=rt('<div class="text-center opacity-50 p-4 text-sm">Enter a search term to find occurrences within this manifest.</div>'),pO=rt('<div class="leading-relaxed"><span><!></span> <span class="bg-yellow-200 text-yellow-900 font-bold px-0.5 rounded"><!></span> <span><!></span></div>'),gO=rt('<div class="leading-relaxed"> </div>'),mO=rt('<button class="w-full text-left card bg-base-100 shadow hover:shadow-md transition-all p-4 text-sm group border border-transparent hover:border-primary focus:outline-none focus:ring-2 focus:ring-primary"><div class="flex justify-between items-baseline mb-1"><span class="font-bold text-xs opacity-70 bg-base-200 px-1.5 py-0.5 rounded"> </span></div> <!></button>'),vO=rt('<div class="text-xs font-bold opacity-50 uppercase tracking-wider pb-2"> </div> <!>',1),yO=rt('<div class="absolute top-0 right-0 h-full w-80 bg-base-200 shadow-2xl z-1000 transform transition-transform duration-300 flex flex-col border-l border-base-300" role="dialog" aria-label="Search Panel"><div class="p-4 bg-base-300 flex justify-between items-center shrink-0"><h2 class="font-bold text-lg">Search</h2> <button class="btn btn-sm btn-circle btn-ghost" aria-label="Close Search">✕</button></div> <div class="p-4 border-b border-base-300 shrink-0"><div class="join w-full"><input type="text" placeholder="Search content..." class="input input-bordered join-item w-full"/> <button class="btn btn-primary join-item" aria-label="Search"><!></button></div></div> <div class="flex-1 overflow-y-auto p-4 space-y-4"><!></div></div>');function _O(r,e){wt(e,!0);const t=Ps(Fs);let i=qe(_i(t.searchQuery));function n(){t.search(P(i))}function s(u){u.key==="Enter"&&n()}function o(u){const c=t.canvases[u.canvasIndex];c&&(t.canvasId=c.id)}var a=de(),l=oe(a);{var h=u=>{var c=yO(),d=ce(c),f=we(ce(d),2);f.__click=()=>t.toggleSearchPanel(),ue(d);var g=we(d,2),p=ce(g),m=ce(p);Bp(m),m.__keydown=s;var v=we(m,2);v.__click=n;var y=ce(v);{var _=M=>{var k=uO();U(M,k)},w=M=>{m_(M,{size:20,weight:"bold"})};ie(y,M=>{t.isSearching?M(_):M(w,!1)})}ue(v),ue(p),ue(g);var A=we(g,2),F=ce(A);{var C=M=>{var k=cO();U(M,k)},R=M=>{var k=de(),z=oe(k);{var D=b=>{var O=dO(),j=ce(O);ue(O),Lt(()=>ai(j,`No results found for "${t.searchQuery??""}"`)),U(b,O)},S=b=>{var O=de(),j=oe(O);{var V=G=>{var H=fO();U(G,H)},Y=G=>{var H=vO(),X=oe(H),K=ce(X);ue(X);var Q=we(X,2);vl(Q,17,()=>t.searchResults,ml,(W,$)=>{var ne=mO();ne.__click=()=>o(P($));var _e=ce(ne),pe=ce(_e),Ce=ce(pe,!0);ue(pe),ue(_e);var Pe=we(_e,2);{var Be=Ge=>{var $e=pO(),ft=ce($e),Pt=ce(ft);Qn(Pt,()=>P($).before),ue(ft);var x=we(ft,2),L=ce(x);Qn(L,()=>P($).match),ue(x);var q=we(x,2),ee=ce(q);Qn(ee,()=>P($).after),ue(q),ue($e),U(Ge,$e)},ke=Ge=>{var $e=gO(),ft=ce($e,!0);ue($e),Lt(()=>ai(ft,P($).match)),U(Ge,$e)};ie(Pe,Ge=>{P($).type==="hit"?Ge(Be):Ge(ke,!1)})}ue(ne),Lt(()=>ai(Ce,P($).canvasLabel)),U(W,ne)}),Lt(()=>ai(K,`${t.searchResults.length??""} Results`)),U(G,H)};ie(j,G=>{t.searchResults.length===0&&!t.searchQuery?G(V):G(Y,!1)},!0)}U(b,O)};ie(z,b=>{t.searchResults.length===0&&t.searchQuery?b(D):b(S,!1)},!0)}U(M,k)};ie(F,M=>{t.isSearching?M(C):M(R,!1)})}ue(A),ue(c),J1(m,()=>P(i),M=>Me(i,M)),U(u,c)};ie(l,u=>{t.showSearchPanel&&u(h)})}U(r,a),Et()}Kn(["click","keydown"]);var xO=rt('<span class="loading loading-spinner loading-lg text-primary"></span>'),wO=rt('<div class="text-error"> </div>'),EO=rt('<div class="text-base-content/50">No image found</div>'),TO=rt("<!> <!>",1),bO=rt('<div id="triiiceratops-viewer" class="w-full h-full relative bg-base-100 flex items-center justify-center"><!> <!> <!> <!> <!> <!></div>');function AO(r,e){wt(e,!0);const t=new Jx;i1(Fs,t),Ri(()=>{e.manifestId&&t.setManifest(e.manifestId)}),Ri(()=>{const v=()=>{t.isFullScreen=!!document.fullscreenElement};return document.addEventListener("fullscreenchange",v),()=>{document.removeEventListener("fullscreenchange",v)}});let i=me(()=>t.manifest),n=me(()=>t.canvases),s=me(()=>t.currentCanvasIndex),o=me(()=>{if(!P(n)||P(s)===-1||!P(n)[P(s)])return console.log("TriiiceratopsViewer: No canvas found"),null;const y=P(n)[P(s)].getImages();if(!y||!y.length)return console.log("TriiiceratopsViewer: No images in canvas"),null;const w=y[0].getResource();if(!w)return console.log("TriiiceratopsViewer: No resource in annotation"),null;const A=w.getService();if(A){let R=A.id;return R&&!R.endsWith("/info.json")&&(R=`${R}/info.json`),R}const F=w.getServices();if(F&&F.length>0){let R=F[0].id;return R&&!R.endsWith("/info.json")&&(R=`${R}/info.json`),R}if(w.id&&w.id.includes("/iiif/")){const R=w.id.split("/"),M=R.findIndex(k=>k==="full"||k.match(/^\d+,\d+,\d+,\d+$/));if(M>0)return`${R.slice(0,M).join("/")}/info.json`}return console.log("TriiiceratopsViewer: No service or ID found, returning raw URL"),{type:"image",url:w.id}});var a=bO(),l=ce(a);{var h=v=>{var y=xO();U(v,y)},u=v=>{var y=de(),_=oe(y);{var w=F=>{var C=wO(),R=ce(C);ue(C),Lt(()=>ai(R,`Error: ${P(i).error??""}`)),U(F,C)},A=F=>{var C=de(),R=oe(C);{var M=z=>{var D=de(),S=oe(D);G1(S,()=>P(o),b=>{ZI(b,{get tileSources(){return P(o)},get viewerState(){return t}})}),U(z,D)},k=z=>{var D=EO();U(z,D)};ie(R,z=>{P(o)?z(M):z(k,!1)},!0)}U(F,C)};ie(_,F=>{var C;(C=P(i))!=null&&C.error?F(w):F(A,!1)},!0)}U(v,y)};ie(l,v=>{var y;(y=P(i))!=null&&y.isFetching?v(h):v(u,!1)})}var c=we(l,2);{var d=v=>{var y=TO(),_=oe(y);dM(_,{get viewerState(){return t}});var w=we(_,2);eD(w,{get canvases(){return P(n)}}),U(v,y)};ie(c,v=>{P(n).length>1&&v(d)})}var f=we(c,2);UM(f,{});var g=we(f,2);hO(g,{});var p=we(g,2);_O(p,{});var m=we(p,2);rO(m,{}),ue(a),U(r,a),Et()}var SO=rt('<div class="w-full h-full"><!></div>');function RO(r,e){wt(e,!0);let t=tx(e,"manifestId",7,"");var i={get manifestId(){return t()},set manifestId(o=""){t(o),cu()}},n=SO(),s=ce(n);return AO(s,{get manifestId(){return t()}}),ue(n),U(r,n),Et(i)}customElements.define("triiiceratops-viewer",sx(RO,{manifestId:{attribute:"manifest-id",reflect:!0,type:"String"}},[],[],!1))})();
|