@annotorious/openseadragon 3.0.11 → 3.0.13

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.
@@ -1,21 +1,21 @@
1
- (function(Mt,Nt){typeof exports=="object"&&typeof module<"u"?Nt(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],Nt):(Mt=typeof globalThis<"u"?globalThis:Mt||self,Nt(Mt.AnnotoriousOSD={},Mt.OpenSeadragon))})(this,function(Mt,Nt){"use strict";var HE=Object.defineProperty;var XE=(Mt,Nt,Pr)=>Nt in Mt?HE(Mt,Nt,{enumerable:!0,configurable:!0,writable:!0,value:Pr}):Mt[Nt]=Pr;var Fl=(Mt,Nt,Pr)=>XE(Mt,typeof Nt!="symbol"?Nt+"":Nt,Pr);var Pr=Object.prototype.hasOwnProperty;function Mr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Mr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Pr.call(r,e)&&++i&&!Pr.call(t,e)||!(e in t)||!Mr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}for(var ao=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ao||{}),Ht=[],lo=0;lo<256;++lo)Ht.push((lo+256).toString(16).slice(1));function Jf(r,t=0){return(Ht[r[t+0]]+Ht[r[t+1]]+Ht[r[t+2]]+Ht[r[t+3]]+"-"+Ht[r[t+4]]+Ht[r[t+5]]+"-"+Ht[r[t+6]]+Ht[r[t+7]]+"-"+Ht[r[t+8]]+Ht[r[t+9]]+"-"+Ht[r[t+10]]+Ht[r[t+11]]+Ht[r[t+12]]+Ht[r[t+13]]+Ht[r[t+14]]+Ht[r[t+15]]).toLowerCase()}var Cs,Qf=new Uint8Array(16);function tp(){if(!Cs&&(Cs=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Cs))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Cs(Qf)}var ep=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Xl={randomUUID:ep};function rp(r,t,e){if(Xl.randomUUID&&!t&&!r)return Xl.randomUUID();r=r||{};var i=r.random||(r.rng||tp)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Jf(i)}const ho=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},ip=(r,t,e,i)=>({id:rp(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),sp=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},np=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},op=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Mr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),ap=(r,t)=>!Mr(r.target,t.target),lp=(r,t)=>{const e=sp(r,t),i=np(r,t),s=op(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:ap(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var dr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(dr||{});const hp=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return lp(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let cp=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const up=250,dp=r=>{const t=cp(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>up)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=hp(e[_],p)}n=m}s=!1};r.observe(o,{origin:dr.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},fp=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!Mr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:w})=>w===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!Mr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!Mr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:dr.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(I=>I.id===v.id)||v))}},{origin:dr.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},pp=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),mp=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,dr.REMOTE):console.error(g)}else i.addAnnotation(ho(y),dr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||pp(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,dr.REMOTE)}else i.bulkAddAnnotation(y.map(ho),x,dr.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(ho(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},gp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let yp=r=>crypto.getRandomValues(new Uint8Array(r)),_p=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},vp=(r,t=21)=>_p(r,t,yp),xp=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=gp[e[r]&63];return t};const bp=()=>({isGuest:!0,id:vp("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),wp=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Ep=()=>{const r=[...wp];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};xp();var Tp=Object.defineProperty,Ap=(r,t,e)=>t in r?Tp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vl=(r,t,e)=>Ap(r,typeof t!="symbol"?t+"":t,e);function At(){}function co(r,t){for(const e in t)r[e]=t[e];return r}function zl(r){return r()}function Wl(){return Object.create(null)}function Pe(r){r.forEach(zl)}function Ut(r){return typeof r=="function"}function qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Sp(r){return Object.keys(r).length===0}function jl(r,...t){if(r==null){for(const i of t)i(void 0);return At}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function uo(r,t,e){r.$$.on_destroy.push(jl(t,e))}function Ip(r,t,e,i){if(r){const s=Yl(r,t,e,i);return r[0](s)}}function Yl(r,t,e,i){return r[1]&&i?co(e.ctx.slice(),r[1](i(t))):e.ctx}function Cp(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Rp(r,t,e,i,s,n){if(s){const o=Yl(t,e,i,n);r.p(o,s)}}function Pp(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function ql(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Rs(r){return r??""}function Me(r,t){r.appendChild(t)}function it(r,t,e){r.insertBefore(t,e||null)}function et(r){r.parentNode&&r.parentNode.removeChild(r)}function fo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function yt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Kl(r){return document.createTextNode(r)}function ge(){return Kl(" ")}function ye(){return Kl("")}function Dt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function T(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Mp(r){return Array.from(r.childNodes)}function fr(r,t,e){r.classList.toggle(t,!!e)}function Bp(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Xi;function Vi(r){Xi=r}function Zl(){if(!Xi)throw new Error("Function called outside component initialization");return Xi}function zi(r){Zl().$$.on_mount.push(r)}function Qr(){const r=Zl();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Bp(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ze(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const ti=[],Ps=[];let ei=[];const Jl=[],Dp=Promise.resolve();let po=!1;function Op(){po||(po=!0,Dp.then(Ql))}function mo(r){ei.push(r)}const go=new Set;let ri=0;function Ql(){if(ri!==0)return;const r=Xi;do{try{for(;ri<ti.length;){const t=ti[ri];ri++,Vi(t),Fp(t.$$)}}catch(t){throw ti.length=0,ri=0,t}for(Vi(null),ti.length=0,ri=0;Ps.length;)Ps.pop()();for(let t=0;t<ei.length;t+=1){const e=ei[t];go.has(e)||(go.add(e),e())}ei.length=0}while(ti.length);for(;Jl.length;)Jl.pop()();po=!1,go.clear(),Vi(r)}function Fp(r){if(r.fragment!==null){r.update(),Pe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(mo)}}function Lp(r){const t=[],e=[];ei.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),ei=t}const Ms=new Set;let Br;function _e(){Br={r:0,c:[],p:Br}}function ve(){Br.r||Pe(Br.c),Br=Br.p}function ot(r,t){r&&r.i&&(Ms.delete(r),r.i(t))}function mt(r,t,e,i){if(r&&r.o){if(Ms.has(r))return;Ms.add(r),Br.c.push(()=>{Ms.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ii(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ce(r){r&&r.c()}function se(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),mo(()=>{const n=r.$$.on_mount.map(zl).filter(Ut);r.$$.on_destroy?r.$$.on_destroy.push(...n):Pe(n),r.$$.on_mount=[]}),s.forEach(mo)}function ne(r,t){const e=r.$$;e.fragment!==null&&(Lp(e.after_update),Pe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Np(r,t){r.$$.dirty[0]===-1&&(ti.push(r),Op(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ue(r,t,e,i,s,n,o=null,a=[-1]){const l=Xi;Vi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:At,not_equal:s,bound:Wl(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Wl(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Np(r,u)),d}):[],h.update(),c=!0,Pe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Mp(t.target);h.fragment&&h.fragment.l(u),u.forEach(et)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),se(r,t.target,t.anchor),Ql()}Vi(l)}class de{constructor(){Vl(this,"$$"),Vl(this,"$$set")}$destroy(){ne(this,1),this.$destroy=At}$on(t,e){if(!Ut(e))return At;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Sp(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Up="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Up);var wt=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(wt||{});const yo={},_o=(r,t)=>yo[r]=t,vo=r=>yo[r.type].area(r),kp=(r,t,e)=>yo[r.type].intersects(r,t,e),Bs=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Gp={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};_o(wt.ELLIPSE,Gp);const $p={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};_o(wt.POLYGON,$p);const Hp={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};_o(wt.RECTANGLE,Hp);const Je=r=>Ds(r.target),Ds=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},Xp=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,c,u]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,m]=[l,h,c,u].map(parseFloat);return{type:wt.RECTANGLE,geometry:{x:d,y:f,w:p,h:m,bounds:{minX:d,minY:t?f-m:f,maxX:d+p,maxY:t?f:f+m}}}},Vp=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},th="http://www.w3.org/2000/svg",eh=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},zp=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${th}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Wp=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(th),i=t.lookupNamespaceURI(null);return e||i?eh(t).firstChild:eh(zp(t)).firstChild},jp=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:wt.POLYGON,geometry:{points:s,bounds:Bs(s)}}},Yp=r=>{const t=Wp(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:wt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},qp=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return jp(t);if(t.includes("<ellipse "))return Yp(t);throw"Unsupported SVG shape: "+t},Kp=r=>{let t;if(r.type===wt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===wt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`};for(var Xt=[],xo=0;xo<256;++xo)Xt.push((xo+256).toString(16).slice(1));function Zp(r,t=0){return(Xt[r[t+0]]+Xt[r[t+1]]+Xt[r[t+2]]+Xt[r[t+3]]+"-"+Xt[r[t+4]]+Xt[r[t+5]]+"-"+Xt[r[t+6]]+Xt[r[t+7]]+"-"+Xt[r[t+8]]+Xt[r[t+9]]+"-"+Xt[r[t+10]]+Xt[r[t+11]]+Xt[r[t+12]]+Xt[r[t+13]]+Xt[r[t+14]]+Xt[r[t+15]]).toLowerCase()}var Os,Jp=new Uint8Array(16);function Qp(){if(!Os&&(Os=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Os))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Os(Jp)}var tm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const rh={randomUUID:tm};function ih(r,t,e){if(rh.randomUUID&&!t&&!r)return rh.randomUUID();r=r||{};var i=r.random||(r.rng||Qp)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Zp(i)}var sh=Object.prototype.hasOwnProperty;function pr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&pr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(sh.call(r,e)&&++i&&!sh.call(t,e)||!(e in t)||!pr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function bo(){}function em(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const si=[];function wo(r,t=bo){let e;const i=new Set;function s(a){if(em(r,a)&&(r=a,e)){const l=!si.length;for(const h of i)h[1](),si.push(h,r);if(l){for(let h=0;h<si.length;h+=2)si[h][0](si[h+1]);si.length=0}}}function n(a){s(a(r))}function o(a,l=bo){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||bo),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const rm=r=>{const{subscribe:t,set:e}=wo();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var nh=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(nh||{});const Fs={selected:[]},im=(r,t,e)=>{const{subscribe:i,set:s}=wo(Fs);let n=t,o=Fs;i(p=>o=p);const a=()=>{pr(o,Fs)||s(Fs)},l=()=>{var p;return((p=o.selected)==null?void 0:p.length)===0},h=p=>{if(l())return!1;const m=typeof p=="string"?p:p.id;return o.selected.some(_=>_.id===m)},c=(p,m)=>{const _=r.getAnnotation(p);if(!_){console.warn("Invalid selection: "+p);return}switch(oh(_,n,e)){case"EDIT":s({selected:[{id:p,editable:!0}],event:m});break;case"SELECT":s({selected:[{id:p}],event:m});break;default:s({selected:[],event:m})}},u=(p,m)=>{const _=Array.isArray(p)?p:[p],y=_.map(x=>r.getAnnotation(x)).filter(x=>!!x);s({selected:y.map(x=>{const g=m===void 0?oh(x,n,e)==="EDIT":m;return{id:x.id,editable:g}})}),y.length!==_.length&&console.warn("Invalid selection",p)},d=p=>{if(l())return!1;const{selected:m}=o;m.some(({id:_})=>p.includes(_))&&s({selected:m.filter(({id:_})=>!p.includes(_))})},f=p=>n=p;return r.observe(({changes:p})=>d((p.deleted||[]).map(m=>m.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,isEmpty:l,isSelected:h,setSelected:u,setUserSelectAction:f,subscribe:i,userSelect:c}},oh=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"};for(var Vt=[],Eo=0;Eo<256;++Eo)Vt.push((Eo+256).toString(16).slice(1));function sm(r,t=0){return(Vt[r[t+0]]+Vt[r[t+1]]+Vt[r[t+2]]+Vt[r[t+3]]+"-"+Vt[r[t+4]]+Vt[r[t+5]]+"-"+Vt[r[t+6]]+Vt[r[t+7]]+"-"+Vt[r[t+8]]+Vt[r[t+9]]+"-"+Vt[r[t+10]]+Vt[r[t+11]]+Vt[r[t+12]]+Vt[r[t+13]]+Vt[r[t+14]]+Vt[r[t+15]]).toLowerCase()}var Ls,nm=new Uint8Array(16);function om(){if(!Ls&&(Ls=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ls))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ls(nm)}var am=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const ah={randomUUID:am};function lm(r,t,e){if(ah.randomUUID&&!t&&!r)return ah.randomUUID();r=r||{};var i=r.random||(r.rng||om)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,sm(i)}const To=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},hm=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},cm=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},um=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!pr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),dm=(r,t)=>!pr(r.target,t.target),lh=(r,t)=>{const e=hm(r,t),i=cm(r,t),s=um(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:dm(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var St=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(St||{});const fm=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.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},pm=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return lh(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},Ao=r=>{const t=r.id===void 0?lm():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},mm=r=>r.id!==void 0,gm=()=>{const r=new Map,t=new Map,e=[],i=(S,R={})=>{e.push({onChange:S,options:R})},s=S=>{const R=e.findIndex(E=>E.onChange==S);R>-1&&e.splice(R,1)},n=(S,R)=>{const E={origin:S,changes:{created:R.created||[],updated:R.updated||[],deleted:R.deleted||[]},state:[...r.values()]};e.forEach(b=>{fm(b,E)&&b.onChange(E)})},o=(S,R=St.LOCAL)=>{if(S.id&&r.get(S.id))throw Error(`Cannot add annotation ${S.id} - exists already`);{const E=Ao(S);r.set(E.id,E),E.bodies.forEach(b=>t.set(b.id,E.id)),n(R,{created:[E]})}},a=(S,R)=>{const E=Ao(typeof S=="string"?R:S),b=typeof S=="string"?S:S.id,D=b&&r.get(b);if(D){const F=lh(D,E);return b===E.id?r.set(b,E):(r.delete(b),r.set(E.id,E)),D.bodies.forEach(G=>t.delete(G.id)),E.bodies.forEach(G=>t.set(G.id,E.id)),F}else console.warn(`Cannot update annotation ${b} - does not exist`)},l=(S,R=St.LOCAL,E=St.LOCAL)=>{const b=mm(R)?E:R,D=a(S,R);D&&n(b,{updated:[D]})},h=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=a(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{updated:E})},c=(S,R=St.LOCAL)=>{const E=r.get(S.annotation);if(E){const b={...E,bodies:[...E.bodies,S]};r.set(E.id,b),t.set(S.id,b.id),n(R,{updated:[{oldValue:E,newValue:b,bodiesCreated:[S]}]})}else console.warn(`Attempt to add body to missing annotation: ${S.annotation}`)},u=()=>[...r.values()],d=(S=St.LOCAL)=>{const R=[...r.values()];r.clear(),t.clear(),n(S,{deleted:R})},f=(S,R=!0,E=St.LOCAL)=>{const b=S.map(Ao);if(R){const D=[...r.values()];r.clear(),t.clear(),b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b,deleted:D})}else{const D=S.reduce((F,G)=>{const $=G.id&&r.get(G.id);return $?[...F,$]:F},[]);if(D.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${D.map(F=>F.id).join(", ")}`);b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b})}},p=S=>{const R=typeof S=="string"?S:S.id,E=r.get(R);if(E)return r.delete(R),E.bodies.forEach(b=>t.delete(b.id)),E;console.warn(`Attempt to delete missing annotation: ${R}`)},m=(S,R=St.LOCAL)=>{const E=p(S);E&&n(R,{deleted:[E]})},_=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=p(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{deleted:E})},y=S=>{const R=r.get(S.annotation);if(R){const E=R.bodies.find(b=>b.id===S.id);if(E){t.delete(E.id);const b={...R,bodies:R.bodies.filter(D=>D.id!==S.id)};return r.set(R.id,b),{oldValue:R,newValue:b,bodiesDeleted:[E]}}else console.warn(`Attempt to delete missing body ${S.id} from annotation ${S.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${S.annotation}`)},x=(S,R=St.LOCAL)=>{const E=y(S);E&&n(R,{updated:[E]})},g=(S,R=St.LOCAL)=>{const E=S.map(b=>y(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},v=S=>{const R=r.get(S);return R?{...R}:void 0},w=S=>{const R=t.get(S);if(R){const E=v(R).bodies.find(b=>b.id===S);if(E)return E;console.error(`Store integrity error: body ${S} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${S}`)},I=(S,R)=>{if(S.annotation!==R.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=r.get(S.annotation);if(E){const b=E.bodies.find(F=>F.id===S.id),D={...E,bodies:E.bodies.map(F=>F.id===b.id?R:F)};return r.set(E.id,D),b.id!==R.id&&(t.delete(b.id),t.set(R.id,D.id)),{oldValue:E,newValue:D,bodiesUpdated:[{oldBody:b,newBody:R}]}}else console.warn(`Attempt to add body to missing annotation ${S.annotation}`)},A=(S,R,E=St.LOCAL)=>{const b=I(S,R);b&&n(E,{updated:[b]})},C=(S,R=St.LOCAL)=>{const E=S.map(b=>I({id:b.id,annotation:b.annotation},b)).filter(Boolean);n(R,{updated:E})},N=S=>{const R=r.get(S.annotation);if(R){const E={...R,target:{...R.target,...S}};return r.set(R.id,E),{oldValue:R,newValue:E,targetUpdated:{oldTarget:R.target,newTarget:S}}}else console.warn(`Attempt to update target on missing annotation: ${S.annotation}`)};return{addAnnotation:o,addBody:c,all:u,bulkAddAnnotation:f,bulkDeleteAnnotation:_,bulkDeleteBodies:g,bulkUpdateAnnotation:h,bulkUpdateBodies:C,bulkUpdateTargets:(S,R=St.LOCAL)=>{const E=S.map(b=>N(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},clear:d,deleteAnnotation:m,deleteBody:x,getAnnotation:v,getBody:w,observe:i,unobserve:s,updateAnnotation:l,updateBody:A,updateTarget:(S,R=St.LOCAL)=>{const E=N(S);E&&n(R,{updated:[E]})}}},ym=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let _m=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const vm=250,xm=r=>{const t=_m(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>vm)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=pm(e[_],p)}n=m}s=!1};r.observe(o,{origin:St.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},bm=()=>{const{subscribe:r,set:t}=wo([]);return{subscribe:r,set:t}},wm=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!pr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:v})=>v===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!pr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!pr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:St.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(w=>w.id===v.id)||v))}},{origin:St.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},Em=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Tm=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,St.REMOTE):console.error(g)}else i.addAnnotation(To(y),St.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||Em(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,St.REMOTE)}else i.bulkAddAnnotation(y.map(To),x,St.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(To(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},Am=(r,t,e)=>typeof t=="function"?t(r,e):t,Sm=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},Im="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Cm=r=>crypto.getRandomValues(new Uint8Array(r)),Rm=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},Pm=(r,t=21)=>Rm(r,t,Cm),Mm=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Im[e[r]&63];return t};const Bm=()=>({isGuest:!0,id:Pm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Dm=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},hh=r=>r?typeof r=="object"?{...r}:r:void 0,Om=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...c}=e;return{id:i||`temp-${Dm(e)}`,annotation:t,type:s,purpose:n,value:o,creator:hh(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...c}}),Fm=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});Mm();const Lm=(r,t={strict:!0,invertY:!1})=>({parse:e=>Nm(e,t),serialize:e=>Um(e,r,t)}),Nm=(r,t={strict:!0,invertY:!1})=>{const e=r.id||ih(),{creator:i,created:s,modified:n,body:o,...a}=r,l=Om(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,c=Array.isArray(h.selector)?h.selector[0]:h.selector,u=(c==null?void 0:c.type)==="FragmentSelector"?Xp(c,t.invertY):(c==null?void 0:c.type)==="SvgSelector"?qp(c):void 0;return u||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:hh(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:u||c}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},Um=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==wt.RECTANGLE?Vp(i.geometry):Kp(i)}catch(u){if(e.strict)throw u;h=i}const c={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Fm(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,selector:h}};return delete c.bodies,"annotation"in c.target&&delete c.target.annotation,c};function ch(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function uh(r){let t,e;return t=new Wi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Ut(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function km(r){let t,e,i,s,n,o,a,l,h,c,u,d=ii(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=uh(ch(r,d,m));const p=m=>mt(f[m],1,1,()=>{f[m]=null});return{c(){t=yt("polygon"),s=ge(),n=yt("polygon"),a=ge();for(let m=0;m<f.length;m+=1)f[m].c();l=ye(),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"points",i=r[4].points.map(dh).join(" ")),T(n,"class","a9s-inner a9s-shape-handle"),T(n,"style",r[1]),T(n,"points",o=r[4].points.map(fh).join(" "))},m(m,_){it(m,t,_),it(m,s,_),it(m,n,_),it(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);it(m,l,_),h=!0,c||(u=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(n,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(dh).join(" ")))&&T(t,"points",i),(!h||_&2)&&T(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(fh).join(" ")))&&T(n,"points",o),_&536){d=ii(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=ch(r,d,y);f[y]?(f[y].p(x,_),ot(f[y],1)):(f[y]=uh(x),f[y].c(),ot(f[y],1),f[y].m(l.parentNode,l))}for(_e(),y=d.length;y<f.length;y+=1)p(y);ve()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)ot(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)mt(f[_]);h=!1},d(m){m&&(et(t),et(s),et(n),et(a),et(l)),fo(f,m),c=!1,Pe(u)}}}function Gm(r){let t,e;return t=new vh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[km,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}const dh=r=>r.join(","),fh=r=>r.join(",");function $m(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Bs(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Hm extends de{constructor(t){super(),ue(this,t,$m,Gm,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const So=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},ni=[];function Xm(r,t=At){let e;const i=new Set;function s(a){if(qt(r,a)&&(r=a,e)){const l=!ni.length;for(const h of i)h[1](),ni.push(h,r);if(l){for(let h=0;h<ni.length;h+=2)ni[h][0](ni[h+1]);ni.length=0}}}function n(a){s(a(r))}function o(a,l=At){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||At),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Vm=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},zm=(r,t)=>{Vm(r,t);const{subscribe:e,set:i}=Xm(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},ph=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Wm(r){let t,e,i,s,n,o;return{c(){t=yt("rect"),T(t,"class",e=Rs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(t,"x",i=r[0]-r[5]/2),T(t,"y",s=r[1]-r[5]/2),T(t,"width",r[5]),T(t,"height",r[5])},m(a,l){it(a,t,l),n||(o=Dt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Rs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&T(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&T(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&T(t,"y",s),l&32&&T(t,"width",a[5]),l&32&&T(t,"height",a[5])},d(a){a&&et(t),n=!1,o()}}}function jm(r){let t,e,i,s,n,o,a,l,h;return{c(){t=yt("g"),e=yt("circle"),s=yt("rect"),T(e,"cx",r[0]),T(e,"cy",r[1]),T(e,"r",i=r[3]/r[2]),T(e,"class","a9s-touch-halo svelte-1sgkh33"),fr(e,"touched",r[4]),T(s,"class",n=Rs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(s,"x",o=r[0]-r[5]/2),T(s,"y",a=r[1]-r[5]/2),T(s,"width",r[5]),T(s,"height",r[5]),T(t,"class","a9s-touch-handle")},m(c,u){it(c,t,u),Me(t,e),Me(t,s),l||(h=[Dt(e,"pointerdown",r[10]),Dt(e,"pointerdown",r[6]),Dt(e,"pointerup",r[7]),Dt(s,"pointerdown",r[9]),Dt(s,"pointerdown",r[6]),Dt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&T(e,"cx",c[0]),u&2&&T(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&T(e,"r",i),u&16&&fr(e,"touched",c[4]),u&256&&n!==(n=Rs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&T(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&T(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&T(s,"y",a),u&32&&T(s,"width",c[5]),u&32&&T(s,"height",c[5])},d(c){c&&et(t),l=!1,Pe(h)}}}function Ym(r){let t;function e(s,n){return ph?jm:Wm}let i=e()(r);return{c(){i.c(),t=ye()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:At,o:At,d(s){s&&et(t),i.d(s)}}}function qm(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){Ze.call(this,r,p)}function d(p){Ze.call(this,r,p)}function f(p){Ze.call(this,r,p)}return r.$$set=p=>{e(8,t=co(co({},t),ql(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=ql(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class Wi extends de{constructor(t){super(),ue(this,t,qm,Ym,qt,{x:0,y:1,scale:2,radius:3})}}function Km(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,Z,P,U,j,rt,Q,H,V,lt;return B=new Wi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Ut(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new Wi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Ut(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new Wi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Ut(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new Wi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Ut(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=yt("rect"),a=ge(),l=yt("rect"),f=ge(),p=yt("rect"),x=ge(),g=yt("rect"),A=ge(),C=yt("rect"),E=ge(),b=yt("rect"),$=ge(),ce(B.$$.fragment),Z=ge(),ce(P.$$.fragment),U=ge(),ce(j.$$.fragment),rt=ge(),ce(Q.$$.fragment),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"x",i=r[4].x),T(t,"y",s=r[4].y),T(t,"width",n=r[4].w),T(t,"height",o=r[4].h),T(l,"class","a9s-inner a9s-shape-handle"),T(l,"style",r[1]),T(l,"x",h=r[4].x),T(l,"y",c=r[4].y),T(l,"width",u=r[4].w),T(l,"height",d=r[4].h),T(p,"class","a9s-edge-handle a9s-edge-handle-top"),T(p,"x",m=r[4].x),T(p,"y",_=r[4].y),T(p,"height",1),T(p,"width",y=r[4].w),T(g,"class","a9s-edge-handle a9s-edge-handle-right"),T(g,"x",v=r[4].x+r[4].w),T(g,"y",w=r[4].y),T(g,"height",I=r[4].h),T(g,"width",1),T(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),T(C,"x",N=r[4].x),T(C,"y",S=r[4].y+r[4].h),T(C,"height",1),T(C,"width",R=r[4].w),T(b,"class","a9s-edge-handle a9s-edge-handle-left"),T(b,"x",D=r[4].x),T(b,"y",F=r[4].y),T(b,"height",G=r[4].h),T(b,"width",1)},m(L,O){it(L,t,O),it(L,a,O),it(L,l,O),it(L,f,O),it(L,p,O),it(L,x,O),it(L,g,O),it(L,A,O),it(L,C,O),it(L,E,O),it(L,b,O),it(L,$,O),se(B,L,O),it(L,Z,O),se(P,L,O),it(L,U,O),se(j,L,O),it(L,rt,O),se(Q,L,O),H=!0,V||(lt=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(l,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(p,"pointerdown",function(){Ut(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Dt(g,"pointerdown",function(){Ut(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Dt(C,"pointerdown",function(){Ut(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Dt(b,"pointerdown",function(){Ut(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&T(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&T(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&T(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&T(t,"height",o),(!H||O&2)&&T(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&T(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&T(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&T(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&T(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&T(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&T(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&T(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&T(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&T(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&T(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&T(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&T(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&T(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&T(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&T(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&T(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(ot(B.$$.fragment,L),ot(P.$$.fragment,L),ot(j.$$.fragment,L),ot(Q.$$.fragment,L),H=!0)},o(L){mt(B.$$.fragment,L),mt(P.$$.fragment,L),mt(j.$$.fragment,L),mt(Q.$$.fragment,L),H=!1},d(L){L&&(et(t),et(a),et(l),et(f),et(p),et(x),et(g),et(A),et(C),et(E),et(b),et($),et(Z),et(U),et(rt)),ne(B,L),ne(P,L),ne(j,L),ne(Q,L),V=!1,Pe(lt)}}}function Zm(r){let t,e;return t=new vh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Km,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Jm(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[_,y]=[m.minX,m.minY],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Qm extends de{constructor(t){super(),ue(this,t,Jm,Zm,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const mh=new Map([[wt.RECTANGLE,Qm],[wt.POLYGON,Hm]]),gh=r=>mh.get(r.type),yh=(r,t)=>mh.set(r,t),tg=r=>({}),_h=r=>({grab:r[0]});function eg(r){let t,e,i,s;const n=r[7].default,o=Ip(n,r,r[6],_h);return{c(){t=yt("g"),o&&o.c(),T(t,"class","a9s-annotation selected")},m(a,l){it(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Dt(t,"pointerup",r[2]),Dt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Rp(o,n,a,a[6],e?Cp(n,a[6],l,tg):Pp(a[6]),_h)},i(a){e||(ot(o,a),e=!0)},o(a){mt(o,a),e=!1},d(a){a&&et(t),o&&o.d(a),i=!1,Pe(s)}}}function rg(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Qr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class vh extends de{constructor(t){super(),ue(this,t,rg,eg,qt,{shape:3,editor:4,transform:5})}}const Ns=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function ig(r,t,e){let i;const s=Qr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return zi(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=Ns(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[n,o,a,l,h,c,u,i]}class sg extends de{constructor(t){super(),ue(this,t,ig,null,qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function ng(r,t,e){const i=Qr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return zi(()=>{const c=n.closest("svg"),u=[],d=(f,p,m)=>{c==null||c.addEventListener(f,p,m),u.push(()=>c==null?void 0:c.removeEventListener(f,p,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class og extends de{constructor(t){super(),ue(this,t,ng,null,qt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function xh(r){let t,e;return{c(){t=yt("rect"),e=yt("rect"),T(t,"class","a9s-outer"),T(t,"x",r[1]),T(t,"y",r[2]),T(t,"width",r[3]),T(t,"height",r[4]),T(e,"class","a9s-inner"),T(e,"x",r[1]),T(e,"y",r[2]),T(e,"width",r[3]),T(e,"height",r[4])},m(i,s){it(i,t,s),it(i,e,s)},p(i,s){s&2&&T(t,"x",i[1]),s&4&&T(t,"y",i[2]),s&8&&T(t,"width",i[3]),s&16&&T(t,"height",i[4]),s&2&&T(e,"x",i[1]),s&4&&T(e,"y",i[2]),s&8&&T(e,"width",i[3]),s&16&&T(e,"height",i[4])},d(i){i&&(et(t),et(e))}}}function ag(r){let t,e=r[0]&&xh(r);return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=xh(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}function lg(r,t,e){const i=Qr();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,c,u,d,f;const p=x=>{const g=x;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))},m=x=>{const g=x;l&&(h=o.elementToImage(g.offsetX,g.offsetY),e(1,c=Math.min(h[0],l[0])),e(2,u=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,f=Math.abs(h[1]-l[1])))},_=x=>{const g=x,v=performance.now()-a;if(n==="click"){if(v>300)return;l?y():(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))}else l&&(v>300||d*f>100?(g.stopPropagation(),y()):(e(0,l=void 0),h=void 0))},y=()=>{if(d*f>15){const x={type:wt.RECTANGLE,geometry:{bounds:{minX:c,minY:u,maxX:c+d,maxY:u+f},x:c,y:u,w:d,h:f}};i("create",x)}e(0,l=void 0),h=void 0};return zi(()=>{s("pointerdown",p),s("pointermove",m),s("pointerup",_,!0)}),r.$$set=x=>{"addEventListener"in x&&e(5,s=x.addEventListener),"drawingMode"in x&&e(6,n=x.drawingMode),"transform"in x&&e(7,o=x.transform)},[l,c,u,d,f,s,n,o]}class hg extends de{constructor(t){super(),ue(this,t,lg,ag,qt,{addEventListener:5,drawingMode:6,transform:7})}}function Io(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function bh(r){let t,e,i,s,n,o=r[2]&&wh(r);return{c(){t=yt("polygon"),i=yt("polygon"),o&&o.c(),n=ye(),T(t,"class","a9s-outer"),T(t,"points",e=r[16]),T(i,"class","a9s-inner"),T(i,"points",s=r[16])},m(a,l){it(a,t,l),it(a,i,l),o&&o.m(a,l),it(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&T(t,"points",e),l&7&&s!==(s=a[16])&&T(i,"points",s),a[2]?o?o.p(a,l):(o=wh(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(et(t),et(i),et(n)),o&&o.d(a)}}}function wh(r){let t,e,i;return{c(){t=yt("rect"),T(t,"class","a9s-corner-handle"),T(t,"x",e=r[0][0][0]-r[3]/2),T(t,"y",i=r[0][0][1]-r[3]/2),T(t,"height",r[3]),T(t,"width",r[3])},m(s,n){it(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&T(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&T(t,"y",i),n&8&&T(t,"height",s[3]),n&8&&T(t,"width",s[3])},d(s){s&&et(t)}}}function cg(r){let t,e=r[1]&&bh(Io(r));return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(Io(i),s):(e=bh(Io(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}const ug=20,dg=1500;function fg(r,t,e){let i;const s=Qr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c=[],u,d,f=!1;const p=g=>{const v=g,{timeStamp:w,offsetX:I,offsetY:A}=v;if(h={timeStamp:w,offsetX:I,offsetY:A},o==="drag"&&c.length===0){const C=a.elementToImage(v.offsetX,v.offsetY);c.push(C),e(1,u=C)}},m=g=>{const v=g;if(d&&clearTimeout(d),c.length>0){if(e(1,u=a.elementToImage(v.offsetX,v.offsetY)),c.length>2){const w=So(u,c[0])*l;e(2,f=w<ug)}v.pointerType==="touch"&&(d=setTimeout(()=>{y()},dg))}},_=g=>{const v=g;if(d&&clearTimeout(d),o==="click"){const w=v.timeStamp-h.timeStamp,I=So([h.offsetX,h.offsetY],[v.offsetX,v.offsetY]);if(w>300||I>15)return;if(f)x();else if(c.length===0){const A=a.elementToImage(v.offsetX,v.offsetY);c.push(A),e(1,u=A)}else c.push(u)}else{if(c.length===1&&So(c[0],u)<=4){e(0,c=[]),e(1,u=void 0);return}v.stopImmediatePropagation(),f?x():c.push(u)}},y=()=>{if(!u)return;const g=[...c,u],v={type:wt.POLYGON,geometry:{bounds:Bs(g),points:g}};vo(v)>4&&(e(0,c=[]),e(1,u=void 0),s("create",v))},x=()=>{const g={type:wt.POLYGON,geometry:{bounds:Bs(c),points:[...c]}};e(0,c=[]),e(1,u=void 0),s("create",g)};return zi(()=>{n("pointerdown",p,!0),n("pointermove",m),n("pointerup",_,!0),n("dblclick",y,!0)}),r.$$set=g=>{"addEventListener"in g&&e(4,n=g.addEventListener),"drawingMode"in g&&e(5,o=g.drawingMode),"transform"in g&&e(6,a=g.transform),"viewportScale"in g&&e(7,l=g.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[c,u,f,i,n,o,a,l]}class pg extends de{constructor(t){super(),ue(this,t,fg,cg,qt,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const Co=new Map([["rectangle",{tool:hg}],["polygon",{tool:pg}]]),Us=()=>[...Co.keys()],ks=r=>Co.get(r),Eh=(r,t,e)=>Co.set(r,{tool:t,opts:e});function mg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("ellipse"),s=yt("ellipse"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"cx",r[2]),T(e,"cy",r[3]),T(e,"rx",r[4]),T(e,"ry",r[5]),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"cx",r[2]),T(s,"cy",r[3]),T(s,"rx",r[4]),T(s,"ry",r[5]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function gg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=n;return r.$$set=u=>{"annotation"in u&&e(0,s=u.annotation),"geom"in u&&e(6,n=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Ns(s,o))},[s,i,a,l,h,c,n,o]}class yg extends de{constructor(t){super(),ue(this,t,gg,mg,qt,{annotation:0,geom:6,style:7})}}function _g(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("polygon"),s=yt("polygon"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"points",r[2].map(vg).join(" ")),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"points",r[2].map(xg).join(" ")),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}const vg=r=>r.join(","),xg=r=>r.join(",");function bg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Ns(s,o))},[s,i,a,n,o]}class wg extends de{constructor(t){super(),ue(this,t,bg,_g,qt,{annotation:0,geom:3,style:4})}}function Eg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("rect"),s=yt("rect"),T(e,"class","a9s-outer"),T(e,"style",i=r[5]?"display:none;":void 0),T(e,"x",r[4]),T(e,"y",r[3]),T(e,"width",r[2]),T(e,"height",r[1]),T(s,"class","a9s-inner"),T(s,"style",r[5]),T(s,"x",r[4]),T(s,"y",r[3]),T(s,"width",r[2]),T(s,"height",r[1]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&T(e,"style",i),a&16&&T(e,"x",o[4]),a&8&&T(e,"y",o[3]),a&4&&T(e,"width",o[2]),a&2&&T(e,"height",o[1]),a&32&&T(s,"style",o[5]),a&16&&T(s,"x",o[4]),a&8&&T(s,"y",o[3]),a&4&&T(s,"width",o[2]),a&2&&T(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function Tg(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Ns(l,c)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,c]}class Ag extends de{constructor(t){super(),ue(this,t,Tg,Eg,qt,{annotation:0,geom:6,style:7})}}const Sg=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),Ig=250,Cg=(r,t)=>{const e=Qr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<Ig){const{x:n,y:o}=Th(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},Th=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())};function Ah(r,t,e){const i=r.slice();i[37]=t[e];const s=i[23](i[37].target.selector);return i[38]=s,i}function Sh(r,t,e){const i=r.slice();return i[41]=t[e],i}function Ro(r){const t=r.slice(),e=t[41].target.selector;return t[44]=e,t}function Ih(r){let t=r[41].id,e,i,s=Ch(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&32768&&qt(t,t=n[41].id)?(_e(),mt(s,1,1,At),ve(),s=Ch(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Rg(r){let t,e;return t=new wg({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Pg(r){let t,e;return t=new Ag({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Mg(r){var t;let e,i;return e=new yg({props:{annotation:r[41],geom:(t=r[44])==null?void 0:t.geometry,style:r[1]}}),{c(){ce(e.$$.fragment)},m(s,n){se(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&32768&&(a.annotation=s[41]),n[0]&32768&&(a.geom=(o=s[44])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ot(e.$$.fragment,s),i=!0)},o(s){mt(e.$$.fragment,s),i=!1},d(s){ne(e,s)}}}function Ch(r){let t,e,i,s;const n=[Mg,Pg,Rg],o=[];function a(l,h){var c,u,d;return((c=l[44])==null?void 0:c.type)===wt.ELLIPSE?0:((u=l[44])==null?void 0:u.type)===wt.RECTANGLE?1:((d=l[44])==null?void 0:d.type)===wt.POLYGON?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Rh(r){let t=Je(r[41])&&!r[8](r[41]),e,i,s=t&&Ih(Ro(r));return{c(){s&&s.c(),e=ye()},m(n,o){s&&s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&33024&&(t=Je(n[41])&&!n[8](n[41])),t?s?(s.p(Ro(n),o),o[0]&33024&&ot(s,1)):(s=Ih(Ro(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(_e(),mt(s,1,1,()=>{s=null}),ve())},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s&&s.d(n)}}}function Ph(r){let t,e,i,s;const n=[Dg,Bg],o=[];function a(l,h){return l[7]?0:l[13]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Bg(r){let t=r[2],e,i,s=Mh(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&4&&qt(t,t=n[2])?(_e(),mt(s,1,1,At),ve(),s=Mh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Dg(r){let t,e,i=ii(r[7]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Oh(Ah(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ye()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&10553506){i=ii(o[7]);let l;for(l=0;l<i.length;l+=1){const h=Ah(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=Oh(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(_e(),l=i.length;l<s.length;l+=1)n(l);ve()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&et(t),fo(s,o)}}}function Mh(r){let t,e;return t=new og({props:{target:r[5],tool:r[13],drawingMode:r[12],transform:r[11],viewportScale:r[16]}}),t.$on("create",r[20]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&8192&&(n.tool=i[13]),s[0]&4096&&(n.drawingMode=i[12]),s[0]&2048&&(n.transform=i[11]),s[0]&65536&&(n.viewportScale=i[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Bh(r){let t=r[37].id,e,i,s=Dh(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&128&&qt(t,t=n[37].id)?(_e(),mt(s,1,1,At),ve(),s=Dh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Dh(r){let t,e;return t=new sg({props:{target:r[5],editor:r[23](r[37].target.selector),annotation:r[37],style:r[1],transform:r[11],viewportScale:r[16]}}),t.$on("change",function(){Ut(r[21](r[37]))&&r[21](r[37]).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&128&&(n.editor=r[23](r[37].target.selector)),s[0]&128&&(n.annotation=r[37]),s[0]&2&&(n.style=r[1]),s[0]&2048&&(n.transform=r[11]),s[0]&65536&&(n.viewportScale=r[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Oh(r){let t,e,i=r[38]&&Bh(r);return{c(){i&&i.c(),t=ye()},m(s,n){i&&i.m(s,n),it(s,t,n),e=!0},p(s,n){s[38]?i?(i.p(s,n),n[0]&128&&ot(i,1)):(i=Bh(s),i.c(),ot(i,1),i.m(t.parentNode,t)):i&&(_e(),mt(i,1,1,()=>{i=null}),ve())},i(s){e||(ot(i),e=!0)},o(s){mt(i),e=!1},d(s){s&&et(t),i&&i.d(s)}}}function Og(r){let t,e,i,s,n,o,a=ii(r[15].filter(r[32])),l=[];for(let u=0;u<a.length;u+=1)l[u]=Rh(Sh(r,a,u));const h=u=>mt(l[u],1,1,()=>{l[u]=null});let c=r[5]&&Ph(r);return{c(){t=yt("svg"),e=yt("g");for(let u=0;u<l.length;u+=1)l[u].c();i=yt("g"),c&&c.c(),T(i,"class","drawing"),T(t,"class","a9s-annotationlayer"),fr(t,"drawing",r[13]),fr(t,"hidden",!r[3]),fr(t,"hover",r[14])},m(u,d){it(u,t,d),Me(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);Me(t,i),c&&c.m(i,null),r[33](i),r[34](t),s=!0,n||(o=[Dt(t,"pointerup",function(){Ut(r[9])&&r[9].apply(this,arguments)}),Dt(t,"pointerdown",function(){Ut(r[10])&&r[10].apply(this,arguments)}),Dt(t,"pointermove",r[22])],n=!0)},p(u,d){if(r=u,d[0]&33026){a=ii(r[15].filter(r[32]));let f;for(f=0;f<a.length;f+=1){const p=Sh(r,a,f);l[f]?(l[f].p(p,d),ot(l[f],1)):(l[f]=Rh(p),l[f].c(),ot(l[f],1),l[f].m(e,null))}for(_e(),f=a.length;f<l.length;f+=1)h(f);ve()}r[5]?c?(c.p(r,d),d[0]&32&&ot(c,1)):(c=Ph(r),c.c(),ot(c,1),c.m(i,null)):c&&(_e(),mt(c,1,1,()=>{c=null}),ve()),(!s||d[0]&8192)&&fr(t,"drawing",r[13]),(!s||d[0]&8)&&fr(t,"hidden",!r[3]),(!s||d[0]&16384)&&fr(t,"hover",r[14])},i(u){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(c),s=!0}},o(u){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)mt(l[d]);mt(c),s=!1},d(u){u&&et(t),fo(l,u),c&&c.d(),r[33](null),r[34](null),n=!1,Pe(o)}}}function Fg(r,t,e){let i,s,n,o,a,l,h,c,u,d,f,p=At,m=()=>(p(),p=jl(E,V=>e(16,f=V)),E);r.$$.on_destroy.push(()=>p());let{drawingEnabled:_}=t,{image:y}=t,{preferredDrawingMode:x}=t,{state:g}=t,{style:v=void 0}=t,{toolName:w=Us()[0]}=t,{user:I}=t,{visible:A=!0}=t;const C=()=>w,N=()=>_;let S,R,E;zi(()=>m(e(6,E=zm(y,R))));const{hover:b,selection:D,store:F}=g;uo(r,b,V=>e(14,c=V)),uo(r,D,V=>e(31,u=V)),uo(r,F,V=>e(15,d=V));let G,$;const B=V=>{G&&F.unobserve(G);const lt=V.filter(({editable:L})=>L).map(({id:L})=>L);lt.length>0?(e(7,$=lt.map(L=>F.getAnnotation(L)).filter(L=>L&&Je(L))),G=L=>{const{updated:O}=L.changes;e(7,$=O==null?void 0:O.map(_t=>_t.newValue))},F.observe(G,{annotations:lt})):e(7,$=void 0)},Z=V=>{const lt=ih(),L={id:lt,bodies:[],target:{annotation:lt,selector:V.detail,creator:I,created:new Date}};F.addAnnotation(L),D.setSelected(L.id)},P=V=>lt=>{var L;const{target:O}=V,_t=10*60*1e3,ht=((L=O.creator)==null?void 0:L.id)!==I.id||!O.created||new Date().getTime()-O.created.getTime()>_t;F.updateTarget({...O,selector:lt.detail,created:ht?O.created:new Date,updated:ht?new Date:void 0,updatedBy:ht?I:void 0})},U=V=>{const{x:lt,y:L}=Th(V,R),O=F.getAt(lt,L);O?c!==O.id&&b.set(O.id):b.set(void 0)},j=V=>gh(V),rt=V=>Je(V);function Q(V){Ps[V?"unshift":"push"](()=>{S=V,e(5,S)})}function H(V){Ps[V?"unshift":"push"](()=>{R=V,e(4,R)})}return r.$$set=V=>{"drawingEnabled"in V&&e(0,_=V.drawingEnabled),"image"in V&&e(24,y=V.image),"preferredDrawingMode"in V&&e(25,x=V.preferredDrawingMode),"state"in V&&e(26,g=V.state),"style"in V&&e(1,v=V.style),"toolName"in V&&e(2,w=V.toolName),"user"in V&&e(27,I=V.user),"visible"in V&&e(3,A=V.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(13,{tool:i,opts:s}=ks(w)||{tool:void 0,opts:void 0},i,(e(30,s),e(2,w))),r.$$.dirty[0]&1107296256&&e(12,n=(s==null?void 0:s.drawingMode)||x),r.$$.dirty[0]&16&&e(11,o=Sg(R)),r.$$.dirty[0]&16&&e(10,{onPointerDown:a,onPointerUp:l}=Cg(R,F),a,(e(9,l),e(4,R))),r.$$.dirty[1]&1&&e(8,h=V=>u.selected.find(lt=>lt.id===V.id&&lt.editable)),r.$$.dirty[1]&1&&B(u.selected)},[_,v,w,A,R,S,E,$,h,l,a,o,n,i,c,d,f,b,D,F,Z,P,U,j,y,x,g,I,C,N,s,u,rt,Q,H]}class Lg extends de{constructor(t){super(),ue(this,t,Fg,Og,qt,{drawingEnabled:0,image:24,preferredDrawingMode:25,state:26,style:1,toolName:2,user:27,visible:3,getDrawingTool:28,isDrawingEnabled:29},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[28]}get isDrawingEnabled(){return this.$$.ctx[29]}}function Fh(r,t,e=0,i=r.length-1,s=Ng){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),p=Math.min(i,Math.floor(t+(l-h)*u/l+d));Fh(r,t,f,p,s)}const n=r[t];let o=e,a=i;for(ji(r,e,t),s(r[i],n)>0&&ji(r,e,i);o<a;){for(ji(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?ji(r,e,a):(a++,ji(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function ji(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Ng(r,t){return r<t?-1:r>t?1:0}class Ug{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!$s(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;$s(t,l)&&(e.leaf?i.push(a):Mo(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!$s(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if($s(t,o)){if(e.leaf||Mo(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=ai([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const c=kg(t,i.children,e);if(c!==-1)return i.children.splice(c,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Mo(i,s)?(n.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(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=ai(t.slice(e,i+1)),oi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=ai([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Lh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);Lh(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return oi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Po(h),u=Hg(t,h)-c;u<o?(o=u,n=c<n?c:n,a=h):u===o&&c<n&&(n=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),qi(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=ai(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,oi(i,this.toBBox),oi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=ai([t,e]),this.data.height=t.height+1,this.data.leaf=!1,oi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Yi(t,0,a,this.toBBox),h=Yi(t,a,i,this.toBBox),c=Xg(l,h),u=Po(l)+Po(h);c<n?(n=c,s=a,o=u<o?u:o):c===n&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Gg,n=t.leaf?this.compareMinY:$g,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Yi(t,0,e,n),a=Yi(t,i-e,i,n);let l=Gs(o)+Gs(a);for(let h=e;h<i-e;h++){const c=t.children[h];qi(o,t.leaf?n(c):c),l+=Gs(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];qi(a,t.leaf?n(c):c),l+=Gs(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)qi(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():oi(t[e],this.toBBox)}}function kg(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function oi(r,t){Yi(r,0,r.children.length,t,r)}function Yi(r,t,e,i,s){s||(s=ai(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];qi(s,r.leaf?i(o):o)}return s}function qi(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function Gg(r,t){return r.minX-t.minX}function $g(r,t){return r.minY-t.minY}function Po(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Gs(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Hg(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Xg(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Mo(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function $s(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function ai(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Lh(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Fh(r,o,t,e,s),n.push(t,o,o,e)}}const Vg=()=>{const r=new Ug,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!Ds(o))return;const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},n=o=>{if(!Ds(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===wt.RECTANGLE||kp(h.selector,o,a));if(l.length>0)return l.sort((h,c)=>vo(h.selector)-vo(c.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,c)=>{if(Ds(c)){const{minX:u,minY:d,maxX:f,maxY:p}=c.selector.geometry.bounds;return[...h,{minX:u,minY:d,maxX:f,maxY:p,target:c}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Nh=r=>{const t=gm(),e=Vg(),i=im(t,r.userSelectAction,r.adapter),s=rm(t),n=bm();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation))},selection:i,hover:s,viewport:n}},zg=r=>{const t=Nh(r);return{...t,store:ym(t.store)}},Wg=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Uh=r=>{const t=Wg(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},kh=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Uh(r):e),Gh=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),$h=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Hh=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{$h?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return $h?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},jg=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Gh(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:nh.EDIT,theme:"light"}),s=zg(i),{selection:n,store:o}=s,a=xm(o),l=wm(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const c=Hh(a);let u=Bm();kh(e,h,i.theme);const d=new Lg({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:u}});d.$on("click",E=>{const{originalEvent:b,annotation:D}=E.detail;D?n.userSelect(D.id,b):n.isEmpty()||n.clear()});const f=Tm(s,a,i.adapter),p=()=>{d.$set({drawingEnabled:!1}),setTimeout(()=>d.$set({drawingEnabled:!0}),1)},m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},_=()=>d.getDrawingTool(),y=()=>u,x=()=>d.isDrawingEnabled(),g=(E,b,D)=>Eh(E,b,D),v=(E,b)=>yh(E,b),w=E=>{if(!ks(E))throw`No drawing tool named ${E}`;d.$set({toolName:E})},I=E=>d.$set({drawingEnabled:E}),A=E=>{console.warn("Filter not implemented yet")},C=E=>d.$set({style:E}),N=E=>kh(e,h,E),S=E=>{u=E,d.$set({user:E})},R=E=>d.$set({visible:E});return{...f,cancelDrawing:p,destroy:m,getDrawingTool:_,getUser:y,isDrawingEnabled:x,listDrawingTools:Us,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:v,setDrawingEnabled:I,setDrawingTool:w,setFilter:A,setStyle:C,setTheme:N,setUser:S,setVisible:R,element:h,state:s}};function Be(){}function Bo(r,t){for(const e in t)r[e]=t[e];return r}function Xh(r){return r()}function Vh(){return Object.create(null)}function Qe(r){r.forEach(Xh)}function Kt(r){return typeof r=="function"}function te(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Yg(r){return Object.keys(r).length===0}function qg(r,...t){if(r==null){for(const i of t)i(void 0);return Be}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Do(r,t,e){r.$$.on_destroy.push(qg(t,e))}function zh(r,t,e,i){if(r){const s=Wh(r,t,e,i);return r[0](s)}}function Wh(r,t,e,i){return r[1]&&i?Bo(e.ctx.slice(),r[1](i(t))):e.ctx}function jh(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Yh(r,t,e,i,s,n){if(s){const o=Wh(t,e,i,n);r.p(o,s)}}function qh(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Kh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Hs(r){return r??""}const Kg=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function tr(r,t){r.appendChild(t)}function ft(r,t,e){r.insertBefore(t,e||null)}function ct(r){r.parentNode&&r.parentNode.removeChild(r)}function Oo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Tt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Fo(r){return document.createTextNode(r)}function xe(){return Fo(" ")}function er(){return Fo("")}function zt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function M(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Zg(r){return Array.from(r.childNodes)}function Jg(r,t){t=""+t,r.data!==t&&(r.data=t)}function Xs(r,t,e){r.classList.toggle(t,!!e)}function Qg(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ki;function Zi(r){Ki=r}function Lo(){if(!Ki)throw new Error("Function called outside component initialization");return Ki}function Vs(r){Lo().$$.on_mount.push(r)}function ty(r){Lo().$$.on_destroy.push(r)}function zs(){const r=Lo();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Qg(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function rr(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const li=[],Ws=[];let hi=[];const Zh=[],ey=Promise.resolve();let No=!1;function ry(){No||(No=!0,ey.then(Jh))}function Uo(r){hi.push(r)}const ko=new Set;let ci=0;function Jh(){if(ci!==0)return;const r=Ki;do{try{for(;ci<li.length;){const t=li[ci];ci++,Zi(t),iy(t.$$)}}catch(t){throw li.length=0,ci=0,t}for(Zi(null),li.length=0,ci=0;Ws.length;)Ws.pop()();for(let t=0;t<hi.length;t+=1){const e=hi[t];ko.has(e)||(ko.add(e),e())}hi.length=0}while(li.length);for(;Zh.length;)Zh.pop()();No=!1,ko.clear(),Zi(r)}function iy(r){if(r.fragment!==null){r.update(),Qe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Uo)}}function sy(r){const t=[],e=[];hi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),hi=t}const js=new Set;let Dr;function De(){Dr={r:0,c:[],p:Dr}}function Oe(){Dr.r||Qe(Dr.c),Dr=Dr.p}function st(r,t){r&&r.i&&(js.delete(r),r.i(t))}function ut(r,t,e,i){if(r&&r.o){if(js.has(r))return;js.add(r),Dr.c.push(()=>{js.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ui(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ee(r){r&&r.c()}function Zt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Uo(()=>{const n=r.$$.on_mount.map(Xh).filter(Kt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Qe(n),r.$$.on_mount=[]}),s.forEach(Uo)}function Jt(r,t){const e=r.$$;e.fragment!==null&&(sy(e.after_update),Qe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function ny(r,t){r.$$.dirty[0]===-1&&(li.push(r),ry(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function oe(r,t,e,i,s,n,o=null,a=[-1]){const l=Ki;Zi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Be,not_equal:s,bound:Vh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Vh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&ny(r,u)),d}):[],h.update(),c=!0,Qe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Zg(t.target);h.fragment&&h.fragment.l(u),u.forEach(ct)}else h.fragment&&h.fragment.c();t.intro&&st(r.$$.fragment),Zt(r,t.target,t.anchor),Jh()}Zi(l)}class ae{constructor(){Fl(this,"$$");Fl(this,"$$set")}$destroy(){Jt(this,1),this.$destroy=Be}$on(t,e){if(!Kt(e))return Be;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Yg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const oy="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(oy);var Or=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Or||{}),Qh=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Qh||{}),Go=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Go||{}),tt=(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))(tt||{}),Fe=(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))(Fe||{}),k=(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))(k||{}),di=(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))(di||{}),J=(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))(J||{}),z=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(z||{}),ir=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(ir||{}),mr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(mr||{}),Le=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Le||{}),ie=(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))(ie||{}),Ne=(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))(Ne||{}),$o=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))($o||{}),fe=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(fe||{}),Ft=(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))(Ft||{}),Ot=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Ot||{}),Ue=(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))(Ue||{});const W={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Ho=/iPhone/i,tc=/iPod/i,ec=/iPad/i,rc=/\biOS-universal(?:.+)Mac\b/i,Xo=/\bAndroid(?:.+)Mobile\b/i,ic=/Android/i,fi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ys=/Silk/i,sr=/Windows Phone/i,sc=/\bWindows(?:.+)ARM\b/i,nc=/BlackBerry/i,oc=/BB10/i,ac=/Opera Mini/i,lc=/\b(CriOS|Chrome)(?:.+)Mobile/i,hc=/Mobile(?:.+)Firefox\b/i,cc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function ay(r){return function(t){return t.test(r)}}function uc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=ay(e),n={apple:{phone:s(Ho)&&!s(sr),ipod:s(tc),tablet:!s(Ho)&&(s(ec)||cc(t))&&!s(sr),universal:s(rc),device:(s(Ho)||s(tc)||s(ec)||s(rc)||cc(t))&&!s(sr)},amazon:{phone:s(fi),tablet:!s(fi)&&s(Ys),device:s(fi)||s(Ys)},android:{phone:!s(sr)&&s(fi)||!s(sr)&&s(Xo),tablet:!s(sr)&&!s(fi)&&!s(Xo)&&(s(Ys)||s(ic)),device:!s(sr)&&(s(fi)||s(Ys)||s(Xo)||s(ic))||s(/\bokhttp\b/i)},windows:{phone:s(sr),tablet:s(sc),device:s(sr)||s(sc)},other:{blackberry:s(nc),blackberry10:s(oc),opera:s(ac),firefox:s(hc),chrome:s(lc),device:s(nc)||s(oc)||s(ac)||s(hc)||s(lc)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ly=uc.default??uc,nr=ly(globalThis.navigator);W.RETINA_PREFIX=/@([0-9\.]+)x/,W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Ji=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 hy(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var fc={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=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 h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],y=arguments.length,x,g;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,u),!0;case 4:return _.fn.call(_.context,c,u,d),!0;case 5:return _.fn.call(_.context,c,u,d,f),!0;case 6:return _.fn.call(_.context,c,u,d,f,p),!0}for(g=1,x=new Array(y-1);g<y;g++)x[g-1]=arguments[g];_.fn.apply(_.context,x)}else{var v=_.length,w;for(g=0;g<v;g++)switch(_[g].once&&this.removeListener(h,_[g].fn,void 0,!0),y){case 1:_[g].fn.call(_[g].context);break;case 2:_[g].fn.call(_[g].context,c);break;case 3:_[g].fn.call(_[g].context,c,u);break;case 4:_[g].fn.call(_[g].context,c,u,d);break;default:if(!x)for(w=1,x=new Array(y-1);w<y;w++)x[w-1]=arguments[w];_[g].fn.apply(_[g].context,x)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,_=[],y=p.length;m<y;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(fc);var cy=fc.exports;const Qi=dc(cy);var Vo={exports:{}};Vo.exports=qs,Vo.exports.default=qs;function qs(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=pc(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=my(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return ts(n,o,e,a,l,f,0),o}function pc(r,t,e,i,s){var n,o;if(s===jo(r,t,e,i)>0)for(n=t;n<e;n+=i)o=yc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=yc(n,r[n],r[n+1],o);return o&&Ks(o,o.next)&&(rs(o),o=o.next),o}function Fr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Ks(e,e.next)||It(e.prev,e,e.next)===0)){if(rs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ts(r,t,e,i,s,n,o){if(r){!o&&n&&xy(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?dy(r,i,s,n):uy(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),rs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=fy(Fr(r),t,e),ts(r,t,e,i,s,n,2)):o===2&&py(r,t,e,i,s,n):ts(Fr(r),t,e,i,s,n,1);break}}}}function uy(r){var t=r.prev,e=r,i=r.next;if(It(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&pi(s,a,n,l,o,h,p.x,p.y)&&It(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function dy(r,t,e,i){var s=r.prev,n=r,o=r.next;if(It(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,c=s.y,u=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,_=c>u?c>d?c:d:u>d?u:d,y=zo(f,p,t,e,i),x=zo(m,_,t,e,i),g=r.prevZ,v=r.nextZ;g&&g.z>=y&&v&&v.z<=x;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0||(g=g.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;g&&g.z>=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function fy(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Ks(s,n)&&mc(s,i,i.next,n)&&es(s,n)&&es(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),rs(i),rs(i.next),i=r=n),i=i.next}while(i!==r);return Fr(i)}function py(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Ey(o,a)){var l=gc(o,a);o=Fr(o,o.next),l=Fr(l,l.next),ts(o,t,e,i,s,n,0),ts(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function my(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=pc(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(wy(h));for(s.sort(gy),n=0;n<s.length;n++)e=yy(s[n],e);return e}function gy(r,t){return r.x-t.x}function yy(r,t){var e=_y(r,t);if(!e)return t;var i=gc(e,r);return Fr(i,i.next),Fr(e,e.next)}function _y(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&pi(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),es(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&vy(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function vy(r,t){return It(r.prev,r,t.prev)<0&&It(t.next,r,r.next)<0}function xy(r,t,e,i){var s=r;do s.z===0&&(s.z=zo(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,by(s)}function by(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function zo(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function wy(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function pi(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function Ey(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Ty(r,t)&&(es(r,t)&&es(t,r)&&Ay(r,t)&&(It(r.prev,r,t.prev)||It(r,t.prev,t))||Ks(r,t)&&It(r.prev,r,r.next)>0&&It(t.prev,t,t.next)>0)}function It(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ks(r,t){return r.x===t.x&&r.y===t.y}function mc(r,t,e,i){var s=Js(It(r,t,e)),n=Js(It(r,t,i)),o=Js(It(e,i,r)),a=Js(It(e,i,t));return!!(s!==n&&o!==a||s===0&&Zs(r,e,t)||n===0&&Zs(r,i,t)||o===0&&Zs(e,r,i)||a===0&&Zs(e,t,i))}function Zs(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Js(r){return r>0?1:r<0?-1:0}function Ty(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&mc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function es(r,t){return It(r.prev,r,r.next)<0?It(r,t,r.next)>=0&&It(r,r.prev,t)>=0:It(r,t,r.prev)<0||It(r,r.next,t)<0}function Ay(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function gc(r,t){var e=new Wo(r.i,r.x,r.y),i=new Wo(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function yc(r,t,e,i){var s=new Wo(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function rs(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 Wo(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}qs.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(jo(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(jo(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function jo(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}qs.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var Sy=Vo.exports;const Iy=dc(Sy);var Qs={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Qs.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Ji=="object"&&Ji;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,m="-",_=/^xn--/,y=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-h,w=Math.floor,I=String.fromCharCode,A;function C(P){throw new RangeError(g[P])}function N(P,U){for(var j=P.length,rt=[];j--;)rt[j]=U(P[j]);return rt}function S(P,U){var j=P.split("@"),rt="";j.length>1&&(rt=j[0]+"@",P=j[1]),P=P.replace(x,".");var Q=P.split("."),H=N(Q,U).join(".");return rt+H}function R(P){for(var U=[],j=0,rt=P.length,Q,H;j<rt;)Q=P.charCodeAt(j++),Q>=55296&&Q<=56319&&j<rt?(H=P.charCodeAt(j++),(H&64512)==56320?U.push(((Q&1023)<<10)+(H&1023)+65536):(U.push(Q),j--)):U.push(Q);return U}function E(P){return N(P,function(U){var j="";return U>65535&&(U-=65536,j+=I(U>>>10&1023|55296),U=56320|U&1023),j+=I(U),j}).join("")}function b(P){return P-48<10?P-22:P-65<26?P-65:P-97<26?P-97:l}function D(P,U){return P+22+75*(P<26)-((U!=0)<<5)}function F(P,U,j){var rt=0;for(P=j?w(P/d):P>>1,P+=w(P/U);P>v*c>>1;rt+=l)P=w(P/v);return w(rt+(v+1)*P/(P+u))}function G(P){var U=[],j=P.length,rt,Q=0,H=p,V=f,lt,L,O,_t,ht,vt,xt,Ye,qe;for(lt=P.lastIndexOf(m),lt<0&&(lt=0),L=0;L<lt;++L)P.charCodeAt(L)>=128&&C("not-basic"),U.push(P.charCodeAt(L));for(O=lt>0?lt+1:0;O<j;){for(_t=Q,ht=1,vt=l;O>=j&&C("invalid-input"),xt=b(P.charCodeAt(O++)),(xt>=l||xt>w((a-Q)/ht))&&C("overflow"),Q+=xt*ht,Ye=vt<=V?h:vt>=V+c?c:vt-V,!(xt<Ye);vt+=l)qe=l-Ye,ht>w(a/qe)&&C("overflow"),ht*=qe;rt=U.length+1,V=F(Q-_t,rt,_t==0),w(Q/rt)>a-H&&C("overflow"),H+=w(Q/rt),Q%=rt,U.splice(Q++,0,H)}return E(U)}function $(P){var U,j,rt,Q,H,V,lt,L,O,_t,ht,vt=[],xt,Ye,qe,ws;for(P=R(P),xt=P.length,U=p,j=0,H=f,V=0;V<xt;++V)ht=P[V],ht<128&&vt.push(I(ht));for(rt=Q=vt.length,Q&&vt.push(m);rt<xt;){for(lt=a,V=0;V<xt;++V)ht=P[V],ht>=U&&ht<lt&&(lt=ht);for(Ye=rt+1,lt-U>w((a-j)/Ye)&&C("overflow"),j+=(lt-U)*Ye,U=lt,V=0;V<xt;++V)if(ht=P[V],ht<U&&++j>a&&C("overflow"),ht==U){for(L=j,O=l;_t=O<=H?h:O>=H+c?c:O-H,!(L<_t);O+=l)ws=L-_t,qe=l-_t,vt.push(I(D(_t+ws%qe,0))),L=w(ws/qe);vt.push(I(D(L,0))),H=F(j,Ye,rt==Q),j=0,++rt}++j,++U}return vt.join("")}function B(P){return S(P,function(U){return _.test(U)?G(U.slice(4).toLowerCase()):U})}function Z(P){return S(P,function(U){return y.test(U)?"xn--"+$(U):U})}if(o={version:"1.4.1",ucs2:{decode:R,encode:E},decode:G,encode:$,toASCII:Z,toUnicode:B},i&&s)if(r.exports==i)s.exports=o;else for(A in o)o.hasOwnProperty(A)&&(i[A]=o[A]);else e.punycode=o})(Ji)}(Qs,Qs.exports);var Cy=Qs.exports,Ry=Error,Py=EvalError,My=RangeError,By=ReferenceError,_c=SyntaxError,is=TypeError,Dy=URIError,Oy=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},vc=typeof Symbol<"u"&&Symbol,Fy=Oy,Ly=function(){return typeof vc!="function"||typeof Symbol!="function"||typeof vc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Fy()},Yo={__proto__:null,foo:{}},Ny=Object,Uy=function(){return{__proto__:Yo}.foo===Yo.foo&&!(Yo instanceof Ny)},ky="Function.prototype.bind called on incompatible ",Gy=Object.prototype.toString,$y=Math.max,Hy="[object Function]",xc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},Xy=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},Vy=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},zy=function(t){var e=this;if(typeof e!="function"||Gy.apply(e)!==Hy)throw new TypeError(ky+e);for(var i=Xy(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,xc(i,arguments));return Object(c)===c?c:this}return e.apply(t,xc(i,arguments))},o=$y(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+Vy(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},Wy=zy,qo=Function.prototype.bind||Wy,jy=Function.prototype.call,Yy=Object.prototype.hasOwnProperty,qy=qo,Ky=qy.call(jy,Yy),pt,Zy=Ry,Jy=Py,Qy=My,t0=By,mi=_c,gi=is,e0=Dy,bc=Function,Ko=function(r){try{return bc('"use strict"; return ('+r+").constructor;")()}catch{}},Lr=Object.getOwnPropertyDescriptor;if(Lr)try{Lr({},"")}catch{Lr=null}var Zo=function(){throw new gi},r0=Lr?function(){try{return arguments.callee,Zo}catch{try{return Lr(arguments,"callee").get}catch{return Zo}}}():Zo,yi=Ly(),i0=Uy(),kt=Object.getPrototypeOf||(i0?function(r){return r.__proto__}:null),_i={},s0=typeof Uint8Array>"u"||!kt?pt:kt(Uint8Array),Nr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?pt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?pt:ArrayBuffer,"%ArrayIteratorPrototype%":yi&&kt?kt([][Symbol.iterator]()):pt,"%AsyncFromSyncIteratorPrototype%":pt,"%AsyncFunction%":_i,"%AsyncGenerator%":_i,"%AsyncGeneratorFunction%":_i,"%AsyncIteratorPrototype%":_i,"%Atomics%":typeof Atomics>"u"?pt:Atomics,"%BigInt%":typeof BigInt>"u"?pt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?pt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?pt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?pt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Zy,"%eval%":eval,"%EvalError%":Jy,"%Float32Array%":typeof Float32Array>"u"?pt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?pt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?pt:FinalizationRegistry,"%Function%":bc,"%GeneratorFunction%":_i,"%Int8Array%":typeof Int8Array>"u"?pt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?pt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?pt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":yi&&kt?kt(kt([][Symbol.iterator]())):pt,"%JSON%":typeof JSON=="object"?JSON:pt,"%Map%":typeof Map>"u"?pt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!yi||!kt?pt:kt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?pt:Promise,"%Proxy%":typeof Proxy>"u"?pt:Proxy,"%RangeError%":Qy,"%ReferenceError%":t0,"%Reflect%":typeof Reflect>"u"?pt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?pt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!yi||!kt?pt:kt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?pt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":yi&&kt?kt(""[Symbol.iterator]()):pt,"%Symbol%":yi?Symbol:pt,"%SyntaxError%":mi,"%ThrowTypeError%":r0,"%TypedArray%":s0,"%TypeError%":gi,"%Uint8Array%":typeof Uint8Array>"u"?pt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?pt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?pt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?pt:Uint32Array,"%URIError%":e0,"%WeakMap%":typeof WeakMap>"u"?pt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?pt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?pt:WeakSet};if(kt)try{null.error}catch(r){var n0=kt(kt(r));Nr["%Error.prototype%"]=n0}var o0=function r(t){var e;if(t==="%AsyncFunction%")e=Ko("async function () {}");else if(t==="%GeneratorFunction%")e=Ko("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Ko("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&kt&&(e=kt(s.prototype))}return Nr[t]=e,e},wc={__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"]},ss=qo,tn=Ky,a0=ss.call(Function.call,Array.prototype.concat),l0=ss.call(Function.apply,Array.prototype.splice),Ec=ss.call(Function.call,String.prototype.replace),en=ss.call(Function.call,String.prototype.slice),h0=ss.call(Function.call,RegExp.prototype.exec),c0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,u0=/\\(\\)?/g,d0=function(t){var e=en(t,0,1),i=en(t,-1);if(e==="%"&&i!=="%")throw new mi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new mi("invalid intrinsic syntax, expected opening `%`");var s=[];return Ec(t,c0,function(n,o,a,l){s[s.length]=a?Ec(l,u0,"$1"):o||n}),s},f0=function(t,e){var i=t,s;if(tn(wc,i)&&(s=wc[i],i="%"+s[0]+"%"),tn(Nr,i)){var n=Nr[i];if(n===_i&&(n=o0(i)),typeof n>"u"&&!e)throw new gi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new mi("intrinsic "+t+" does not exist!")},vi=function(t,e){if(typeof t!="string"||t.length===0)throw new gi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new gi('"allowMissing" argument must be a boolean');if(h0(/^%?[^%]*%?$/,t)===null)throw new mi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=d0(t),s=i.length>0?i[0]:"",n=f0("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],l0(i,a0([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=en(d,0,1),p=en(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new mi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",tn(Nr,o))a=Nr[o];else if(a!=null){if(!(d in a)){if(!e)throw new gi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Lr&&c+1>=i.length){var m=Lr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=tn(a,d),a=a[d];u&&!l&&(Nr[o]=a)}}return a},Tc={exports:{}},Jo,Ac;function Qo(){if(Ac)return Jo;Ac=1;var r=vi,t=r("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Jo=t,Jo}var p0=vi,rn=p0("%Object.getOwnPropertyDescriptor%",!0);if(rn)try{rn([],"length")}catch{rn=null}var Sc=rn,Ic=Qo(),m0=_c,xi=is,Cc=Sc,g0=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new xi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new xi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xi("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Cc&&Cc(t,e);if(Ic)Ic(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:i,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=i;else throw new m0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ta=Qo(),Rc=function(){return!!ta};Rc.hasArrayLengthDefineBug=function(){if(!ta)return null;try{return ta([],"length",{value:1}).length!==1}catch{return!0}};var y0=Rc,_0=vi,Pc=g0,v0=y0(),Mc=Sc,Bc=is,x0=_0("%Math.floor%"),b0=function(t,e){if(typeof t!="function")throw new Bc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||x0(e)!==e)throw new Bc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&Mc){var o=Mc(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(v0?Pc(t,"length",e,!0,!0):Pc(t,"length",e)),t};(function(r){var t=qo,e=vi,i=b0,s=is,n=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),a=e("%Reflect.apply%",!0)||t.call(o,n),l=Qo(),h=e("%Math.max%");r.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return i(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(r.exports,"apply",{value:c}):r.exports.apply=c})(Tc);var w0=Tc.exports,Dc=vi,Oc=w0,E0=Oc(Dc("String.prototype.indexOf")),T0=function(t,e){var i=Dc(t,!!e);return typeof i=="function"&&E0(t,".prototype.")>-1?Oc(i):i};const A0=hy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ea=typeof Map=="function"&&Map.prototype,ra=Object.getOwnPropertyDescriptor&&ea?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,sn=ea&&ra&&typeof ra.get=="function"?ra.get:null,Fc=ea&&Map.prototype.forEach,ia=typeof Set=="function"&&Set.prototype,sa=Object.getOwnPropertyDescriptor&&ia?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,nn=ia&&sa&&typeof sa.get=="function"?sa.get:null,Lc=ia&&Set.prototype.forEach,S0=typeof WeakMap=="function"&&WeakMap.prototype,ns=S0?WeakMap.prototype.has:null,I0=typeof WeakSet=="function"&&WeakSet.prototype,os=I0?WeakSet.prototype.has:null,C0=typeof WeakRef=="function"&&WeakRef.prototype,Nc=C0?WeakRef.prototype.deref:null,R0=Boolean.prototype.valueOf,P0=Object.prototype.toString,M0=Function.prototype.toString,B0=String.prototype.match,na=String.prototype.slice,gr=String.prototype.replace,D0=String.prototype.toUpperCase,Uc=String.prototype.toLowerCase,kc=RegExp.prototype.test,Gc=Array.prototype.concat,ke=Array.prototype.join,O0=Array.prototype.slice,$c=Math.floor,oa=typeof BigInt=="function"?BigInt.prototype.valueOf:null,aa=Object.getOwnPropertySymbols,la=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,bi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Qt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===bi||!0)?Symbol.toStringTag:null,Hc=Object.prototype.propertyIsEnumerable,Xc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Vc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||kc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-$c(-r):$c(r);if(i!==r){var s=String(i),n=na.call(t,s.length+1);return gr.call(s,e,"$&_")+"."+gr.call(gr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return gr.call(t,e,"$&_")}var ha=A0,zc=ha.custom,Wc=qc(zc)?zc:null,F0=function r(t,e,i,s){var n=e||{};if(yr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(yr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=yr(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(yr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(yr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Zc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Vc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Vc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return ca(t)?"[Array]":"[Object]";var u=Q0(n,i);if(typeof s>"u")s=[];else if(Kc(s,t)>=0)return"[Circular]";function d(b,D,F){if(D&&(s=O0.call(s),s.push(D)),F){var G={depth:n.depth};return yr(n,"quoteStyle")&&(G.quoteStyle=n.quoteStyle),r(b,G,i+1,s)}return r(b,n,i+1,s)}if(typeof t=="function"&&!Yc(t)){var f=V0(t),p=on(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+ke.call(p,", ")+" }":"")}if(qc(t)){var m=bi?gr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):la.call(t);return typeof t=="object"&&!bi?as(m):m}if(K0(t)){for(var _="<"+Uc.call(String(t.nodeName)),y=t.attributes||[],x=0;x<y.length;x++)_+=" "+y[x].name+"="+jc(L0(y[x].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+Uc.call(String(t.nodeName))+">",_}if(ca(t)){if(t.length===0)return"[]";var g=on(t,d);return u&&!J0(g)?"["+da(g,u)+"]":"[ "+ke.call(g,", ")+" ]"}if(U0(t)){var v=on(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Hc.call(t,"cause")?"{ ["+String(t)+"] "+ke.call(Gc.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+ke.call(v,", ")+" }"}if(typeof t=="object"&&o){if(Wc&&typeof t[Wc]=="function"&&ha)return ha(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(z0(t)){var w=[];return Fc&&Fc.call(t,function(b,D){w.push(d(D,t,!0)+" => "+d(b,t))}),Jc("Map",sn.call(t),w,u)}if(Y0(t)){var I=[];return Lc&&Lc.call(t,function(b){I.push(d(b,t))}),Jc("Set",nn.call(t),I,u)}if(W0(t))return ua("WeakMap");if(q0(t))return ua("WeakSet");if(j0(t))return ua("WeakRef");if(G0(t))return as(d(Number(t)));if(H0(t))return as(d(oa.call(t)));if($0(t))return as(R0.call(t));if(k0(t))return as(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Ji<"u"&&t===Ji)return"{ [object globalThis] }";if(!N0(t)&&!Yc(t)){var A=on(t,d),C=Xc?Xc(t)===Object.prototype:t instanceof Object||t.constructor===Object,N=t instanceof Object?"":"null prototype",S=!C&&Qt&&Object(t)===t&&Qt in t?na.call(_r(t),8,-1):N?"Object":"",R=C||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",E=R+(S||N?"["+ke.call(Gc.call([],S||[],N||[]),": ")+"] ":"");return A.length===0?E+"{}":u?E+"{"+da(A,u)+"}":E+"{ "+ke.call(A,", ")+" }"}return String(t)};function jc(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function L0(r){return gr.call(String(r),/"/g,"&quot;")}function ca(r){return _r(r)==="[object Array]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function N0(r){return _r(r)==="[object Date]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function Yc(r){return _r(r)==="[object RegExp]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function U0(r){return _r(r)==="[object Error]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function k0(r){return _r(r)==="[object String]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function G0(r){return _r(r)==="[object Number]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function $0(r){return _r(r)==="[object Boolean]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function qc(r){if(bi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!la)return!1;try{return la.call(r),!0}catch{}return!1}function H0(r){if(!r||typeof r!="object"||!oa)return!1;try{return oa.call(r),!0}catch{}return!1}var X0=Object.prototype.hasOwnProperty||function(r){return r in this};function yr(r,t){return X0.call(r,t)}function _r(r){return P0.call(r)}function V0(r){if(r.name)return r.name;var t=B0.call(M0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Kc(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function z0(r){if(!sn||!r||typeof r!="object")return!1;try{sn.call(r);try{nn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function W0(r){if(!ns||!r||typeof r!="object")return!1;try{ns.call(r,ns);try{os.call(r,os)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function j0(r){if(!Nc||!r||typeof r!="object")return!1;try{return Nc.call(r),!0}catch{}return!1}function Y0(r){if(!nn||!r||typeof r!="object")return!1;try{nn.call(r);try{sn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function q0(r){if(!os||!r||typeof r!="object")return!1;try{os.call(r,os);try{ns.call(r,ns)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function K0(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Zc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Zc(na.call(r,0,t.maxStringLength),t)+i}var s=gr.call(gr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Z0);return jc(s,"single",t)}function Z0(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+D0.call(t.toString(16))}function as(r){return"Object("+r+")"}function ua(r){return r+" { ? }"}function Jc(r,t,e,i){var s=i?da(e,i):ke.call(e,", ");return r+" ("+t+") {"+s+"}"}function J0(r){for(var t=0;t<r.length;t++)if(Kc(r[t],`
2
- `)>=0)return!1;return!0}function Q0(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=ke.call(Array(r.indent+1)," ");else return null;return{base:e,prev:ke.call(Array(t+1),e)}}function da(r,t){if(r.length===0)return"";var e=`
1
+ (function(Mt,Nt){typeof exports=="object"&&typeof module<"u"?Nt(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],Nt):(Mt=typeof globalThis<"u"?globalThis:Mt||self,Nt(Mt.AnnotoriousOSD={},Mt.OpenSeadragon))})(this,function(Mt,Nt){"use strict";var kE=Object.defineProperty;var GE=(Mt,Nt,Pr)=>Nt in Mt?kE(Mt,Nt,{enumerable:!0,configurable:!0,writable:!0,value:Pr}):Mt[Nt]=Pr;var Ml=(Mt,Nt,Pr)=>GE(Mt,typeof Nt!="symbol"?Nt+"":Nt,Pr);var Pr=Object.prototype.hasOwnProperty;function Mr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Mr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Pr.call(r,e)&&++i&&!Pr.call(t,e)||!(e in t)||!Mr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var io=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(io||{});const Ht=[];for(let r=0;r<256;++r)Ht.push((r+256).toString(16).slice(1));function qf(r,t=0){return(Ht[r[t+0]]+Ht[r[t+1]]+Ht[r[t+2]]+Ht[r[t+3]]+"-"+Ht[r[t+4]]+Ht[r[t+5]]+"-"+Ht[r[t+6]]+Ht[r[t+7]]+"-"+Ht[r[t+8]]+Ht[r[t+9]]+"-"+Ht[r[t+10]]+Ht[r[t+11]]+Ht[r[t+12]]+Ht[r[t+13]]+Ht[r[t+14]]+Ht[r[t+15]]).toLowerCase()}let so;const Kf=new Uint8Array(16);function Zf(){if(!so){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");so=crypto.getRandomValues.bind(crypto)}return so(Kf)}const Jf=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),kl={randomUUID:Jf};function Qf(r,t,e){if(kl.randomUUID&&!t&&!r)return kl.randomUUID();r=r||{};const i=r.random||(r.rng||Zf)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,qf(i)}const no=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},tp=(r,t,e,i)=>({id:Qf(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),ep=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},rp=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},ip=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Mr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),sp=(r,t)=>!Mr(r.target,t.target),np=(r,t)=>{const e=ep(r,t),i=rp(r,t),s=ip(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:sp(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var fr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(fr||{});const op=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return np(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let ap=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const lp=250,hp=r=>{const t=ap(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>lp)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=op(e[_],p)}n=m}s=!1};r.observe(o,{origin:fr.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},cp=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!Mr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:w})=>w===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!Mr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!Mr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:fr.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(I=>I.id===v.id)||v))}},{origin:fr.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},up=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),dp=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,fr.REMOTE):console.error(g)}else i.addAnnotation(no(y),fr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||up(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,fr.REMOTE)}else i.bulkAddAnnotation(y.map(no),x,fr.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(no(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},fp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let pp=r=>crypto.getRandomValues(new Uint8Array(r)),mp=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},gp=(r,t=21)=>mp(r,t,pp),yp=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=fp[e[r]&63];return t};const _p=()=>({isGuest:!0,id:gp("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),vp=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],xp=()=>{const r=[...vp];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};yp();var bp=Object.defineProperty,wp=(r,t,e)=>t in r?bp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gl=(r,t,e)=>wp(r,typeof t!="symbol"?t+"":t,e);function At(){}function oo(r,t){for(const e in t)r[e]=t[e];return r}function $l(r){return r()}function Hl(){return Object.create(null)}function Pe(r){r.forEach($l)}function Ut(r){return typeof r=="function"}function qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Ep(r){return Object.keys(r).length===0}function Xl(r,...t){if(r==null){for(const i of t)i(void 0);return At}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function ao(r,t,e){r.$$.on_destroy.push(Xl(t,e))}function Tp(r,t,e,i){if(r){const s=Vl(r,t,e,i);return r[0](s)}}function Vl(r,t,e,i){return r[1]&&i?oo(e.ctx.slice(),r[1](i(t))):e.ctx}function Ap(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Sp(r,t,e,i,s,n){if(s){const o=Vl(t,e,i,n);r.p(o,s)}}function Ip(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function zl(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Cs(r){return r??""}function Me(r,t){r.appendChild(t)}function it(r,t,e){r.insertBefore(t,e||null)}function et(r){r.parentNode&&r.parentNode.removeChild(r)}function lo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function yt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Wl(r){return document.createTextNode(r)}function ge(){return Wl(" ")}function ye(){return Wl("")}function Dt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function T(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Cp(r){return Array.from(r.childNodes)}function pr(r,t,e){r.classList.toggle(t,!!e)}function Rp(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Xi;function Vi(r){Xi=r}function jl(){if(!Xi)throw new Error("Function called outside component initialization");return Xi}function zi(r){jl().$$.on_mount.push(r)}function Qr(){const r=jl();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Rp(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ze(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const ti=[],Rs=[];let ei=[];const Yl=[],Pp=Promise.resolve();let ho=!1;function Mp(){ho||(ho=!0,Pp.then(ql))}function co(r){ei.push(r)}const uo=new Set;let ri=0;function ql(){if(ri!==0)return;const r=Xi;do{try{for(;ri<ti.length;){const t=ti[ri];ri++,Vi(t),Bp(t.$$)}}catch(t){throw ti.length=0,ri=0,t}for(Vi(null),ti.length=0,ri=0;Rs.length;)Rs.pop()();for(let t=0;t<ei.length;t+=1){const e=ei[t];uo.has(e)||(uo.add(e),e())}ei.length=0}while(ti.length);for(;Yl.length;)Yl.pop()();ho=!1,uo.clear(),Vi(r)}function Bp(r){if(r.fragment!==null){r.update(),Pe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(co)}}function Dp(r){const t=[],e=[];ei.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),ei=t}const Ps=new Set;let Br;function _e(){Br={r:0,c:[],p:Br}}function ve(){Br.r||Pe(Br.c),Br=Br.p}function ot(r,t){r&&r.i&&(Ps.delete(r),r.i(t))}function mt(r,t,e,i){if(r&&r.o){if(Ps.has(r))return;Ps.add(r),Br.c.push(()=>{Ps.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ii(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ce(r){r&&r.c()}function se(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),co(()=>{const n=r.$$.on_mount.map($l).filter(Ut);r.$$.on_destroy?r.$$.on_destroy.push(...n):Pe(n),r.$$.on_mount=[]}),s.forEach(co)}function ne(r,t){const e=r.$$;e.fragment!==null&&(Dp(e.after_update),Pe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Op(r,t){r.$$.dirty[0]===-1&&(ti.push(r),Mp(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ue(r,t,e,i,s,n,o=null,a=[-1]){const l=Xi;Vi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:At,not_equal:s,bound:Hl(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Hl(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Op(r,u)),d}):[],h.update(),c=!0,Pe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Cp(t.target);h.fragment&&h.fragment.l(u),u.forEach(et)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),se(r,t.target,t.anchor),ql()}Vi(l)}class de{constructor(){Gl(this,"$$"),Gl(this,"$$set")}$destroy(){ne(this,1),this.$destroy=At}$on(t,e){if(!Ut(e))return At;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Ep(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Fp="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Fp);var wt=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(wt||{});const fo={},po=(r,t)=>fo[r]=t,mo=r=>fo[r.type].area(r),Lp=(r,t,e)=>fo[r.type].intersects(r,t,e),Ms=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Np={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};po(wt.ELLIPSE,Np);const Up={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};po(wt.POLYGON,Up);const kp={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};po(wt.RECTANGLE,kp);const Je=r=>Bs(r.target),Bs=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},Gp=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,c,u]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,m]=[l,h,c,u].map(parseFloat);return{type:wt.RECTANGLE,geometry:{x:d,y:f,w:p,h:m,bounds:{minX:d,minY:t?f-m:f,maxX:d+p,maxY:t?f:f+m}}}},$p=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},Kl="http://www.w3.org/2000/svg",Zl=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Hp=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Kl}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Xp=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Kl),i=t.lookupNamespaceURI(null);return e||i?Zl(t).firstChild:Zl(Hp(t)).firstChild},Vp=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:wt.POLYGON,geometry:{points:s,bounds:Ms(s)}}},zp=r=>{const t=Xp(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:wt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},Wp=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return Vp(t);if(t.includes("<ellipse "))return zp(t);throw"Unsupported SVG shape: "+t},jp=r=>{let t;if(r.type===wt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===wt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},Xt=[];for(let r=0;r<256;++r)Xt.push((r+256).toString(16).slice(1));function Yp(r,t=0){return(Xt[r[t+0]]+Xt[r[t+1]]+Xt[r[t+2]]+Xt[r[t+3]]+"-"+Xt[r[t+4]]+Xt[r[t+5]]+"-"+Xt[r[t+6]]+Xt[r[t+7]]+"-"+Xt[r[t+8]]+Xt[r[t+9]]+"-"+Xt[r[t+10]]+Xt[r[t+11]]+Xt[r[t+12]]+Xt[r[t+13]]+Xt[r[t+14]]+Xt[r[t+15]]).toLowerCase()}let go;const qp=new Uint8Array(16);function Kp(){if(!go){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");go=crypto.getRandomValues.bind(crypto)}return go(qp)}const Zp=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Jl={randomUUID:Zp};function Ql(r,t,e){if(Jl.randomUUID&&!t&&!r)return Jl.randomUUID();r=r||{};const i=r.random||(r.rng||Kp)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Yp(i)}var th=Object.prototype.hasOwnProperty;function mr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&mr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(th.call(r,e)&&++i&&!th.call(t,e)||!(e in t)||!mr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function yo(){}function Jp(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const si=[];function _o(r,t=yo){let e;const i=new Set;function s(a){if(Jp(r,a)&&(r=a,e)){const l=!si.length;for(const h of i)h[1](),si.push(h,r);if(l){for(let h=0;h<si.length;h+=2)si[h][0](si[h+1]);si.length=0}}}function n(a){s(a(r))}function o(a,l=yo){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||yo),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Qp=r=>{const{subscribe:t,set:e}=_o();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var eh=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(eh||{});const Ds={selected:[]},tm=(r,t,e)=>{const{subscribe:i,set:s}=_o(Ds);let n=t,o=Ds;i(p=>o=p);const a=()=>{mr(o,Ds)||s(Ds)},l=()=>{var p;return((p=o.selected)==null?void 0:p.length)===0},h=p=>{if(l())return!1;const m=typeof p=="string"?p:p.id;return o.selected.some(_=>_.id===m)},c=(p,m)=>{let _;if(Array.isArray(p)){if(_=p.map(x=>r.getAnnotation(x)).filter(Boolean),_.length<p.length){console.warn("Invalid selection: "+p.filter(x=>!_.some(g=>g.id===x)));return}}else{const x=r.getAnnotation(p);if(!x){console.warn("Invalid selection: "+p);return}_=[x]}const y=_.reduce((x,g)=>{const v=rh(g,n,e);return v==="EDIT"?[...x,{id:g.id,editable:!0}]:v==="SELECT"?[...x,{id:g.id}]:x},[]);s({selected:y,event:m})},u=(p,m)=>{const _=Array.isArray(p)?p:[p],y=_.map(x=>r.getAnnotation(x)).filter(x=>!!x);s({selected:y.map(x=>{const g=m===void 0?rh(x,n,e)==="EDIT":m;return{id:x.id,editable:g}})}),y.length!==_.length&&console.warn("Invalid selection",p)},d=p=>{if(l())return!1;const{selected:m}=o;m.some(({id:_})=>p.includes(_))&&s({selected:m.filter(({id:_})=>!p.includes(_))})},f=p=>n=p;return r.observe(({changes:p})=>d((p.deleted||[]).map(m=>m.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,isEmpty:l,isSelected:h,setSelected:u,setUserSelectAction:f,subscribe:i,userSelect:c}},rh=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},Vt=[];for(let r=0;r<256;++r)Vt.push((r+256).toString(16).slice(1));function em(r,t=0){return(Vt[r[t+0]]+Vt[r[t+1]]+Vt[r[t+2]]+Vt[r[t+3]]+"-"+Vt[r[t+4]]+Vt[r[t+5]]+"-"+Vt[r[t+6]]+Vt[r[t+7]]+"-"+Vt[r[t+8]]+Vt[r[t+9]]+"-"+Vt[r[t+10]]+Vt[r[t+11]]+Vt[r[t+12]]+Vt[r[t+13]]+Vt[r[t+14]]+Vt[r[t+15]]).toLowerCase()}let vo;const rm=new Uint8Array(16);function im(){if(!vo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");vo=crypto.getRandomValues.bind(crypto)}return vo(rm)}const sm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ih={randomUUID:sm};function nm(r,t,e){if(ih.randomUUID&&!t&&!r)return ih.randomUUID();r=r||{};const i=r.random||(r.rng||im)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,em(i)}const xo=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},om=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},am=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},lm=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!mr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),hm=(r,t)=>!mr(r.target,t.target),sh=(r,t)=>{const e=om(r,t),i=am(r,t),s=lm(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:hm(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var St=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(St||{});const cm=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.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},um=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return sh(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},bo=r=>{const t=r.id===void 0?nm():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},dm=r=>r.id!==void 0,fm=()=>{const r=new Map,t=new Map,e=[],i=(S,R={})=>{e.push({onChange:S,options:R})},s=S=>{const R=e.findIndex(E=>E.onChange==S);R>-1&&e.splice(R,1)},n=(S,R)=>{const E={origin:S,changes:{created:R.created||[],updated:R.updated||[],deleted:R.deleted||[]},state:[...r.values()]};e.forEach(b=>{cm(b,E)&&b.onChange(E)})},o=(S,R=St.LOCAL)=>{if(S.id&&r.get(S.id))throw Error(`Cannot add annotation ${S.id} - exists already`);{const E=bo(S);r.set(E.id,E),E.bodies.forEach(b=>t.set(b.id,E.id)),n(R,{created:[E]})}},a=(S,R)=>{const E=bo(typeof S=="string"?R:S),b=typeof S=="string"?S:S.id,D=b&&r.get(b);if(D){const F=sh(D,E);return b===E.id?r.set(b,E):(r.delete(b),r.set(E.id,E)),D.bodies.forEach(G=>t.delete(G.id)),E.bodies.forEach(G=>t.set(G.id,E.id)),F}else console.warn(`Cannot update annotation ${b} - does not exist`)},l=(S,R=St.LOCAL,E=St.LOCAL)=>{const b=dm(R)?E:R,D=a(S,R);D&&n(b,{updated:[D]})},h=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=a(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{updated:E})},c=(S,R=St.LOCAL)=>{const E=r.get(S.annotation);if(E){const b={...E,bodies:[...E.bodies,S]};r.set(E.id,b),t.set(S.id,b.id),n(R,{updated:[{oldValue:E,newValue:b,bodiesCreated:[S]}]})}else console.warn(`Attempt to add body to missing annotation: ${S.annotation}`)},u=()=>[...r.values()],d=(S=St.LOCAL)=>{const R=[...r.values()];r.clear(),t.clear(),n(S,{deleted:R})},f=(S,R=!0,E=St.LOCAL)=>{const b=S.map(bo);if(R){const D=[...r.values()];r.clear(),t.clear(),b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b,deleted:D})}else{const D=S.reduce((F,G)=>{const $=G.id&&r.get(G.id);return $?[...F,$]:F},[]);if(D.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${D.map(F=>F.id).join(", ")}`);b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b})}},p=S=>{const R=typeof S=="string"?S:S.id,E=r.get(R);if(E)return r.delete(R),E.bodies.forEach(b=>t.delete(b.id)),E;console.warn(`Attempt to delete missing annotation: ${R}`)},m=(S,R=St.LOCAL)=>{const E=p(S);E&&n(R,{deleted:[E]})},_=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=p(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{deleted:E})},y=S=>{const R=r.get(S.annotation);if(R){const E=R.bodies.find(b=>b.id===S.id);if(E){t.delete(E.id);const b={...R,bodies:R.bodies.filter(D=>D.id!==S.id)};return r.set(R.id,b),{oldValue:R,newValue:b,bodiesDeleted:[E]}}else console.warn(`Attempt to delete missing body ${S.id} from annotation ${S.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${S.annotation}`)},x=(S,R=St.LOCAL)=>{const E=y(S);E&&n(R,{updated:[E]})},g=(S,R=St.LOCAL)=>{const E=S.map(b=>y(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},v=S=>{const R=r.get(S);return R?{...R}:void 0},w=S=>{const R=t.get(S);if(R){const E=v(R).bodies.find(b=>b.id===S);if(E)return E;console.error(`Store integrity error: body ${S} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${S}`)},I=(S,R)=>{if(S.annotation!==R.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=r.get(S.annotation);if(E){const b=E.bodies.find(F=>F.id===S.id),D={...E,bodies:E.bodies.map(F=>F.id===b.id?R:F)};return r.set(E.id,D),b.id!==R.id&&(t.delete(b.id),t.set(R.id,D.id)),{oldValue:E,newValue:D,bodiesUpdated:[{oldBody:b,newBody:R}]}}else console.warn(`Attempt to add body to missing annotation ${S.annotation}`)},A=(S,R,E=St.LOCAL)=>{const b=I(S,R);b&&n(E,{updated:[b]})},C=(S,R=St.LOCAL)=>{const E=S.map(b=>I({id:b.id,annotation:b.annotation},b)).filter(Boolean);n(R,{updated:E})},N=S=>{const R=r.get(S.annotation);if(R){const E={...R,target:{...R.target,...S}};return r.set(R.id,E),{oldValue:R,newValue:E,targetUpdated:{oldTarget:R.target,newTarget:S}}}else console.warn(`Attempt to update target on missing annotation: ${S.annotation}`)};return{addAnnotation:o,addBody:c,all:u,bulkAddAnnotation:f,bulkDeleteAnnotation:_,bulkDeleteBodies:g,bulkUpdateAnnotation:h,bulkUpdateBodies:C,bulkUpdateTargets:(S,R=St.LOCAL)=>{const E=S.map(b=>N(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},clear:d,deleteAnnotation:m,deleteBody:x,getAnnotation:v,getBody:w,observe:i,unobserve:s,updateAnnotation:l,updateBody:A,updateTarget:(S,R=St.LOCAL)=>{const E=N(S);E&&n(R,{updated:[E]})}}},pm=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let mm=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const gm=250,ym=r=>{const t=mm(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>gm)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=um(e[_],p)}n=m}s=!1};r.observe(o,{origin:St.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},_m=()=>{const{subscribe:r,set:t}=_o([]);return{subscribe:r,set:t}},vm=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!mr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:v})=>v===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!mr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!mr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:St.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(w=>w.id===v.id)||v))}},{origin:St.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},xm=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),bm=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,St.REMOTE):console.error(g)}else i.addAnnotation(xo(y),St.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||xm(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,St.REMOTE)}else i.bulkAddAnnotation(y.map(xo),x,St.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(xo(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},wm=(r,t,e)=>typeof t=="function"?t(r,e):t,Em=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},Tm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Am=r=>crypto.getRandomValues(new Uint8Array(r)),Sm=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},Im=(r,t=21)=>Sm(r,t,Am),Cm=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Tm[e[r]&63];return t};const Rm=()=>({isGuest:!0,id:Im("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Pm=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},nh=r=>r?typeof r=="object"?{...r}:r:void 0,Mm=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...c}=e;return{id:i||`temp-${Pm(e)}`,annotation:t,type:s,purpose:n,value:o,creator:nh(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...c}}),Bm=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});Cm();const Dm=(r,t={strict:!0,invertY:!1})=>({parse:e=>Om(e,t),serialize:e=>Fm(e,r,t)}),Om=(r,t={strict:!0,invertY:!1})=>{const e=r.id||Ql(),{creator:i,created:s,modified:n,body:o,...a}=r,l=Mm(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,c=Array.isArray(h.selector)?h.selector[0]:h.selector,u=(c==null?void 0:c.type)==="FragmentSelector"?Gp(c,t.invertY):(c==null?void 0:c.type)==="SvgSelector"?Wp(c):void 0;return u||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:nh(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:u||c}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},Fm=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==wt.RECTANGLE?$p(i.geometry):jp(i)}catch(u){if(e.strict)throw u;h=i}const c={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Bm(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,selector:h}};return delete c.bodies,"annotation"in c.target&&delete c.target.annotation,c};function oh(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function ah(r){let t,e;return t=new Wi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Ut(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Lm(r){let t,e,i,s,n,o,a,l,h,c,u,d=ii(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=ah(oh(r,d,m));const p=m=>mt(f[m],1,1,()=>{f[m]=null});return{c(){t=yt("polygon"),s=ge(),n=yt("polygon"),a=ge();for(let m=0;m<f.length;m+=1)f[m].c();l=ye(),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"points",i=r[4].points.map(lh).join(" ")),T(n,"class","a9s-inner a9s-shape-handle"),T(n,"style",r[1]),T(n,"points",o=r[4].points.map(hh).join(" "))},m(m,_){it(m,t,_),it(m,s,_),it(m,n,_),it(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);it(m,l,_),h=!0,c||(u=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(n,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(lh).join(" ")))&&T(t,"points",i),(!h||_&2)&&T(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(hh).join(" ")))&&T(n,"points",o),_&536){d=ii(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=oh(r,d,y);f[y]?(f[y].p(x,_),ot(f[y],1)):(f[y]=ah(x),f[y].c(),ot(f[y],1),f[y].m(l.parentNode,l))}for(_e(),y=d.length;y<f.length;y+=1)p(y);ve()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)ot(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)mt(f[_]);h=!1},d(m){m&&(et(t),et(s),et(n),et(a),et(l)),lo(f,m),c=!1,Pe(u)}}}function Nm(r){let t,e;return t=new mh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Lm,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}const lh=r=>r.join(","),hh=r=>r.join(",");function Um(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Ms(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class km extends de{constructor(t){super(),ue(this,t,Um,Nm,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const wo=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},ni=[];function Gm(r,t=At){let e;const i=new Set;function s(a){if(qt(r,a)&&(r=a,e)){const l=!ni.length;for(const h of i)h[1](),ni.push(h,r);if(l){for(let h=0;h<ni.length;h+=2)ni[h][0](ni[h+1]);ni.length=0}}}function n(a){s(a(r))}function o(a,l=At){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||At),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const $m=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},Hm=(r,t)=>{$m(r,t);const{subscribe:e,set:i}=Gm(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},ch=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Xm(r){let t,e,i,s,n,o;return{c(){t=yt("rect"),T(t,"class",e=Cs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(t,"x",i=r[0]-r[5]/2),T(t,"y",s=r[1]-r[5]/2),T(t,"width",r[5]),T(t,"height",r[5])},m(a,l){it(a,t,l),n||(o=Dt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Cs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&T(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&T(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&T(t,"y",s),l&32&&T(t,"width",a[5]),l&32&&T(t,"height",a[5])},d(a){a&&et(t),n=!1,o()}}}function Vm(r){let t,e,i,s,n,o,a,l,h;return{c(){t=yt("g"),e=yt("circle"),s=yt("rect"),T(e,"cx",r[0]),T(e,"cy",r[1]),T(e,"r",i=r[3]/r[2]),T(e,"class","a9s-touch-halo svelte-1sgkh33"),pr(e,"touched",r[4]),T(s,"class",n=Cs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(s,"x",o=r[0]-r[5]/2),T(s,"y",a=r[1]-r[5]/2),T(s,"width",r[5]),T(s,"height",r[5]),T(t,"class","a9s-touch-handle")},m(c,u){it(c,t,u),Me(t,e),Me(t,s),l||(h=[Dt(e,"pointerdown",r[10]),Dt(e,"pointerdown",r[6]),Dt(e,"pointerup",r[7]),Dt(s,"pointerdown",r[9]),Dt(s,"pointerdown",r[6]),Dt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&T(e,"cx",c[0]),u&2&&T(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&T(e,"r",i),u&16&&pr(e,"touched",c[4]),u&256&&n!==(n=Cs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&T(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&T(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&T(s,"y",a),u&32&&T(s,"width",c[5]),u&32&&T(s,"height",c[5])},d(c){c&&et(t),l=!1,Pe(h)}}}function zm(r){let t;function e(s,n){return ch?Vm:Xm}let i=e()(r);return{c(){i.c(),t=ye()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:At,o:At,d(s){s&&et(t),i.d(s)}}}function Wm(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){Ze.call(this,r,p)}function d(p){Ze.call(this,r,p)}function f(p){Ze.call(this,r,p)}return r.$$set=p=>{e(8,t=oo(oo({},t),zl(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=zl(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class Wi extends de{constructor(t){super(),ue(this,t,Wm,zm,qt,{x:0,y:1,scale:2,radius:3})}}function jm(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,K,P,U,j,rt,Q,H,V,lt;return B=new Wi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Ut(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new Wi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Ut(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new Wi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Ut(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new Wi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Ut(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=yt("rect"),a=ge(),l=yt("rect"),f=ge(),p=yt("rect"),x=ge(),g=yt("rect"),A=ge(),C=yt("rect"),E=ge(),b=yt("rect"),$=ge(),ce(B.$$.fragment),K=ge(),ce(P.$$.fragment),U=ge(),ce(j.$$.fragment),rt=ge(),ce(Q.$$.fragment),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"x",i=r[4].x),T(t,"y",s=r[4].y),T(t,"width",n=r[4].w),T(t,"height",o=r[4].h),T(l,"class","a9s-inner a9s-shape-handle"),T(l,"style",r[1]),T(l,"x",h=r[4].x),T(l,"y",c=r[4].y),T(l,"width",u=r[4].w),T(l,"height",d=r[4].h),T(p,"class","a9s-edge-handle a9s-edge-handle-top"),T(p,"x",m=r[4].x),T(p,"y",_=r[4].y),T(p,"height",1),T(p,"width",y=r[4].w),T(g,"class","a9s-edge-handle a9s-edge-handle-right"),T(g,"x",v=r[4].x+r[4].w),T(g,"y",w=r[4].y),T(g,"height",I=r[4].h),T(g,"width",1),T(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),T(C,"x",N=r[4].x),T(C,"y",S=r[4].y+r[4].h),T(C,"height",1),T(C,"width",R=r[4].w),T(b,"class","a9s-edge-handle a9s-edge-handle-left"),T(b,"x",D=r[4].x),T(b,"y",F=r[4].y),T(b,"height",G=r[4].h),T(b,"width",1)},m(L,O){it(L,t,O),it(L,a,O),it(L,l,O),it(L,f,O),it(L,p,O),it(L,x,O),it(L,g,O),it(L,A,O),it(L,C,O),it(L,E,O),it(L,b,O),it(L,$,O),se(B,L,O),it(L,K,O),se(P,L,O),it(L,U,O),se(j,L,O),it(L,rt,O),se(Q,L,O),H=!0,V||(lt=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(l,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(p,"pointerdown",function(){Ut(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Dt(g,"pointerdown",function(){Ut(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Dt(C,"pointerdown",function(){Ut(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Dt(b,"pointerdown",function(){Ut(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&T(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&T(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&T(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&T(t,"height",o),(!H||O&2)&&T(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&T(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&T(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&T(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&T(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&T(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&T(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&T(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&T(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&T(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&T(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&T(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&T(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&T(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&T(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&T(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&T(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(ot(B.$$.fragment,L),ot(P.$$.fragment,L),ot(j.$$.fragment,L),ot(Q.$$.fragment,L),H=!0)},o(L){mt(B.$$.fragment,L),mt(P.$$.fragment,L),mt(j.$$.fragment,L),mt(Q.$$.fragment,L),H=!1},d(L){L&&(et(t),et(a),et(l),et(f),et(p),et(x),et(g),et(A),et(C),et(E),et(b),et($),et(K),et(U),et(rt)),ne(B,L),ne(P,L),ne(j,L),ne(Q,L),V=!1,Pe(lt)}}}function Ym(r){let t,e;return t=new mh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[jm,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function qm(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[_,y]=[m.minX,m.minY],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Km extends de{constructor(t){super(),ue(this,t,qm,Ym,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const uh=new Map([[wt.RECTANGLE,Km],[wt.POLYGON,km]]),dh=r=>uh.get(r.type),fh=(r,t)=>uh.set(r,t),Zm=r=>({}),ph=r=>({grab:r[0]});function Jm(r){let t,e,i,s;const n=r[7].default,o=Tp(n,r,r[6],ph);return{c(){t=yt("g"),o&&o.c(),T(t,"class","a9s-annotation selected")},m(a,l){it(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Dt(t,"pointerup",r[2]),Dt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Sp(o,n,a,a[6],e?Ap(n,a[6],l,Zm):Ip(a[6]),ph)},i(a){e||(ot(o,a),e=!0)},o(a){mt(o,a),e=!1},d(a){a&&et(t),o&&o.d(a),i=!1,Pe(s)}}}function Qm(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Qr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class mh extends de{constructor(t){super(),ue(this,t,Qm,Jm,qt,{shape:3,editor:4,transform:5})}}const Os=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function tg(r,t,e){let i;const s=Qr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return zi(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=Os(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[n,o,a,l,h,c,u,i]}class eg extends de{constructor(t){super(),ue(this,t,tg,null,qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function rg(r,t,e){const i=Qr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return zi(()=>{const c=n.closest("svg"),u=[],d=(f,p,m)=>{c==null||c.addEventListener(f,p,m),u.push(()=>c==null?void 0:c.removeEventListener(f,p,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class ig extends de{constructor(t){super(),ue(this,t,rg,null,qt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function gh(r){let t,e;return{c(){t=yt("rect"),e=yt("rect"),T(t,"class","a9s-outer"),T(t,"x",r[1]),T(t,"y",r[2]),T(t,"width",r[3]),T(t,"height",r[4]),T(e,"class","a9s-inner"),T(e,"x",r[1]),T(e,"y",r[2]),T(e,"width",r[3]),T(e,"height",r[4])},m(i,s){it(i,t,s),it(i,e,s)},p(i,s){s&2&&T(t,"x",i[1]),s&4&&T(t,"y",i[2]),s&8&&T(t,"width",i[3]),s&16&&T(t,"height",i[4]),s&2&&T(e,"x",i[1]),s&4&&T(e,"y",i[2]),s&8&&T(e,"width",i[3]),s&16&&T(e,"height",i[4])},d(i){i&&(et(t),et(e))}}}function sg(r){let t,e=r[0]&&gh(r);return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=gh(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}function ng(r,t,e){const i=Qr();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,c,u,d,f;const p=x=>{const g=x;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))},m=x=>{const g=x;l&&(h=o.elementToImage(g.offsetX,g.offsetY),e(1,c=Math.min(h[0],l[0])),e(2,u=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,f=Math.abs(h[1]-l[1])))},_=x=>{const g=x,v=performance.now()-a;if(n==="click"){if(v>300)return;l?y():(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))}else l&&(v>300||d*f>100?(g.stopPropagation(),y()):(e(0,l=void 0),h=void 0))},y=()=>{if(d*f>15){const x={type:wt.RECTANGLE,geometry:{bounds:{minX:c,minY:u,maxX:c+d,maxY:u+f},x:c,y:u,w:d,h:f}};i("create",x)}e(0,l=void 0),h=void 0};return zi(()=>{s("pointerdown",p),s("pointermove",m),s("pointerup",_,!0)}),r.$$set=x=>{"addEventListener"in x&&e(5,s=x.addEventListener),"drawingMode"in x&&e(6,n=x.drawingMode),"transform"in x&&e(7,o=x.transform)},[l,c,u,d,f,s,n,o]}class og extends de{constructor(t){super(),ue(this,t,ng,sg,qt,{addEventListener:5,drawingMode:6,transform:7})}}function Eo(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function yh(r){let t,e,i,s,n,o=r[2]&&_h(r);return{c(){t=yt("polygon"),i=yt("polygon"),o&&o.c(),n=ye(),T(t,"class","a9s-outer"),T(t,"points",e=r[16]),T(i,"class","a9s-inner"),T(i,"points",s=r[16])},m(a,l){it(a,t,l),it(a,i,l),o&&o.m(a,l),it(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&T(t,"points",e),l&7&&s!==(s=a[16])&&T(i,"points",s),a[2]?o?o.p(a,l):(o=_h(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(et(t),et(i),et(n)),o&&o.d(a)}}}function _h(r){let t,e,i;return{c(){t=yt("rect"),T(t,"class","a9s-corner-handle"),T(t,"x",e=r[0][0][0]-r[3]/2),T(t,"y",i=r[0][0][1]-r[3]/2),T(t,"height",r[3]),T(t,"width",r[3])},m(s,n){it(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&T(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&T(t,"y",i),n&8&&T(t,"height",s[3]),n&8&&T(t,"width",s[3])},d(s){s&&et(t)}}}function ag(r){let t,e=r[1]&&yh(Eo(r));return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(Eo(i),s):(e=yh(Eo(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}const lg=20,hg=1500;function cg(r,t,e){let i;const s=Qr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c=[],u,d,f=!1;const p=g=>{const v=g,{timeStamp:w,offsetX:I,offsetY:A}=v;if(h={timeStamp:w,offsetX:I,offsetY:A},o==="drag"&&c.length===0){const C=a.elementToImage(v.offsetX,v.offsetY);c.push(C),e(1,u=C)}},m=g=>{const v=g;if(d&&clearTimeout(d),c.length>0){if(e(1,u=a.elementToImage(v.offsetX,v.offsetY)),c.length>2){const w=wo(u,c[0])*l;e(2,f=w<lg)}v.pointerType==="touch"&&(d=setTimeout(()=>{y()},hg))}},_=g=>{const v=g;if(d&&clearTimeout(d),o==="click"){const w=v.timeStamp-h.timeStamp,I=wo([h.offsetX,h.offsetY],[v.offsetX,v.offsetY]);if(w>300||I>15)return;if(f)x();else if(c.length===0){const A=a.elementToImage(v.offsetX,v.offsetY);c.push(A),e(1,u=A)}else c.push(u)}else{if(c.length===1&&wo(c[0],u)<=4){e(0,c=[]),e(1,u=void 0);return}v.stopImmediatePropagation(),f?x():c.push(u)}},y=()=>{if(!u)return;const g=[...c,u],v={type:wt.POLYGON,geometry:{bounds:Ms(g),points:g}};mo(v)>4&&(e(0,c=[]),e(1,u=void 0),s("create",v))},x=()=>{const g={type:wt.POLYGON,geometry:{bounds:Ms(c),points:[...c]}};e(0,c=[]),e(1,u=void 0),s("create",g)};return zi(()=>{n("pointerdown",p,!0),n("pointermove",m),n("pointerup",_,!0),n("dblclick",y,!0)}),r.$$set=g=>{"addEventListener"in g&&e(4,n=g.addEventListener),"drawingMode"in g&&e(5,o=g.drawingMode),"transform"in g&&e(6,a=g.transform),"viewportScale"in g&&e(7,l=g.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[c,u,f,i,n,o,a,l]}class ug extends de{constructor(t){super(),ue(this,t,cg,ag,qt,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const To=new Map([["rectangle",{tool:og}],["polygon",{tool:ug}]]),Fs=()=>[...To.keys()],Ls=r=>To.get(r),vh=(r,t,e)=>To.set(r,{tool:t,opts:e});function dg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("ellipse"),s=yt("ellipse"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"cx",r[2]),T(e,"cy",r[3]),T(e,"rx",r[4]),T(e,"ry",r[5]),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"cx",r[2]),T(s,"cy",r[3]),T(s,"rx",r[4]),T(s,"ry",r[5]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function fg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=n;return r.$$set=u=>{"annotation"in u&&e(0,s=u.annotation),"geom"in u&&e(6,n=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Os(s,o))},[s,i,a,l,h,c,n,o]}class pg extends de{constructor(t){super(),ue(this,t,fg,dg,qt,{annotation:0,geom:6,style:7})}}function mg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("polygon"),s=yt("polygon"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"points",r[2].map(gg).join(" ")),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"points",r[2].map(yg).join(" ")),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}const gg=r=>r.join(","),yg=r=>r.join(",");function _g(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Os(s,o))},[s,i,a,n,o]}class vg extends de{constructor(t){super(),ue(this,t,_g,mg,qt,{annotation:0,geom:3,style:4})}}function xg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("rect"),s=yt("rect"),T(e,"class","a9s-outer"),T(e,"style",i=r[5]?"display:none;":void 0),T(e,"x",r[4]),T(e,"y",r[3]),T(e,"width",r[2]),T(e,"height",r[1]),T(s,"class","a9s-inner"),T(s,"style",r[5]),T(s,"x",r[4]),T(s,"y",r[3]),T(s,"width",r[2]),T(s,"height",r[1]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&T(e,"style",i),a&16&&T(e,"x",o[4]),a&8&&T(e,"y",o[3]),a&4&&T(e,"width",o[2]),a&2&&T(e,"height",o[1]),a&32&&T(s,"style",o[5]),a&16&&T(s,"x",o[4]),a&8&&T(s,"y",o[3]),a&4&&T(s,"width",o[2]),a&2&&T(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function bg(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Os(l,c)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,c]}class wg extends de{constructor(t){super(),ue(this,t,bg,xg,qt,{annotation:0,geom:6,style:7})}}const Eg=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),Tg=250,Ag=(r,t)=>{const e=Qr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<Tg){const{x:n,y:o}=xh(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},xh=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())};function bh(r,t,e){const i=r.slice();i[37]=t[e];const s=i[23](i[37].target.selector);return i[38]=s,i}function wh(r,t,e){const i=r.slice();return i[41]=t[e],i}function Ao(r){const t=r.slice(),e=t[41].target.selector;return t[44]=e,t}function Eh(r){let t=r[41].id,e,i,s=Th(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&32768&&qt(t,t=n[41].id)?(_e(),mt(s,1,1,At),ve(),s=Th(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Sg(r){let t,e;return t=new vg({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Ig(r){let t,e;return t=new wg({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Cg(r){var t;let e,i;return e=new pg({props:{annotation:r[41],geom:(t=r[44])==null?void 0:t.geometry,style:r[1]}}),{c(){ce(e.$$.fragment)},m(s,n){se(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&32768&&(a.annotation=s[41]),n[0]&32768&&(a.geom=(o=s[44])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ot(e.$$.fragment,s),i=!0)},o(s){mt(e.$$.fragment,s),i=!1},d(s){ne(e,s)}}}function Th(r){let t,e,i,s;const n=[Cg,Ig,Sg],o=[];function a(l,h){var c,u,d;return((c=l[44])==null?void 0:c.type)===wt.ELLIPSE?0:((u=l[44])==null?void 0:u.type)===wt.RECTANGLE?1:((d=l[44])==null?void 0:d.type)===wt.POLYGON?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Ah(r){let t=Je(r[41])&&!r[8](r[41]),e,i,s=t&&Eh(Ao(r));return{c(){s&&s.c(),e=ye()},m(n,o){s&&s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&33024&&(t=Je(n[41])&&!n[8](n[41])),t?s?(s.p(Ao(n),o),o[0]&33024&&ot(s,1)):(s=Eh(Ao(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(_e(),mt(s,1,1,()=>{s=null}),ve())},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s&&s.d(n)}}}function Sh(r){let t,e,i,s;const n=[Pg,Rg],o=[];function a(l,h){return l[7]?0:l[13]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Rg(r){let t=r[2],e,i,s=Ih(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&4&&qt(t,t=n[2])?(_e(),mt(s,1,1,At),ve(),s=Ih(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Pg(r){let t,e,i=ii(r[7]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Ph(bh(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ye()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&10553506){i=ii(o[7]);let l;for(l=0;l<i.length;l+=1){const h=bh(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=Ph(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(_e(),l=i.length;l<s.length;l+=1)n(l);ve()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&et(t),lo(s,o)}}}function Ih(r){let t,e;return t=new ig({props:{target:r[5],tool:r[13],drawingMode:r[12],transform:r[11],viewportScale:r[16]}}),t.$on("create",r[20]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&8192&&(n.tool=i[13]),s[0]&4096&&(n.drawingMode=i[12]),s[0]&2048&&(n.transform=i[11]),s[0]&65536&&(n.viewportScale=i[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Ch(r){let t=r[37].id,e,i,s=Rh(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&128&&qt(t,t=n[37].id)?(_e(),mt(s,1,1,At),ve(),s=Rh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Rh(r){let t,e;return t=new eg({props:{target:r[5],editor:r[23](r[37].target.selector),annotation:r[37],style:r[1],transform:r[11],viewportScale:r[16]}}),t.$on("change",function(){Ut(r[21](r[37]))&&r[21](r[37]).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&128&&(n.editor=r[23](r[37].target.selector)),s[0]&128&&(n.annotation=r[37]),s[0]&2&&(n.style=r[1]),s[0]&2048&&(n.transform=r[11]),s[0]&65536&&(n.viewportScale=r[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Ph(r){let t,e,i=r[38]&&Ch(r);return{c(){i&&i.c(),t=ye()},m(s,n){i&&i.m(s,n),it(s,t,n),e=!0},p(s,n){s[38]?i?(i.p(s,n),n[0]&128&&ot(i,1)):(i=Ch(s),i.c(),ot(i,1),i.m(t.parentNode,t)):i&&(_e(),mt(i,1,1,()=>{i=null}),ve())},i(s){e||(ot(i),e=!0)},o(s){mt(i),e=!1},d(s){s&&et(t),i&&i.d(s)}}}function Mg(r){let t,e,i,s,n,o,a=ii(r[15].filter(r[32])),l=[];for(let u=0;u<a.length;u+=1)l[u]=Ah(wh(r,a,u));const h=u=>mt(l[u],1,1,()=>{l[u]=null});let c=r[5]&&Sh(r);return{c(){t=yt("svg"),e=yt("g");for(let u=0;u<l.length;u+=1)l[u].c();i=yt("g"),c&&c.c(),T(i,"class","drawing"),T(t,"class","a9s-annotationlayer"),pr(t,"drawing",r[13]),pr(t,"hidden",!r[3]),pr(t,"hover",r[14])},m(u,d){it(u,t,d),Me(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);Me(t,i),c&&c.m(i,null),r[33](i),r[34](t),s=!0,n||(o=[Dt(t,"pointerup",function(){Ut(r[9])&&r[9].apply(this,arguments)}),Dt(t,"pointerdown",function(){Ut(r[10])&&r[10].apply(this,arguments)}),Dt(t,"pointermove",r[22])],n=!0)},p(u,d){if(r=u,d[0]&33026){a=ii(r[15].filter(r[32]));let f;for(f=0;f<a.length;f+=1){const p=wh(r,a,f);l[f]?(l[f].p(p,d),ot(l[f],1)):(l[f]=Ah(p),l[f].c(),ot(l[f],1),l[f].m(e,null))}for(_e(),f=a.length;f<l.length;f+=1)h(f);ve()}r[5]?c?(c.p(r,d),d[0]&32&&ot(c,1)):(c=Sh(r),c.c(),ot(c,1),c.m(i,null)):c&&(_e(),mt(c,1,1,()=>{c=null}),ve()),(!s||d[0]&8192)&&pr(t,"drawing",r[13]),(!s||d[0]&8)&&pr(t,"hidden",!r[3]),(!s||d[0]&16384)&&pr(t,"hover",r[14])},i(u){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(c),s=!0}},o(u){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)mt(l[d]);mt(c),s=!1},d(u){u&&et(t),lo(l,u),c&&c.d(),r[33](null),r[34](null),n=!1,Pe(o)}}}function Bg(r,t,e){let i,s,n,o,a,l,h,c,u,d,f,p=At,m=()=>(p(),p=Xl(E,V=>e(16,f=V)),E);r.$$.on_destroy.push(()=>p());let{drawingEnabled:_}=t,{image:y}=t,{preferredDrawingMode:x}=t,{state:g}=t,{style:v=void 0}=t,{toolName:w=Fs()[0]}=t,{user:I}=t,{visible:A=!0}=t;const C=()=>w,N=()=>_;let S,R,E;zi(()=>m(e(6,E=Hm(y,R))));const{hover:b,selection:D,store:F}=g;ao(r,b,V=>e(14,c=V)),ao(r,D,V=>e(31,u=V)),ao(r,F,V=>e(15,d=V));let G,$;const B=V=>{G&&F.unobserve(G);const lt=V.filter(({editable:L})=>L).map(({id:L})=>L);lt.length>0?(e(7,$=lt.map(L=>F.getAnnotation(L)).filter(L=>L&&Je(L))),G=L=>{const{updated:O}=L.changes;e(7,$=O==null?void 0:O.map(_t=>_t.newValue))},F.observe(G,{annotations:lt})):e(7,$=void 0)},K=V=>{const lt=Ql(),L={id:lt,bodies:[],target:{annotation:lt,selector:V.detail,creator:I,created:new Date}};F.addAnnotation(L),D.setSelected(L.id)},P=V=>lt=>{var L;const{target:O}=V,_t=10*60*1e3,ht=((L=O.creator)==null?void 0:L.id)!==I.id||!O.created||new Date().getTime()-O.created.getTime()>_t;F.updateTarget({...O,selector:lt.detail,created:ht?O.created:new Date,updated:ht?new Date:void 0,updatedBy:ht?I:void 0})},U=V=>{const{x:lt,y:L}=xh(V,R),O=F.getAt(lt,L);O?c!==O.id&&b.set(O.id):b.set(void 0)},j=V=>dh(V),rt=V=>Je(V);function Q(V){Rs[V?"unshift":"push"](()=>{S=V,e(5,S)})}function H(V){Rs[V?"unshift":"push"](()=>{R=V,e(4,R)})}return r.$$set=V=>{"drawingEnabled"in V&&e(0,_=V.drawingEnabled),"image"in V&&e(24,y=V.image),"preferredDrawingMode"in V&&e(25,x=V.preferredDrawingMode),"state"in V&&e(26,g=V.state),"style"in V&&e(1,v=V.style),"toolName"in V&&e(2,w=V.toolName),"user"in V&&e(27,I=V.user),"visible"in V&&e(3,A=V.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(13,{tool:i,opts:s}=Ls(w)||{tool:void 0,opts:void 0},i,(e(30,s),e(2,w))),r.$$.dirty[0]&1107296256&&e(12,n=(s==null?void 0:s.drawingMode)||x),r.$$.dirty[0]&16&&e(11,o=Eg(R)),r.$$.dirty[0]&16&&e(10,{onPointerDown:a,onPointerUp:l}=Ag(R,F),a,(e(9,l),e(4,R))),r.$$.dirty[1]&1&&e(8,h=V=>u.selected.find(lt=>lt.id===V.id&&lt.editable)),r.$$.dirty[1]&1&&B(u.selected)},[_,v,w,A,R,S,E,$,h,l,a,o,n,i,c,d,f,b,D,F,K,P,U,j,y,x,g,I,C,N,s,u,rt,Q,H]}class Dg extends de{constructor(t){super(),ue(this,t,Bg,Mg,qt,{drawingEnabled:0,image:24,preferredDrawingMode:25,state:26,style:1,toolName:2,user:27,visible:3,getDrawingTool:28,isDrawingEnabled:29},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[28]}get isDrawingEnabled(){return this.$$.ctx[29]}}function Mh(r,t,e=0,i=r.length-1,s=Og){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),p=Math.min(i,Math.floor(t+(l-h)*u/l+d));Mh(r,t,f,p,s)}const n=r[t];let o=e,a=i;for(ji(r,e,t),s(r[i],n)>0&&ji(r,e,i);o<a;){for(ji(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?ji(r,e,a):(a++,ji(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function ji(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Og(r,t){return r<t?-1:r>t?1:0}class Fg{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Us(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;Us(t,l)&&(e.leaf?i.push(a):Io(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Us(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if(Us(t,o)){if(e.leaf||Io(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=ai([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const c=Lg(t,i.children,e);if(c!==-1)return i.children.splice(c,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Io(i,s)?(n.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(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=ai(t.slice(e,i+1)),oi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=ai([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Bh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);Bh(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return oi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=So(h),u=kg(t,h)-c;u<o?(o=u,n=c<n?c:n,a=h):u===o&&c<n&&(n=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),qi(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=ai(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,oi(i,this.toBBox),oi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=ai([t,e]),this.data.height=t.height+1,this.data.leaf=!1,oi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Yi(t,0,a,this.toBBox),h=Yi(t,a,i,this.toBBox),c=Gg(l,h),u=So(l)+So(h);c<n?(n=c,s=a,o=u<o?u:o):c===n&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Ng,n=t.leaf?this.compareMinY:Ug,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Yi(t,0,e,n),a=Yi(t,i-e,i,n);let l=Ns(o)+Ns(a);for(let h=e;h<i-e;h++){const c=t.children[h];qi(o,t.leaf?n(c):c),l+=Ns(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];qi(a,t.leaf?n(c):c),l+=Ns(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)qi(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():oi(t[e],this.toBBox)}}function Lg(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function oi(r,t){Yi(r,0,r.children.length,t,r)}function Yi(r,t,e,i,s){s||(s=ai(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];qi(s,r.leaf?i(o):o)}return s}function qi(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function Ng(r,t){return r.minX-t.minX}function Ug(r,t){return r.minY-t.minY}function So(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Ns(r){return r.maxX-r.minX+(r.maxY-r.minY)}function kg(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Gg(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Io(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Us(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function ai(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Bh(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Mh(r,o,t,e,s),n.push(t,o,o,e)}}const $g=()=>{const r=new Fg,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!Bs(o))return;const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},n=o=>{if(!Bs(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===wt.RECTANGLE||Lp(h.selector,o,a));if(l.length>0)return l.sort((h,c)=>mo(h.selector)-mo(c.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,c)=>{if(Bs(c)){const{minX:u,minY:d,maxX:f,maxY:p}=c.selector.geometry.bounds;return[...h,{minX:u,minY:d,maxX:f,maxY:p,target:c}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Dh=r=>{const t=fm(),e=$g(),i=tm(t,r.userSelectAction,r.adapter),s=Qp(t),n=_m();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation))},selection:i,hover:s,viewport:n}},Hg=r=>{const t=Dh(r);return{...t,store:pm(t.store)}},Xg=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Oh=r=>{const t=Xg(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},Fh=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Oh(r):e),Lh=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),Nh=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Uh=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{Nh?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Nh?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},Vg=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Lh(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:eh.EDIT,theme:"light"}),s=Hg(i),{selection:n,store:o}=s,a=ym(o),l=vm(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const c=Uh(a);let u=Rm();Fh(e,h,i.theme);const d=new Dg({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:u}});d.$on("click",E=>{const{originalEvent:b,annotation:D}=E.detail;D?n.userSelect(D.id,b):n.isEmpty()||n.clear()});const f=bm(s,a,i.adapter),p=()=>{d.$set({drawingEnabled:!1}),setTimeout(()=>d.$set({drawingEnabled:!0}),1)},m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},_=()=>d.getDrawingTool(),y=()=>u,x=()=>d.isDrawingEnabled(),g=(E,b,D)=>vh(E,b,D),v=(E,b)=>fh(E,b),w=E=>{if(!Ls(E))throw`No drawing tool named ${E}`;d.$set({toolName:E})},I=E=>d.$set({drawingEnabled:E}),A=E=>{console.warn("Filter not implemented yet")},C=E=>d.$set({style:E}),N=E=>Fh(e,h,E),S=E=>{u=E,d.$set({user:E})},R=E=>d.$set({visible:E});return{...f,cancelDrawing:p,destroy:m,getDrawingTool:_,getUser:y,isDrawingEnabled:x,listDrawingTools:Fs,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:v,setDrawingEnabled:I,setDrawingTool:w,setFilter:A,setStyle:C,setTheme:N,setUser:S,setVisible:R,element:h,state:s}};function Be(){}function Co(r,t){for(const e in t)r[e]=t[e];return r}function kh(r){return r()}function Gh(){return Object.create(null)}function Qe(r){r.forEach(kh)}function Kt(r){return typeof r=="function"}function te(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function zg(r){return Object.keys(r).length===0}function Wg(r,...t){if(r==null){for(const i of t)i(void 0);return Be}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Ro(r,t,e){r.$$.on_destroy.push(Wg(t,e))}function $h(r,t,e,i){if(r){const s=Hh(r,t,e,i);return r[0](s)}}function Hh(r,t,e,i){return r[1]&&i?Co(e.ctx.slice(),r[1](i(t))):e.ctx}function Xh(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Vh(r,t,e,i,s,n){if(s){const o=Hh(t,e,i,n);r.p(o,s)}}function zh(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Wh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function ks(r){return r??""}const jg=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function tr(r,t){r.appendChild(t)}function ft(r,t,e){r.insertBefore(t,e||null)}function ct(r){r.parentNode&&r.parentNode.removeChild(r)}function Po(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Tt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Mo(r){return document.createTextNode(r)}function xe(){return Mo(" ")}function er(){return Mo("")}function zt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function M(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Yg(r){return Array.from(r.childNodes)}function qg(r,t){t=""+t,r.data!==t&&(r.data=t)}function Gs(r,t,e){r.classList.toggle(t,!!e)}function Kg(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ki;function Zi(r){Ki=r}function Bo(){if(!Ki)throw new Error("Function called outside component initialization");return Ki}function $s(r){Bo().$$.on_mount.push(r)}function Zg(r){Bo().$$.on_destroy.push(r)}function Hs(){const r=Bo();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Kg(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function rr(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const li=[],Xs=[];let hi=[];const jh=[],Jg=Promise.resolve();let Do=!1;function Qg(){Do||(Do=!0,Jg.then(Yh))}function Oo(r){hi.push(r)}const Fo=new Set;let ci=0;function Yh(){if(ci!==0)return;const r=Ki;do{try{for(;ci<li.length;){const t=li[ci];ci++,Zi(t),ty(t.$$)}}catch(t){throw li.length=0,ci=0,t}for(Zi(null),li.length=0,ci=0;Xs.length;)Xs.pop()();for(let t=0;t<hi.length;t+=1){const e=hi[t];Fo.has(e)||(Fo.add(e),e())}hi.length=0}while(li.length);for(;jh.length;)jh.pop()();Do=!1,Fo.clear(),Zi(r)}function ty(r){if(r.fragment!==null){r.update(),Qe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Oo)}}function ey(r){const t=[],e=[];hi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),hi=t}const Vs=new Set;let Dr;function De(){Dr={r:0,c:[],p:Dr}}function Oe(){Dr.r||Qe(Dr.c),Dr=Dr.p}function st(r,t){r&&r.i&&(Vs.delete(r),r.i(t))}function ut(r,t,e,i){if(r&&r.o){if(Vs.has(r))return;Vs.add(r),Dr.c.push(()=>{Vs.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ui(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ee(r){r&&r.c()}function Zt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Oo(()=>{const n=r.$$.on_mount.map(kh).filter(Kt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Qe(n),r.$$.on_mount=[]}),s.forEach(Oo)}function Jt(r,t){const e=r.$$;e.fragment!==null&&(ey(e.after_update),Qe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function ry(r,t){r.$$.dirty[0]===-1&&(li.push(r),Qg(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function oe(r,t,e,i,s,n,o=null,a=[-1]){const l=Ki;Zi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Be,not_equal:s,bound:Gh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Gh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&ry(r,u)),d}):[],h.update(),c=!0,Qe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Yg(t.target);h.fragment&&h.fragment.l(u),u.forEach(ct)}else h.fragment&&h.fragment.c();t.intro&&st(r.$$.fragment),Zt(r,t.target,t.anchor),Yh()}Zi(l)}class ae{constructor(){Ml(this,"$$");Ml(this,"$$set")}$destroy(){Jt(this,1),this.$destroy=Be}$on(t,e){if(!Kt(e))return Be;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!zg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const iy="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(iy);var Or=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Or||{}),qh=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(qh||{}),Lo=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Lo||{}),tt=(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))(tt||{}),Fe=(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))(Fe||{}),k=(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))(k||{}),di=(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))(di||{}),J=(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))(J||{}),z=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(z||{}),ir=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(ir||{}),gr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(gr||{}),Le=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Le||{}),ie=(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))(ie||{}),Ne=(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))(Ne||{}),No=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(No||{}),fe=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(fe||{}),Ft=(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))(Ft||{}),Ot=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Ot||{}),Ue=(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))(Ue||{});const W={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Uo=/iPhone/i,Kh=/iPod/i,Zh=/iPad/i,Jh=/\biOS-universal(?:.+)Mac\b/i,ko=/\bAndroid(?:.+)Mobile\b/i,Qh=/Android/i,fi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,zs=/Silk/i,sr=/Windows Phone/i,tc=/\bWindows(?:.+)ARM\b/i,ec=/BlackBerry/i,rc=/BB10/i,ic=/Opera Mini/i,sc=/\b(CriOS|Chrome)(?:.+)Mobile/i,nc=/Mobile(?:.+)Firefox\b/i,oc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function sy(r){return function(t){return t.test(r)}}function ac(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=sy(e),n={apple:{phone:s(Uo)&&!s(sr),ipod:s(Kh),tablet:!s(Uo)&&(s(Zh)||oc(t))&&!s(sr),universal:s(Jh),device:(s(Uo)||s(Kh)||s(Zh)||s(Jh)||oc(t))&&!s(sr)},amazon:{phone:s(fi),tablet:!s(fi)&&s(zs),device:s(fi)||s(zs)},android:{phone:!s(sr)&&s(fi)||!s(sr)&&s(ko),tablet:!s(sr)&&!s(fi)&&!s(ko)&&(s(zs)||s(Qh)),device:!s(sr)&&(s(fi)||s(zs)||s(ko)||s(Qh))||s(/\bokhttp\b/i)},windows:{phone:s(sr),tablet:s(tc),device:s(sr)||s(tc)},other:{blackberry:s(ec),blackberry10:s(rc),opera:s(ic),firefox:s(nc),chrome:s(sc),device:s(ec)||s(rc)||s(ic)||s(nc)||s(sc)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ny=ac.default??ac,nr=ny(globalThis.navigator);W.RETINA_PREFIX=/@([0-9\.]+)x/,W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Ji=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function oy(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var hc={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=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 h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],y=arguments.length,x,g;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,u),!0;case 4:return _.fn.call(_.context,c,u,d),!0;case 5:return _.fn.call(_.context,c,u,d,f),!0;case 6:return _.fn.call(_.context,c,u,d,f,p),!0}for(g=1,x=new Array(y-1);g<y;g++)x[g-1]=arguments[g];_.fn.apply(_.context,x)}else{var v=_.length,w;for(g=0;g<v;g++)switch(_[g].once&&this.removeListener(h,_[g].fn,void 0,!0),y){case 1:_[g].fn.call(_[g].context);break;case 2:_[g].fn.call(_[g].context,c);break;case 3:_[g].fn.call(_[g].context,c,u);break;case 4:_[g].fn.call(_[g].context,c,u,d);break;default:if(!x)for(w=1,x=new Array(y-1);w<y;w++)x[w-1]=arguments[w];_[g].fn.apply(_[g].context,x)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,_=[],y=p.length;m<y;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(hc);var ay=hc.exports;const Qi=lc(ay);var Go={exports:{}};Go.exports=Ws,Go.exports.default=Ws;function Ws(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=cc(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=dy(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return ts(n,o,e,a,l,f,0),o}function cc(r,t,e,i,s){var n,o;if(s===Xo(r,t,e,i)>0)for(n=t;n<e;n+=i)o=fc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=fc(n,r[n],r[n+1],o);return o&&js(o,o.next)&&(rs(o),o=o.next),o}function Fr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(js(e,e.next)||It(e.prev,e,e.next)===0)){if(rs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ts(r,t,e,i,s,n,o){if(r){!o&&n&&yy(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?hy(r,i,s,n):ly(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),rs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=cy(Fr(r),t,e),ts(r,t,e,i,s,n,2)):o===2&&uy(r,t,e,i,s,n):ts(Fr(r),t,e,i,s,n,1);break}}}}function ly(r){var t=r.prev,e=r,i=r.next;if(It(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&pi(s,a,n,l,o,h,p.x,p.y)&&It(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function hy(r,t,e,i){var s=r.prev,n=r,o=r.next;if(It(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,c=s.y,u=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,_=c>u?c>d?c:d:u>d?u:d,y=$o(f,p,t,e,i),x=$o(m,_,t,e,i),g=r.prevZ,v=r.nextZ;g&&g.z>=y&&v&&v.z<=x;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0||(g=g.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;g&&g.z>=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function cy(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!js(s,n)&&uc(s,i,i.next,n)&&es(s,n)&&es(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),rs(i),rs(i.next),i=r=n),i=i.next}while(i!==r);return Fr(i)}function uy(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&xy(o,a)){var l=dc(o,a);o=Fr(o,o.next),l=Fr(l,l.next),ts(o,t,e,i,s,n,0),ts(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function dy(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=cc(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(vy(h));for(s.sort(fy),n=0;n<s.length;n++)e=py(s[n],e);return e}function fy(r,t){return r.x-t.x}function py(r,t){var e=my(r,t);if(!e)return t;var i=dc(e,r);return Fr(i,i.next),Fr(e,e.next)}function my(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&pi(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),es(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&gy(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function gy(r,t){return It(r.prev,r,t.prev)<0&&It(t.next,r,r.next)<0}function yy(r,t,e,i){var s=r;do s.z===0&&(s.z=$o(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,_y(s)}function _y(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function $o(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function vy(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function pi(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function xy(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!by(r,t)&&(es(r,t)&&es(t,r)&&wy(r,t)&&(It(r.prev,r,t.prev)||It(r,t.prev,t))||js(r,t)&&It(r.prev,r,r.next)>0&&It(t.prev,t,t.next)>0)}function It(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function js(r,t){return r.x===t.x&&r.y===t.y}function uc(r,t,e,i){var s=qs(It(r,t,e)),n=qs(It(r,t,i)),o=qs(It(e,i,r)),a=qs(It(e,i,t));return!!(s!==n&&o!==a||s===0&&Ys(r,e,t)||n===0&&Ys(r,i,t)||o===0&&Ys(e,r,i)||a===0&&Ys(e,t,i))}function Ys(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function qs(r){return r>0?1:r<0?-1:0}function by(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&uc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function es(r,t){return It(r.prev,r,r.next)<0?It(r,t,r.next)>=0&&It(r,r.prev,t)>=0:It(r,t,r.prev)<0||It(r,r.next,t)<0}function wy(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function dc(r,t){var e=new Ho(r.i,r.x,r.y),i=new Ho(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function fc(r,t,e,i){var s=new Ho(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function rs(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 Ho(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ws.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Xo(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(Xo(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Xo(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}Ws.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var Ey=Go.exports;const Ty=lc(Ey);var Ks={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Ks.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Ji=="object"&&Ji;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,m="-",_=/^xn--/,y=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-h,w=Math.floor,I=String.fromCharCode,A;function C(P){throw new RangeError(g[P])}function N(P,U){for(var j=P.length,rt=[];j--;)rt[j]=U(P[j]);return rt}function S(P,U){var j=P.split("@"),rt="";j.length>1&&(rt=j[0]+"@",P=j[1]),P=P.replace(x,".");var Q=P.split("."),H=N(Q,U).join(".");return rt+H}function R(P){for(var U=[],j=0,rt=P.length,Q,H;j<rt;)Q=P.charCodeAt(j++),Q>=55296&&Q<=56319&&j<rt?(H=P.charCodeAt(j++),(H&64512)==56320?U.push(((Q&1023)<<10)+(H&1023)+65536):(U.push(Q),j--)):U.push(Q);return U}function E(P){return N(P,function(U){var j="";return U>65535&&(U-=65536,j+=I(U>>>10&1023|55296),U=56320|U&1023),j+=I(U),j}).join("")}function b(P){return P-48<10?P-22:P-65<26?P-65:P-97<26?P-97:l}function D(P,U){return P+22+75*(P<26)-((U!=0)<<5)}function F(P,U,j){var rt=0;for(P=j?w(P/d):P>>1,P+=w(P/U);P>v*c>>1;rt+=l)P=w(P/v);return w(rt+(v+1)*P/(P+u))}function G(P){var U=[],j=P.length,rt,Q=0,H=p,V=f,lt,L,O,_t,ht,vt,xt,Ye,qe;for(lt=P.lastIndexOf(m),lt<0&&(lt=0),L=0;L<lt;++L)P.charCodeAt(L)>=128&&C("not-basic"),U.push(P.charCodeAt(L));for(O=lt>0?lt+1:0;O<j;){for(_t=Q,ht=1,vt=l;O>=j&&C("invalid-input"),xt=b(P.charCodeAt(O++)),(xt>=l||xt>w((a-Q)/ht))&&C("overflow"),Q+=xt*ht,Ye=vt<=V?h:vt>=V+c?c:vt-V,!(xt<Ye);vt+=l)qe=l-Ye,ht>w(a/qe)&&C("overflow"),ht*=qe;rt=U.length+1,V=F(Q-_t,rt,_t==0),w(Q/rt)>a-H&&C("overflow"),H+=w(Q/rt),Q%=rt,U.splice(Q++,0,H)}return E(U)}function $(P){var U,j,rt,Q,H,V,lt,L,O,_t,ht,vt=[],xt,Ye,qe,ws;for(P=R(P),xt=P.length,U=p,j=0,H=f,V=0;V<xt;++V)ht=P[V],ht<128&&vt.push(I(ht));for(rt=Q=vt.length,Q&&vt.push(m);rt<xt;){for(lt=a,V=0;V<xt;++V)ht=P[V],ht>=U&&ht<lt&&(lt=ht);for(Ye=rt+1,lt-U>w((a-j)/Ye)&&C("overflow"),j+=(lt-U)*Ye,U=lt,V=0;V<xt;++V)if(ht=P[V],ht<U&&++j>a&&C("overflow"),ht==U){for(L=j,O=l;_t=O<=H?h:O>=H+c?c:O-H,!(L<_t);O+=l)ws=L-_t,qe=l-_t,vt.push(I(D(_t+ws%qe,0))),L=w(ws/qe);vt.push(I(D(L,0))),H=F(j,Ye,rt==Q),j=0,++rt}++j,++U}return vt.join("")}function B(P){return S(P,function(U){return _.test(U)?G(U.slice(4).toLowerCase()):U})}function K(P){return S(P,function(U){return y.test(U)?"xn--"+$(U):U})}if(o={version:"1.4.1",ucs2:{decode:R,encode:E},decode:G,encode:$,toASCII:K,toUnicode:B},i&&s)if(r.exports==i)s.exports=o;else for(A in o)o.hasOwnProperty(A)&&(i[A]=o[A]);else e.punycode=o})(Ji)}(Ks,Ks.exports);var Ay=Ks.exports,Sy=Error,Iy=EvalError,Cy=RangeError,Ry=ReferenceError,pc=SyntaxError,is=TypeError,Py=URIError,My=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},mc=typeof Symbol<"u"&&Symbol,By=My,Dy=function(){return typeof mc!="function"||typeof Symbol!="function"||typeof mc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:By()},Vo={__proto__:null,foo:{}},Oy=Object,Fy=function(){return{__proto__:Vo}.foo===Vo.foo&&!(Vo instanceof Oy)},Ly="Function.prototype.bind called on incompatible ",Ny=Object.prototype.toString,Uy=Math.max,ky="[object Function]",gc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},Gy=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},$y=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},Hy=function(t){var e=this;if(typeof e!="function"||Ny.apply(e)!==ky)throw new TypeError(Ly+e);for(var i=Gy(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,gc(i,arguments));return Object(c)===c?c:this}return e.apply(t,gc(i,arguments))},o=Uy(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+$y(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},Xy=Hy,zo=Function.prototype.bind||Xy,Vy=Function.prototype.call,zy=Object.prototype.hasOwnProperty,Wy=zo,jy=Wy.call(Vy,zy),pt,Yy=Sy,qy=Iy,Ky=Cy,Zy=Ry,mi=pc,gi=is,Jy=Py,yc=Function,Wo=function(r){try{return yc('"use strict"; return ('+r+").constructor;")()}catch{}},Lr=Object.getOwnPropertyDescriptor;if(Lr)try{Lr({},"")}catch{Lr=null}var jo=function(){throw new gi},Qy=Lr?function(){try{return arguments.callee,jo}catch{try{return Lr(arguments,"callee").get}catch{return jo}}}():jo,yi=Dy(),t0=Fy(),kt=Object.getPrototypeOf||(t0?function(r){return r.__proto__}:null),_i={},e0=typeof Uint8Array>"u"||!kt?pt:kt(Uint8Array),Nr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?pt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?pt:ArrayBuffer,"%ArrayIteratorPrototype%":yi&&kt?kt([][Symbol.iterator]()):pt,"%AsyncFromSyncIteratorPrototype%":pt,"%AsyncFunction%":_i,"%AsyncGenerator%":_i,"%AsyncGeneratorFunction%":_i,"%AsyncIteratorPrototype%":_i,"%Atomics%":typeof Atomics>"u"?pt:Atomics,"%BigInt%":typeof BigInt>"u"?pt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?pt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?pt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?pt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Yy,"%eval%":eval,"%EvalError%":qy,"%Float32Array%":typeof Float32Array>"u"?pt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?pt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?pt:FinalizationRegistry,"%Function%":yc,"%GeneratorFunction%":_i,"%Int8Array%":typeof Int8Array>"u"?pt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?pt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?pt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":yi&&kt?kt(kt([][Symbol.iterator]())):pt,"%JSON%":typeof JSON=="object"?JSON:pt,"%Map%":typeof Map>"u"?pt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!yi||!kt?pt:kt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?pt:Promise,"%Proxy%":typeof Proxy>"u"?pt:Proxy,"%RangeError%":Ky,"%ReferenceError%":Zy,"%Reflect%":typeof Reflect>"u"?pt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?pt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!yi||!kt?pt:kt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?pt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":yi&&kt?kt(""[Symbol.iterator]()):pt,"%Symbol%":yi?Symbol:pt,"%SyntaxError%":mi,"%ThrowTypeError%":Qy,"%TypedArray%":e0,"%TypeError%":gi,"%Uint8Array%":typeof Uint8Array>"u"?pt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?pt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?pt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?pt:Uint32Array,"%URIError%":Jy,"%WeakMap%":typeof WeakMap>"u"?pt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?pt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?pt:WeakSet};if(kt)try{null.error}catch(r){var r0=kt(kt(r));Nr["%Error.prototype%"]=r0}var i0=function r(t){var e;if(t==="%AsyncFunction%")e=Wo("async function () {}");else if(t==="%GeneratorFunction%")e=Wo("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Wo("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&kt&&(e=kt(s.prototype))}return Nr[t]=e,e},_c={__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"]},ss=zo,Zs=jy,s0=ss.call(Function.call,Array.prototype.concat),n0=ss.call(Function.apply,Array.prototype.splice),vc=ss.call(Function.call,String.prototype.replace),Js=ss.call(Function.call,String.prototype.slice),o0=ss.call(Function.call,RegExp.prototype.exec),a0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,l0=/\\(\\)?/g,h0=function(t){var e=Js(t,0,1),i=Js(t,-1);if(e==="%"&&i!=="%")throw new mi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new mi("invalid intrinsic syntax, expected opening `%`");var s=[];return vc(t,a0,function(n,o,a,l){s[s.length]=a?vc(l,l0,"$1"):o||n}),s},c0=function(t,e){var i=t,s;if(Zs(_c,i)&&(s=_c[i],i="%"+s[0]+"%"),Zs(Nr,i)){var n=Nr[i];if(n===_i&&(n=i0(i)),typeof n>"u"&&!e)throw new gi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new mi("intrinsic "+t+" does not exist!")},vi=function(t,e){if(typeof t!="string"||t.length===0)throw new gi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new gi('"allowMissing" argument must be a boolean');if(o0(/^%?[^%]*%?$/,t)===null)throw new mi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=h0(t),s=i.length>0?i[0]:"",n=c0("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],n0(i,s0([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=Js(d,0,1),p=Js(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new mi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",Zs(Nr,o))a=Nr[o];else if(a!=null){if(!(d in a)){if(!e)throw new gi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Lr&&c+1>=i.length){var m=Lr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=Zs(a,d),a=a[d];u&&!l&&(Nr[o]=a)}}return a},xc={exports:{}},Yo,bc;function qo(){if(bc)return Yo;bc=1;var r=vi,t=r("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Yo=t,Yo}var u0=vi,Qs=u0("%Object.getOwnPropertyDescriptor%",!0);if(Qs)try{Qs([],"length")}catch{Qs=null}var wc=Qs,Ec=qo(),d0=pc,xi=is,Tc=wc,f0=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new xi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new xi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xi("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Tc&&Tc(t,e);if(Ec)Ec(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:i,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=i;else throw new d0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Ko=qo(),Ac=function(){return!!Ko};Ac.hasArrayLengthDefineBug=function(){if(!Ko)return null;try{return Ko([],"length",{value:1}).length!==1}catch{return!0}};var p0=Ac,m0=vi,Sc=f0,g0=p0(),Ic=wc,Cc=is,y0=m0("%Math.floor%"),_0=function(t,e){if(typeof t!="function")throw new Cc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||y0(e)!==e)throw new Cc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&Ic){var o=Ic(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(g0?Sc(t,"length",e,!0,!0):Sc(t,"length",e)),t};(function(r){var t=zo,e=vi,i=_0,s=is,n=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),a=e("%Reflect.apply%",!0)||t.call(o,n),l=qo(),h=e("%Math.max%");r.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return i(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(r.exports,"apply",{value:c}):r.exports.apply=c})(xc);var v0=xc.exports,Rc=vi,Pc=v0,x0=Pc(Rc("String.prototype.indexOf")),b0=function(t,e){var i=Rc(t,!!e);return typeof i=="function"&&x0(t,".prototype.")>-1?Pc(i):i};const w0=oy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Zo=typeof Map=="function"&&Map.prototype,Jo=Object.getOwnPropertyDescriptor&&Zo?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,tn=Zo&&Jo&&typeof Jo.get=="function"?Jo.get:null,Mc=Zo&&Map.prototype.forEach,Qo=typeof Set=="function"&&Set.prototype,ta=Object.getOwnPropertyDescriptor&&Qo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,en=Qo&&ta&&typeof ta.get=="function"?ta.get:null,Bc=Qo&&Set.prototype.forEach,E0=typeof WeakMap=="function"&&WeakMap.prototype,ns=E0?WeakMap.prototype.has:null,T0=typeof WeakSet=="function"&&WeakSet.prototype,os=T0?WeakSet.prototype.has:null,A0=typeof WeakRef=="function"&&WeakRef.prototype,Dc=A0?WeakRef.prototype.deref:null,S0=Boolean.prototype.valueOf,I0=Object.prototype.toString,C0=Function.prototype.toString,R0=String.prototype.match,ea=String.prototype.slice,yr=String.prototype.replace,P0=String.prototype.toUpperCase,Oc=String.prototype.toLowerCase,Fc=RegExp.prototype.test,Lc=Array.prototype.concat,ke=Array.prototype.join,M0=Array.prototype.slice,Nc=Math.floor,ra=typeof BigInt=="function"?BigInt.prototype.valueOf:null,ia=Object.getOwnPropertySymbols,sa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,bi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Qt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===bi||!0)?Symbol.toStringTag:null,Uc=Object.prototype.propertyIsEnumerable,kc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Gc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Fc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-Nc(-r):Nc(r);if(i!==r){var s=String(i),n=ea.call(t,s.length+1);return yr.call(s,e,"$&_")+"."+yr.call(yr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return yr.call(t,e,"$&_")}var na=w0,$c=na.custom,Hc=Wc($c)?$c:null,Xc={__proto__:null,double:'"',single:"'"},B0={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},D0=function r(t,e,i,s){var n=e||{};if(or(n,"quoteStyle")&&!or(Xc,n.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(or(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=or(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(or(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(or(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Yc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Gc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Gc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return oa(t)?"[Array]":"[Object]";var u=Z0(n,i);if(typeof s>"u")s=[];else if(jc(s,t)>=0)return"[Circular]";function d(b,D,F){if(D&&(s=M0.call(s),s.push(D)),F){var G={depth:n.depth};return or(n,"quoteStyle")&&(G.quoteStyle=n.quoteStyle),r(b,G,i+1,s)}return r(b,n,i+1,s)}if(typeof t=="function"&&!zc(t)){var f=H0(t),p=rn(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+ke.call(p,", ")+" }":"")}if(Wc(t)){var m=bi?yr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):sa.call(t);return typeof t=="object"&&!bi?as(m):m}if(Y0(t)){for(var _="<"+Oc.call(String(t.nodeName)),y=t.attributes||[],x=0;x<y.length;x++)_+=" "+y[x].name+"="+Vc(O0(y[x].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+Oc.call(String(t.nodeName))+">",_}if(oa(t)){if(t.length===0)return"[]";var g=rn(t,d);return u&&!K0(g)?"["+la(g,u)+"]":"[ "+ke.call(g,", ")+" ]"}if(L0(t)){var v=rn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Uc.call(t,"cause")?"{ ["+String(t)+"] "+ke.call(Lc.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+ke.call(v,", ")+" }"}if(typeof t=="object"&&o){if(Hc&&typeof t[Hc]=="function"&&na)return na(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(X0(t)){var w=[];return Mc&&Mc.call(t,function(b,D){w.push(d(D,t,!0)+" => "+d(b,t))}),qc("Map",tn.call(t),w,u)}if(W0(t)){var I=[];return Bc&&Bc.call(t,function(b){I.push(d(b,t))}),qc("Set",en.call(t),I,u)}if(V0(t))return aa("WeakMap");if(j0(t))return aa("WeakSet");if(z0(t))return aa("WeakRef");if(U0(t))return as(d(Number(t)));if(G0(t))return as(d(ra.call(t)));if(k0(t))return as(S0.call(t));if(N0(t))return as(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Ji<"u"&&t===Ji)return"{ [object globalThis] }";if(!F0(t)&&!zc(t)){var A=rn(t,d),C=kc?kc(t)===Object.prototype:t instanceof Object||t.constructor===Object,N=t instanceof Object?"":"null prototype",S=!C&&Qt&&Object(t)===t&&Qt in t?ea.call(_r(t),8,-1):N?"Object":"",R=C||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",E=R+(S||N?"["+ke.call(Lc.call([],S||[],N||[]),": ")+"] ":"");return A.length===0?E+"{}":u?E+"{"+la(A,u)+"}":E+"{ "+ke.call(A,", ")+" }"}return String(t)};function Vc(r,t,e){var i=e.quoteStyle||t,s=Xc[i];return s+r+s}function O0(r){return yr.call(String(r),/"/g,"&quot;")}function oa(r){return _r(r)==="[object Array]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function F0(r){return _r(r)==="[object Date]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function zc(r){return _r(r)==="[object RegExp]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function L0(r){return _r(r)==="[object Error]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function N0(r){return _r(r)==="[object String]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function U0(r){return _r(r)==="[object Number]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function k0(r){return _r(r)==="[object Boolean]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function Wc(r){if(bi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!sa)return!1;try{return sa.call(r),!0}catch{}return!1}function G0(r){if(!r||typeof r!="object"||!ra)return!1;try{return ra.call(r),!0}catch{}return!1}var $0=Object.prototype.hasOwnProperty||function(r){return r in this};function or(r,t){return $0.call(r,t)}function _r(r){return I0.call(r)}function H0(r){if(r.name)return r.name;var t=R0.call(C0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function jc(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function X0(r){if(!tn||!r||typeof r!="object")return!1;try{tn.call(r);try{en.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function V0(r){if(!ns||!r||typeof r!="object")return!1;try{ns.call(r,ns);try{os.call(r,os)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function z0(r){if(!Dc||!r||typeof r!="object")return!1;try{return Dc.call(r),!0}catch{}return!1}function W0(r){if(!en||!r||typeof r!="object")return!1;try{en.call(r);try{tn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function j0(r){if(!os||!r||typeof r!="object")return!1;try{os.call(r,os);try{ns.call(r,ns)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function Y0(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Yc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Yc(ea.call(r,0,t.maxStringLength),t)+i}var s=B0[t.quoteStyle||"single"];s.lastIndex=0;var n=yr.call(yr.call(r,s,"\\$1"),/[\x00-\x1f]/g,q0);return Vc(n,"single",t)}function q0(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+P0.call(t.toString(16))}function as(r){return"Object("+r+")"}function aa(r){return r+" { ? }"}function qc(r,t,e,i){var s=i?la(e,i):ke.call(e,", ");return r+" ("+t+") {"+s+"}"}function K0(r){for(var t=0;t<r.length;t++)if(jc(r[t],`
2
+ `)>=0)return!1;return!0}function Z0(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=ke.call(Array(r.indent+1)," ");else return null;return{base:e,prev:ke.call(Array(t+1),e)}}function la(r,t){if(r.length===0)return"";var e=`
3
3
  `+t.prev+t.base;return e+ke.call(r,","+e)+`
4
- `+t.prev}function on(r,t){var e=ca(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=yr(r,s)?t(r[s],r):""}var n=typeof aa=="function"?aa(r):[],o;if(bi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)yr(r,l)&&(e&&String(Number(l))===l&&l<r.length||bi&&o["$"+l]instanceof Symbol||(kc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof aa=="function")for(var h=0;h<n.length;h++)Hc.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var Qc=vi,wi=T0,t_=F0,e_=is,an=Qc("%WeakMap%",!0),ln=Qc("%Map%",!0),r_=wi("WeakMap.prototype.get",!0),i_=wi("WeakMap.prototype.set",!0),s_=wi("WeakMap.prototype.has",!0),n_=wi("Map.prototype.get",!0),o_=wi("Map.prototype.set",!0),a_=wi("Map.prototype.has",!0),fa=function(r,t){for(var e=r,i;(i=e.next)!==null;e=i)if(i.key===t)return e.next=i.next,i.next=r.next,r.next=i,i},l_=function(r,t){var e=fa(r,t);return e&&e.value},h_=function(r,t,e){var i=fa(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},c_=function(r,t){return!!fa(r,t)},u_=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new e_("Side channel does not contain "+t_(n))},get:function(n){if(an&&n&&(typeof n=="object"||typeof n=="function")){if(t)return r_(t,n)}else if(ln){if(e)return n_(e,n)}else if(i)return l_(i,n)},has:function(n){if(an&&n&&(typeof n=="object"||typeof n=="function")){if(t)return s_(t,n)}else if(ln){if(e)return a_(e,n)}else if(i)return c_(i,n);return!1},set:function(n,o){an&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new an),i_(t,n,o)):ln?(e||(e=new ln),o_(e,n,o)):(i||(i={key:{},next:null}),h_(i,n,o))}};return s},d_=String.prototype.replace,f_=/%20/g,pa={RFC1738:"RFC1738",RFC3986:"RFC3986"},ma={default:pa.RFC3986,formatters:{RFC1738:function(r){return d_.call(r,f_,"+")},RFC3986:function(r){return String(r)}},RFC1738:pa.RFC1738,RFC3986:pa.RFC3986},p_=ma,ga=Object.prototype.hasOwnProperty,Ur=Array.isArray,Ge=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),m_=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Ur(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},tu=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},g_=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Ur(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!ga.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Ur(t)&&!Ur(e)&&(s=tu(t,i)),Ur(t)&&Ur(e)?(e.forEach(function(n,o){if(ga.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return ga.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},y_=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},__=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},ya=1024,v_=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=ya){for(var h=o.length>=ya?o.slice(l,l+ya):o,c=[],u=0;u<h.length;++u){var d=h.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===p_.RFC1738&&(d===40||d===41)){c[c.length]=h.charAt(u);continue}if(d<128){c[c.length]=Ge[d];continue}if(d<2048){c[c.length]=Ge[192|d>>6]+Ge[128|d&63];continue}if(d<55296||d>=57344){c[c.length]=Ge[224|d>>12]+Ge[128|d>>6&63]+Ge[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|h.charCodeAt(u)&1023),c[c.length]=Ge[240|d>>18]+Ge[128|d>>12&63]+Ge[128|d>>6&63]+Ge[128|d&63]}a+=c.join("")}return a},x_=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return m_(e),t},b_=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},w_=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},E_=function(t,e){return[].concat(t,e)},T_=function(t,e){if(Ur(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},eu={arrayToObject:tu,assign:y_,combine:E_,compact:x_,decode:__,encode:v_,isBuffer:w_,isRegExp:b_,maybeMap:T_,merge:g_},ru=u_,hn=eu,ls=ma,A_=Object.prototype.hasOwnProperty,iu={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},$e=Array.isArray,S_=Array.prototype.push,su=function(r,t){S_.apply(r,$e(t)?t:[t])},I_=Date.prototype.toISOString,nu=ls.default,Lt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:hn.encode,encodeValuesOnly:!1,format:nu,formatter:ls.formatters[nu],indices:!1,serializeDate:function(t){return I_.call(t)},skipNulls:!1,strictNullHandling:!1},C_=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},_a={},R_=function r(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x){for(var g=t,v=x,w=0,I=!1;(v=v.get(_a))!==void 0&&!I;){var A=v.get(t);if(w+=1,typeof A<"u"){if(A===w)throw new RangeError("Cyclic object value");I=!0}typeof v.get(_a)>"u"&&(w=0)}if(typeof c=="function"?g=c(e,g):g instanceof Date?g=f(g):i==="comma"&&$e(g)&&(g=hn.maybeMap(g,function(P){return P instanceof Date?f(P):P})),g===null){if(o)return h&&!_?h(e,Lt.encoder,y,"key",p):e;g=""}if(C_(g)||hn.isBuffer(g)){if(h){var C=_?e:h(e,Lt.encoder,y,"key",p);return[m(C)+"="+m(h(g,Lt.encoder,y,"value",p))]}return[m(e)+"="+m(String(g))]}var N=[];if(typeof g>"u")return N;var S;if(i==="comma"&&$e(g))_&&h&&(g=hn.maybeMap(g,h)),S=[{value:g.length>0?g.join(",")||null:void 0}];else if($e(c))S=c;else{var R=Object.keys(g);S=u?R.sort(u):R}var E=l?e.replace(/\./g,"%2E"):e,b=s&&$e(g)&&g.length===1?E+"[]":E;if(n&&$e(g)&&g.length===0)return b+"[]";for(var D=0;D<S.length;++D){var F=S[D],G=typeof F=="object"&&typeof F.value<"u"?F.value:g[F];if(!(a&&G===null)){var $=d&&l?F.replace(/\./g,"%2E"):F,B=$e(g)?typeof i=="function"?i(b,$):b:b+(d?"."+$:"["+$+"]");x.set(t,w);var Z=ru();Z.set(_a,x),su(N,r(G,B,i,s,n,o,a,l,i==="comma"&&_&&$e(g)?null:h,c,u,d,f,p,m,_,y,Z))}}return N},P_=function(t){if(!t)return Lt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Lt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=ls.default;if(typeof t.format<"u"){if(!A_.call(ls.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=ls.formatters[i],n=Lt.filter;(typeof t.filter=="function"||$e(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in iu?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Lt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var a=typeof t.allowDots>"u"?t.encodeDotInKeys===!0?!0:Lt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Lt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Lt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Lt.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Lt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Lt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Lt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Lt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Lt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Lt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Lt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Lt.strictNullHandling}},M_=function(r,t){var e=r,i=P_(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):$e(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=iu[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=ru(),c=0;c<s.length;++c){var u=s[c];i.skipNulls&&e[u]===null||su(o,R_(e[u],u,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var d=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""},Ei=eu,va=Object.prototype.hasOwnProperty,B_=Array.isArray,Pt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:Ei.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},D_=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},ou=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},O_="utf8=%26%2310003%3B",F_="utf8=%E2%9C%93",L_=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,n),a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===F_?h="utf-8":o[l]===O_&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Pt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Pt.decoder,h,"key"),p=Ei.maybeMap(ou(c.slice(d+1),e),function(_){return e.decoder(_,Pt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=D_(p)),c.indexOf("[]=")>-1&&(p=B_(p)?[p]:p);var m=va.call(i,f);m&&e.duplicates==="combine"?i[f]=Ei.combine(i[f],p):(!m||e.duplicates==="last")&&(i[f]=p)}return i},N_=function(r,t,e,i){for(var s=i?t:ou(t,e),n=r.length-1;n>=0;--n){var o,a=r[n];if(a==="[]"&&e.parseArrays)o=e.allowEmptyArrays&&(s===""||e.strictNullHandling&&s===null)?[]:[].concat(s);else{o=e.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=e.decodeDotInKeys?l.replace(/%2E/g,"."):l,c=parseInt(h,10);!e.parseArrays&&h===""?o={0:s}:!isNaN(c)&&a!==h&&String(c)===h&&c>=0&&e.parseArrays&&c<=e.arrayLimit?(o=[],o[c]=s):h!=="__proto__"&&(o[h]=s)}s=o}return s},U_=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,c=[];if(h){if(!i.plainObjects&&va.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(n))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&va.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");c.push("["+n.slice(l.index)+"]")}return N_(c,e,i,s)}},k_=function(t){if(!t)return Pt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.decodeDotInKeys<"u"&&typeof t.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(t.decoder!==null&&typeof t.decoder<"u"&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?Pt.charset:t.charset,i=typeof t.duplicates>"u"?Pt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Pt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Pt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Pt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Pt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Pt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Pt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Pt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Pt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Pt.decoder,delimiter:typeof t.delimiter=="string"||Ei.isRegExp(t.delimiter)?t.delimiter:Pt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Pt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Pt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Pt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Pt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Pt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Pt.strictNullHandling}},G_=function(r,t){var e=k_(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?L_(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=U_(a,i[a],e,typeof r=="string");s=Ei.merge(s,l,e)}return e.allowSparse===!0?s:Ei.compact(s)},$_=M_,H_=G_,X_=ma,V_={formats:X_,parse:H_,stringify:$_},z_=Cy;function or(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var W_=/^([a-z0-9.+-]+:)/i,j_=/:[0-9]*$/,Y_=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,q_=["<",">",'"',"`"," ","\r",`
5
- `," "],K_=["{","}","|","\\","^","`"].concat(q_),xa=["'"].concat(K_),au=["%","/","?",";","#"].concat(xa),lu=["/","?","#"],Z_=255,hu=/^[+a-z0-9A-Z_-]{0,63}$/,J_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Q_={javascript:!0,"javascript:":!0},ba={javascript:!0,"javascript:":!0},Ti={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},wa=V_;function tv(r,t,e){if(r&&typeof r=="object"&&r instanceof or)return r;var i=new or;return i.parse(r,t,e),i}or.prototype.parse=function(r,t,e){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=Y_.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=wa.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=W_.exec(a);if(h){h=h[0];var c=h.toLowerCase();this.protocol=c,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var u=a.substr(0,2)==="//";u&&!(h&&ba[h])&&(a=a.substr(2),this.slashes=!0)}if(!ba[h]&&(u||h&&!Ti[h])){for(var d=-1,f=0;f<lu.length;f++){var p=a.indexOf(lu[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,_;d===-1?_=a.lastIndexOf("@"):_=a.lastIndexOf("@",d),_!==-1&&(m=a.slice(0,_),a=a.slice(_+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<au.length;f++){var p=a.indexOf(au[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var y=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!y)for(var x=this.hostname.split(/\./),f=0,g=x.length;f<g;f++){var v=x[f];if(v&&!v.match(hu)){for(var w="",I=0,A=v.length;I<A;I++)v.charCodeAt(I)>127?w+="x":w+=v[I];if(!w.match(hu)){var C=x.slice(0,f),N=x.slice(f+1),S=v.match(J_);S&&(C.push(S[1]),N.unshift(S[2])),N.length&&(a="/"+N.join(".")+a),this.hostname=C.join(".");break}}}this.hostname.length>Z_?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=z_.toASCII(this.hostname));var R=this.port?":"+this.port:"",E=this.hostname||"";this.host=E+R,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Q_[c])for(var f=0,g=xa.length;f<g;f++){var b=xa[f];if(a.indexOf(b)!==-1){var D=encodeURIComponent(b);D===b&&(D=escape(b)),a=a.split(b).join(D)}}var F=a.indexOf("#");F!==-1&&(this.hash=a.substr(F),a=a.slice(0,F));var G=a.indexOf("?");if(G!==-1?(this.search=a.substr(G),this.query=a.substr(G+1),t&&(this.query=wa.parse(this.query)),a=a.slice(0,G)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Ti[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var R=this.pathname||"",$=this.search||"";this.path=R+$}return this.href=this.format(),this},or.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=wa.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Ti[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i},or.prototype.resolve=function(r){return this.resolveObject(tv(r,!1,!0)).format()},or.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new or;t.parse(r,!1,!0),r=t}for(var e=new or,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return Ti[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(r.protocol&&r.protocol!==e.protocol){if(!Ti[r.protocol]){for(var h=Object.keys(r),c=0;c<h.length;c++){var u=h[c];e[u]=r[u]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!ba[r.protocol]){for(var g=(r.pathname||"").split("/");g.length&&!(r.host=g.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),g[0]!==""&&g.unshift(""),g.length<2&&g.unshift(""),e.pathname=g.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",_=m||p||e.host&&r.pathname,y=_,x=e.pathname&&e.pathname.split("/")||[],g=r.pathname&&r.pathname.split("/")||[],v=e.protocol&&!Ti[e.protocol];if(v&&(e.hostname="",e.port=null,e.host&&(x[0]===""?x[0]=e.host:x.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(g[0]===""?g[0]=r.host:g.unshift(r.host)),r.host=null),_=_&&(g[0]===""||x[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,x=g;else if(g.length)x||(x=[]),x.pop(),x=x.concat(g),e.search=r.search,e.query=r.query;else if(r.search!=null){if(v){e.host=x.shift(),e.hostname=e.host;var w=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;w&&(e.auth=w.shift(),e.hostname=w.shift(),e.host=e.hostname)}return e.search=r.search,e.query=r.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!x.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var I=x.slice(-1)[0],A=(e.host||r.host||x.length>1)&&(I==="."||I==="..")||I==="",C=0,N=x.length;N>=0;N--)I=x[N],I==="."?x.splice(N,1):I===".."?(x.splice(N,1),C++):C&&(x.splice(N,1),C--);if(!_&&!y)for(;C--;C)x.unshift("..");_&&x[0]!==""&&(!x[0]||x[0].charAt(0)!=="/")&&x.unshift(""),A&&x.join("/").substr(-1)!=="/"&&x.push("");var S=x[0]===""||x[0]&&x[0].charAt(0)==="/";if(v){e.hostname=S?"":x.length?x.shift():"",e.host=e.hostname;var w=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;w&&(e.auth=w.shift(),e.hostname=w.shift(),e.host=e.hostname)}return _=_||e.host&&x.length,_&&!S&&x.unshift(""),x.length>0?e.pathname=x.join("/"):(e.pathname=null,e.path=null),(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=r.auth||e.auth,e.slashes=e.slashes||r.slashes,e.href=e.format(),e},or.prototype.parseHost=function(){var r=this.host,t=j_.exec(r);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),r=r.substr(0,r.length-t.length)),r&&(this.hostname=r)};const cu={};function dt(r,t,e=3){if(cu[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
4
+ `+t.prev}function rn(r,t){var e=oa(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=or(r,s)?t(r[s],r):""}var n=typeof ia=="function"?ia(r):[],o;if(bi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)or(r,l)&&(e&&String(Number(l))===l&&l<r.length||bi&&o["$"+l]instanceof Symbol||(Fc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof ia=="function")for(var h=0;h<n.length;h++)Uc.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var Kc=vi,wi=b0,J0=D0,Q0=is,sn=Kc("%WeakMap%",!0),nn=Kc("%Map%",!0),t_=wi("WeakMap.prototype.get",!0),e_=wi("WeakMap.prototype.set",!0),r_=wi("WeakMap.prototype.has",!0),i_=wi("Map.prototype.get",!0),s_=wi("Map.prototype.set",!0),n_=wi("Map.prototype.has",!0),ha=function(r,t){for(var e=r,i;(i=e.next)!==null;e=i)if(i.key===t)return e.next=i.next,i.next=r.next,r.next=i,i},o_=function(r,t){var e=ha(r,t);return e&&e.value},a_=function(r,t,e){var i=ha(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},l_=function(r,t){return!!ha(r,t)},h_=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new Q0("Side channel does not contain "+J0(n))},get:function(n){if(sn&&n&&(typeof n=="object"||typeof n=="function")){if(t)return t_(t,n)}else if(nn){if(e)return i_(e,n)}else if(i)return o_(i,n)},has:function(n){if(sn&&n&&(typeof n=="object"||typeof n=="function")){if(t)return r_(t,n)}else if(nn){if(e)return n_(e,n)}else if(i)return l_(i,n);return!1},set:function(n,o){sn&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new sn),e_(t,n,o)):nn?(e||(e=new nn),s_(e,n,o)):(i||(i={key:{},next:null}),a_(i,n,o))}};return s},c_=String.prototype.replace,u_=/%20/g,ca={RFC1738:"RFC1738",RFC3986:"RFC3986"},ua={default:ca.RFC3986,formatters:{RFC1738:function(r){return c_.call(r,u_,"+")},RFC3986:function(r){return String(r)}},RFC1738:ca.RFC1738,RFC3986:ca.RFC3986},d_=ua,da=Object.prototype.hasOwnProperty,Ur=Array.isArray,Ge=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),f_=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Ur(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},Zc=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},p_=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Ur(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!da.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Ur(t)&&!Ur(e)&&(s=Zc(t,i)),Ur(t)&&Ur(e)?(e.forEach(function(n,o){if(da.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return da.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},m_=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},g_=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},fa=1024,y_=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=fa){for(var h=o.length>=fa?o.slice(l,l+fa):o,c=[],u=0;u<h.length;++u){var d=h.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===d_.RFC1738&&(d===40||d===41)){c[c.length]=h.charAt(u);continue}if(d<128){c[c.length]=Ge[d];continue}if(d<2048){c[c.length]=Ge[192|d>>6]+Ge[128|d&63];continue}if(d<55296||d>=57344){c[c.length]=Ge[224|d>>12]+Ge[128|d>>6&63]+Ge[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|h.charCodeAt(u)&1023),c[c.length]=Ge[240|d>>18]+Ge[128|d>>12&63]+Ge[128|d>>6&63]+Ge[128|d&63]}a+=c.join("")}return a},__=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return f_(e),t},v_=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},x_=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},b_=function(t,e){return[].concat(t,e)},w_=function(t,e){if(Ur(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},Jc={arrayToObject:Zc,assign:m_,combine:b_,compact:__,decode:g_,encode:y_,isBuffer:x_,isRegExp:v_,maybeMap:w_,merge:p_},Qc=h_,on=Jc,ls=ua,E_=Object.prototype.hasOwnProperty,tu={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},$e=Array.isArray,T_=Array.prototype.push,eu=function(r,t){T_.apply(r,$e(t)?t:[t])},A_=Date.prototype.toISOString,ru=ls.default,Lt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:on.encode,encodeValuesOnly:!1,format:ru,formatter:ls.formatters[ru],indices:!1,serializeDate:function(t){return A_.call(t)},skipNulls:!1,strictNullHandling:!1},S_=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},pa={},I_=function r(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x){for(var g=t,v=x,w=0,I=!1;(v=v.get(pa))!==void 0&&!I;){var A=v.get(t);if(w+=1,typeof A<"u"){if(A===w)throw new RangeError("Cyclic object value");I=!0}typeof v.get(pa)>"u"&&(w=0)}if(typeof c=="function"?g=c(e,g):g instanceof Date?g=f(g):i==="comma"&&$e(g)&&(g=on.maybeMap(g,function(P){return P instanceof Date?f(P):P})),g===null){if(o)return h&&!_?h(e,Lt.encoder,y,"key",p):e;g=""}if(S_(g)||on.isBuffer(g)){if(h){var C=_?e:h(e,Lt.encoder,y,"key",p);return[m(C)+"="+m(h(g,Lt.encoder,y,"value",p))]}return[m(e)+"="+m(String(g))]}var N=[];if(typeof g>"u")return N;var S;if(i==="comma"&&$e(g))_&&h&&(g=on.maybeMap(g,h)),S=[{value:g.length>0?g.join(",")||null:void 0}];else if($e(c))S=c;else{var R=Object.keys(g);S=u?R.sort(u):R}var E=l?e.replace(/\./g,"%2E"):e,b=s&&$e(g)&&g.length===1?E+"[]":E;if(n&&$e(g)&&g.length===0)return b+"[]";for(var D=0;D<S.length;++D){var F=S[D],G=typeof F=="object"&&typeof F.value<"u"?F.value:g[F];if(!(a&&G===null)){var $=d&&l?F.replace(/\./g,"%2E"):F,B=$e(g)?typeof i=="function"?i(b,$):b:b+(d?"."+$:"["+$+"]");x.set(t,w);var K=Qc();K.set(pa,x),eu(N,r(G,B,i,s,n,o,a,l,i==="comma"&&_&&$e(g)?null:h,c,u,d,f,p,m,_,y,K))}}return N},C_=function(t){if(!t)return Lt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Lt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=ls.default;if(typeof t.format<"u"){if(!E_.call(ls.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=ls.formatters[i],n=Lt.filter;(typeof t.filter=="function"||$e(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in tu?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Lt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var a=typeof t.allowDots>"u"?t.encodeDotInKeys===!0?!0:Lt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Lt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Lt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Lt.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Lt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Lt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Lt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Lt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Lt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Lt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Lt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Lt.strictNullHandling}},R_=function(r,t){var e=r,i=C_(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):$e(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=tu[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=Qc(),c=0;c<s.length;++c){var u=s[c];i.skipNulls&&e[u]===null||eu(o,I_(e[u],u,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var d=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""},Ei=Jc,ma=Object.prototype.hasOwnProperty,P_=Array.isArray,Pt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:Ei.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},M_=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},iu=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},B_="utf8=%26%2310003%3B",D_="utf8=%E2%9C%93",O_=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,n),a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===D_?h="utf-8":o[l]===B_&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Pt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Pt.decoder,h,"key"),p=Ei.maybeMap(iu(c.slice(d+1),e),function(_){return e.decoder(_,Pt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=M_(p)),c.indexOf("[]=")>-1&&(p=P_(p)?[p]:p);var m=ma.call(i,f);m&&e.duplicates==="combine"?i[f]=Ei.combine(i[f],p):(!m||e.duplicates==="last")&&(i[f]=p)}return i},F_=function(r,t,e,i){for(var s=i?t:iu(t,e),n=r.length-1;n>=0;--n){var o,a=r[n];if(a==="[]"&&e.parseArrays)o=e.allowEmptyArrays&&(s===""||e.strictNullHandling&&s===null)?[]:[].concat(s);else{o=e.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=e.decodeDotInKeys?l.replace(/%2E/g,"."):l,c=parseInt(h,10);!e.parseArrays&&h===""?o={0:s}:!isNaN(c)&&a!==h&&String(c)===h&&c>=0&&e.parseArrays&&c<=e.arrayLimit?(o=[],o[c]=s):h!=="__proto__"&&(o[h]=s)}s=o}return s},L_=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,c=[];if(h){if(!i.plainObjects&&ma.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(n))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&ma.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");c.push("["+n.slice(l.index)+"]")}return F_(c,e,i,s)}},N_=function(t){if(!t)return Pt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.decodeDotInKeys<"u"&&typeof t.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(t.decoder!==null&&typeof t.decoder<"u"&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?Pt.charset:t.charset,i=typeof t.duplicates>"u"?Pt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Pt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Pt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Pt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Pt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Pt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Pt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Pt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Pt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Pt.decoder,delimiter:typeof t.delimiter=="string"||Ei.isRegExp(t.delimiter)?t.delimiter:Pt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Pt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Pt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Pt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Pt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Pt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Pt.strictNullHandling}},U_=function(r,t){var e=N_(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?O_(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=L_(a,i[a],e,typeof r=="string");s=Ei.merge(s,l,e)}return e.allowSparse===!0?s:Ei.compact(s)},k_=R_,G_=U_,$_=ua,H_={formats:$_,parse:G_,stringify:k_},X_=Ay;function ar(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var V_=/^([a-z0-9.+-]+:)/i,z_=/:[0-9]*$/,W_=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,j_=["<",">",'"',"`"," ","\r",`
5
+ `," "],Y_=["{","}","|","\\","^","`"].concat(j_),ga=["'"].concat(Y_),su=["%","/","?",";","#"].concat(ga),nu=["/","?","#"],q_=255,ou=/^[+a-z0-9A-Z_-]{0,63}$/,K_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Z_={javascript:!0,"javascript:":!0},ya={javascript:!0,"javascript:":!0},Ti={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},_a=H_;function J_(r,t,e){if(r&&typeof r=="object"&&r instanceof ar)return r;var i=new ar;return i.parse(r,t,e),i}ar.prototype.parse=function(r,t,e){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=W_.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=_a.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=V_.exec(a);if(h){h=h[0];var c=h.toLowerCase();this.protocol=c,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var u=a.substr(0,2)==="//";u&&!(h&&ya[h])&&(a=a.substr(2),this.slashes=!0)}if(!ya[h]&&(u||h&&!Ti[h])){for(var d=-1,f=0;f<nu.length;f++){var p=a.indexOf(nu[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,_;d===-1?_=a.lastIndexOf("@"):_=a.lastIndexOf("@",d),_!==-1&&(m=a.slice(0,_),a=a.slice(_+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<su.length;f++){var p=a.indexOf(su[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var y=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!y)for(var x=this.hostname.split(/\./),f=0,g=x.length;f<g;f++){var v=x[f];if(v&&!v.match(ou)){for(var w="",I=0,A=v.length;I<A;I++)v.charCodeAt(I)>127?w+="x":w+=v[I];if(!w.match(ou)){var C=x.slice(0,f),N=x.slice(f+1),S=v.match(K_);S&&(C.push(S[1]),N.unshift(S[2])),N.length&&(a="/"+N.join(".")+a),this.hostname=C.join(".");break}}}this.hostname.length>q_?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=X_.toASCII(this.hostname));var R=this.port?":"+this.port:"",E=this.hostname||"";this.host=E+R,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Z_[c])for(var f=0,g=ga.length;f<g;f++){var b=ga[f];if(a.indexOf(b)!==-1){var D=encodeURIComponent(b);D===b&&(D=escape(b)),a=a.split(b).join(D)}}var F=a.indexOf("#");F!==-1&&(this.hash=a.substr(F),a=a.slice(0,F));var G=a.indexOf("?");if(G!==-1?(this.search=a.substr(G),this.query=a.substr(G+1),t&&(this.query=_a.parse(this.query)),a=a.slice(0,G)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Ti[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var R=this.pathname||"",$=this.search||"";this.path=R+$}return this.href=this.format(),this},ar.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=_a.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Ti[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i},ar.prototype.resolve=function(r){return this.resolveObject(J_(r,!1,!0)).format()},ar.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new ar;t.parse(r,!1,!0),r=t}for(var e=new ar,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return Ti[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(r.protocol&&r.protocol!==e.protocol){if(!Ti[r.protocol]){for(var h=Object.keys(r),c=0;c<h.length;c++){var u=h[c];e[u]=r[u]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!ya[r.protocol]){for(var g=(r.pathname||"").split("/");g.length&&!(r.host=g.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),g[0]!==""&&g.unshift(""),g.length<2&&g.unshift(""),e.pathname=g.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",_=m||p||e.host&&r.pathname,y=_,x=e.pathname&&e.pathname.split("/")||[],g=r.pathname&&r.pathname.split("/")||[],v=e.protocol&&!Ti[e.protocol];if(v&&(e.hostname="",e.port=null,e.host&&(x[0]===""?x[0]=e.host:x.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(g[0]===""?g[0]=r.host:g.unshift(r.host)),r.host=null),_=_&&(g[0]===""||x[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,x=g;else if(g.length)x||(x=[]),x.pop(),x=x.concat(g),e.search=r.search,e.query=r.query;else if(r.search!=null){if(v){e.host=x.shift(),e.hostname=e.host;var w=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;w&&(e.auth=w.shift(),e.hostname=w.shift(),e.host=e.hostname)}return e.search=r.search,e.query=r.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!x.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var I=x.slice(-1)[0],A=(e.host||r.host||x.length>1)&&(I==="."||I==="..")||I==="",C=0,N=x.length;N>=0;N--)I=x[N],I==="."?x.splice(N,1):I===".."?(x.splice(N,1),C++):C&&(x.splice(N,1),C--);if(!_&&!y)for(;C--;C)x.unshift("..");_&&x[0]!==""&&(!x[0]||x[0].charAt(0)!=="/")&&x.unshift(""),A&&x.join("/").substr(-1)!=="/"&&x.push("");var S=x[0]===""||x[0]&&x[0].charAt(0)==="/";if(v){e.hostname=S?"":x.length?x.shift():"",e.host=e.hostname;var w=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;w&&(e.auth=w.shift(),e.hostname=w.shift(),e.host=e.hostname)}return _=_||e.host&&x.length,_&&!S&&x.unshift(""),x.length>0?e.pathname=x.join("/"):(e.pathname=null,e.path=null),(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=r.auth||e.auth,e.slashes=e.slashes||r.slashes,e.href=e.format(),e},ar.prototype.parseHost=function(){var r=this.host,t=z_.exec(r);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),r=r.substr(0,r.length-t.length)),r&&(this.hostname=r)};const au={};function dt(r,t,e=3){if(au[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
6
6
  Deprecated since v${r}`):(i=i.split(`
7
7
  `).splice(e).join(`
8
8
  `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
9
9
  Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
10
- Deprecated since v${r}`),console.warn(i))),cu[t]=!0}function be(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function hs(r){return r.split("?")[0].split("#")[0]}function ev(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rv(r,t,e){return r.replace(new RegExp(ev(t),"g"),e)}function iv(r,t){let e="",i=0,s=-1,n=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(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const Gt={toPosix(r){return rv(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){be(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(be(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=hs(this.toPosix(t??W.ADAPTER.getBaseUrl())),s=hs(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Gt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(be(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=iv(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return be(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(be(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(be(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){be(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){be(r),t&&be(t),r=hs(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){be(r),r=hs(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){be(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=hs(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Ea;async function sv(){return Ea??(Ea=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return ie.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 ie.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?ie.PMA:ie.UNPACK})()),Ea}let Ta;function nv(){return typeof Ta>"u"&&(Ta=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!W.ADAPTER.getWebGLRenderingContext())return!1;const e=W.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),Ta}var ov={grad:.9,turn:360,rad:360/(2*Math.PI)},ar=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},$t=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},pe=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},uu=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},du=function(r){return{r:pe(r.r,0,255),g:pe(r.g,0,255),b:pe(r.b,0,255),a:pe(r.a)}},Aa=function(r){return{r:$t(r.r),g:$t(r.g),b:$t(r.b),a:$t(r.a,3)}},av=/^#([0-9a-f]{3,8})$/i,cn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},fu=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},pu=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%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:s}},mu=function(r){return{h:uu(r.h),s:pe(r.s,0,100),l:pe(r.l,0,100),a:pe(r.a)}},gu=function(r){return{h:$t(r.h),s:$t(r.s),l:$t(r.l),a:$t(r.a,3)}},yu=function(r){return pu((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},cs=function(r){return{h:(t=fu(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},lv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,uv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sa={string:[[function(r){var t=av.exec(r);return t?(r=t[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?$t(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?$t(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=cv.exec(r)||uv.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:du({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=lv.exec(r)||hv.exec(r);if(!t)return null;var e,i,s=mu({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(ov[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return yu(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return ar(t)&&ar(e)&&ar(i)?du({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!ar(t)||!ar(e)||!ar(i))return null;var o=mu({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return yu(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!ar(t)||!ar(e)||!ar(i))return null;var o=function(a){return{h:uu(a.h),s:pe(a.s,0,100),v:pe(a.v,0,100),a:pe(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return pu(o)},"hsv"]]},_u=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},dv=function(r){return typeof r=="string"?_u(r.trim(),Sa.string):typeof r=="object"&&r!==null?_u(r,Sa.object):[null,void 0]},Ia=function(r,t){var e=cs(r);return{h:e.h,s:pe(e.s+100*t,0,100),l:e.l,a:e.a}},Ca=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},vu=function(r,t){var e=cs(r);return{h:e.h,s:e.s,l:pe(e.l+100*t,0,100),a:e.a}},Ra=function(){function r(t){this.parsed=dv(t)[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 $t(Ca(this.rgba),2)},r.prototype.isDark=function(){return Ca(this.rgba)<.5},r.prototype.isLight=function(){return Ca(this.rgba)>=.5},r.prototype.toHex=function(){return t=Aa(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?cn($t(255*n)):"","#"+cn(e)+cn(i)+cn(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return Aa(this.rgba)},r.prototype.toRgbString=function(){return t=Aa(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return gu(cs(this.rgba))},r.prototype.toHslString=function(){return t=gu(cs(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=fu(this.rgba),{h:$t(t.h),s:$t(t.s),v:$t(t.v),a:$t(t.a,3)};var t},r.prototype.invert=function(){return He({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),He(Ia(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),He(Ia(this.rgba,-t))},r.prototype.grayscale=function(){return He(Ia(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),He(vu(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),He(vu(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?He({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):$t(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=cs(this.rgba);return typeof t=="number"?He({h:t,s:e.s,l:e.l,a:e.a}):$t(e.h)},r.prototype.isEqual=function(t){return this.toHex()===He(t).toHex()},r}(),He=function(r){return r instanceof Ra?r:new Ra(r)},xu=[],fv=function(r){r.forEach(function(t){xu.indexOf(t)<0&&(t(Ra,Sa),xu.push(t))})};function pv(r,t){var e={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 s in e)i[e[s]]=s;var n={};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 c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var p in e){var m=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<u&&(u=m,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}fv([pv]);const Ai=class ro{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}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(t){return this.value=t,this}set value(t){if(t instanceof ro)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=ro.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=ro.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=He(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};Ai.shared=new Ai,Ai.temp=new Ai,Ai.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let bt=Ai;function mv(r){return dt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),bt.shared.setValue(r).toHex()}function gv(r){return dt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),bt.shared.setValue(r).toNumber()}function yv(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[tt.NORMAL_NPM]=tt.NORMAL,r[tt.ADD_NPM]=tt.ADD,r[tt.SCREEN_NPM]=tt.SCREEN,t[tt.NORMAL]=tt.NORMAL_NPM,t[tt.ADD]=tt.ADD_NPM,t[tt.SCREEN]=tt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const bu=yv();function wu(r,t){return bu[t?1:0][r]}function _v(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function Eu(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 un(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 Tu(r){return!(r&r-1)&&!!r}function Au(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Si(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function vr(r){return r===0?0:r<0?-1:1}let vv=0;function kr(){return++vv}const Pa=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,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}};Pa.EMPTY=new Pa(0,0,0,0);let Su=Pa;const Iu={},Xe=Object.create(null),xr=Object.create(null);class xv{constructor(t,e,i){this._canvas=W.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||W.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}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 Cu(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Ru(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function bv(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&Cu(s,t,o);)++o;if(o===e)return Su.EMPTY;for(;Cu(s,t,l);)--l;for(;Ru(s,t,n,o,l);)++n;for(;Ru(s,t,a,o,l);)--a;return++a,++l,new Su(n,o,a,l)}function wv(r){const t=bv(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function Ev(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function lr(r,t=1){var i;const e=(i=W.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var X=(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))(X||{});const Ma=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},Pu=(r,t)=>Ma(r).priority??t,Y={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ma).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(Ma).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(o=s[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>Pu(n,e)-Pu(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class Ba{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,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(t){return this[`${t}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(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const Tv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
- `);function Av(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
12
- else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Sv(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=Tv.replace(/%forloop%/gi,Av(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const Da=0,Oa=1,Fa=2,La=3,Na=4,Ua=5;class Ve{constructor(){this.data=0,this.blendMode=tt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Da)}set blend(t){!!(this.data&1<<Da)!==t&&(this.data^=1<<Da)}get offsets(){return!!(this.data&1<<Oa)}set offsets(t){!!(this.data&1<<Oa)!==t&&(this.data^=1<<Oa)}get culling(){return!!(this.data&1<<Fa)}set culling(t){!!(this.data&1<<Fa)!==t&&(this.data^=1<<Fa)}get depthTest(){return!!(this.data&1<<La)}set depthTest(t){!!(this.data&1<<La)!==t&&(this.data^=1<<La)}get depthMask(){return!!(this.data&1<<Ua)}set depthMask(t){!!(this.data&1<<Ua)!==t&&(this.data^=1<<Ua)}get clockwiseFrontFace(){return!!(this.data&1<<Na)}set clockwiseFrontFace(t){!!(this.data&1<<Na)!==t&&(this.data^=1<<Na)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==tt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Ve;return t.depthTest=!1,t.blend=!0,t}}Ve.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const ka=[];function Mu(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=ka.length-1;i>=0;--i){const s=ka[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class we{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][h](t,e,i,s,n,o,a,l);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}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(we.prototype,{dispatch:{value:we.prototype.emit},run:{value:we.prototype.emit}});class us{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new we("setRealSize"),this.onUpdate=new we("update"),this.onError=new we("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}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(t,e,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(t,e){return!1}}class dn extends us{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ie.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const Iv={scaleMode:ir.NEAREST,alphaMode:ie.NPM},Ga=class ki extends Qi{constructor(t=null,e=null){super(),e=Object.assign({},ki.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof us)&&(t=Mu(t,p),t.internal=!0),this.resolution=f||W.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=i,this.uid=kr(),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(t)}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(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Tu(this.realWidth)&&Tu(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,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(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete xr[this.cacheId],delete Xe[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),ki.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=W.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${kr()}`}n=t._pixiId}let o=xr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new ki(t,e),o.cacheId=n,ki.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new dn(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=k.RGBA,a=J.FLOAT):t instanceof Int32Array?(o=k.RGBA_INTEGER,a=J.INT):t instanceof Uint32Array?(o=k.RGBA_INTEGER,a=J.UNSIGNED_INT):t instanceof Int16Array?(o=k.RGBA_INTEGER,a=J.SHORT):t instanceof Uint16Array?(o=k.RGBA_INTEGER,a=J.UNSIGNED_SHORT):t instanceof Int8Array?(o=k.RGBA,a=J.BYTE):(o=k.RGBA,a=J.UNSIGNED_BYTE),n.internal=!0,new ki(n,Object.assign({},Iv,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),xr[e]&&xr[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),xr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=xr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete xr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete xr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Ga.defaultOptions={mipmap:Le.POW2,anisotropicLevel:0,scaleMode:ir.LINEAR,wrapMode:mr.CLAMP,alphaMode:ie.UNPACK,target:di.TEXTURE_2D,format:k.RGBA,type:J.UNSIGNED_BYTE},Ga._globalBatch=0;let nt=Ga;class $a{constructor(){this.texArray=null,this.blend=0,this.type=Fe.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Cv=0;class Bt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=Cv++,this.disposeRunner=new we("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Ue.ELEMENT_ARRAY_BUFFER:Ue.ARRAY_BUFFER}get index(){return this.type===Ue.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Bt(t)}}class fn{constructor(t,e=0,i=!1,s=J.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new fn(t,e,i,s,n)}}const Rv={Float32Array,Uint32Array,Int32Array,Uint8Array};function Pv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=Eu(c);s[u]||(s[u]=new Rv[u](n)),o=s[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(n)}const Bu={5126:4,5123:2,5121:1};let Mv=0;const Bv={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class br{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Mv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new we("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Bt||(e instanceof Array&&(e=new Float32Array(e)),e=new Bt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,s,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new fn(c,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Bt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Bt(t)),t.type=Ue.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Bt;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*Bu[n.type]/4),n.buffer=0}for(i.data=Pv(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new br;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Bt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new fn(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Ue.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new br,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new Bv[Eu(o.buffers[a].data)](s[a]),e.buffers[a]=new Bt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Ue.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*Bu[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class Du extends br{constructor(t=!1){super(),this._buffer=new Bt(null,t,!1),this._indexBuffer=new Bt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,J.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,J.FLOAT).addAttribute("aColor",this._buffer,4,!0,J.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,J.FLOAT).addIndex(this._indexBuffer)}}const pn=Math.PI*2,Dv=180/Math.PI,Ov=Math.PI/180;var Wt=(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))(Wt||{});class gt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new gt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}gt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const mn=[new gt,new gt,new gt,new gt];class at{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Wt.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 at(0,0,0,0)}clone(){return new at(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const C=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=C)return!1;const N=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>N}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=mn[0].set(t.left,t.top),l=mn[1].set(t.left,t.bottom),h=mn[2].set(t.right,t.top),c=mn[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=s||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*i+f*n,m=d*s+f*n,_=d*i+f*o,y=d*s+f*o;if(Math.max(p,m,_,y)<=d*a.x+f*a.y||Math.min(p,m,_,y)>=d*c.x+f*c.y)return!1;const x=u*(a.y-h.y),g=u*(h.x-a.x),v=x*i+g*n,w=x*s+g*n,I=x*i+g*o,A=x*s+g*o;return!(Math.max(v,w,I,A)<=x*a.x+g*a.y||Math.min(v,w,I,A)>=x*c.x+g*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}}at.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class gn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Wt.CIRC}clone(){return new gn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new at(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}gn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class yn{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Wt.ELIP}clone(){return new yn(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new at(this.x-this.width,this.y-this.height,this.width,this.height)}}yn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Gr{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Wt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Gr(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}Gr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class _n{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Wt.RREC}clone(){return new _n(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}_n.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Et{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(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(t,e){e=e||new gt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new gt;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(pn-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/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 t=new Et;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new Et}static get TEMP_MATRIX(){return new Et}}Et.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 $r=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Hr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Xr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Vr=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ha=[],Ou=[],vn=Math.sign;function Fv(){for(let r=0;r<16;r++){const t=[];Ha.push(t);for(let e=0;e<16;e++){const i=vn($r[r]*$r[e]+Xr[r]*Hr[e]),s=vn(Hr[r]*$r[e]+Vr[r]*Hr[e]),n=vn($r[r]*Xr[e]+Xr[r]*Vr[e]),o=vn(Hr[r]*Xr[e]+Vr[r]*Vr[e]);for(let a=0;a<16;a++)if($r[a]===i&&Hr[a]===s&&Xr[a]===n&&Vr[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Et;t.set($r[r],Hr[r],Xr[r],Vr[r],0,0),Ou.push(t)}}Fv();const Ct={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=>$r[r],uY:r=>Hr[r],vX:r=>Xr[r],vY:r=>Vr[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Ha[r][t],sub:(r,t)=>Ha[r][Ct.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Ct.S:Ct.N:Math.abs(t)*2<=Math.abs(r)?r>0?Ct.E:Ct.W:t>0?r>0?Ct.SE:Ct.SW:r>0?Ct.NE:Ct.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=Ou[Ct.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class hr{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new hr(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}hr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Xa=class{constructor(){this.worldTransform=new Et,this.localTransform=new Et,this.position=new hr(this.onChange,this,0,0),this.scale=new hr(this.onChange,this,1,1),this.pivot=new hr(this.onChange,this,0,0),this.skew=new hr(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 t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const e=r.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.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())}};Xa.IDENTITY=new Xa;let Va=Xa;Va.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 Lv=`varying vec2 vTextureCoord;
10
+ Deprecated since v${r}`),console.warn(i))),au[t]=!0}function be(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function hs(r){return r.split("?")[0].split("#")[0]}function Q_(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tv(r,t,e){return r.replace(new RegExp(Q_(t),"g"),e)}function ev(r,t){let e="",i=0,s=-1,n=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(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const Gt={toPosix(r){return tv(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){be(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(be(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=hs(this.toPosix(t??W.ADAPTER.getBaseUrl())),s=hs(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Gt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(be(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=ev(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return be(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(be(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(be(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){be(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){be(r),t&&be(t),r=hs(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){be(r),r=hs(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){be(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=hs(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let va;async function rv(){return va??(va=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return ie.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 ie.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?ie.PMA:ie.UNPACK})()),va}let xa;function iv(){return typeof xa>"u"&&(xa=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!W.ADAPTER.getWebGLRenderingContext())return!1;const e=W.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),xa}var sv={grad:.9,turn:360,rad:360/(2*Math.PI)},lr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},$t=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},pe=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},lu=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},hu=function(r){return{r:pe(r.r,0,255),g:pe(r.g,0,255),b:pe(r.b,0,255),a:pe(r.a)}},ba=function(r){return{r:$t(r.r),g:$t(r.g),b:$t(r.b),a:$t(r.a,3)}},nv=/^#([0-9a-f]{3,8})$/i,an=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},cu=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},uu=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%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:s}},du=function(r){return{h:lu(r.h),s:pe(r.s,0,100),l:pe(r.l,0,100),a:pe(r.a)}},fu=function(r){return{h:$t(r.h),s:$t(r.s),l:$t(r.l),a:$t(r.a,3)}},pu=function(r){return uu((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},cs=function(r){return{h:(t=cu(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},ov=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,av=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wa={string:[[function(r){var t=nv.exec(r);return t?(r=t[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?$t(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?$t(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=lv.exec(r)||hv.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:hu({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=ov.exec(r)||av.exec(r);if(!t)return null;var e,i,s=du({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(sv[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return pu(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return lr(t)&&lr(e)&&lr(i)?hu({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!lr(t)||!lr(e)||!lr(i))return null;var o=du({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return pu(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!lr(t)||!lr(e)||!lr(i))return null;var o=function(a){return{h:lu(a.h),s:pe(a.s,0,100),v:pe(a.v,0,100),a:pe(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return uu(o)},"hsv"]]},mu=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},cv=function(r){return typeof r=="string"?mu(r.trim(),wa.string):typeof r=="object"&&r!==null?mu(r,wa.object):[null,void 0]},Ea=function(r,t){var e=cs(r);return{h:e.h,s:pe(e.s+100*t,0,100),l:e.l,a:e.a}},Ta=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},gu=function(r,t){var e=cs(r);return{h:e.h,s:e.s,l:pe(e.l+100*t,0,100),a:e.a}},Aa=function(){function r(t){this.parsed=cv(t)[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 $t(Ta(this.rgba),2)},r.prototype.isDark=function(){return Ta(this.rgba)<.5},r.prototype.isLight=function(){return Ta(this.rgba)>=.5},r.prototype.toHex=function(){return t=ba(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?an($t(255*n)):"","#"+an(e)+an(i)+an(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return ba(this.rgba)},r.prototype.toRgbString=function(){return t=ba(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return fu(cs(this.rgba))},r.prototype.toHslString=function(){return t=fu(cs(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=cu(this.rgba),{h:$t(t.h),s:$t(t.s),v:$t(t.v),a:$t(t.a,3)};var t},r.prototype.invert=function(){return He({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),He(Ea(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),He(Ea(this.rgba,-t))},r.prototype.grayscale=function(){return He(Ea(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),He(gu(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),He(gu(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?He({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):$t(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=cs(this.rgba);return typeof t=="number"?He({h:t,s:e.s,l:e.l,a:e.a}):$t(e.h)},r.prototype.isEqual=function(t){return this.toHex()===He(t).toHex()},r}(),He=function(r){return r instanceof Aa?r:new Aa(r)},yu=[],uv=function(r){r.forEach(function(t){yu.indexOf(t)<0&&(t(Aa,wa),yu.push(t))})};function dv(r,t){var e={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 s in e)i[e[s]]=s;var n={};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 c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var p in e){var m=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<u&&(u=m,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}uv([dv]);const Ai=class Jn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}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(t){return this.value=t,this}set value(t){if(t instanceof Jn)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=Jn.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Jn.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=He(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};Ai.shared=new Ai,Ai.temp=new Ai,Ai.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let bt=Ai;function fv(r){return dt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),bt.shared.setValue(r).toHex()}function pv(r){return dt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),bt.shared.setValue(r).toNumber()}function mv(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[tt.NORMAL_NPM]=tt.NORMAL,r[tt.ADD_NPM]=tt.ADD,r[tt.SCREEN_NPM]=tt.SCREEN,t[tt.NORMAL]=tt.NORMAL_NPM,t[tt.ADD]=tt.ADD_NPM,t[tt.SCREEN]=tt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const _u=mv();function vu(r,t){return _u[t?1:0][r]}function gv(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function xu(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 ln(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 bu(r){return!(r&r-1)&&!!r}function wu(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Si(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function vr(r){return r===0?0:r<0?-1:1}let yv=0;function kr(){return++yv}const Sa=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,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}};Sa.EMPTY=new Sa(0,0,0,0);let Eu=Sa;const Tu={},Xe=Object.create(null),xr=Object.create(null);class _v{constructor(t,e,i){this._canvas=W.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||W.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}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 Au(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Su(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function vv(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&Au(s,t,o);)++o;if(o===e)return Eu.EMPTY;for(;Au(s,t,l);)--l;for(;Su(s,t,n,o,l);)++n;for(;Su(s,t,a,o,l);)--a;return++a,++l,new Eu(n,o,a,l)}function xv(r){const t=vv(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function bv(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function hr(r,t=1){var i;const e=(i=W.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var X=(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))(X||{});const Ia=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},Iu=(r,t)=>Ia(r).priority??t,Y={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ia).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(Ia).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(o=s[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>Iu(n,e)-Iu(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class Ca{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,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(t){return this[`${t}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(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const wv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
+ `);function Ev(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
12
+ else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Tv(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=wv.replace(/%forloop%/gi,Ev(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const Ra=0,Pa=1,Ma=2,Ba=3,Da=4,Oa=5;class Ve{constructor(){this.data=0,this.blendMode=tt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Ra)}set blend(t){!!(this.data&1<<Ra)!==t&&(this.data^=1<<Ra)}get offsets(){return!!(this.data&1<<Pa)}set offsets(t){!!(this.data&1<<Pa)!==t&&(this.data^=1<<Pa)}get culling(){return!!(this.data&1<<Ma)}set culling(t){!!(this.data&1<<Ma)!==t&&(this.data^=1<<Ma)}get depthTest(){return!!(this.data&1<<Ba)}set depthTest(t){!!(this.data&1<<Ba)!==t&&(this.data^=1<<Ba)}get depthMask(){return!!(this.data&1<<Oa)}set depthMask(t){!!(this.data&1<<Oa)!==t&&(this.data^=1<<Oa)}get clockwiseFrontFace(){return!!(this.data&1<<Da)}set clockwiseFrontFace(t){!!(this.data&1<<Da)!==t&&(this.data^=1<<Da)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==tt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Ve;return t.depthTest=!1,t.blend=!0,t}}Ve.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Fa=[];function Cu(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=Fa.length-1;i>=0;--i){const s=Fa[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class we{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][h](t,e,i,s,n,o,a,l);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}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(we.prototype,{dispatch:{value:we.prototype.emit},run:{value:we.prototype.emit}});class us{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new we("setRealSize"),this.onUpdate=new we("update"),this.onError=new we("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}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(t,e,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(t,e){return!1}}class hn extends us{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ie.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const Av={scaleMode:ir.NEAREST,alphaMode:ie.NPM},La=class ki extends Qi{constructor(t=null,e=null){super(),e=Object.assign({},ki.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof us)&&(t=Cu(t,p),t.internal=!0),this.resolution=f||W.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=i,this.uid=kr(),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(t)}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(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=bu(this.realWidth)&&bu(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,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(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete xr[this.cacheId],delete Xe[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),ki.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=W.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${kr()}`}n=t._pixiId}let o=xr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new ki(t,e),o.cacheId=n,ki.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new hn(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=k.RGBA,a=J.FLOAT):t instanceof Int32Array?(o=k.RGBA_INTEGER,a=J.INT):t instanceof Uint32Array?(o=k.RGBA_INTEGER,a=J.UNSIGNED_INT):t instanceof Int16Array?(o=k.RGBA_INTEGER,a=J.SHORT):t instanceof Uint16Array?(o=k.RGBA_INTEGER,a=J.UNSIGNED_SHORT):t instanceof Int8Array?(o=k.RGBA,a=J.BYTE):(o=k.RGBA,a=J.UNSIGNED_BYTE),n.internal=!0,new ki(n,Object.assign({},Av,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),xr[e]&&xr[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),xr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=xr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete xr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete xr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};La.defaultOptions={mipmap:Le.POW2,anisotropicLevel:0,scaleMode:ir.LINEAR,wrapMode:gr.CLAMP,alphaMode:ie.UNPACK,target:di.TEXTURE_2D,format:k.RGBA,type:J.UNSIGNED_BYTE},La._globalBatch=0;let nt=La;class Na{constructor(){this.texArray=null,this.blend=0,this.type=Fe.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Sv=0;class Bt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=Sv++,this.disposeRunner=new we("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Ue.ELEMENT_ARRAY_BUFFER:Ue.ARRAY_BUFFER}get index(){return this.type===Ue.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Bt(t)}}class cn{constructor(t,e=0,i=!1,s=J.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new cn(t,e,i,s,n)}}const Iv={Float32Array,Uint32Array,Int32Array,Uint8Array};function Cv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=xu(c);s[u]||(s[u]=new Iv[u](n)),o=s[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(n)}const Ru={5126:4,5123:2,5121:1};let Rv=0;const Pv={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class br{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Rv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new we("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Bt||(e instanceof Array&&(e=new Float32Array(e)),e=new Bt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,s,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new cn(c,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Bt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Bt(t)),t.type=Ue.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Bt;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*Ru[n.type]/4),n.buffer=0}for(i.data=Cv(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new br;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Bt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new cn(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Ue.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new br,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new Pv[xu(o.buffers[a].data)](s[a]),e.buffers[a]=new Bt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Ue.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*Ru[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class Pu extends br{constructor(t=!1){super(),this._buffer=new Bt(null,t,!1),this._indexBuffer=new Bt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,J.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,J.FLOAT).addAttribute("aColor",this._buffer,4,!0,J.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,J.FLOAT).addIndex(this._indexBuffer)}}const un=Math.PI*2,Mv=180/Math.PI,Bv=Math.PI/180;var Wt=(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))(Wt||{});class gt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new gt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}gt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const dn=[new gt,new gt,new gt,new gt];class at{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Wt.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 at(0,0,0,0)}clone(){return new at(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const C=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=C)return!1;const N=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>N}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=dn[0].set(t.left,t.top),l=dn[1].set(t.left,t.bottom),h=dn[2].set(t.right,t.top),c=dn[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=s||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*i+f*n,m=d*s+f*n,_=d*i+f*o,y=d*s+f*o;if(Math.max(p,m,_,y)<=d*a.x+f*a.y||Math.min(p,m,_,y)>=d*c.x+f*c.y)return!1;const x=u*(a.y-h.y),g=u*(h.x-a.x),v=x*i+g*n,w=x*s+g*n,I=x*i+g*o,A=x*s+g*o;return!(Math.max(v,w,I,A)<=x*a.x+g*a.y||Math.min(v,w,I,A)>=x*c.x+g*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}}at.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class fn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Wt.CIRC}clone(){return new fn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new at(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}fn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class pn{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Wt.ELIP}clone(){return new pn(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new at(this.x-this.width,this.y-this.height,this.width,this.height)}}pn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Gr{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Wt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Gr(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}Gr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class mn{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Wt.RREC}clone(){return new mn(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}mn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Et{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(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(t,e){e=e||new gt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new gt;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(un-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/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 t=new Et;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new Et}static get TEMP_MATRIX(){return new Et}}Et.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 $r=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Hr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Xr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Vr=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ua=[],Mu=[],gn=Math.sign;function Dv(){for(let r=0;r<16;r++){const t=[];Ua.push(t);for(let e=0;e<16;e++){const i=gn($r[r]*$r[e]+Xr[r]*Hr[e]),s=gn(Hr[r]*$r[e]+Vr[r]*Hr[e]),n=gn($r[r]*Xr[e]+Xr[r]*Vr[e]),o=gn(Hr[r]*Xr[e]+Vr[r]*Vr[e]);for(let a=0;a<16;a++)if($r[a]===i&&Hr[a]===s&&Xr[a]===n&&Vr[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Et;t.set($r[r],Hr[r],Xr[r],Vr[r],0,0),Mu.push(t)}}Dv();const Ct={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=>$r[r],uY:r=>Hr[r],vX:r=>Xr[r],vY:r=>Vr[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Ua[r][t],sub:(r,t)=>Ua[r][Ct.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Ct.S:Ct.N:Math.abs(t)*2<=Math.abs(r)?r>0?Ct.E:Ct.W:t>0?r>0?Ct.SE:Ct.SW:r>0?Ct.NE:Ct.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=Mu[Ct.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class cr{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new cr(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}cr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const ka=class{constructor(){this.worldTransform=new Et,this.localTransform=new Et,this.position=new cr(this.onChange,this,0,0),this.scale=new cr(this.onChange,this,1,1),this.pivot=new cr(this.onChange,this,0,0),this.skew=new cr(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 t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const e=r.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.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())}};ka.IDENTITY=new ka;let Ga=ka;Ga.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 Ov=`varying vec2 vTextureCoord;
13
13
 
14
14
  uniform sampler2D uSampler;
15
15
 
16
16
  void main(void){
17
17
  gl_FragColor *= texture2D(uSampler, vTextureCoord);
18
- }`,Nv=`attribute vec2 aVertexPosition;
18
+ }`,Fv=`attribute vec2 aVertexPosition;
19
19
  attribute vec2 aTextureCoord;
20
20
 
21
21
  uniform mat3 projectionMatrix;
@@ -26,7 +26,7 @@ void main(void){
26
26
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
27
27
  vTextureCoord = aTextureCoord;
28
28
  }
29
- `;function Fu(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function za(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Lu(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return za(2*t);case"bvec3":return za(3*t);case"bvec4":return za(4*t);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 Ii=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
29
+ `;function Bu(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function $a(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Du(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return $a(2*t);case"bvec3":return $a(3*t);case"bvec4":return $a(4*t);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 Ii=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
30
30
  if(uv["${r}"] !== ud["${r}"].value)
31
31
  {
32
32
  ud["${r}"].value = uv["${r}"]
@@ -146,7 +146,7 @@ void main(void){
146
146
  cv[3] = v[3];
147
147
 
148
148
  gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3])
149
- }`}],Uv={float:`
149
+ }`}],Lv={float:`
150
150
  if (cv !== v)
151
151
  {
152
152
  cu.value = v;
@@ -282,7 +282,7 @@ void main(void){
282
282
  cu.value = v;
283
283
 
284
284
  gl.uniform1i(location, v);
285
- }`},kv={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 Gv(r,t){var i;const e=[`
285
+ }`},Nv={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 Uv(r,t){var i;const e=[`
286
286
  var v = null;
287
287
  var cv = null;
288
288
  var cu = null;
@@ -292,18 +292,18 @@ void main(void){
292
292
  renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');
293
293
  `):e.push(`
294
294
  renderer.shader.syncUniformGroup(uv.${s}, syncData);
295
- `));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<Ii.length;l++)if(Ii[l].test(n,o)){e.push(Ii[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?Uv:kv)[n.type].replace("location",`ud["${s}"].location`);e.push(`
295
+ `));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<Ii.length;l++)if(Ii[l].test(n,o)){e.push(Ii[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?Lv:Nv)[n.type].replace("location",`ud["${s}"].location`);e.push(`
296
296
  cu = ud["${s}"];
297
297
  cv = cu.value;
298
298
  v = uv["${s}"];
299
299
  ${l};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
300
- `))}const Nu={};let Ci=Nu;function $v(){if(Ci===Nu||Ci!=null&&Ci.isContextLost()){const r=W.ADAPTER.createCanvas();let t;W.PREFER_ENV>=Or.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Ci=t}return Ci}let xn;function Hv(){if(!xn){xn=fe.MEDIUM;const r=$v();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(xn=t.precision?fe.HIGH:fe.MEDIUM)}}return xn}function Uu(r,t){const e=r.getShaderSource(t).split(`
300
+ `))}const Ou={};let Ci=Ou;function kv(){if(Ci===Ou||Ci!=null&&Ci.isContextLost()){const r=W.ADAPTER.createCanvas();let t;W.PREFER_ENV>=Or.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Ci=t}return Ci}let yn;function Gv(){if(!yn){yn=fe.MEDIUM;const r=kv();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(yn=t.precision?fe.HIGH:fe.MEDIUM)}}return yn}function Fu(r,t){const e=r.getShaderSource(t).split(`
301
301
  `).map((h,c)=>`${c}: ${h}`),i=r.getShaderInfoLog(t),s=i.split(`
302
302
  `),n={},o=s.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),a=[""];o.forEach(h=>{e[h-1]=`%c${e[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
303
- `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Xv(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Uu(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Uu(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Vv={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 ku(r){return Vv[r]}let bn=null;const Gu={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 $u(r,t){if(!bn){const e=Object.keys(Gu);bn={};for(let i=0;i<e.length;++i){const s=e[i];bn[r[s]]=Gu[s]}}return bn[t]}function Hu(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===fe.HIGH&&e!==fe.HIGH&&(i=fe.MEDIUM),`precision ${i} float;
304
- ${r}`}else if(e!==fe.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let ds;function zv(){if(typeof ds=="boolean")return ds;try{ds=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ds=!1}return ds}let Wv=0;const wn={},Wa=class Gi{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=Wv++,this.vertexSrc=t||Gi.defaultVertexSrc,this.fragmentSrc=e||Gi.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),wn[i]?(wn[i]++,i+=`-${wn[i]}`):wn[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
303
+ `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function $v(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Fu(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Fu(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Hv={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 Lu(r){return Hv[r]}let _n=null;const Nu={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 Uu(r,t){if(!_n){const e=Object.keys(Nu);_n={};for(let i=0;i<e.length;++i){const s=e[i];_n[r[s]]=Nu[s]}}return _n[t]}function ku(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===fe.HIGH&&e!==fe.HIGH&&(i=fe.MEDIUM),`precision ${i} float;
304
+ ${r}`}else if(e!==fe.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let ds;function Xv(){if(typeof ds=="boolean")return ds;try{ds=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ds=!1}return ds}let Vv=0;const vn={},Ha=class Gi{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=Vv++,this.vertexSrc=t||Gi.defaultVertexSrc,this.fragmentSrc=e||Gi.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),vn[i]?(vn[i]++,i+=`-${vn[i]}`):vn[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
305
305
  ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
306
- ${this.fragmentSrc}`,this.vertexSrc=Hu(this.vertexSrc,Gi.defaultVertexPrecision,fe.HIGH),this.fragmentSrc=Hu(this.fragmentSrc,Gi.defaultFragmentPrecision,Hv())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Nv}static get defaultFragmentSrc(){return Lv}static from(t,e,i){const s=t+e;let n=Iu[s];return n||(Iu[s]=n=new Gi(t,e,i)),n}};Wa.defaultVertexPrecision=fe.HIGH,Wa.defaultFragmentPrecision=nr.apple.device?fe.HIGH:fe.MEDIUM;let cr=Wa,jv=0;class Ee{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=jv++,this.static=!!e,this.ubo=!!i,t instanceof Bt?(this.buffer=t,this.buffer.type=Ue.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Bt(new Float32Array(1)),this.buffer.type=Ue.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new Ee(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new Ee(t,e,i)}static uboFrom(t,e){return new Ee(t,e??!0,!0)}}class ze{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Ee?this.uniformGroup=e:this.uniformGroup=new Ee(e):this.uniformGroup=new Ee({}),this.disposeRunner=new we("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=cr.from(t,e);return new ze(s,i)}}class Yv{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=Ee.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new cr(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Et,default:this.defaultGroupCache[t]};return new ze(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
306
+ ${this.fragmentSrc}`,this.vertexSrc=ku(this.vertexSrc,Gi.defaultVertexPrecision,fe.HIGH),this.fragmentSrc=ku(this.fragmentSrc,Gi.defaultFragmentPrecision,Gv())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Fv}static get defaultFragmentSrc(){return Ov}static from(t,e,i){const s=t+e;let n=Tu[s];return n||(Tu[s]=n=new Gi(t,e,i)),n}};Ha.defaultVertexPrecision=fe.HIGH,Ha.defaultFragmentPrecision=nr.apple.device?fe.HIGH:fe.MEDIUM;let ur=Ha,zv=0;class Ee{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=zv++,this.static=!!e,this.ubo=!!i,t instanceof Bt?(this.buffer=t,this.buffer.type=Ue.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Bt(new Float32Array(1)),this.buffer.type=Ue.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new Ee(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new Ee(t,e,i)}static uboFrom(t,e){return new Ee(t,e??!0,!0)}}class ze{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Ee?this.uniformGroup=e:this.uniformGroup=new Ee(e):this.uniformGroup=new Ee({}),this.disposeRunner=new we("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=ur.from(t,e);return new ze(s,i)}}class Wv{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=Ee.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new ur(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Et,default:this.defaultGroupCache[t]};return new ze(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
307
307
  `,e+=`
308
308
  `;for(let i=0;i<t;i++)i>0&&(e+=`
309
309
  else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
@@ -311,7 +311,7 @@ else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
311
311
  color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
312
312
  }`;return e+=`
313
313
  `,e+=`
314
- `,e}}class ja{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function qv(){return!nr.apple.device}function Kv(r){let t=!0;const e=W.ADAPTER.getNavigator();if(nr.tablet||nr.phone){if(nr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(nr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class En{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Zv=`varying vec2 vTextureCoord;
314
+ `,e}}class Xa{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function jv(){return!nr.apple.device}function Yv(r){let t=!0;const e=W.ADAPTER.getNavigator();if(nr.tablet||nr.phone){if(nr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(nr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class xn{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var qv=`varying vec2 vTextureCoord;
315
315
  varying vec4 vColor;
316
316
  varying float vTextureId;
317
317
  uniform sampler2D uSamplers[%count%];
@@ -321,7 +321,7 @@ void main(void){
321
321
  %forloop%
322
322
  gl_FragColor = color * vColor;
323
323
  }
324
- `,Jv=`precision highp float;
324
+ `,Kv=`precision highp float;
325
325
  attribute vec2 aVertexPosition;
326
326
  attribute vec2 aTextureCoord;
327
327
  attribute vec4 aColor;
@@ -342,14 +342,14 @@ void main(void){
342
342
  vTextureId = aTextureId;
343
343
  vColor = aColor * tint;
344
344
  }
345
- `;const fs=class Re extends En{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Du,this.vertexSize=6,this.state=Ve.for2d(),this.size=Re.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),t.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??Kv(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??qv(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return dt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Jv}static get defaultFragmentTemplate(){return Zv}setShaderGenerator({vertex:t=Re.defaultVertexSrc,fragment:e=Re.defaultFragmentTemplate}={}){this.shaderGenerator=new Yv(t,e)}contextChange(){const t=this.renderer.gl;W.PREFER_ENV===Or.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Re.defaultMaxTextures),this.maxTextures=Sv(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Re,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new $a);for(;e.length<s;)e.push(new ja);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=Re._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++nt._globalBatch,l=0,h=i[0],c=0;s.copyBoundTextures(n,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,u),c=u,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,this._bufferSize),++l,++a);for(let u=0;u<n.length;u++)n[u]=null;nt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=Re._drawCallPool;let h=this._dcIndex,c=this._aIndex,u=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=s[f],m=p._texture.baseTexture,_=bu[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==_&&(d.size=u-d.start,e=f,d=l[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,n,o,c,u),c+=p.vertexData.length/2*a,u+=p.indices.length,d.blend=_}e<i&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;Re.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=Re._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:c,blend:u}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,c*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),Re.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].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(t){const e=un(Math.ceil(t/8)),i=Au(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Ba(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=un(Math.ceil(t/12)),i=Au(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=bt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<u.length;m+=2)a[s++]=u[m],a[s++]=u[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=p,a[s++]=d;for(let m=0;m<c.length;m++)i[n++]=l+c[m]}};fs.defaultBatchSize=4096,fs.extension={name:"batch",type:X.RendererPlugin},fs._drawCallPool=[],fs._textureArrayPool=[];let zr=fs;Y.add(zr);var Qv=`varying vec2 vTextureCoord;
345
+ `;const fs=class Re extends xn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Pu,this.vertexSize=6,this.state=Ve.for2d(),this.size=Re.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),t.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??Yv(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??jv(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return dt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Kv}static get defaultFragmentTemplate(){return qv}setShaderGenerator({vertex:t=Re.defaultVertexSrc,fragment:e=Re.defaultFragmentTemplate}={}){this.shaderGenerator=new Wv(t,e)}contextChange(){const t=this.renderer.gl;W.PREFER_ENV===Or.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Re.defaultMaxTextures),this.maxTextures=Tv(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Re,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Na);for(;e.length<s;)e.push(new Xa);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=Re._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++nt._globalBatch,l=0,h=i[0],c=0;s.copyBoundTextures(n,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,u),c=u,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,this._bufferSize),++l,++a);for(let u=0;u<n.length;u++)n[u]=null;nt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=Re._drawCallPool;let h=this._dcIndex,c=this._aIndex,u=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=s[f],m=p._texture.baseTexture,_=_u[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==_&&(d.size=u-d.start,e=f,d=l[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,n,o,c,u),c+=p.vertexData.length/2*a,u+=p.indices.length,d.blend=_}e<i&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;Re.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=Re._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:c,blend:u}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,c*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),Re.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].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(t){const e=ln(Math.ceil(t/8)),i=wu(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Ca(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=ln(Math.ceil(t/12)),i=wu(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=bt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<u.length;m+=2)a[s++]=u[m],a[s++]=u[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=p,a[s++]=d;for(let m=0;m<c.length;m++)i[n++]=l+c[m]}};fs.defaultBatchSize=4096,fs.extension={name:"batch",type:X.RendererPlugin},fs._drawCallPool=[],fs._textureArrayPool=[];let zr=fs;Y.add(zr);var Zv=`varying vec2 vTextureCoord;
346
346
 
347
347
  uniform sampler2D uSampler;
348
348
 
349
349
  void main(void){
350
350
  gl_FragColor = texture2D(uSampler, vTextureCoord);
351
351
  }
352
- `,t1=`attribute vec2 aVertexPosition;
352
+ `,Jv=`attribute vec2 aVertexPosition;
353
353
 
354
354
  uniform mat3 projectionMatrix;
355
355
 
@@ -375,7 +375,7 @@ void main(void)
375
375
  gl_Position = filterVertexPosition();
376
376
  vTextureCoord = filterTextureCoord();
377
377
  }
378
- `;const Ya=class Es extends ze{constructor(t,e,i){const s=cr.from(t||Es.defaultVertexSrc,e||Es.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=Es.defaultResolution,this.multisample=Es.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Ve}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return t1}static get defaultFragmentSrc(){return Qv}};Ya.defaultResolution=1,Ya.defaultMultisample=Ot.NONE;let re=Ya;class Tn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new bt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}Tn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Tn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"background"},Y.add(Tn);class Xu{constructor(t){this.renderer=t,this.emptyRenderer=new En(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=n[h],u=c._batchLocation;if(u>=0&&u<s&&e[u]===c){o[h]=u;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}Xu.extension={type:X.RendererSystem,name:"batch"},Y.add(Xu);let Vu=0;class An{constructor(t){this.renderer=t,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(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Vu++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Vu++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(W.PREFER_ENV>=Or.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!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:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}An.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},An.extension={type:X.RendererSystem,name:"context"},Y.add(An);class qa{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!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 we("disposeFramebuffer"),this.multisample=Ot.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new nt(null,{scaleMode:ir.NEAREST,resolution:1,mipmap:Le.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new nt(null,{scaleMode:ir.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Le.OFF,format:k.DEPTH_COMPONENT,type:J.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(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class zu extends nt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Ot.NONE),super(null,t),this.mipmap=Le.OFF,this.valid=!0,this._clear=new bt([0,0,0,0]),this.framebuffer=new qa(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*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 ur extends us{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=Ev(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ie.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Wu extends ur{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;ur.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??W.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ie.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(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(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Ka{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(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=Ct.add(i,Ct.NW),this.x0=l+o*Ct.uX(i),this.y0=h+a*Ct.uY(i),i=Ct.add(i,2),this.x1=l+o*Ct.uX(i),this.y1=h+a*Ct.uY(i),i=Ct.add(i,2),this.x2=l+o*Ct.uX(i),this.y2=h+a*Ct.uY(i),i=Ct.add(i,2),this.x3=l+o*Ct.uX(i),this.y3=h+a*Ct.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;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}}Ka.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 ju=new Ka;function Sn(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class q extends Qi{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new at(0,0,1,1)),t instanceof q&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=ju,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!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 gt(o.x,o.y):new gt(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&Xe[e.url]&&q.removeFromCache(e.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,q.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new q(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===ju&&(this._uvs=new Ka),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=W.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof nt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${kr()}`,nt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${kr()}`}n=t._pixiId}let o=Xe[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof nt)?(e.resolution||(e.resolution=lr(t)),o=new q(new nt(t,e)),o.baseTexture.cacheId=n,nt.addToCache(o.baseTexture,n),q.addToCache(o,n)):!o&&t instanceof nt&&(o=new q(t),q.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=q.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new q(nt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new nt(t,Object.assign({scaleMode:nt.defaultOptions.scaleMode,resolution:lr(e)},s)),{resource:o}=n;o instanceof Wu&&(o.url=e);const a=new q(n);return i||(i=e),nt.addToCache(a.baseTexture,i),q.addToCache(a,i),i!==e&&(nt.addToCache(a.baseTexture,e),q.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Xe[e]&&Xe[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Xe[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Xe[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Xe[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Xe[t.textureCacheIds[e]]===t&&delete Xe[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return q._EMPTY||(q._EMPTY=new q(new nt),Sn(q._EMPTY),Sn(q._EMPTY.baseTexture)),q._EMPTY}static get WHITE(){if(!q._WHITE){const t=W.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),q._WHITE=new q(nt.from(t)),Sn(q._WHITE),Sn(q._WHITE.baseTexture)}return q._WHITE}}class Wr extends q{constructor(t,e){super(t,e),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(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Wr(new zu(t))}}class Yu{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Ot.NONE){const s=new zu(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Wr(s)}getOptimalTexture(t,e,i=1,s=Ot.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=un(t),e=un(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Ot.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Yu.SCREEN_KEY=-1;class e1 extends br{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class qu extends br{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 Bt(this.vertices),this.uvBuffer=new Bt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class r1{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Ot.NONE,this.sourceFrame=new at,this.destinationFrame=new at,this.bindingSourceFrame=new at,this.bindingDestinationFrame=new at,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const In=[new gt,new gt,new gt,new gt],Za=new Et;class Ku{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Yu,this.statePool=[],this.quad=new e1,this.quadUv=new qu,this.tempRect=new at,this.activeState={},this.globalUniforms=new Ee({outputFrame:new at,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(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new r1,o=i.renderTexture;let a,l;if(o.current){const _=o.current;a=_.resolution,l=_.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let _=1;_<e.length;_++){const y=e[_];h=Math.min(h,y.resolution||a),c=Math.min(c,y.multisample??l),u=this.useMaxPadding?Math.max(u,y.padding):u+y.padding,d=d&&y.autoFit,f=f||(y.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Za.copyFrom(i.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Ne.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,Ne.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,Ne.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Ne.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===Ne.CLEAR||e===Ne.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Fe.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Fe.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(Et.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=Ot.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||Ot.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=In[0],s=In[1],n=In[2],o=In[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),c=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?Za.copyFrom(n):Za.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Ku.extension={type:X.RendererSystem,name:"filter"},Y.add(Ku);class i1{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Ot.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const s1=new at;class Zu{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new qa(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new at,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;W.PREFER_ENV===Or.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}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(t,e,i,s,n=Go.COLOR|Go.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new i1(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Ot.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=Ot.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=s.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new qa(s.width,s.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=s1,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new at}destroy(){this.renderer=null}}Zu.extension={type:X.RendererSystem,name:"framebuffer"},Y.add(Zu);const Ja={5126:4,5123:2,5121:1};class Ju{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;W.PREFER_ENV===Or.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*Ja[d[m].type];for(const m in d){const _=d[m],y=_.size;_.stride===void 0&&(f[_.buffer]===y*Ja[_.type]?_.stride=0:_.stride=f[_.buffer]),_.start===void 0&&(_.start=p[_.buffer],p[_.buffer]+=y*Ja[_.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let m=0;m<u.length;m++){const _=u[m];o.bind(_),i&&_._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,s.bindVertexArray(null),o.unbind(Ue.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(u),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Ju.extension={type:X.RendererSystem,name:"geometry"},Y.add(Ju);const Qu=new Et;class td{constructor(t,e){this._texture=t,this.mapCoord=new Et,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._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 s=e.orig,n=e.trim;n&&(Qu.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Qu));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var n1=`varying vec2 vMaskCoord;
378
+ `;const Va=class Es extends ze{constructor(t,e,i){const s=ur.from(t||Es.defaultVertexSrc,e||Es.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=Es.defaultResolution,this.multisample=Es.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Ve}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Jv}static get defaultFragmentSrc(){return Zv}};Va.defaultResolution=1,Va.defaultMultisample=Ot.NONE;let re=Va;class bn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new bt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}bn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},bn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"background"},Y.add(bn);class Gu{constructor(t){this.renderer=t,this.emptyRenderer=new xn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=n[h],u=c._batchLocation;if(u>=0&&u<s&&e[u]===c){o[h]=u;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}Gu.extension={type:X.RendererSystem,name:"batch"},Y.add(Gu);let $u=0;class wn{constructor(t){this.renderer=t,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(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=$u++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=$u++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(W.PREFER_ENV>=Or.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!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:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}wn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},wn.extension={type:X.RendererSystem,name:"context"},Y.add(wn);class za{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!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 we("disposeFramebuffer"),this.multisample=Ot.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new nt(null,{scaleMode:ir.NEAREST,resolution:1,mipmap:Le.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new nt(null,{scaleMode:ir.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Le.OFF,format:k.DEPTH_COMPONENT,type:J.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(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Hu extends nt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Ot.NONE),super(null,t),this.mipmap=Le.OFF,this.valid=!0,this._clear=new bt([0,0,0,0]),this.framebuffer=new za(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*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 dr extends us{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=bv(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ie.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Xu extends dr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;dr.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??W.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ie.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(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(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Wa{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(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=Ct.add(i,Ct.NW),this.x0=l+o*Ct.uX(i),this.y0=h+a*Ct.uY(i),i=Ct.add(i,2),this.x1=l+o*Ct.uX(i),this.y1=h+a*Ct.uY(i),i=Ct.add(i,2),this.x2=l+o*Ct.uX(i),this.y2=h+a*Ct.uY(i),i=Ct.add(i,2),this.x3=l+o*Ct.uX(i),this.y3=h+a*Ct.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;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}}Wa.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 Vu=new Wa;function En(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class q extends Qi{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new at(0,0,1,1)),t instanceof q&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Vu,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!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 gt(o.x,o.y):new gt(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&Xe[e.url]&&q.removeFromCache(e.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,q.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new q(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Vu&&(this._uvs=new Wa),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=W.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof nt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${kr()}`,nt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${kr()}`}n=t._pixiId}let o=Xe[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof nt)?(e.resolution||(e.resolution=hr(t)),o=new q(new nt(t,e)),o.baseTexture.cacheId=n,nt.addToCache(o.baseTexture,n),q.addToCache(o,n)):!o&&t instanceof nt&&(o=new q(t),q.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=q.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new q(nt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new nt(t,Object.assign({scaleMode:nt.defaultOptions.scaleMode,resolution:hr(e)},s)),{resource:o}=n;o instanceof Xu&&(o.url=e);const a=new q(n);return i||(i=e),nt.addToCache(a.baseTexture,i),q.addToCache(a,i),i!==e&&(nt.addToCache(a.baseTexture,e),q.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Xe[e]&&Xe[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Xe[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Xe[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Xe[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Xe[t.textureCacheIds[e]]===t&&delete Xe[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return q._EMPTY||(q._EMPTY=new q(new nt),En(q._EMPTY),En(q._EMPTY.baseTexture)),q._EMPTY}static get WHITE(){if(!q._WHITE){const t=W.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),q._WHITE=new q(nt.from(t)),En(q._WHITE),En(q._WHITE.baseTexture)}return q._WHITE}}class Wr extends q{constructor(t,e){super(t,e),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(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Wr(new Hu(t))}}class zu{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Ot.NONE){const s=new Hu(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Wr(s)}getOptimalTexture(t,e,i=1,s=Ot.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=ln(t),e=ln(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Ot.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}zu.SCREEN_KEY=-1;class Qv extends br{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Wu extends br{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 Bt(this.vertices),this.uvBuffer=new Bt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class t1{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Ot.NONE,this.sourceFrame=new at,this.destinationFrame=new at,this.bindingSourceFrame=new at,this.bindingDestinationFrame=new at,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Tn=[new gt,new gt,new gt,new gt],ja=new Et;class ju{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new zu,this.statePool=[],this.quad=new Qv,this.quadUv=new Wu,this.tempRect=new at,this.activeState={},this.globalUniforms=new Ee({outputFrame:new at,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(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new t1,o=i.renderTexture;let a,l;if(o.current){const _=o.current;a=_.resolution,l=_.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let _=1;_<e.length;_++){const y=e[_];h=Math.min(h,y.resolution||a),c=Math.min(c,y.multisample??l),u=this.useMaxPadding?Math.max(u,y.padding):u+y.padding,d=d&&y.autoFit,f=f||(y.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(ja.copyFrom(i.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Ne.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,Ne.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,Ne.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Ne.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===Ne.CLEAR||e===Ne.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Fe.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Fe.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(Et.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=Ot.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||Ot.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=Tn[0],s=Tn[1],n=Tn[2],o=Tn[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),c=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?ja.copyFrom(n):ja.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}ju.extension={type:X.RendererSystem,name:"filter"},Y.add(ju);class e1{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Ot.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const r1=new at;class Yu{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new za(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new at,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;W.PREFER_ENV===Or.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}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(t,e,i,s,n=Lo.COLOR|Lo.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new e1(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Ot.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=Ot.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=s.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new za(s.width,s.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=r1,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new at}destroy(){this.renderer=null}}Yu.extension={type:X.RendererSystem,name:"framebuffer"},Y.add(Yu);const Ya={5126:4,5123:2,5121:1};class qu{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;W.PREFER_ENV===Or.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*Ya[d[m].type];for(const m in d){const _=d[m],y=_.size;_.stride===void 0&&(f[_.buffer]===y*Ya[_.type]?_.stride=0:_.stride=f[_.buffer]),_.start===void 0&&(_.start=p[_.buffer],p[_.buffer]+=y*Ya[_.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let m=0;m<u.length;m++){const _=u[m];o.bind(_),i&&_._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,s.bindVertexArray(null),o.unbind(Ue.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(u),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}qu.extension={type:X.RendererSystem,name:"geometry"},Y.add(qu);const Ku=new Et;class Zu{constructor(t,e){this._texture=t,this.mapCoord=new Et,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._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 s=e.orig,n=e.trim;n&&(Ku.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Ku));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var i1=`varying vec2 vMaskCoord;
379
379
  varying vec2 vTextureCoord;
380
380
 
381
381
  uniform sampler2D uSampler;
@@ -400,7 +400,7 @@ void main(void)
400
400
 
401
401
  gl_FragColor = original;
402
402
  }
403
- `,o1=`attribute vec2 aVertexPosition;
403
+ `,s1=`attribute vec2 aVertexPosition;
404
404
  attribute vec2 aTextureCoord;
405
405
 
406
406
  uniform mat3 projectionMatrix;
@@ -416,7 +416,7 @@ void main(void)
416
416
  vTextureCoord = aTextureCoord;
417
417
  vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
418
418
  }
419
- `;class a1 extends re{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||o1,e||n1,i),this.maskSprite=s,this.maskMatrix=new Et}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new td(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class l1{constructor(t=null){this.type=Ft.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=re.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(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Ft.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class ed{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new l1;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Ft.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Ft.SCISSOR:this.renderer.scissor.push(i);break;case Ft.STENCIL:this.renderer.stencil.push(i);break;case Ft.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Ft.COLOR:this.pushColorMask(i);break}i.type===Ft.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Ft.SCISSOR:this.renderer.scissor.pop(e);break;case Ft.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Ft.SPRITE:this.popSpriteMask(e);break;case Ft.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Ft.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Ft.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Ft.SCISSOR:t.type=Ft.STENCIL:t.type=Ft.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new a1])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}ed.extension={type:X.RendererSystem,name:"mask"},Y.add(ed);class rd{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const id=new Et,sd=[],nd=class io extends rd{constructor(t){super(t),this.glConst=W.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,sd.pop()??new at);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||io.isMatrixRotated(e.worldTransform)||io.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){io.isMatrixRotated(n)||(n=n?id.copyFrom(n):id.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&sd.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};nd.extension={type:X.RendererSystem,name:"scissor"};let h1=nd;Y.add(h1);class od extends rd{constructor(t){super(t),this.glConst=W.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}od.extension={type:X.RendererSystem,name:"stencil"},Y.add(od);class ad{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return dt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return dt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return dt("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}ad.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_plugin"},Y.add(ad);class ld{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Et,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}ld.extension={type:X.RendererSystem,name:"projection"},Y.add(ld);const c1=new Va,hd=new at;class cd{constructor(t){this.renderer=t,this._tempMatrix=new Et}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(hd))||t.getLocalBounds(hd,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=Wr.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=c1,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}cd.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"textureGenerator"},Y.add(cd);const jr=new at,ps=new at;class ud{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new at,this.destinationFrame=new at,this.viewportFrame=new at}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(jr.width=t.frame.width,jr.height=t.frame.height,e=jr),i||(ps.x=t.frame.x,ps.y=t.frame.y,ps.width=e.width,ps.height=e.height,i=ps),o=n.framebuffer):(a=s.resolution,e||(jr.width=s._view.screen.width,jr.height=s._view.screen.height,e=jr),i||(i=jr,i.width=e.width,i.height=e.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,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=bt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:c,height:u}=this.viewportFrame;l=Math.round(l),h=Math.round(h),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,c,u)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}ud.extension={type:X.RendererSystem,name:"renderTexture"},Y.add(ud);class u1{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function d1(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=$u(t,n.type),a={type:o,name:n.name,size:ku(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function f1(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=$u(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Lu(l,n.size)}}return e}function p1(r,t){var a;const e=Fu(r,r.VERTEX_SHADER,t.vertexSrc),i=Fu(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Xv(r,s,e,i),t.attributeData=d1(s,r),t.uniformData=f1(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,c)=>h>c?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(s,l),value:Lu(h.type,h.size)}}return new u1(s,o)}function m1(r,t,e,i,s){e.buffer.update(s)}const g1={float:`
419
+ `;class n1 extends re{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||s1,e||i1,i),this.maskSprite=s,this.maskMatrix=new Et}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new Zu(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class o1{constructor(t=null){this.type=Ft.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=re.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(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Ft.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Ju{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new o1;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Ft.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Ft.SCISSOR:this.renderer.scissor.push(i);break;case Ft.STENCIL:this.renderer.stencil.push(i);break;case Ft.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Ft.COLOR:this.pushColorMask(i);break}i.type===Ft.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Ft.SCISSOR:this.renderer.scissor.pop(e);break;case Ft.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Ft.SPRITE:this.popSpriteMask(e);break;case Ft.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Ft.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Ft.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Ft.SCISSOR:t.type=Ft.STENCIL:t.type=Ft.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new n1])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Ju.extension={type:X.RendererSystem,name:"mask"},Y.add(Ju);class Qu{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const td=new Et,ed=[],rd=class Qn extends Qu{constructor(t){super(t),this.glConst=W.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,ed.pop()??new at);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Qn.isMatrixRotated(e.worldTransform)||Qn.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Qn.isMatrixRotated(n)||(n=n?td.copyFrom(n):td.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&ed.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};rd.extension={type:X.RendererSystem,name:"scissor"};let a1=rd;Y.add(a1);class id extends Qu{constructor(t){super(t),this.glConst=W.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}id.extension={type:X.RendererSystem,name:"stencil"},Y.add(id);class sd{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return dt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return dt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return dt("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}sd.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_plugin"},Y.add(sd);class nd{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Et,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}nd.extension={type:X.RendererSystem,name:"projection"},Y.add(nd);const l1=new Ga,od=new at;class ad{constructor(t){this.renderer=t,this._tempMatrix=new Et}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(od))||t.getLocalBounds(od,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=Wr.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=l1,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}ad.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"textureGenerator"},Y.add(ad);const jr=new at,ps=new at;class ld{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new at,this.destinationFrame=new at,this.viewportFrame=new at}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(jr.width=t.frame.width,jr.height=t.frame.height,e=jr),i||(ps.x=t.frame.x,ps.y=t.frame.y,ps.width=e.width,ps.height=e.height,i=ps),o=n.framebuffer):(a=s.resolution,e||(jr.width=s._view.screen.width,jr.height=s._view.screen.height,e=jr),i||(i=jr,i.width=e.width,i.height=e.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,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=bt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:c,height:u}=this.viewportFrame;l=Math.round(l),h=Math.round(h),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,c,u)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}ld.extension={type:X.RendererSystem,name:"renderTexture"},Y.add(ld);class h1{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function c1(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=Uu(t,n.type),a={type:o,name:n.name,size:Lu(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function u1(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Uu(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Du(l,n.size)}}return e}function d1(r,t){var a;const e=Bu(r,r.VERTEX_SHADER,t.vertexSrc),i=Bu(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||$v(r,s,e,i),t.attributeData=c1(s,r),t.uniformData=u1(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,c)=>h>c?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(s,l),value:Du(h.type,h.size)}}return new h1(s,o)}function f1(r,t,e,i,s){e.buffer.update(s)}const p1={float:`
420
420
  data[offset] = v;
421
421
  `,vec2:`
422
422
  data[offset] = v[0];
@@ -454,7 +454,7 @@ void main(void)
454
454
  {
455
455
  data[offset + i] = v[i];
456
456
  }
457
- `},dd={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:16*2,mat3:16*3,mat4:16*4};function y1(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=dd[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function _1(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function v1(r,t){if(!r.autoManage)return{size:0,syncFunc:m1};const e=_1(r.uniforms,t),{uboElements:i,size:s}=y1(e),n=[`
457
+ `},hd={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:16*2,mat3:16*3,mat4:16*4};function m1(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=hd[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function g1(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function y1(r,t){if(!r.autoManage)return{size:0,syncFunc:f1};const e=g1(r.uniforms,t),{uboElements:i,size:s}=m1(e),n=[`
458
458
  var v = null;
459
459
  var v2 = null;
460
460
  var cv = null;
@@ -462,7 +462,7 @@ void main(void)
462
462
  var gl = renderer.gl
463
463
  var index = 0;
464
464
  var data = buffer.data;
465
- `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<Ii.length;u++){const d=Ii[u];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,Ii[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){const u=ku(a.data.type),d=Math.max(dd[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(`
465
+ `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<Ii.length;u++){const d=Ii[u];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,Ii[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){const u=Lu(a.data.type),d=Math.max(hd[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(`
466
466
  cv = ud.${h}.value;
467
467
  v = uv.${h};
468
468
  offset = ${a.offset/4};
@@ -478,7 +478,7 @@ void main(void)
478
478
  offset += ${p};
479
479
  }
480
480
 
481
- `)}else{const u=g1[a.data.type];n.push(`
481
+ `)}else{const u=p1[a.data.type];n.push(`
482
482
  cv = ud.${h}.value;
483
483
  v = uv.${h};
484
484
  offset = ${a.offset/4};
@@ -486,7 +486,7 @@ void main(void)
486
486
  `)}}return n.push(`
487
487
  renderer.buffer.update(buffer);
488
488
  `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
489
- `))}}let x1=0;const Cn={textureCount:0,uboCount:0};class fd{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=x1++}systemCheck(){if(!zv())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(Cn.textureCount=0,Cn.uboCount=0,this.syncUniformGroup(t.uniformGroup,Cn)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Gv(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,Cn,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=v1(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=p1(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}fd.extension={type:X.RendererSystem,name:"shader"},Y.add(fd);class Rn{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Rn.defaultOptions={hello:!1},Rn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"startup"},Y.add(Rn);function b1(r,t=[]){return t[tt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.ADD]=[r.ONE,r.ONE],t[tt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.NONE]=[0,0],t[tt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[tt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[tt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[tt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[tt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[tt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[tt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[tt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[tt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[tt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const w1=0,E1=1,T1=2,A1=3,S1=4,I1=5,pd=class Ll{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=tt.NONE,this._blendEq=!1,this.map=[],this.map[w1]=this.setBlend,this.map[E1]=this.setOffset,this.map[T1]=this.setCullFace,this.map[A1]=this.setDepthTest,this.map[S1]=this.setFrontFace,this.map[I1]=this.setDepthMask,this.checks=[],this.defaultState=new Ve,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=b1(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(Ll.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Ll.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}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(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};pd.extension={type:X.RendererSystem,name:"state"};let C1=pd;Y.add(C1);class R1 extends Qi{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new we(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const ms=class so{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=so.defaultMaxIdle,this.checkCountMax=so.defaultCheckCountMax,this.mode=so.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==$o.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};ms.defaultMode=$o.AUTO,ms.defaultMaxIdle=60*60,ms.defaultCheckCountMax=60*10,ms.extension={type:X.RendererSystem,name:"textureGC"};let Yr=ms;Y.add(Yr);class Qa{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=J.UNSIGNED_BYTE,this.internalFormat=k.RGBA,this.samplerType=0}}function P1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:z.FLOAT,[r.RGBA]:z.FLOAT,[r.ALPHA]:z.FLOAT,[r.LUMINANCE]:z.FLOAT,[r.LUMINANCE_ALPHA]:z.FLOAT,[r.R8]:z.FLOAT,[r.R8_SNORM]:z.FLOAT,[r.RG8]:z.FLOAT,[r.RG8_SNORM]:z.FLOAT,[r.RGB8]:z.FLOAT,[r.RGB8_SNORM]:z.FLOAT,[r.RGB565]:z.FLOAT,[r.RGBA4]:z.FLOAT,[r.RGB5_A1]:z.FLOAT,[r.RGBA8]:z.FLOAT,[r.RGBA8_SNORM]:z.FLOAT,[r.RGB10_A2]:z.FLOAT,[r.RGB10_A2UI]:z.FLOAT,[r.SRGB8]:z.FLOAT,[r.SRGB8_ALPHA8]:z.FLOAT,[r.R16F]:z.FLOAT,[r.RG16F]:z.FLOAT,[r.RGB16F]:z.FLOAT,[r.RGBA16F]:z.FLOAT,[r.R32F]:z.FLOAT,[r.RG32F]:z.FLOAT,[r.RGB32F]:z.FLOAT,[r.RGBA32F]:z.FLOAT,[r.R11F_G11F_B10F]:z.FLOAT,[r.RGB9_E5]:z.FLOAT,[r.R8I]:z.INT,[r.R8UI]:z.UINT,[r.R16I]:z.INT,[r.R16UI]:z.UINT,[r.R32I]:z.INT,[r.R32UI]:z.UINT,[r.RG8I]:z.INT,[r.RG8UI]:z.UINT,[r.RG16I]:z.INT,[r.RG16UI]:z.UINT,[r.RG32I]:z.INT,[r.RG32UI]:z.UINT,[r.RGB8I]:z.INT,[r.RGB8UI]:z.UINT,[r.RGB16I]:z.INT,[r.RGB16UI]:z.UINT,[r.RGB32I]:z.INT,[r.RGB32UI]:z.UINT,[r.RGBA8I]:z.INT,[r.RGBA8UI]:z.UINT,[r.RGBA16I]:z.INT,[r.RGBA16UI]:z.UINT,[r.RGBA32I]:z.INT,[r.RGBA32UI]:z.UINT,[r.DEPTH_COMPONENT16]:z.FLOAT,[r.DEPTH_COMPONENT24]:z.FLOAT,[r.DEPTH_COMPONENT32F]:z.FLOAT,[r.DEPTH_STENCIL]:z.FLOAT,[r.DEPTH24_STENCIL8]:z.FLOAT,[r.DEPTH32F_STENCIL8]:z.FLOAT}:t={[r.RGB]:z.FLOAT,[r.RGBA]:z.FLOAT,[r.ALPHA]:z.FLOAT,[r.LUMINANCE]:z.FLOAT,[r.LUMINANCE_ALPHA]:z.FLOAT,[r.DEPTH_STENCIL]:z.FLOAT},t}function M1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[J.UNSIGNED_BYTE]:{[k.RGBA]:r.RGBA8,[k.RGB]:r.RGB8,[k.RG]:r.RG8,[k.RED]:r.R8,[k.RGBA_INTEGER]:r.RGBA8UI,[k.RGB_INTEGER]:r.RGB8UI,[k.RG_INTEGER]:r.RG8UI,[k.RED_INTEGER]:r.R8UI,[k.ALPHA]:r.ALPHA,[k.LUMINANCE]:r.LUMINANCE,[k.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[J.BYTE]:{[k.RGBA]:r.RGBA8_SNORM,[k.RGB]:r.RGB8_SNORM,[k.RG]:r.RG8_SNORM,[k.RED]:r.R8_SNORM,[k.RGBA_INTEGER]:r.RGBA8I,[k.RGB_INTEGER]:r.RGB8I,[k.RG_INTEGER]:r.RG8I,[k.RED_INTEGER]:r.R8I},[J.UNSIGNED_SHORT]:{[k.RGBA_INTEGER]:r.RGBA16UI,[k.RGB_INTEGER]:r.RGB16UI,[k.RG_INTEGER]:r.RG16UI,[k.RED_INTEGER]:r.R16UI,[k.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[J.SHORT]:{[k.RGBA_INTEGER]:r.RGBA16I,[k.RGB_INTEGER]:r.RGB16I,[k.RG_INTEGER]:r.RG16I,[k.RED_INTEGER]:r.R16I},[J.UNSIGNED_INT]:{[k.RGBA_INTEGER]:r.RGBA32UI,[k.RGB_INTEGER]:r.RGB32UI,[k.RG_INTEGER]:r.RG32UI,[k.RED_INTEGER]:r.R32UI,[k.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[J.INT]:{[k.RGBA_INTEGER]:r.RGBA32I,[k.RGB_INTEGER]:r.RGB32I,[k.RG_INTEGER]:r.RG32I,[k.RED_INTEGER]:r.R32I},[J.FLOAT]:{[k.RGBA]:r.RGBA32F,[k.RGB]:r.RGB32F,[k.RG]:r.RG32F,[k.RED]:r.R32F,[k.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[J.HALF_FLOAT]:{[k.RGBA]:r.RGBA16F,[k.RGB]:r.RGB16F,[k.RG]:r.RG16F,[k.RED]:r.R16F},[J.UNSIGNED_SHORT_5_6_5]:{[k.RGB]:r.RGB565},[J.UNSIGNED_SHORT_4_4_4_4]:{[k.RGBA]:r.RGBA4},[J.UNSIGNED_SHORT_5_5_5_1]:{[k.RGBA]:r.RGB5_A1},[J.UNSIGNED_INT_2_10_10_10_REV]:{[k.RGBA]:r.RGB10_A2,[k.RGBA_INTEGER]:r.RGB10_A2UI},[J.UNSIGNED_INT_10F_11F_11F_REV]:{[k.RGB]:r.R11F_G11F_B10F},[J.UNSIGNED_INT_5_9_9_9_REV]:{[k.RGB]:r.RGB9_E5},[J.UNSIGNED_INT_24_8]:{[k.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[J.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[k.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[J.UNSIGNED_BYTE]:{[k.RGBA]:r.RGBA,[k.RGB]:r.RGB,[k.ALPHA]:r.ALPHA,[k.LUMINANCE]:r.LUMINANCE,[k.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[J.UNSIGNED_SHORT_5_6_5]:{[k.RGB]:r.RGB},[J.UNSIGNED_SHORT_4_4_4_4]:{[k.RGBA]:r.RGBA},[J.UNSIGNED_SHORT_5_5_5_1]:{[k.RGBA]:r.RGBA}},t}class md{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new nt,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=M1(t),this.samplerTypes=P1(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new Qa(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Qa(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==z.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Qa(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??z.FLOAT,this.webGLVersion===2&&t.type===J.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==z.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&Si(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Le.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=mr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==Le.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===ir.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===ir.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===ir.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===ir.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}md.extension={type:X.RendererSystem,name:"texture"},Y.add(md);class gd{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}gd.extension={type:X.RendererSystem,name:"transformFeedback"},Y.add(gd);class Pn{constructor(t){this.renderer=t}init(t){this.screen=new at(0,0,t.width,t.height),this.element=t.view||W.ADAPTER.createCanvas(),this.resolution=t.resolution||W.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Pn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Pn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_view"},Y.add(Pn),W.PREFER_ENV=Or.WEBGL2,W.STRICT_TEXTURE_CACHE=!1,W.RENDER_OPTIONS={...An.defaultOptions,...Tn.defaultOptions,...Pn.defaultOptions,...Rn.defaultOptions},Object.defineProperties(W,{WRAP_MODE:{get(){return nt.defaultOptions.wrapMode},set(r){dt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),nt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return nt.defaultOptions.scaleMode},set(r){dt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),nt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return nt.defaultOptions.mipmap},set(r){dt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),nt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return nt.defaultOptions.anisotropicLevel},set(r){dt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),nt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return dt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),re.defaultResolution},set(r){re.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return dt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),re.defaultMultisample},set(r){re.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return zr.defaultMaxTextures},set(r){dt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),zr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return zr.defaultBatchSize},set(r){dt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),zr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return zr.canUploadSameBuffer},set(r){dt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),zr.canUploadSameBuffer=r}},GC_MODE:{get(){return Yr.defaultMode},set(r){dt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Yr.defaultMode=r}},GC_MAX_IDLE:{get(){return Yr.defaultMaxIdle},set(r){dt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Yr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Yr.defaultCheckCountMax},set(r){dt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Yr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return cr.defaultVertexPrecision},set(r){dt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),cr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return cr.defaultFragmentPrecision},set(r){dt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),cr.defaultFragmentPrecision=r}}});var qr=(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))(qr||{});class tl{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!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 e=this.next;return this.next=t?null:e,this.previous=null,e}}const yd=class he{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 tl(null,null,1/0),this.deltaMS=1/he.targetFPMS,this.elapsedMS=1/he.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),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(t,e,i=qr.NORMAL){return this._addListener(new tl(t,e,i))}addOnce(t,e,i=qr.NORMAL){return this._addListener(new tl(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*he.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,he.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!he._shared){const t=he._shared=new he;t.autoStart=!0,t._protected=!0}return he._shared}static get system(){if(!he._system){const t=he._system=new he;t.autoStart=!0,t._protected=!0}return he._system}};yd.targetFPMS=.06;let le=yd;Object.defineProperties(W,{TARGET_FPMS:{get(){return le.targetFPMS},set(r){dt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),le.targetFPMS=r}}});class _d{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,qr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?le.shared:new le,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}_d.extension=X.Application,Y.add(_d);const vd=[];Y.handleByList(X.Renderer,vd);function xd(r){for(const t of vd)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var B1=`attribute vec2 aVertexPosition;
489
+ `))}}let _1=0;const An={textureCount:0,uboCount:0};class cd{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=_1++}systemCheck(){if(!Xv())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(An.textureCount=0,An.uboCount=0,this.syncUniformGroup(t.uniformGroup,An)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Uv(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,An,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=y1(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=d1(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}cd.extension={type:X.RendererSystem,name:"shader"},Y.add(cd);class Sn{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Sn.defaultOptions={hello:!1},Sn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"startup"},Y.add(Sn);function v1(r,t=[]){return t[tt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.ADD]=[r.ONE,r.ONE],t[tt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.NONE]=[0,0],t[tt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[tt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[tt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[tt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[tt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[tt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[tt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[tt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[tt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[tt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[tt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const x1=0,b1=1,w1=2,E1=3,T1=4,A1=5,ud=class Bl{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=tt.NONE,this._blendEq=!1,this.map=[],this.map[x1]=this.setBlend,this.map[b1]=this.setOffset,this.map[w1]=this.setCullFace,this.map[E1]=this.setDepthTest,this.map[T1]=this.setFrontFace,this.map[A1]=this.setDepthMask,this.checks=[],this.defaultState=new Ve,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=v1(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(Bl.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Bl.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}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(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};ud.extension={type:X.RendererSystem,name:"state"};let S1=ud;Y.add(S1);class I1 extends Qi{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new we(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const ms=class to{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=to.defaultMaxIdle,this.checkCountMax=to.defaultCheckCountMax,this.mode=to.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==No.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};ms.defaultMode=No.AUTO,ms.defaultMaxIdle=60*60,ms.defaultCheckCountMax=60*10,ms.extension={type:X.RendererSystem,name:"textureGC"};let Yr=ms;Y.add(Yr);class qa{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=J.UNSIGNED_BYTE,this.internalFormat=k.RGBA,this.samplerType=0}}function C1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:z.FLOAT,[r.RGBA]:z.FLOAT,[r.ALPHA]:z.FLOAT,[r.LUMINANCE]:z.FLOAT,[r.LUMINANCE_ALPHA]:z.FLOAT,[r.R8]:z.FLOAT,[r.R8_SNORM]:z.FLOAT,[r.RG8]:z.FLOAT,[r.RG8_SNORM]:z.FLOAT,[r.RGB8]:z.FLOAT,[r.RGB8_SNORM]:z.FLOAT,[r.RGB565]:z.FLOAT,[r.RGBA4]:z.FLOAT,[r.RGB5_A1]:z.FLOAT,[r.RGBA8]:z.FLOAT,[r.RGBA8_SNORM]:z.FLOAT,[r.RGB10_A2]:z.FLOAT,[r.RGB10_A2UI]:z.FLOAT,[r.SRGB8]:z.FLOAT,[r.SRGB8_ALPHA8]:z.FLOAT,[r.R16F]:z.FLOAT,[r.RG16F]:z.FLOAT,[r.RGB16F]:z.FLOAT,[r.RGBA16F]:z.FLOAT,[r.R32F]:z.FLOAT,[r.RG32F]:z.FLOAT,[r.RGB32F]:z.FLOAT,[r.RGBA32F]:z.FLOAT,[r.R11F_G11F_B10F]:z.FLOAT,[r.RGB9_E5]:z.FLOAT,[r.R8I]:z.INT,[r.R8UI]:z.UINT,[r.R16I]:z.INT,[r.R16UI]:z.UINT,[r.R32I]:z.INT,[r.R32UI]:z.UINT,[r.RG8I]:z.INT,[r.RG8UI]:z.UINT,[r.RG16I]:z.INT,[r.RG16UI]:z.UINT,[r.RG32I]:z.INT,[r.RG32UI]:z.UINT,[r.RGB8I]:z.INT,[r.RGB8UI]:z.UINT,[r.RGB16I]:z.INT,[r.RGB16UI]:z.UINT,[r.RGB32I]:z.INT,[r.RGB32UI]:z.UINT,[r.RGBA8I]:z.INT,[r.RGBA8UI]:z.UINT,[r.RGBA16I]:z.INT,[r.RGBA16UI]:z.UINT,[r.RGBA32I]:z.INT,[r.RGBA32UI]:z.UINT,[r.DEPTH_COMPONENT16]:z.FLOAT,[r.DEPTH_COMPONENT24]:z.FLOAT,[r.DEPTH_COMPONENT32F]:z.FLOAT,[r.DEPTH_STENCIL]:z.FLOAT,[r.DEPTH24_STENCIL8]:z.FLOAT,[r.DEPTH32F_STENCIL8]:z.FLOAT}:t={[r.RGB]:z.FLOAT,[r.RGBA]:z.FLOAT,[r.ALPHA]:z.FLOAT,[r.LUMINANCE]:z.FLOAT,[r.LUMINANCE_ALPHA]:z.FLOAT,[r.DEPTH_STENCIL]:z.FLOAT},t}function R1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[J.UNSIGNED_BYTE]:{[k.RGBA]:r.RGBA8,[k.RGB]:r.RGB8,[k.RG]:r.RG8,[k.RED]:r.R8,[k.RGBA_INTEGER]:r.RGBA8UI,[k.RGB_INTEGER]:r.RGB8UI,[k.RG_INTEGER]:r.RG8UI,[k.RED_INTEGER]:r.R8UI,[k.ALPHA]:r.ALPHA,[k.LUMINANCE]:r.LUMINANCE,[k.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[J.BYTE]:{[k.RGBA]:r.RGBA8_SNORM,[k.RGB]:r.RGB8_SNORM,[k.RG]:r.RG8_SNORM,[k.RED]:r.R8_SNORM,[k.RGBA_INTEGER]:r.RGBA8I,[k.RGB_INTEGER]:r.RGB8I,[k.RG_INTEGER]:r.RG8I,[k.RED_INTEGER]:r.R8I},[J.UNSIGNED_SHORT]:{[k.RGBA_INTEGER]:r.RGBA16UI,[k.RGB_INTEGER]:r.RGB16UI,[k.RG_INTEGER]:r.RG16UI,[k.RED_INTEGER]:r.R16UI,[k.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[J.SHORT]:{[k.RGBA_INTEGER]:r.RGBA16I,[k.RGB_INTEGER]:r.RGB16I,[k.RG_INTEGER]:r.RG16I,[k.RED_INTEGER]:r.R16I},[J.UNSIGNED_INT]:{[k.RGBA_INTEGER]:r.RGBA32UI,[k.RGB_INTEGER]:r.RGB32UI,[k.RG_INTEGER]:r.RG32UI,[k.RED_INTEGER]:r.R32UI,[k.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[J.INT]:{[k.RGBA_INTEGER]:r.RGBA32I,[k.RGB_INTEGER]:r.RGB32I,[k.RG_INTEGER]:r.RG32I,[k.RED_INTEGER]:r.R32I},[J.FLOAT]:{[k.RGBA]:r.RGBA32F,[k.RGB]:r.RGB32F,[k.RG]:r.RG32F,[k.RED]:r.R32F,[k.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[J.HALF_FLOAT]:{[k.RGBA]:r.RGBA16F,[k.RGB]:r.RGB16F,[k.RG]:r.RG16F,[k.RED]:r.R16F},[J.UNSIGNED_SHORT_5_6_5]:{[k.RGB]:r.RGB565},[J.UNSIGNED_SHORT_4_4_4_4]:{[k.RGBA]:r.RGBA4},[J.UNSIGNED_SHORT_5_5_5_1]:{[k.RGBA]:r.RGB5_A1},[J.UNSIGNED_INT_2_10_10_10_REV]:{[k.RGBA]:r.RGB10_A2,[k.RGBA_INTEGER]:r.RGB10_A2UI},[J.UNSIGNED_INT_10F_11F_11F_REV]:{[k.RGB]:r.R11F_G11F_B10F},[J.UNSIGNED_INT_5_9_9_9_REV]:{[k.RGB]:r.RGB9_E5},[J.UNSIGNED_INT_24_8]:{[k.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[J.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[k.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[J.UNSIGNED_BYTE]:{[k.RGBA]:r.RGBA,[k.RGB]:r.RGB,[k.ALPHA]:r.ALPHA,[k.LUMINANCE]:r.LUMINANCE,[k.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[J.UNSIGNED_SHORT_5_6_5]:{[k.RGB]:r.RGB},[J.UNSIGNED_SHORT_4_4_4_4]:{[k.RGBA]:r.RGBA},[J.UNSIGNED_SHORT_5_5_5_1]:{[k.RGBA]:r.RGBA}},t}class dd{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new nt,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=R1(t),this.samplerTypes=C1(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new qa(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new qa(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==z.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new qa(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??z.FLOAT,this.webGLVersion===2&&t.type===J.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==z.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&Si(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Le.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=gr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==Le.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===ir.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===ir.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===ir.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===ir.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}dd.extension={type:X.RendererSystem,name:"texture"},Y.add(dd);class fd{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}fd.extension={type:X.RendererSystem,name:"transformFeedback"},Y.add(fd);class In{constructor(t){this.renderer=t}init(t){this.screen=new at(0,0,t.width,t.height),this.element=t.view||W.ADAPTER.createCanvas(),this.resolution=t.resolution||W.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}In.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},In.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_view"},Y.add(In),W.PREFER_ENV=Or.WEBGL2,W.STRICT_TEXTURE_CACHE=!1,W.RENDER_OPTIONS={...wn.defaultOptions,...bn.defaultOptions,...In.defaultOptions,...Sn.defaultOptions},Object.defineProperties(W,{WRAP_MODE:{get(){return nt.defaultOptions.wrapMode},set(r){dt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),nt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return nt.defaultOptions.scaleMode},set(r){dt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),nt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return nt.defaultOptions.mipmap},set(r){dt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),nt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return nt.defaultOptions.anisotropicLevel},set(r){dt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),nt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return dt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),re.defaultResolution},set(r){re.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return dt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),re.defaultMultisample},set(r){re.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return zr.defaultMaxTextures},set(r){dt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),zr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return zr.defaultBatchSize},set(r){dt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),zr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return zr.canUploadSameBuffer},set(r){dt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),zr.canUploadSameBuffer=r}},GC_MODE:{get(){return Yr.defaultMode},set(r){dt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Yr.defaultMode=r}},GC_MAX_IDLE:{get(){return Yr.defaultMaxIdle},set(r){dt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Yr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Yr.defaultCheckCountMax},set(r){dt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Yr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return ur.defaultVertexPrecision},set(r){dt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),ur.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return ur.defaultFragmentPrecision},set(r){dt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),ur.defaultFragmentPrecision=r}}});var qr=(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))(qr||{});class Ka{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!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 e=this.next;return this.next=t?null:e,this.previous=null,e}}const pd=class he{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 Ka(null,null,1/0),this.deltaMS=1/he.targetFPMS,this.elapsedMS=1/he.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),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(t,e,i=qr.NORMAL){return this._addListener(new Ka(t,e,i))}addOnce(t,e,i=qr.NORMAL){return this._addListener(new Ka(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*he.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,he.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!he._shared){const t=he._shared=new he;t.autoStart=!0,t._protected=!0}return he._shared}static get system(){if(!he._system){const t=he._system=new he;t.autoStart=!0,t._protected=!0}return he._system}};pd.targetFPMS=.06;let le=pd;Object.defineProperties(W,{TARGET_FPMS:{get(){return le.targetFPMS},set(r){dt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),le.targetFPMS=r}}});class md{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,qr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?le.shared:new le,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}md.extension=X.Application,Y.add(md);const gd=[];Y.handleByList(X.Renderer,gd);function yd(r){for(const t of gd)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var P1=`attribute vec2 aVertexPosition;
490
490
  attribute vec2 aTextureCoord;
491
491
 
492
492
  uniform mat3 projectionMatrix;
@@ -497,7 +497,7 @@ void main(void)
497
497
  {
498
498
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
499
499
  vTextureCoord = aTextureCoord;
500
- }`,D1=`attribute vec2 aVertexPosition;
500
+ }`,M1=`attribute vec2 aVertexPosition;
501
501
 
502
502
  uniform mat3 projectionMatrix;
503
503
 
@@ -523,7 +523,7 @@ void main(void)
523
523
  gl_Position = filterVertexPosition();
524
524
  vTextureCoord = filterTextureCoord();
525
525
  }
526
- `;const O1=B1,bd=D1;class wd{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Ot.HIGH?this.multisample=Ot.HIGH:e>=Ot.MEDIUM?this.multisample=Ot.MEDIUM:e>=Ot.LOW?this.multisample=Ot.LOW:this.multisample=Ot.NONE}destroy(){}}wd.extension={type:X.RendererSystem,name:"_multisample"},Y.add(wd);class F1{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Ed{constructor(t){this.renderer=t,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(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new F1(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Ed.extension={type:X.RendererSystem,name:"buffer"},Y.add(Ed);class Td{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Td.extension={type:X.RendererSystem,name:"objectRenderer"},Y.add(Td);const Mn=class Nl extends R1{constructor(t){super(),this.type=Qh.WEBGL,t=Object.assign({},W.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ee({projectionMatrix:new Et},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Nl.__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(e),"useContextAlpha"in t&&(dt("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Nl.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:nv()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),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(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}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 dt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return dt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return dt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return dt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){dt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return dt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){dt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return dt("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Mn.extension={type:X.Renderer,priority:1},Mn.__plugins={},Mn.__systems={};let el=Mn;Y.handleByMap(X.RendererPlugin,el.__plugins),Y.handleByMap(X.RendererSystem,el.__systems),Y.add(el);class Ad extends us{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new nt;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof us?this.addResourceAt(t[i],i):this.addResourceAt(Mu(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class L1 extends Ad{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=di.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class N1 extends ur{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Sd=class Ts extends Ad{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Ts.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Ts.SIDES;a++)this.items[a].target=di.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=di.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=di.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<Ts.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Ts.SIDES}};Sd.SIDES=6;let U1=Sd;class Ri extends ur{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Ri.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await W.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ie.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Ri._EMPTY=Ri._EMPTY??W.ADAPTER.createCanvas(0,0),Ri._EMPTY}}const rl=class no extends ur{constructor(t,e){e=e||{},super(W.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},no.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 t=new Image;ur.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${kr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=no.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&no.SVG_XML.test(t)}};rl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,rl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let il=rl;class k1 extends ur{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const sl=class Ul extends ur{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];ur.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||Ul.MIME_TYPES[c]||`video/${c}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.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),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=le.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!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 t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.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 t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(le.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||(le.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(le.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Ul.TYPES.includes(e)}};sl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],sl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Id=sl;ka.push(Ri,Wu,N1,Id,k1,il,dn,U1,L1);class Bn{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(t){return this.minX>this.maxX||this.minY>this.maxY?at.EMPTY:(t=t||new at(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*e.x+n*e.y+a,c=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,_=o*e+l*i+c,y=a*e+h*i+u;d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*i+c,y=a*s+h*i+u,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*e+l*n+c,y=a*e+h*n+u,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*n+c,y=a*s+h*n+u,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],c=t[l+1];s=h<s?h:s,n=c<n?c:n,o=h>o?h:o,a=c>a?c:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,_=this.maxY;for(let y=i;y<s;y+=2){const x=e[y],g=e[y+1],v=a*x+h*g+u,w=c*g+l*x+d;f=Math.min(f,v-n),m=Math.max(m,v+n),p=Math.min(p,w-o),_=Math.max(_,w+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=_}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class Rt extends Qi{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Va,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 Bn,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(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(Rt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}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(t,e){return t||(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),e||(this._boundsRect||(this._boundsRect=new at),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new at),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Bn);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){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 G1),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*Dv}set angle(t){this.transform.rotation=t*Ov}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class G1 extends Rt{constructor(){super(...arguments),this.sortDirty=null}}Rt.prototype.displayObjectUpdateTransform=Rt.prototype.updateTransform;const $1=new Et;function H1(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Cd=class kl extends Rt{constructor(){super(),this.children=[],this.sortableChildren=kl.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Si(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Si(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Si(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(H1),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 t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==kl.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=$1.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);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(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==Ft.NONE));if(s&&t.batch.flush(),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};Cd.defaultSortableChildren=!1;let Te=Cd;Te.prototype.containerUpdateTransform=Te.prototype.updateTransform,Object.defineProperties(W,{SORTABLE_CHILDREN:{get(){return Te.defaultSortableChildren},set(r){dt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Te.defaultSortableChildren=r}}});const gs=new gt,X1=new Uint16Array([0,1,2,0,2,3]);class Pi extends Te{constructor(t){super(),this._anchor=new hr(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new bt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=tt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||q.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=X1,this.pluginName="batch",this.isSprite=!0,this._roundPixels=W.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=vr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=vr(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,_=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,_=c.y-d._y*u.height,m=_+c.height):(p=-d._x*u.width,f=p+u.width,_=-d._y*u.height,m=_+u.height),h[0]=i*p+n*_+a,h[1]=o*_+s*p+l,h[2]=i*f+n*_+a,h[3]=o*_+s*f+l,h[4]=i*f+n*m+a,h[5]=o*m+s*f+l,h[6]=i*p+n*m+a,h[7]=o*m+s*p+l,this._roundPixels){const y=W.RESOLUTION;for(let x=0;x<h.length;++x)h[x]=Math.round(h[x]*y)/y}}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 t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty,d=-s._x*i.width,f=d+i.width,p=-s._y*i.height,m=p+i.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*m+c,e[5]=h*m+a*f+u,e[6]=o*d+l*m+c,e[7]=h*m+a*d+u,this._roundPixels){const _=W.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*_)/_}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Bn),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),t||(this._localBoundsRect||(this._localBoundsRect=new at),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,gs);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return gs.x>=s&&gs.x<s+e&&(n=-i*this.anchor.y,gs.y>=n&&gs.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof q?t:q.from(t,e);return new Pi(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=vr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=vr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||q.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Rd=new Et;Rt.prototype._cacheAsBitmap=!1,Rt.prototype._cacheData=null,Rt.prototype._cacheAsBitmapResolution=null,Rt.prototype._cacheAsBitmapMultisample=null;class V1{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(Rt.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 t;r?(this._cacheData||(this._cacheData=new V1),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),Rt.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))},Rt.prototype._initCachedDisplayObject=function(r){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new at,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=Wr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${kr()}`;this._cacheData.textureCacheId=h,nt.addToCache(l.baseTexture,h),q.addToCache(l,h);const c=this.transform.localTransform.copyTo(Rd).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new Pi(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},Rt.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))},Rt.prototype._initCachedDisplayObjectCanvas=function(r){var c;if((c=this._cacheData)!=null&&c.sprite)return;const t=this.getLocalBounds(new at,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Wr.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${kr()}`;this._cacheData.textureCacheId=a,nt.addToCache(o.baseTexture,a),q.addToCache(o,a);const l=Rd;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,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=e;const h=new Pi(o);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)},Rt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Rt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Rt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,nt.removeFromCache(this._cacheData.textureCacheId),q.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Rt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Rt.prototype.name=null,Te.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},Rt.prototype.getGlobalPosition=function(r=new gt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var z1=`varying vec2 vTextureCoord;
526
+ `;const B1=P1,_d=M1;class vd{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Ot.HIGH?this.multisample=Ot.HIGH:e>=Ot.MEDIUM?this.multisample=Ot.MEDIUM:e>=Ot.LOW?this.multisample=Ot.LOW:this.multisample=Ot.NONE}destroy(){}}vd.extension={type:X.RendererSystem,name:"_multisample"},Y.add(vd);class D1{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class xd{constructor(t){this.renderer=t,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(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new D1(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}xd.extension={type:X.RendererSystem,name:"buffer"},Y.add(xd);class bd{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}bd.extension={type:X.RendererSystem,name:"objectRenderer"},Y.add(bd);const Cn=class Dl extends I1{constructor(t){super(),this.type=qh.WEBGL,t=Object.assign({},W.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ee({projectionMatrix:new Et},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Dl.__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(e),"useContextAlpha"in t&&(dt("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Dl.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:iv()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),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(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}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 dt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return dt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return dt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return dt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){dt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return dt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){dt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return dt("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Cn.extension={type:X.Renderer,priority:1},Cn.__plugins={},Cn.__systems={};let Za=Cn;Y.handleByMap(X.RendererPlugin,Za.__plugins),Y.handleByMap(X.RendererSystem,Za.__systems),Y.add(Za);class wd extends us{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new nt;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof us?this.addResourceAt(t[i],i):this.addResourceAt(Cu(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class O1 extends wd{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=di.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class F1 extends dr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Ed=class Ts extends wd{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Ts.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Ts.SIDES;a++)this.items[a].target=di.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=di.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=di.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<Ts.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Ts.SIDES}};Ed.SIDES=6;let L1=Ed;class Ri extends dr{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Ri.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await W.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ie.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Ri._EMPTY=Ri._EMPTY??W.ADAPTER.createCanvas(0,0),Ri._EMPTY}}const Ja=class eo extends dr{constructor(t,e){e=e||{},super(W.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},eo.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 t=new Image;dr.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${kr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=eo.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&eo.SVG_XML.test(t)}};Ja.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Ja.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Qa=Ja;class N1 extends dr{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const tl=class Ol extends dr{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];dr.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||Ol.MIME_TYPES[c]||`video/${c}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.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),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=le.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!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 t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.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 t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(le.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||(le.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(le.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Ol.TYPES.includes(e)}};tl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],tl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Td=tl;Fa.push(Ri,Xu,F1,Td,N1,Qa,hn,L1,O1);class Rn{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(t){return this.minX>this.maxX||this.minY>this.maxY?at.EMPTY:(t=t||new at(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*e.x+n*e.y+a,c=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,_=o*e+l*i+c,y=a*e+h*i+u;d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*i+c,y=a*s+h*i+u,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*e+l*n+c,y=a*e+h*n+u,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*n+c,y=a*s+h*n+u,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],c=t[l+1];s=h<s?h:s,n=c<n?c:n,o=h>o?h:o,a=c>a?c:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,_=this.maxY;for(let y=i;y<s;y+=2){const x=e[y],g=e[y+1],v=a*x+h*g+u,w=c*g+l*x+d;f=Math.min(f,v-n),m=Math.max(m,v+n),p=Math.min(p,w-o),_=Math.max(_,w+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=_}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class Rt extends Qi{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Ga,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 Rn,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(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(Rt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}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(t,e){return t||(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),e||(this._boundsRect||(this._boundsRect=new at),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new at),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Rn);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){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 U1),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*Mv}set angle(t){this.transform.rotation=t*Bv}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class U1 extends Rt{constructor(){super(...arguments),this.sortDirty=null}}Rt.prototype.displayObjectUpdateTransform=Rt.prototype.updateTransform;const k1=new Et;function G1(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Ad=class Fl extends Rt{constructor(){super(),this.children=[],this.sortableChildren=Fl.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Si(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Si(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Si(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(G1),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 t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==Fl.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=k1.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);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(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==Ft.NONE));if(s&&t.batch.flush(),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};Ad.defaultSortableChildren=!1;let Te=Ad;Te.prototype.containerUpdateTransform=Te.prototype.updateTransform,Object.defineProperties(W,{SORTABLE_CHILDREN:{get(){return Te.defaultSortableChildren},set(r){dt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Te.defaultSortableChildren=r}}});const gs=new gt,$1=new Uint16Array([0,1,2,0,2,3]);class Pi extends Te{constructor(t){super(),this._anchor=new cr(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new bt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=tt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||q.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=$1,this.pluginName="batch",this.isSprite=!0,this._roundPixels=W.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=vr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=vr(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,_=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,_=c.y-d._y*u.height,m=_+c.height):(p=-d._x*u.width,f=p+u.width,_=-d._y*u.height,m=_+u.height),h[0]=i*p+n*_+a,h[1]=o*_+s*p+l,h[2]=i*f+n*_+a,h[3]=o*_+s*f+l,h[4]=i*f+n*m+a,h[5]=o*m+s*f+l,h[6]=i*p+n*m+a,h[7]=o*m+s*p+l,this._roundPixels){const y=W.RESOLUTION;for(let x=0;x<h.length;++x)h[x]=Math.round(h[x]*y)/y}}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 t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty,d=-s._x*i.width,f=d+i.width,p=-s._y*i.height,m=p+i.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*m+c,e[5]=h*m+a*f+u,e[6]=o*d+l*m+c,e[7]=h*m+a*d+u,this._roundPixels){const _=W.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*_)/_}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Rn),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),t||(this._localBoundsRect||(this._localBoundsRect=new at),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,gs);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return gs.x>=s&&gs.x<s+e&&(n=-i*this.anchor.y,gs.y>=n&&gs.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof q?t:q.from(t,e);return new Pi(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=vr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=vr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||q.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Sd=new Et;Rt.prototype._cacheAsBitmap=!1,Rt.prototype._cacheData=null,Rt.prototype._cacheAsBitmapResolution=null,Rt.prototype._cacheAsBitmapMultisample=null;class H1{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(Rt.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 t;r?(this._cacheData||(this._cacheData=new H1),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),Rt.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))},Rt.prototype._initCachedDisplayObject=function(r){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new at,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=Wr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${kr()}`;this._cacheData.textureCacheId=h,nt.addToCache(l.baseTexture,h),q.addToCache(l,h);const c=this.transform.localTransform.copyTo(Sd).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new Pi(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},Rt.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))},Rt.prototype._initCachedDisplayObjectCanvas=function(r){var c;if((c=this._cacheData)!=null&&c.sprite)return;const t=this.getLocalBounds(new at,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Wr.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${kr()}`;this._cacheData.textureCacheId=a,nt.addToCache(o.baseTexture,a),q.addToCache(o,a);const l=Sd;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,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=e;const h=new Pi(o);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)},Rt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Rt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Rt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,nt.removeFromCache(this._cacheData.textureCacheId),q.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Rt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Rt.prototype.name=null,Te.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},Rt.prototype.getGlobalPosition=function(r=new gt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var X1=`varying vec2 vTextureCoord;
527
527
 
528
528
  uniform sampler2D uSampler;
529
529
  uniform float uAlpha;
@@ -532,9 +532,9 @@ void main(void)
532
532
  {
533
533
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
534
534
  }
535
- `;class W1 extends re{constructor(t=1){super(O1,z1,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const j1={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]},Y1=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
536
- `);function q1(r){const t=j1[r],e=t.length;let i=Y1,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
537
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const K1=`
535
+ `;class V1 extends re{constructor(t=1){super(B1,X1,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const z1={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]},W1=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
536
+ `);function j1(r){const t=z1[r],e=t.length;let i=W1,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
537
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const Y1=`
538
538
  attribute vec2 aVertexPosition;
539
539
 
540
540
  uniform mat3 projectionMatrix;
@@ -564,8 +564,8 @@ void main(void)
564
564
 
565
565
  vec2 textureCoord = filterTextureCoord();
566
566
  %blur%
567
- }`;function Z1(r,t){const e=Math.ceil(r/2);let i=K1,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
568
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class nl extends re{constructor(t,e=8,i=4,s=re.defaultResolution,n=5){const o=Z1(n,t),a=q1(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,Ne.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,Ne.BLIT),this.uniforms.uSampler=l;const c=l;l=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class J1 extends re{constructor(t=8,e=4,i=re.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new nl(!0,t,e,i,s),this.blurYFilter=new nl(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,Ne.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}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(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var Q1=`varying vec2 vTextureCoord;
567
+ }`;function q1(r,t){const e=Math.ceil(r/2);let i=Y1,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
568
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class el extends re{constructor(t,e=8,i=4,s=re.defaultResolution,n=5){const o=q1(n,t),a=j1(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,Ne.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,Ne.BLIT),this.uniforms.uSampler=l;const c=l;l=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class K1 extends re{constructor(t=8,e=4,i=re.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new el(!0,t,e,i,s),this.blurYFilter=new el(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,Ne.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}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(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var Z1=`varying vec2 vTextureCoord;
569
569
  uniform sampler2D uSampler;
570
570
  uniform float m[20];
571
571
  uniform float uAlpha;
@@ -617,7 +617,7 @@ void main(void)
617
617
 
618
618
  gl_FragColor = vec4(rgb, result.a);
619
619
  }
620
- `;class ol extends re{constructor(){const t={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(bd,Q1,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=bt.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,c=o*(1-i)+a*s,u=o*(1-i)+a*s,d=i+o*(1-i),f=o*(1-i)-a*s,p=o*(1-i)-a*s,m=o*(1-i)+a*s,_=i+o*(1-i),y=[l,h,c,0,0,u,d,f,0,0,p,m,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[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(e,t)}polaroid(t){const e=[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(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[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(e,t)}browni(t){const e=[.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(e,t)}vintage(t){const e=[.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(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=bt.shared,[a,l,h]=o.setValue(i).toArray(),[c,u,d]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,h,t,0,c,u,d,e,0,a-c,l-u,h-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}ol.prototype.grayscale=ol.prototype.greyscale;var tx=`varying vec2 vFilterCoord;
620
+ `;class rl extends re{constructor(){const t={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(_d,Z1,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=bt.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,c=o*(1-i)+a*s,u=o*(1-i)+a*s,d=i+o*(1-i),f=o*(1-i)-a*s,p=o*(1-i)-a*s,m=o*(1-i)+a*s,_=i+o*(1-i),y=[l,h,c,0,0,u,d,f,0,0,p,m,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[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(e,t)}polaroid(t){const e=[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(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[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(e,t)}browni(t){const e=[.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(e,t)}vintage(t){const e=[.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(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=bt.shared,[a,l,h]=o.setValue(i).toArray(),[c,u,d]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,h,t,0,c,u,d,e,0,a-c,l-u,h-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}rl.prototype.grayscale=rl.prototype.greyscale;var J1=`varying vec2 vFilterCoord;
621
621
  varying vec2 vTextureCoord;
622
622
 
623
623
  uniform vec2 scale;
@@ -637,7 +637,7 @@ void main(void)
637
637
 
638
638
  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
639
639
  }
640
- `,ex=`attribute vec2 aVertexPosition;
640
+ `,Q1=`attribute vec2 aVertexPosition;
641
641
 
642
642
  uniform mat3 projectionMatrix;
643
643
  uniform mat3 filterMatrix;
@@ -666,7 +666,7 @@ void main(void)
666
666
  vTextureCoord = filterTextureCoord();
667
667
  vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
668
668
  }
669
- `;class rx extends re{constructor(t,e){const i=new Et;t.renderable=!1,super(ex,tx,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new gt(e,e)}apply(t,e,i,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var ix=`varying vec2 v_rgbNW;
669
+ `;class tx extends re{constructor(t,e){const i=new Et;t.renderable=!1,super(Q1,J1,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new gt(e,e)}apply(t,e,i,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var ex=`varying vec2 v_rgbNW;
670
670
  varying vec2 v_rgbNE;
671
671
  varying vec2 v_rgbSW;
672
672
  varying vec2 v_rgbSE;
@@ -787,7 +787,7 @@ void main() {
787
787
 
788
788
  gl_FragColor = color;
789
789
  }
790
- `,sx=`
790
+ `,rx=`
791
791
  attribute vec2 aVertexPosition;
792
792
 
793
793
  uniform mat3 projectionMatrix;
@@ -829,7 +829,7 @@ void main(void) {
829
829
 
830
830
  texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
831
831
  }
832
- `;class nx extends re{constructor(){super(sx,ix)}}var ox=`precision highp float;
832
+ `;class ix extends re{constructor(){super(rx,ex)}}var sx=`precision highp float;
833
833
 
834
834
  varying vec2 vTextureCoord;
835
835
  varying vec4 vColor;
@@ -863,8 +863,8 @@ void main()
863
863
 
864
864
  gl_FragColor = color;
865
865
  }
866
- `;class ax extends re{constructor(t=.5,e=Math.random()){super(bd,ox,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Pd={AlphaFilter:W1,BlurFilter:J1,BlurFilterPass:nl,ColorMatrixFilter:ol,DisplacementFilter:rx,FXAAFilter:nx,NoiseFilter:ax};Object.entries(Pd).forEach(([r,t])=>{Object.defineProperty(Pd,r,{get(){return dt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class lx{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(le.system.add(this.tickerUpdate,this,qr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(le.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 t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const wr=new lx;class ys{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ys.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new gt,this.page=new gt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}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(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){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 Dn extends ys{constructor(){super(...arguments),this.client=new gt,this.movement=new gt,this.offset=new gt,this.global=new gt,this.screen=new gt}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(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class Ae extends Dn{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 Mi extends Dn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Mi.DOM_DELTA_PIXEL=0,Mi.DOM_DELTA_LINE=1,Mi.DOM_DELTA_PAGE=2;const hx=2048,cx=new gt,al=new gt;class ux{constructor(t){this.dispatch=new Qi,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,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(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){wr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,cx.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<hx&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(wr.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(wr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const c=l[h],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,i,s,n);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,al),!t.hitArea.contains(al.x,al.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,o;e=e??t.type;const i=`on${e}`;(o=(n=t.currentTarget)[i])==null||o.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof Ae)){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 e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,n);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);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;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);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 s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;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 s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,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(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof Mi)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(Ae);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Mi);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Ae);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Ae&&e instanceof Ae&&(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)}copyMouseData(t,e){t instanceof Dn&&e instanceof Dn&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const dx=1,fx={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ll=class Gl{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new ux(null),wr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Ae(null),this.rootWheelEvent=new Mi(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Gl.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!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(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Gl._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,wr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,wr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;wr.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.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;wr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.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(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;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=dx),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,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,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=fx[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};ll.extension={name:"events",type:[X.RendererSystem,X.CanvasRendererSystem]},ll.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let hl=ll;Y.add(hl);function Md(r){return r==="dynamic"||r==="static"}const px={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??Md(hl.defaultEventMode)},set interactive(r){dt("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??hl.defaultEventMode},set eventMode(r){this._internalInteractive=Md(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof ys))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}};Rt.mixin(px);const mx={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Rt.mixin(mx);const gx=9,On=100,yx=0,_x=0,Bd=2,Dd=1,vx=-1e3,xx=-1e3,bx=2;class Od{constructor(t){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,(nr.tablet||nr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${On}px`,e.style.height=`${On}px`,e.style.position="absolute",e.style.top=`${yx}px`,e.style.left=`${_x}px`,e.style.zIndex=Bd.toString(),this.div=e,this.renderer=t,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 t=document.createElement("button");t.style.width=`${Dd}px`,t.style.height=`${Dd}px`,t.style.position="absolute",t.style.top=`${vx}px`,t.style.left=`${xx}px`,t.style.zIndex=bx.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;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),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!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),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(nr.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,c=n/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.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,Si(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*h}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*h}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${On}px`,e.style.height=`${On}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Bd.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new ys(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===gx&&this.activate()}_onMouseMove(t){t.movementX===0&&t.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}}Od.extension={name:"accessibility",type:[X.RendererPlugin,X.CanvasRendererPlugin]},Y.add(Od);const Fd=class $l{constructor(t){this.stage=new Te,t=Object.assign({forceCanvas:!1},t),this.renderer=xd(t),$l._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=$l._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Fd._plugins=[];let wx=Fd;Y.handleByList(X.Application,wx._plugins);class Ld{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(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 e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Ld.extension=X.Application,Y.add(Ld);const Nd={loader:X.LoadParser,resolver:X.ResolveParser,cache:X.CacheParser,detection:X.DetectionParser};Y.handle(X.Asset,r=>{const t=r.ref;Object.entries(Nd).filter(([e])=>!!t[e]).forEach(([e,i])=>Y.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Nd).filter(e=>!!t[e]).forEach(e=>Y.remove(t[e]))});class Ex{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),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 t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Bi(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Er(r,t){const e=r.split("?")[0],i=Gt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Se=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),cl=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Ud(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Ud(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function Tx(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Ud(r,s,0,e,i)}else i.push(r);return i}const Fn=r=>!Array.isArray(r);class Ax{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Se(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof q){const a=e;i.forEach(l=>{a.baseTexture!==q.EMPTY.baseTexture&&nt.addToCache(a.baseTexture,l),q.addToCache(a,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Kr=new Ax;class Sx{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Fn(t),o=Se(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=Gt.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),s[h.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(u){throw delete this.promiseCache[c],delete s[h.src],new Error(`[Loader.load] Failed to load ${c}.
867
- ${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Se(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=Gt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var Ie=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ie||{});const Ix=".json",Cx="application/json",Rx={extension:{type:X.LoadParser,priority:Ie.Low},name:"loadJson",test(r){return Bi(r,Cx)||Er(r,Ix)},async load(r){return await(await W.ADAPTER.fetch(r)).json()}};Y.add(Rx);const Px=".txt",Mx="text/plain",Bx={name:"loadTxt",extension:{type:X.LoadParser,priority:Ie.Low},test(r){return Bi(r,Mx)||Er(r,Px)},async load(r){return await(await W.ADAPTER.fetch(r)).text()}};Y.add(Bx);const Dx=["normal","bold","100","200","300","400","500","600","700","800","900"],Ox=[".ttf",".otf",".woff",".woff2"],Fx=["font/ttf","font/otf","font/woff","font/woff2"],Lx=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Nx(r){const t=Gt.extname(r),e=Gt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(Lx)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const Ux=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function kx(r){return Ux.test(r)?r:encodeURI(r)}const Gx={extension:{type:X.LoadParser,priority:Ie.Low},name:"loadWebFont",test(r){return Bi(r,Fx)||Er(r,Ox)},async load(r,t){var i,s,n;const e=W.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??Nx(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(c=>Dx.includes(c)))??["normal"],h=t.data??{};for(let c=0;c<l.length;c++){const u=l[c],d=new FontFace(a,`url(${kx(r)})`,{...h,weight:u});await d.load(),e.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(t=>W.ADAPTER.getFontFaceSet().delete(t))}};Y.add(Gx);const $x=`(function() {
866
+ `;class nx extends re{constructor(t=.5,e=Math.random()){super(_d,sx,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Id={AlphaFilter:V1,BlurFilter:K1,BlurFilterPass:el,ColorMatrixFilter:rl,DisplacementFilter:tx,FXAAFilter:ix,NoiseFilter:nx};Object.entries(Id).forEach(([r,t])=>{Object.defineProperty(Id,r,{get(){return dt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class ox{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(le.system.add(this.tickerUpdate,this,qr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(le.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 t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const wr=new ox;class ys{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ys.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new gt,this.page=new gt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}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(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){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 Pn extends ys{constructor(){super(...arguments),this.client=new gt,this.movement=new gt,this.offset=new gt,this.global=new gt,this.screen=new gt}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(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class Ae extends Pn{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 Mi extends Pn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Mi.DOM_DELTA_PIXEL=0,Mi.DOM_DELTA_LINE=1,Mi.DOM_DELTA_PAGE=2;const ax=2048,lx=new gt,il=new gt;class hx{constructor(t){this.dispatch=new Qi,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,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(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){wr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,lx.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<ax&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(wr.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(wr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const c=l[h],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,i,s,n);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,il),!t.hitArea.contains(il.x,il.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,o;e=e??t.type;const i=`on${e}`;(o=(n=t.currentTarget)[i])==null||o.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof Ae)){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 e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,n);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);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;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);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 s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;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 s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,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(t){if(!(t instanceof Ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof Mi)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(Ae);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Mi);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Ae);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Ae&&e instanceof Ae&&(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)}copyMouseData(t,e){t instanceof Pn&&e instanceof Pn&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const cx=1,ux={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},sl=class Ll{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new hx(null),wr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Ae(null),this.rootWheelEvent=new Mi(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ll.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!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(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Ll._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,wr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,wr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;wr.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.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;wr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.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(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;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=cx),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,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,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=ux[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};sl.extension={name:"events",type:[X.RendererSystem,X.CanvasRendererSystem]},sl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let nl=sl;Y.add(nl);function Cd(r){return r==="dynamic"||r==="static"}const dx={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??Cd(nl.defaultEventMode)},set interactive(r){dt("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??nl.defaultEventMode},set eventMode(r){this._internalInteractive=Cd(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof ys))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}};Rt.mixin(dx);const fx={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Rt.mixin(fx);const px=9,Mn=100,mx=0,gx=0,Rd=2,Pd=1,yx=-1e3,_x=-1e3,vx=2;class Md{constructor(t){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,(nr.tablet||nr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Mn}px`,e.style.height=`${Mn}px`,e.style.position="absolute",e.style.top=`${mx}px`,e.style.left=`${gx}px`,e.style.zIndex=Rd.toString(),this.div=e,this.renderer=t,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 t=document.createElement("button");t.style.width=`${Pd}px`,t.style.height=`${Pd}px`,t.style.position="absolute",t.style.top=`${yx}px`,t.style.left=`${_x}px`,t.style.zIndex=vx.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;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),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!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),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(nr.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,c=n/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.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,Si(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*h}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*h}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${Mn}px`,e.style.height=`${Mn}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Rd.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new ys(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===px&&this.activate()}_onMouseMove(t){t.movementX===0&&t.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}}Md.extension={name:"accessibility",type:[X.RendererPlugin,X.CanvasRendererPlugin]},Y.add(Md);const Bd=class Nl{constructor(t){this.stage=new Te,t=Object.assign({forceCanvas:!1},t),this.renderer=yd(t),Nl._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=Nl._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Bd._plugins=[];let xx=Bd;Y.handleByList(X.Application,xx._plugins);class Dd{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(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 e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Dd.extension=X.Application,Y.add(Dd);const Od={loader:X.LoadParser,resolver:X.ResolveParser,cache:X.CacheParser,detection:X.DetectionParser};Y.handle(X.Asset,r=>{const t=r.ref;Object.entries(Od).filter(([e])=>!!t[e]).forEach(([e,i])=>Y.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Od).filter(e=>!!t[e]).forEach(e=>Y.remove(t[e]))});class bx{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),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 t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Bi(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Er(r,t){const e=r.split("?")[0],i=Gt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Se=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),ol=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Fd(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Fd(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function wx(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Fd(r,s,0,e,i)}else i.push(r);return i}const Bn=r=>!Array.isArray(r);class Ex{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Se(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof q){const a=e;i.forEach(l=>{a.baseTexture!==q.EMPTY.baseTexture&&nt.addToCache(a.baseTexture,l),q.addToCache(a,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Kr=new Ex;class Tx{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Bn(t),o=Se(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=Gt.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),s[h.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(u){throw delete this.promiseCache[c],delete s[h.src],new Error(`[Loader.load] Failed to load ${c}.
867
+ ${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Se(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=Gt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var Ie=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ie||{});const Ax=".json",Sx="application/json",Ix={extension:{type:X.LoadParser,priority:Ie.Low},name:"loadJson",test(r){return Bi(r,Sx)||Er(r,Ax)},async load(r){return await(await W.ADAPTER.fetch(r)).json()}};Y.add(Ix);const Cx=".txt",Rx="text/plain",Px={name:"loadTxt",extension:{type:X.LoadParser,priority:Ie.Low},test(r){return Bi(r,Rx)||Er(r,Cx)},async load(r){return await(await W.ADAPTER.fetch(r)).text()}};Y.add(Px);const Mx=["normal","bold","100","200","300","400","500","600","700","800","900"],Bx=[".ttf",".otf",".woff",".woff2"],Dx=["font/ttf","font/otf","font/woff","font/woff2"],Ox=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Fx(r){const t=Gt.extname(r),e=Gt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(Ox)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const Lx=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Nx(r){return Lx.test(r)?r:encodeURI(r)}const Ux={extension:{type:X.LoadParser,priority:Ie.Low},name:"loadWebFont",test(r){return Bi(r,Dx)||Er(r,Bx)},async load(r,t){var i,s,n;const e=W.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??Fx(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(c=>Mx.includes(c)))??["normal"],h=t.data??{};for(let c=0;c<l.length;c++){const u=l[c],d=new FontFace(a,`url(${Nx(r)})`,{...h,weight:u});await d.load(),e.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(t=>W.ADAPTER.getFontFaceSet().delete(t))}};Y.add(Ux);const kx=`(function() {
868
868
  "use strict";
869
869
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
870
870
  async function checkImageBitmap() {
@@ -881,7 +881,7 @@ ${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Se
881
881
  self.postMessage(result);
882
882
  });
883
883
  })();
884
- `;let Di=null,ul=class{constructor(){Di||(Di=URL.createObjectURL(new Blob([$x],{type:"application/javascript"}))),this.worker=new Worker(Di)}};ul.revokeObjectURL=function(){Di&&(URL.revokeObjectURL(Di),Di=null)};const Hx=`(function() {
884
+ `;let Di=null,al=class{constructor(){Di||(Di=URL.createObjectURL(new Blob([kx],{type:"application/javascript"}))),this.worker=new Worker(Di)}};al.revokeObjectURL=function(){Di&&(URL.revokeObjectURL(Di),Di=null)};const Gx=`(function() {
885
885
  "use strict";
886
886
  async function loadImageBitmap(url) {
887
887
  const response = await fetch(url);
@@ -907,8 +907,8 @@ ${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Se
907
907
  }
908
908
  };
909
909
  })();
910
- `;let Oi=null;class kd{constructor(){Oi||(Oi=URL.createObjectURL(new Blob([Hx],{type:"application/javascript"}))),this.worker=new Worker(Oi)}}kd.revokeObjectURL=function(){Oi&&(URL.revokeObjectURL(Oi),Oi=null)};let Gd=0,dl;class Xx{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(t=>{const{worker:e}=new ul;e.addEventListener("message",i=>{e.terminate(),ul.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){dl===void 0&&(dl=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<dl&&(this._createdWorkers++,t=new kd().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Gd]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Gd++,id:i})}}const $d=new Xx;function _s(r,t,e){r.resource.internal=!0;const i=new q(r),s=()=>{delete t.promiseCache[e],Kr.has(e)&&Kr.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),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."),s())}),i}const Vx=[".jpeg",".jpg",".png",".webp",".avif"],zx=["image/jpeg","image/png","image/webp","image/avif"];async function Wx(r){const t=await W.ADAPTER.fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Ln={name:"loadTextures",extension:{type:X.LoadParser,priority:Ie.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Bi(r,zx)||Er(r,Vx)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await $d.isImageBitmapSupported()?s=await $d.loadImageBitmap(r):s=await Wx(r):s=await new Promise((l,h)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=r,c.complete?l(c):(c.onload=()=>l(c),c.onerror=u=>h(u))});const n={...t.data};n.resolution??(n.resolution=lr(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new nt(s,n);return o.resource.src=r,_s(o,e,r)},unload(r){r.destroy(!0)}};Y.add(Ln);const jx=".svg",Yx="image/svg+xml",qx={extension:{type:X.LoadParser,priority:Ie.High},name:"loadSVG",test(r){return Bi(r,Yx)||Er(r,jx)},async testParse(r){return il.test(r)},async parse(r,t,e){var n;const i=new il(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new nt(i,{resolution:lr(r),...t==null?void 0:t.data});return s.resource.src=t.src,_s(s,e,t.src)},async load(r,t){return(await W.ADAPTER.fetch(r)).text()},unload:Ln.unload};Y.add(qx);const Kx=[".mp4",".m4v",".webm",".ogv"],Zx=["video/mp4","video/webm","video/ogg"],Jx={name:"loadVideo",extension:{type:X.LoadParser,priority:Ie.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return Bi(r,Zx)||Er(r,Kx)},async load(r,t,e){var o;let i;const s=await(await W.ADAPTER.fetch(r)).blob(),n=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,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions,autoLoad:!0},l=new Id(n,a);await l.load();const h=new nt(l,{alphaMode:await sv(),resolution:lr(r),...t==null?void 0:t.data});h.resource.src=r,i=_s(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};Y.add(Jx);class Qx{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${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(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}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(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return Se(e||i||s||n,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(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,o=s.alias??s.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));i.push(...l),a=[...o,...l]}this.add({...s,alias:a,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const o=e[s],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(dt("7.2.0",`Assets.add now uses an object instead of individual parameters.
911
- Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},Se(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=Se(h||c).map(y=>typeof y=="string"?Tx(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const _=[];p.forEach(y=>{y.forEach(x=>{let g={};if(typeof x!="object"){g.src=x;for(let v=0;v<this._parsers.length;v++){const w=this._parsers[v];if(w.test(x)){g=w.parse(x);break}}}else u=x.data??u,d=x.format??d,f=x.loadParser??f,g={...g,...x};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this.buildResolvedAsset(g,{aliases:m,data:u,format:d,loadParser:f}),_.push(g)})}),m.forEach(y=>{this._assetMap[y]=_})})}resolveBundle(t){const e=Fn(t);t=Se(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Fn(t);t=Se(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const c=n.filter(u=>u[l]?u[l]===h:!1);c.length&&(n=c)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=Gt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??t.format??Gt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class tb{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Qx,this.loader=new Sx,this.cache=Kr,this._backgroundLoader=new Ex(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=Fn(t),s=Se(t).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}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e==null||e(++a/l)},c=o.map(u=>{const d=s[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{n[u]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Kr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Kr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,Kr.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=Se(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Se(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{Kr.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return Ln.config.preferWorkers}set preferWorkers(t){dt("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Nn=new tb;Y.handleByList(X.LoadParser,Nn.loader.parsers).handleByList(X.ResolveParser,Nn.resolver.parsers).handleByList(X.CacheParser,Nn.cache.parsers).handleByList(X.DetectionParser,Nn.detections);const eb={extension:X.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof q),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};Y.add(eb);async function Hd(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const rb={extension:{type:X.DetectionParser,priority:1},test:async()=>Hd("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};Y.add(rb);const ib={extension:{type:X.DetectionParser,priority:0},test:async()=>Hd("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};Y.add(ib);const Xd=["png","jpg","jpeg"],sb={extension:{type:X.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Xd],remove:async r=>r.filter(t=>!Xd.includes(t))};Y.add(sb);const nb="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function fl(r){return nb?!1:document.createElement("video").canPlayType(r)!==""}const ob={extension:{type:X.DetectionParser,priority:0},test:async()=>fl("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};Y.add(ob);const ab={extension:{type:X.DetectionParser,priority:0},test:async()=>fl("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};Y.add(ab);const lb={extension:{type:X.DetectionParser,priority:0},test:async()=>fl("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};Y.add(lb);const hb={extension:X.ResolveParser,test:Ln.test,parse:r=>{var t;return{resolution:parseFloat(((t=W.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:Gt.extname(r).slice(1),src:r}}};Y.add(hb);var jt=(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))(jt||{});const Un={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 We,Fi;function Vd(){Fi={bptc:We.getExtension("EXT_texture_compression_bptc"),astc:We.getExtension("WEBGL_compressed_texture_astc"),etc:We.getExtension("WEBGL_compressed_texture_etc"),s3tc:We.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:We.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:We.getExtension("WEBGL_compressed_texture_pvrtc")||We.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:We.getExtension("WEBGL_compressed_texture_etc1"),atc:We.getExtension("WEBGL_compressed_texture_atc")}}const cb={extension:{type:X.DetectionParser,priority:2},test:async()=>{const r=W.ADAPTER.createCanvas().getContext("webgl");return r?(We=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Fi||Vd();const t=[];for(const e in Fi)Fi[e]&&t.push(e);return[...t,...r]},remove:async r=>(Fi||Vd(),r.filter(t=>!(t in Fi)))};Y.add(cb);class ub extends dn{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new Ba(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Ba(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Zr extends ub{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Zr._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Zr._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=Zr._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Un[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Un[e];return l}}const pl=4,kn=124,db=32,zd=20,fb=542327876,Gn={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},pb={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},$n={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},mb=1,gb=2,yb=4,_b=64,vb=512,xb=131072,bb=827611204,wb=861165636,Eb=894720068,Tb=808540228,Ab=4,Sb={[bb]:jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[wb]:jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Eb]:jt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Ib={70:jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:jt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:jt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:jt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:jt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:jt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:jt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Cb(r){const t=new Uint32Array(r);if(t[0]!==fb)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,kn/Uint32Array.BYTES_PER_ELEMENT),i=e[Gn.HEIGHT],s=e[Gn.WIDTH],n=e[Gn.MIPMAP_COUNT],o=new Uint32Array(r,Gn.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,db/Uint32Array.BYTES_PER_ELEMENT),a=o[mb];if(a&yb){const l=o[pb.FOURCC];if(l!==Tb){const x=Sb[l],g=pl+kn,v=new Uint8Array(r,g);return[new Zr(v,{format:x,width:s,height:i,levels:n})]}const h=pl+kn,c=new Uint32Array(t.buffer,h,zd/Uint32Array.BYTES_PER_ELEMENT),u=c[$n.DXGI_FORMAT],d=c[$n.RESOURCE_DIMENSION],f=c[$n.MISC_FLAG],p=c[$n.ARRAY_SIZE],m=Ib[u];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===Ab)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const _=new Array,y=pl+kn+zd;if(p===1)_.push(new Uint8Array(r,y));else{const x=Un[m];let g=0,v=s,w=i;for(let A=0;A<n;A++){const C=Math.max(1,v+3&-4),N=Math.max(1,w+3&-4),S=C*N*x;g+=S,v=v>>>1,w=w>>>1}let I=y;for(let A=0;A<p;A++)_.push(new Uint8Array(r,I,g)),I+=g}return _.map(x=>new Zr(x,{format:m,width:s,height:i,levels:n}))}throw a&_b?new Error("DDSParser does not support uncompressed texture data."):a&vb?new Error("DDSParser does not supported YUV uncompressed texture data."):a&xb?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&gb?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 Wd=[171,75,84,88,32,49,49,187,13,10,26,10],Rb=67305985,Ce={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,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},ml=64,jd={[J.UNSIGNED_BYTE]:1,[J.UNSIGNED_SHORT]:2,[J.INT]:4,[J.UNSIGNED_INT]:4,[J.FLOAT]:4,[J.HALF_FLOAT]:8},Pb={[k.RGBA]:4,[k.RGB]:3,[k.RG]:2,[k.RED]:1,[k.LUMINANCE]:1,[k.LUMINANCE_ALPHA]:2,[k.ALPHA]:1},Mb={[J.UNSIGNED_SHORT_4_4_4_4]:2,[J.UNSIGNED_SHORT_5_5_5_1]:2,[J.UNSIGNED_SHORT_5_6_5]:2};function Bb(r,t,e=!1){const i=new DataView(t);if(!Db(r,i))return null;const s=i.getUint32(Ce.ENDIANNESS,!0)===Rb,n=i.getUint32(Ce.GL_TYPE,s),o=i.getUint32(Ce.GL_FORMAT,s),a=i.getUint32(Ce.GL_INTERNAL_FORMAT,s),l=i.getUint32(Ce.PIXEL_WIDTH,s),h=i.getUint32(Ce.PIXEL_HEIGHT,s)||1,c=i.getUint32(Ce.PIXEL_DEPTH,s)||1,u=i.getUint32(Ce.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(Ce.NUMBER_OF_FACES,s),f=i.getUint32(Ce.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(Ce.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,y=l+3&-4,x=h+3&-4,g=new Array(u);let v=l*h;n===0&&(v=y*x);let w;if(n!==0?jd[n]?w=jd[n]*Pb[o]:w=Mb[n]:w=Un[a],w===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const I=e?Fb(i,p,s):null;let A=v*w,C=l,N=h,S=y,R=x,E=ml+p;for(let b=0;b<f;b++){const D=i.getUint32(E,s);let F=E+4;for(let G=0;G<u;G++){let $=g[G];$||($=g[G]=new Array(f)),$[b]={levelID:b,levelWidth:f>1||n!==0?C:S,levelHeight:f>1||n!==0?N:R,levelBuffer:new Uint8Array(t,F,A)},F+=A}E+=D+4,E=E%4!==0?E+4-E%4:E,C=C>>1||1,N=N>>1||1,S=C+m-1&~(m-1),R=N+_-1&~(_-1),A=S*R*w}return n!==0?{uncompressed:g.map(b=>{let D=b[0].levelBuffer,F=!1;return n===J.FLOAT?D=new Float32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4):n===J.UNSIGNED_INT?(F=!0,D=new Uint32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4)):n===J.INT&&(F=!0,D=new Int32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4)),{resource:new dn(D,{width:b[0].levelWidth,height:b[0].levelHeight}),type:n,format:F?Ob(o):o}}),kvData:I}:{compressed:g.map(b=>new Zr(null,{format:a,width:l,height:h,levels:f,levelBuffers:b})),kvData:I}}function Db(r,t){for(let e=0;e<Wd.length;e++)if(t.getUint8(e)!==Wd[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function Ob(r){switch(r){case k.RGBA:return k.RGBA_INTEGER;case k.RGB:return k.RGB_INTEGER;case k.RG:return k.RG_INTEGER;case k.RED:return k.RED_INTEGER;default:return r}}function Fb(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(ml+s,e),o=ml+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&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)),c=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,c),s+=4+n+a}return i}const Lb={extension:{type:X.LoadParser,priority:Ie.High},name:"loadDDS",test(r){return Er(r,".dds")},async load(r,t,e){const i=await(await W.ADAPTER.fetch(r)).arrayBuffer(),s=Cb(i).map(n=>{const o=new nt(n,{mipmap:Le.OFF,alphaMode:ie.NO_PREMULTIPLIED_ALPHA,resolution:lr(r),...t.data});return _s(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};Y.add(Lb);const Nb={extension:{type:X.LoadParser,priority:Ie.High},name:"loadKTX",test(r){return Er(r,".ktx")},async load(r,t,e){const i=await(await W.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=Bb(r,i),a=s??n,l={mipmap:Le.OFF,alphaMode:ie.NO_PREMULTIPLIED_ALPHA,resolution:lr(r),...t.data},h=a.map(c=>{a===n&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new nt(u,l);return d.ktxKeyValueData=o,_s(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};Y.add(Nb);const Ub=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],kb={extension:X.ResolveParser,test:r=>{const t=Gt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(Ub.includes(n))return{resolution:parseFloat(((i=W.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=W.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};Y.add(kb);const Hn=new at,Gb=4,Yd=class As{constructor(t){this.renderer=t,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(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.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)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,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(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&As._flipY(i,s,n),a&&As._unpremultiplyAlpha(i);const l=new xv(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&As._flipY(i,s,n),a&&As._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof Wr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(Hn.width=e.width,Hn.height=e.height,e=Hn)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===k.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else s=i.resolution,e||(e=Hn,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*s),1),u=Math.max(Math.round(e.height*s),1),d=new Uint8Array(Gb*c*u);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),c,u,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:c,height:u,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Yd.extension={name:"extract",type:X.RendererSystem};let $b=Yd;Y.add($b);const Xn={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Wt.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===Wt.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,s=n=0}else{const p=r.shape,m=p.width/2,_=p.height/2;e=p.x+m,i=p.y+_,o=a=Math.max(0,Math.min(p.radius,Math.min(m,_))),s=m-o,n=_-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let c=0,u=l*4+(s?2:0)+2,d=u,f=h;{const p=s+o,m=n,_=e+p,y=e-p,x=i+m;if(t[c++]=_,t[c++]=x,t[--u]=x,t[--u]=y,n){const g=i-m;t[d++]=y,t[d++]=g,t[--f]=g,t[--f]=_}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),_=s+Math.cos(m)*o,y=n+Math.sin(m)*a,x=e+_,g=e-_,v=i+y,w=i-y;t[c++]=x,t[c++]=v,t[--u]=v,t[--u]=g,t[d++]=g,t[d++]=w,t[--f]=w,t[--f]=x}{const p=s,m=n+a,_=e+p,y=e-p,x=i+m,g=i-m;t[c++]=_,t[c++]=x,t[--f]=g,t[--f]=_,s&&(t[c++]=y,t[c++]=x,t[--f]=g,t[--f]=y)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Wt.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.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),n++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function qd(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const Kd={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){qd(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];qd(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=Iy(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},Hb={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},Xb={build(r){Xn.build(r)},triangulate(r,t){Xn.triangulate(r,t)}};var me=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(me||{}),Tr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Tr||{});const Li={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,t=20){if(!this.adaptive||!r||isNaN(r))return t;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class Zd{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=s-e,u=i-t,d=Math.abs(l*u-h*c);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=l*l+h*h,p=c*c+u*u,m=l*c+h*u,_=n*Math.sqrt(f)/d,y=n*Math.sqrt(p)/d,x=_*m/f,g=y*m/p,v=_*u+y*h,w=_*c+y*l,I=h*(y+x),A=l*(y+x),C=u*(_+g),N=c*(_+g),S=Math.atan2(A-w,I-v),R=Math.atan2(N-w,C-v);return{cx:v+t,cy:w+e,radius:n,startAngle:S,endAngle:R,anticlockwise:h*c>u*l}}static arc(t,e,i,s,n,o,a,l,h){const c=a-o,u=Li._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/pn)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),_=u-1,y=_%1/_;for(let x=0;x<=_;++x){const g=x+y*x,v=d+o+f*g,w=Math.cos(v),I=-Math.sin(v);h.push((p*w+m*I)*n+i,(p*-I+m*w)*n+s)}}}class Vb{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class gl{static curveLength(t,e,i,s,n,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,m=0,_=0,y=0,x=0,g=0,v=t,w=e;for(let I=1;I<=10;++I)c=I/10,u=c*c,d=u*c,f=1-c,p=f*f,m=p*f,_=m*t+3*p*c*i+3*f*u*n+d*a,y=m*e+3*p*c*s+3*f*u*o+d*l,x=v-_,g=w-y,v=_,w=y,h+=Math.sqrt(x*x+g*g);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=Li._segmentsCount(gl.curveLength(l,h,t,e,i,s,n,o));let u=0,d=0,f=0,p=0,m=0;a.push(l,h);for(let _=1,y=0;_<=c;++_)y=_/c,u=1-y,d=u*u,f=d*u,p=y*y,m=p*y,a.push(f*l+3*d*y*t+3*u*p*i+m*n,f*h+3*d*y*e+3*u*p*s+m*o)}}function Jd(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,c=r+e*n,u=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,m=h+f,_=c+d,y=u+f;return a.push(p,m,_,y),2}function Jr(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let c=Math.atan2(l,h),u=Math.atan2(s-r,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(l*l+h*h),_=(15*p*Math.sqrt(m)/Math.PI>>0)+1,y=f/_;if(d+=y,a){o.push(r,t,e,i);for(let x=1,g=d;x<_;x++,g+=y)o.push(r,t,r+Math.sin(g)*m,t+Math.cos(g)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let x=1,g=d;x<_;x++,g+=y)o.push(r+Math.sin(g)*m,t+Math.cos(g)*m,r,t);o.push(s,n,r,t)}return _*2}function zb(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new gt(i[0],i[1]),a=new gt(i[i.length-2],i[i.length-1]),l=e.type!==Wt.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const $=(o.x+a.x)*.5,B=(a.y+o.y)*.5;i.unshift($,B),i.push($,B)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=n.width/2,m=p*p,_=n.miterLimit*n.miterLimit;let y=i[0],x=i[1],g=i[2],v=i[3],w=0,I=0,A=-(x-v),C=y-g,N=0,S=0,R=Math.sqrt(A*A+C*C);A/=R,C/=R,A*=p,C*=p;const E=n.alignment,b=(1-E)*2,D=E*2;l||(n.cap===Tr.ROUND?d+=Jr(y-A*(b-D)*.5,x-C*(b-D)*.5,y-A*b,x-C*b,y+A*D,x+C*D,c,!0)+2:n.cap===Tr.SQUARE&&(d+=Jd(y,x,A,C,b,D,!0,c))),c.push(y-A*b,x-C*b,y+A*D,x+C*D);for(let $=1;$<u-1;++$){y=i[($-1)*2],x=i[($-1)*2+1],g=i[$*2],v=i[$*2+1],w=i[($+1)*2],I=i[($+1)*2+1],A=-(x-v),C=y-g,R=Math.sqrt(A*A+C*C),A/=R,C/=R,A*=p,C*=p,N=-(v-I),S=g-w,R=Math.sqrt(N*N+S*S),N/=R,S/=R,N*=p,S*=p;const B=g-y,Z=x-v,P=g-w,U=I-v,j=B*P+Z*U,rt=Z*P-U*B,Q=rt<0;if(Math.abs(rt)<.001*Math.abs(j)){c.push(g-A*b,v-C*b,g+A*D,v+C*D),j>=0&&(n.join===me.ROUND?d+=Jr(g,v,g-A*b,v-C*b,g-N*b,v-S*b,c,!1)+4:d+=2,c.push(g-N*D,v-S*D,g+N*b,v+S*b));continue}const H=(-A+y)*(-C+v)-(-A+g)*(-C+x),V=(-N+w)*(-S+v)-(-N+g)*(-S+I),lt=(B*V-P*H)/rt,L=(U*H-Z*V)/rt,O=(lt-g)*(lt-g)+(L-v)*(L-v),_t=g+(lt-g)*b,ht=v+(L-v)*b,vt=g-(lt-g)*D,xt=v-(L-v)*D,Ye=Math.min(B*B+Z*Z,P*P+U*U),qe=Q?b:D,ws=Ye+qe*qe*m,$E=O<=ws;let eo=n.join;if(eo===me.MITER&&O/m>_&&(eo=me.BEVEL),$E)switch(eo){case me.MITER:{c.push(_t,ht,vt,xt);break}case me.BEVEL:{Q?c.push(_t,ht,g+A*D,v+C*D,_t,ht,g+N*D,v+S*D):c.push(g-A*b,v-C*b,vt,xt,g-N*b,v-S*b,vt,xt),d+=2;break}case me.ROUND:{Q?(c.push(_t,ht,g+A*D,v+C*D),d+=Jr(g,v,g+A*D,v+C*D,g+N*D,v+S*D,c,!0)+4,c.push(_t,ht,g+N*D,v+S*D)):(c.push(g-A*b,v-C*b,vt,xt),d+=Jr(g,v,g-A*b,v-C*b,g-N*b,v-S*b,c,!1)+4,c.push(g-N*b,v-S*b,vt,xt));break}}else{switch(c.push(g-A*b,v-C*b,g+A*D,v+C*D),eo){case me.MITER:{Q?c.push(vt,xt,vt,xt):c.push(_t,ht,_t,ht),d+=2;break}case me.ROUND:{Q?d+=Jr(g,v,g+A*D,v+C*D,g+N*D,v+S*D,c,!0)+2:d+=Jr(g,v,g-A*b,v-C*b,g-N*b,v-S*b,c,!1)+2;break}}c.push(g-N*b,v-S*b,g+N*D,v+S*D),d+=2}}y=i[(u-2)*2],x=i[(u-2)*2+1],g=i[(u-1)*2],v=i[(u-1)*2+1],A=-(x-v),C=y-g,R=Math.sqrt(A*A+C*C),A/=R,C/=R,A*=p,C*=p,c.push(g-A*b,v-C*b,g+A*D,v+C*D),l||(n.cap===Tr.ROUND?d+=Jr(g-A*(b-D)*.5,v-C*(b-D)*.5,g-A*b,v-C*b,g+A*D,v+C*D,c,!1)+2:n.cap===Tr.SQUARE&&(d+=Jd(g,v,A,C,b,D,!1,c)));const F=t.indices,G=Li.epsilon*Li.epsilon;for(let $=f;$<d+f-2;++$)y=c[$*2],x=c[$*2+1],g=c[($+1)*2],v=c[($+1)*2+1],w=c[($+2)*2],I=c[($+2)*2+1],!(Math.abs(y*(v-I)+g*(I-x)+w*(x-v))<G)&&F.push($,$+1,$+2)}function Wb(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Wt.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let c=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,h)}function Qd(r,t){r.lineStyle.native?Wb(r,t):zb(r,t)}class yl{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,c=2*s-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),_=2*u*m,y=2*Math.sqrt(f),x=d/m;return(_*p+m*d*(p-y)+(4*f*u-d*d)*Math.log((2*m+x+p)/(x+y)))/(4*_)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=Li._segmentsCount(yl.curveLength(o,a,t,e,i,s));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,c+(e+(s-e)*d-c)*d)}}}const _l={[Wt.POLY]:Kd,[Wt.CIRC]:Xn,[Wt.ELIP]:Xn,[Wt.RECT]:Hb,[Wt.RREC]:Xb},tf=[],Vn=[];class zn{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new zn(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 Ni=new gt,ef=class Yf extends Du{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 Bn,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 t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Vn.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),tf.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new zn(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new zn(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].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(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Ni):Ni.copyFrom(t),s.shape.contains(Ni.x,Ni.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(Ni.x,Ni.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;_l[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,_=this.points.length/2;p.wrapMode=mr.REPEAT,d===0?this.processFill(h):this.processLine(h);const y=this.points.length/2-_;y!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,_),i=null),i||(i=tf.pop()||new Vb,i.begin(f,m,_),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,_,y,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,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(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<Yf.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++nt._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),Vn.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Vn.pop();s||(s=new $a,s.texArray=new ja),s.texArray.count=0,s.start=0,s.size=0,s.type=Fe.TRIANGLES;let n=0,o=null,a=0,l=!1,h=Fe.TRIANGLES,c=0;this.drawCalls.push(s);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?Fe.LINES:Fe.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=Vn.pop(),s||(s=new $a,s.texArray=new ja),this.drawCalls.push(s)),s.start=c,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=mr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,c+=d.size,a=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}nt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Kd.triangulate(t,this):_l[t.type].triangulate(t,this)}processLine(t){Qd(t,this);for(let e=0;e<t.holes.length;e++)Qd(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];_l[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=bt.shared.setValue(e).toLittleEndianNumber(),a=bt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let u=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,c=l.height/n.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[i]+o),p=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)f=Math.min(f,Math.floor(t[m]+o)),p=Math.min(p,Math.floor(t[m+1]+o));u-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+u)*h,t[m+1]=(t[m+1]+d)*c}};ef.BATCHABLE_SIZE=100;let jb=ef;class Wn{constructor(){this.color=16777215,this.alpha=1,this.texture=q.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Wn;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=q.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class vl extends Wn{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Tr.BUTT,this.join=me.MITER,this.miterLimit=10}clone(){const t=new vl;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Tr.BUTT,this.join=me.MITER,this.miterLimit=10}}const xl={},bl=class oo extends Te{constructor(t=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 Wn,this._lineStyle=new vl,this._matrix=null,this._holeMode=!1,this.state=Ve.for2d(),this._geometry=t||new jb,this._geometry.refCount++,this._transformID=-1,this._tintColor=new bt(16777215),this.blendMode=tt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new oo(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:q.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Tr.BUTT,join:me.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Gr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Gr,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(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),yl.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),gl.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=Zd.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(l,h,c,u,d,f)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=pn:o&&s<=n&&(s+=pn),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-l);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return Zd.arc(a,l,t,e,i,s,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:q.WHITE,color:t,alpha:e})}normalizeColor(t){const e=bt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:q.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new at(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new _n(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new gn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new yn(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Gr(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,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 t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Wt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:bt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,bt.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!xl[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new Et,default:Ee.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;xl[i]=new ze(a,o)}e=xl[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,oo._TEMP_POINT),this._geometry.containsPoint(oo._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=bt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=i*f+n*p+a,c[u++]=o*p+s*f+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){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(t)}};bl.curves=Li,bl._TEMP_POINT=new gt;let vs=bl;class Yb{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const wl=new gt,rf=new Gr,sf=class qf extends Te{constructor(t,e,i,s=Fe.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Ve.for2d(),this.drawMode=s,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=W.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Fe.TRIANGLES&&e.length<qf.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,c=s.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=W.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new Yb(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,wl);const e=this.geometry.getBuffer("aVertexPosition").data,i=rf.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,c=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[c],i[5]=e[c+1],rf.contains(wl.x,wl.y))return!0}return!1}destroy(t){super.destroy(t),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}};sf.BATCHABLE_SIZE=100;let nf=sf;class qb extends br{constructor(t,e,i){super();const s=new Bt(t),n=new Bt(e,!0),o=new Bt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,J.FLOAT).addAttribute("aTextureCoord",n,2,!1,J.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Kb=`varying vec2 vTextureCoord;
910
+ `;let Oi=null;class Ld{constructor(){Oi||(Oi=URL.createObjectURL(new Blob([Gx],{type:"application/javascript"}))),this.worker=new Worker(Oi)}}Ld.revokeObjectURL=function(){Oi&&(URL.revokeObjectURL(Oi),Oi=null)};let Nd=0,ll;class $x{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(t=>{const{worker:e}=new al;e.addEventListener("message",i=>{e.terminate(),al.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){ll===void 0&&(ll=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<ll&&(this._createdWorkers++,t=new Ld().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Nd]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Nd++,id:i})}}const Ud=new $x;function _s(r,t,e){r.resource.internal=!0;const i=new q(r),s=()=>{delete t.promiseCache[e],Kr.has(e)&&Kr.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),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."),s())}),i}const Hx=[".jpeg",".jpg",".png",".webp",".avif"],Xx=["image/jpeg","image/png","image/webp","image/avif"];async function Vx(r){const t=await W.ADAPTER.fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Dn={name:"loadTextures",extension:{type:X.LoadParser,priority:Ie.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Bi(r,Xx)||Er(r,Hx)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Ud.isImageBitmapSupported()?s=await Ud.loadImageBitmap(r):s=await Vx(r):s=await new Promise((l,h)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=r,c.complete?l(c):(c.onload=()=>l(c),c.onerror=u=>h(u))});const n={...t.data};n.resolution??(n.resolution=hr(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new nt(s,n);return o.resource.src=r,_s(o,e,r)},unload(r){r.destroy(!0)}};Y.add(Dn);const zx=".svg",Wx="image/svg+xml",jx={extension:{type:X.LoadParser,priority:Ie.High},name:"loadSVG",test(r){return Bi(r,Wx)||Er(r,zx)},async testParse(r){return Qa.test(r)},async parse(r,t,e){var n;const i=new Qa(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new nt(i,{resolution:hr(r),...t==null?void 0:t.data});return s.resource.src=t.src,_s(s,e,t.src)},async load(r,t){return(await W.ADAPTER.fetch(r)).text()},unload:Dn.unload};Y.add(jx);const Yx=[".mp4",".m4v",".webm",".ogv"],qx=["video/mp4","video/webm","video/ogg"],Kx={name:"loadVideo",extension:{type:X.LoadParser,priority:Ie.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return Bi(r,qx)||Er(r,Yx)},async load(r,t,e){var o;let i;const s=await(await W.ADAPTER.fetch(r)).blob(),n=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,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions,autoLoad:!0},l=new Td(n,a);await l.load();const h=new nt(l,{alphaMode:await rv(),resolution:hr(r),...t==null?void 0:t.data});h.resource.src=r,i=_s(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};Y.add(Kx);class Zx{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${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(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}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(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return Se(e||i||s||n,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(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,o=s.alias??s.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));i.push(...l),a=[...o,...l]}this.add({...s,alias:a,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const o=e[s],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(dt("7.2.0",`Assets.add now uses an object instead of individual parameters.
911
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},Se(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=Se(h||c).map(y=>typeof y=="string"?wx(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const _=[];p.forEach(y=>{y.forEach(x=>{let g={};if(typeof x!="object"){g.src=x;for(let v=0;v<this._parsers.length;v++){const w=this._parsers[v];if(w.test(x)){g=w.parse(x);break}}}else u=x.data??u,d=x.format??d,f=x.loadParser??f,g={...g,...x};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this.buildResolvedAsset(g,{aliases:m,data:u,format:d,loadParser:f}),_.push(g)})}),m.forEach(y=>{this._assetMap[y]=_})})}resolveBundle(t){const e=Bn(t);t=Se(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Bn(t);t=Se(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const c=n.filter(u=>u[l]?u[l]===h:!1);c.length&&(n=c)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=Gt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??t.format??Gt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Jx{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Zx,this.loader=new Tx,this.cache=Kr,this._backgroundLoader=new bx(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=Bn(t),s=Se(t).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}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e==null||e(++a/l)},c=o.map(u=>{const d=s[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{n[u]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Kr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Kr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,Kr.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=Se(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Se(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{Kr.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return Dn.config.preferWorkers}set preferWorkers(t){dt("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const On=new Jx;Y.handleByList(X.LoadParser,On.loader.parsers).handleByList(X.ResolveParser,On.resolver.parsers).handleByList(X.CacheParser,On.cache.parsers).handleByList(X.DetectionParser,On.detections);const Qx={extension:X.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof q),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};Y.add(Qx);async function kd(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const tb={extension:{type:X.DetectionParser,priority:1},test:async()=>kd("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};Y.add(tb);const eb={extension:{type:X.DetectionParser,priority:0},test:async()=>kd("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};Y.add(eb);const Gd=["png","jpg","jpeg"],rb={extension:{type:X.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Gd],remove:async r=>r.filter(t=>!Gd.includes(t))};Y.add(rb);const ib="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function hl(r){return ib?!1:document.createElement("video").canPlayType(r)!==""}const sb={extension:{type:X.DetectionParser,priority:0},test:async()=>hl("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};Y.add(sb);const nb={extension:{type:X.DetectionParser,priority:0},test:async()=>hl("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};Y.add(nb);const ob={extension:{type:X.DetectionParser,priority:0},test:async()=>hl("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};Y.add(ob);const ab={extension:X.ResolveParser,test:Dn.test,parse:r=>{var t;return{resolution:parseFloat(((t=W.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:Gt.extname(r).slice(1),src:r}}};Y.add(ab);var jt=(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))(jt||{});const Fn={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 We,Fi;function $d(){Fi={bptc:We.getExtension("EXT_texture_compression_bptc"),astc:We.getExtension("WEBGL_compressed_texture_astc"),etc:We.getExtension("WEBGL_compressed_texture_etc"),s3tc:We.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:We.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:We.getExtension("WEBGL_compressed_texture_pvrtc")||We.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:We.getExtension("WEBGL_compressed_texture_etc1"),atc:We.getExtension("WEBGL_compressed_texture_atc")}}const lb={extension:{type:X.DetectionParser,priority:2},test:async()=>{const r=W.ADAPTER.createCanvas().getContext("webgl");return r?(We=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Fi||$d();const t=[];for(const e in Fi)Fi[e]&&t.push(e);return[...t,...r]},remove:async r=>(Fi||$d(),r.filter(t=>!(t in Fi)))};Y.add(lb);class hb extends hn{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new Ca(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Ca(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Zr extends hb{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Zr._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Zr._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=Zr._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Fn[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Fn[e];return l}}const cl=4,Ln=124,cb=32,Hd=20,ub=542327876,Nn={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},db={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},Un={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},fb=1,pb=2,mb=4,gb=64,yb=512,_b=131072,vb=827611204,xb=861165636,bb=894720068,wb=808540228,Eb=4,Tb={[vb]:jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[xb]:jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[bb]:jt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Ab={70:jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:jt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:jt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:jt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:jt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:jt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:jt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Sb(r){const t=new Uint32Array(r);if(t[0]!==ub)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Ln/Uint32Array.BYTES_PER_ELEMENT),i=e[Nn.HEIGHT],s=e[Nn.WIDTH],n=e[Nn.MIPMAP_COUNT],o=new Uint32Array(r,Nn.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,cb/Uint32Array.BYTES_PER_ELEMENT),a=o[fb];if(a&mb){const l=o[db.FOURCC];if(l!==wb){const x=Tb[l],g=cl+Ln,v=new Uint8Array(r,g);return[new Zr(v,{format:x,width:s,height:i,levels:n})]}const h=cl+Ln,c=new Uint32Array(t.buffer,h,Hd/Uint32Array.BYTES_PER_ELEMENT),u=c[Un.DXGI_FORMAT],d=c[Un.RESOURCE_DIMENSION],f=c[Un.MISC_FLAG],p=c[Un.ARRAY_SIZE],m=Ab[u];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===Eb)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const _=new Array,y=cl+Ln+Hd;if(p===1)_.push(new Uint8Array(r,y));else{const x=Fn[m];let g=0,v=s,w=i;for(let A=0;A<n;A++){const C=Math.max(1,v+3&-4),N=Math.max(1,w+3&-4),S=C*N*x;g+=S,v=v>>>1,w=w>>>1}let I=y;for(let A=0;A<p;A++)_.push(new Uint8Array(r,I,g)),I+=g}return _.map(x=>new Zr(x,{format:m,width:s,height:i,levels:n}))}throw a&gb?new Error("DDSParser does not support uncompressed texture data."):a&yb?new Error("DDSParser does not supported YUV uncompressed texture data."):a&_b?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&pb?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 Xd=[171,75,84,88,32,49,49,187,13,10,26,10],Ib=67305985,Ce={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,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},ul=64,Vd={[J.UNSIGNED_BYTE]:1,[J.UNSIGNED_SHORT]:2,[J.INT]:4,[J.UNSIGNED_INT]:4,[J.FLOAT]:4,[J.HALF_FLOAT]:8},Cb={[k.RGBA]:4,[k.RGB]:3,[k.RG]:2,[k.RED]:1,[k.LUMINANCE]:1,[k.LUMINANCE_ALPHA]:2,[k.ALPHA]:1},Rb={[J.UNSIGNED_SHORT_4_4_4_4]:2,[J.UNSIGNED_SHORT_5_5_5_1]:2,[J.UNSIGNED_SHORT_5_6_5]:2};function Pb(r,t,e=!1){const i=new DataView(t);if(!Mb(r,i))return null;const s=i.getUint32(Ce.ENDIANNESS,!0)===Ib,n=i.getUint32(Ce.GL_TYPE,s),o=i.getUint32(Ce.GL_FORMAT,s),a=i.getUint32(Ce.GL_INTERNAL_FORMAT,s),l=i.getUint32(Ce.PIXEL_WIDTH,s),h=i.getUint32(Ce.PIXEL_HEIGHT,s)||1,c=i.getUint32(Ce.PIXEL_DEPTH,s)||1,u=i.getUint32(Ce.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(Ce.NUMBER_OF_FACES,s),f=i.getUint32(Ce.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(Ce.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,y=l+3&-4,x=h+3&-4,g=new Array(u);let v=l*h;n===0&&(v=y*x);let w;if(n!==0?Vd[n]?w=Vd[n]*Cb[o]:w=Rb[n]:w=Fn[a],w===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const I=e?Db(i,p,s):null;let A=v*w,C=l,N=h,S=y,R=x,E=ul+p;for(let b=0;b<f;b++){const D=i.getUint32(E,s);let F=E+4;for(let G=0;G<u;G++){let $=g[G];$||($=g[G]=new Array(f)),$[b]={levelID:b,levelWidth:f>1||n!==0?C:S,levelHeight:f>1||n!==0?N:R,levelBuffer:new Uint8Array(t,F,A)},F+=A}E+=D+4,E=E%4!==0?E+4-E%4:E,C=C>>1||1,N=N>>1||1,S=C+m-1&~(m-1),R=N+_-1&~(_-1),A=S*R*w}return n!==0?{uncompressed:g.map(b=>{let D=b[0].levelBuffer,F=!1;return n===J.FLOAT?D=new Float32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4):n===J.UNSIGNED_INT?(F=!0,D=new Uint32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4)):n===J.INT&&(F=!0,D=new Int32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4)),{resource:new hn(D,{width:b[0].levelWidth,height:b[0].levelHeight}),type:n,format:F?Bb(o):o}}),kvData:I}:{compressed:g.map(b=>new Zr(null,{format:a,width:l,height:h,levels:f,levelBuffers:b})),kvData:I}}function Mb(r,t){for(let e=0;e<Xd.length;e++)if(t.getUint8(e)!==Xd[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function Bb(r){switch(r){case k.RGBA:return k.RGBA_INTEGER;case k.RGB:return k.RGB_INTEGER;case k.RG:return k.RG_INTEGER;case k.RED:return k.RED_INTEGER;default:return r}}function Db(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(ul+s,e),o=ul+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&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)),c=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,c),s+=4+n+a}return i}const Ob={extension:{type:X.LoadParser,priority:Ie.High},name:"loadDDS",test(r){return Er(r,".dds")},async load(r,t,e){const i=await(await W.ADAPTER.fetch(r)).arrayBuffer(),s=Sb(i).map(n=>{const o=new nt(n,{mipmap:Le.OFF,alphaMode:ie.NO_PREMULTIPLIED_ALPHA,resolution:hr(r),...t.data});return _s(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};Y.add(Ob);const Fb={extension:{type:X.LoadParser,priority:Ie.High},name:"loadKTX",test(r){return Er(r,".ktx")},async load(r,t,e){const i=await(await W.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=Pb(r,i),a=s??n,l={mipmap:Le.OFF,alphaMode:ie.NO_PREMULTIPLIED_ALPHA,resolution:hr(r),...t.data},h=a.map(c=>{a===n&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new nt(u,l);return d.ktxKeyValueData=o,_s(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};Y.add(Fb);const Lb=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],Nb={extension:X.ResolveParser,test:r=>{const t=Gt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(Lb.includes(n))return{resolution:parseFloat(((i=W.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=W.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};Y.add(Nb);const kn=new at,Ub=4,zd=class As{constructor(t){this.renderer=t,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(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.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)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,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(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&As._flipY(i,s,n),a&&As._unpremultiplyAlpha(i);const l=new _v(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&As._flipY(i,s,n),a&&As._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof Wr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(kn.width=e.width,kn.height=e.height,e=kn)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===k.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else s=i.resolution,e||(e=kn,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*s),1),u=Math.max(Math.round(e.height*s),1),d=new Uint8Array(Ub*c*u);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),c,u,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:c,height:u,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};zd.extension={name:"extract",type:X.RendererSystem};let kb=zd;Y.add(kb);const Gn={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Wt.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===Wt.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,s=n=0}else{const p=r.shape,m=p.width/2,_=p.height/2;e=p.x+m,i=p.y+_,o=a=Math.max(0,Math.min(p.radius,Math.min(m,_))),s=m-o,n=_-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let c=0,u=l*4+(s?2:0)+2,d=u,f=h;{const p=s+o,m=n,_=e+p,y=e-p,x=i+m;if(t[c++]=_,t[c++]=x,t[--u]=x,t[--u]=y,n){const g=i-m;t[d++]=y,t[d++]=g,t[--f]=g,t[--f]=_}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),_=s+Math.cos(m)*o,y=n+Math.sin(m)*a,x=e+_,g=e-_,v=i+y,w=i-y;t[c++]=x,t[c++]=v,t[--u]=v,t[--u]=g,t[d++]=g,t[d++]=w,t[--f]=w,t[--f]=x}{const p=s,m=n+a,_=e+p,y=e-p,x=i+m,g=i-m;t[c++]=_,t[c++]=x,t[--f]=g,t[--f]=_,s&&(t[c++]=y,t[c++]=x,t[--f]=g,t[--f]=y)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Wt.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.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),n++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function Wd(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const jd={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){Wd(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];Wd(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=Ty(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},Gb={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},$b={build(r){Gn.build(r)},triangulate(r,t){Gn.triangulate(r,t)}};var me=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(me||{}),Tr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Tr||{});const Li={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,t=20){if(!this.adaptive||!r||isNaN(r))return t;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class Yd{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=s-e,u=i-t,d=Math.abs(l*u-h*c);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=l*l+h*h,p=c*c+u*u,m=l*c+h*u,_=n*Math.sqrt(f)/d,y=n*Math.sqrt(p)/d,x=_*m/f,g=y*m/p,v=_*u+y*h,w=_*c+y*l,I=h*(y+x),A=l*(y+x),C=u*(_+g),N=c*(_+g),S=Math.atan2(A-w,I-v),R=Math.atan2(N-w,C-v);return{cx:v+t,cy:w+e,radius:n,startAngle:S,endAngle:R,anticlockwise:h*c>u*l}}static arc(t,e,i,s,n,o,a,l,h){const c=a-o,u=Li._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/un)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),_=u-1,y=_%1/_;for(let x=0;x<=_;++x){const g=x+y*x,v=d+o+f*g,w=Math.cos(v),I=-Math.sin(v);h.push((p*w+m*I)*n+i,(p*-I+m*w)*n+s)}}}class Hb{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class dl{static curveLength(t,e,i,s,n,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,m=0,_=0,y=0,x=0,g=0,v=t,w=e;for(let I=1;I<=10;++I)c=I/10,u=c*c,d=u*c,f=1-c,p=f*f,m=p*f,_=m*t+3*p*c*i+3*f*u*n+d*a,y=m*e+3*p*c*s+3*f*u*o+d*l,x=v-_,g=w-y,v=_,w=y,h+=Math.sqrt(x*x+g*g);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=Li._segmentsCount(dl.curveLength(l,h,t,e,i,s,n,o));let u=0,d=0,f=0,p=0,m=0;a.push(l,h);for(let _=1,y=0;_<=c;++_)y=_/c,u=1-y,d=u*u,f=d*u,p=y*y,m=p*y,a.push(f*l+3*d*y*t+3*u*p*i+m*n,f*h+3*d*y*e+3*u*p*s+m*o)}}function qd(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,c=r+e*n,u=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,m=h+f,_=c+d,y=u+f;return a.push(p,m,_,y),2}function Jr(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let c=Math.atan2(l,h),u=Math.atan2(s-r,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(l*l+h*h),_=(15*p*Math.sqrt(m)/Math.PI>>0)+1,y=f/_;if(d+=y,a){o.push(r,t,e,i);for(let x=1,g=d;x<_;x++,g+=y)o.push(r,t,r+Math.sin(g)*m,t+Math.cos(g)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let x=1,g=d;x<_;x++,g+=y)o.push(r+Math.sin(g)*m,t+Math.cos(g)*m,r,t);o.push(s,n,r,t)}return _*2}function Xb(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new gt(i[0],i[1]),a=new gt(i[i.length-2],i[i.length-1]),l=e.type!==Wt.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const $=(o.x+a.x)*.5,B=(a.y+o.y)*.5;i.unshift($,B),i.push($,B)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=n.width/2,m=p*p,_=n.miterLimit*n.miterLimit;let y=i[0],x=i[1],g=i[2],v=i[3],w=0,I=0,A=-(x-v),C=y-g,N=0,S=0,R=Math.sqrt(A*A+C*C);A/=R,C/=R,A*=p,C*=p;const E=n.alignment,b=(1-E)*2,D=E*2;l||(n.cap===Tr.ROUND?d+=Jr(y-A*(b-D)*.5,x-C*(b-D)*.5,y-A*b,x-C*b,y+A*D,x+C*D,c,!0)+2:n.cap===Tr.SQUARE&&(d+=qd(y,x,A,C,b,D,!0,c))),c.push(y-A*b,x-C*b,y+A*D,x+C*D);for(let $=1;$<u-1;++$){y=i[($-1)*2],x=i[($-1)*2+1],g=i[$*2],v=i[$*2+1],w=i[($+1)*2],I=i[($+1)*2+1],A=-(x-v),C=y-g,R=Math.sqrt(A*A+C*C),A/=R,C/=R,A*=p,C*=p,N=-(v-I),S=g-w,R=Math.sqrt(N*N+S*S),N/=R,S/=R,N*=p,S*=p;const B=g-y,K=x-v,P=g-w,U=I-v,j=B*P+K*U,rt=K*P-U*B,Q=rt<0;if(Math.abs(rt)<.001*Math.abs(j)){c.push(g-A*b,v-C*b,g+A*D,v+C*D),j>=0&&(n.join===me.ROUND?d+=Jr(g,v,g-A*b,v-C*b,g-N*b,v-S*b,c,!1)+4:d+=2,c.push(g-N*D,v-S*D,g+N*b,v+S*b));continue}const H=(-A+y)*(-C+v)-(-A+g)*(-C+x),V=(-N+w)*(-S+v)-(-N+g)*(-S+I),lt=(B*V-P*H)/rt,L=(U*H-K*V)/rt,O=(lt-g)*(lt-g)+(L-v)*(L-v),_t=g+(lt-g)*b,ht=v+(L-v)*b,vt=g-(lt-g)*D,xt=v-(L-v)*D,Ye=Math.min(B*B+K*K,P*P+U*U),qe=Q?b:D,ws=Ye+qe*qe*m,UE=O<=ws;let Zn=n.join;if(Zn===me.MITER&&O/m>_&&(Zn=me.BEVEL),UE)switch(Zn){case me.MITER:{c.push(_t,ht,vt,xt);break}case me.BEVEL:{Q?c.push(_t,ht,g+A*D,v+C*D,_t,ht,g+N*D,v+S*D):c.push(g-A*b,v-C*b,vt,xt,g-N*b,v-S*b,vt,xt),d+=2;break}case me.ROUND:{Q?(c.push(_t,ht,g+A*D,v+C*D),d+=Jr(g,v,g+A*D,v+C*D,g+N*D,v+S*D,c,!0)+4,c.push(_t,ht,g+N*D,v+S*D)):(c.push(g-A*b,v-C*b,vt,xt),d+=Jr(g,v,g-A*b,v-C*b,g-N*b,v-S*b,c,!1)+4,c.push(g-N*b,v-S*b,vt,xt));break}}else{switch(c.push(g-A*b,v-C*b,g+A*D,v+C*D),Zn){case me.MITER:{Q?c.push(vt,xt,vt,xt):c.push(_t,ht,_t,ht),d+=2;break}case me.ROUND:{Q?d+=Jr(g,v,g+A*D,v+C*D,g+N*D,v+S*D,c,!0)+2:d+=Jr(g,v,g-A*b,v-C*b,g-N*b,v-S*b,c,!1)+2;break}}c.push(g-N*b,v-S*b,g+N*D,v+S*D),d+=2}}y=i[(u-2)*2],x=i[(u-2)*2+1],g=i[(u-1)*2],v=i[(u-1)*2+1],A=-(x-v),C=y-g,R=Math.sqrt(A*A+C*C),A/=R,C/=R,A*=p,C*=p,c.push(g-A*b,v-C*b,g+A*D,v+C*D),l||(n.cap===Tr.ROUND?d+=Jr(g-A*(b-D)*.5,v-C*(b-D)*.5,g-A*b,v-C*b,g+A*D,v+C*D,c,!1)+2:n.cap===Tr.SQUARE&&(d+=qd(g,v,A,C,b,D,!1,c)));const F=t.indices,G=Li.epsilon*Li.epsilon;for(let $=f;$<d+f-2;++$)y=c[$*2],x=c[$*2+1],g=c[($+1)*2],v=c[($+1)*2+1],w=c[($+2)*2],I=c[($+2)*2+1],!(Math.abs(y*(v-I)+g*(I-x)+w*(x-v))<G)&&F.push($,$+1,$+2)}function Vb(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Wt.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let c=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,h)}function Kd(r,t){r.lineStyle.native?Vb(r,t):Xb(r,t)}class fl{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,c=2*s-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),_=2*u*m,y=2*Math.sqrt(f),x=d/m;return(_*p+m*d*(p-y)+(4*f*u-d*d)*Math.log((2*m+x+p)/(x+y)))/(4*_)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=Li._segmentsCount(fl.curveLength(o,a,t,e,i,s));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,c+(e+(s-e)*d-c)*d)}}}const pl={[Wt.POLY]:jd,[Wt.CIRC]:Gn,[Wt.ELIP]:Gn,[Wt.RECT]:Gb,[Wt.RREC]:$b},Zd=[],$n=[];class Hn{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new Hn(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 Ni=new gt,Jd=class zf extends Pu{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 Rn,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 t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),$n.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),Zd.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new Hn(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Hn(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].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(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Ni):Ni.copyFrom(t),s.shape.contains(Ni.x,Ni.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(Ni.x,Ni.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;pl[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,_=this.points.length/2;p.wrapMode=gr.REPEAT,d===0?this.processFill(h):this.processLine(h);const y=this.points.length/2-_;y!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,_),i=null),i||(i=Zd.pop()||new Hb,i.begin(f,m,_),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,_,y,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,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(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<zf.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++nt._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),$n.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=$n.pop();s||(s=new Na,s.texArray=new Xa),s.texArray.count=0,s.start=0,s.size=0,s.type=Fe.TRIANGLES;let n=0,o=null,a=0,l=!1,h=Fe.TRIANGLES,c=0;this.drawCalls.push(s);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?Fe.LINES:Fe.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=$n.pop(),s||(s=new Na,s.texArray=new Xa),this.drawCalls.push(s)),s.start=c,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=gr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,c+=d.size,a=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}nt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?jd.triangulate(t,this):pl[t.type].triangulate(t,this)}processLine(t){Kd(t,this);for(let e=0;e<t.holes.length;e++)Kd(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];pl[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=bt.shared.setValue(e).toLittleEndianNumber(),a=bt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let u=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,c=l.height/n.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[i]+o),p=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)f=Math.min(f,Math.floor(t[m]+o)),p=Math.min(p,Math.floor(t[m+1]+o));u-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+u)*h,t[m+1]=(t[m+1]+d)*c}};Jd.BATCHABLE_SIZE=100;let zb=Jd;class Xn{constructor(){this.color=16777215,this.alpha=1,this.texture=q.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Xn;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=q.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class ml extends Xn{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Tr.BUTT,this.join=me.MITER,this.miterLimit=10}clone(){const t=new ml;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Tr.BUTT,this.join=me.MITER,this.miterLimit=10}}const gl={},yl=class ro extends Te{constructor(t=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 Xn,this._lineStyle=new ml,this._matrix=null,this._holeMode=!1,this.state=Ve.for2d(),this._geometry=t||new zb,this._geometry.refCount++,this._transformID=-1,this._tintColor=new bt(16777215),this.blendMode=tt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new ro(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:q.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Tr.BUTT,join:me.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Gr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Gr,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(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),fl.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),dl.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=Yd.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(l,h,c,u,d,f)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=un:o&&s<=n&&(s+=un),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-l);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return Yd.arc(a,l,t,e,i,s,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:q.WHITE,color:t,alpha:e})}normalizeColor(t){const e=bt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:q.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new at(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new mn(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new fn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new pn(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Gr(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,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 t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Wt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:bt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,bt.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!gl[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new Et,default:Ee.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;gl[i]=new ze(a,o)}e=gl[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,ro._TEMP_POINT),this._geometry.containsPoint(ro._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=bt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=i*f+n*p+a,c[u++]=o*p+s*f+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){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(t)}};yl.curves=Li,yl._TEMP_POINT=new gt;let vs=yl;class Wb{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const _l=new gt,Qd=new Gr,tf=class Wf extends Te{constructor(t,e,i,s=Fe.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Ve.for2d(),this.drawMode=s,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=W.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Fe.TRIANGLES&&e.length<Wf.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,c=s.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=W.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new Wb(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,_l);const e=this.geometry.getBuffer("aVertexPosition").data,i=Qd.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,c=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[c],i[5]=e[c+1],Qd.contains(_l.x,_l.y))return!0}return!1}destroy(t){super.destroy(t),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}};tf.BATCHABLE_SIZE=100;let ef=tf;class jb extends br{constructor(t,e,i){super();const s=new Bt(t),n=new Bt(e,!0),o=new Bt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,J.FLOAT).addAttribute("aTextureCoord",n,2,!1,J.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Yb=`varying vec2 vTextureCoord;
912
912
  uniform vec4 uColor;
913
913
 
914
914
  uniform sampler2D uSampler;
@@ -917,7 +917,7 @@ void main(void)
917
917
  {
918
918
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
919
919
  }
920
- `,Zb=`attribute vec2 aVertexPosition;
920
+ `,qb=`attribute vec2 aVertexPosition;
921
921
  attribute vec2 aTextureCoord;
922
922
 
923
923
  uniform mat3 projectionMatrix;
@@ -932,7 +932,7 @@ void main(void)
932
932
 
933
933
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
934
934
  }
935
- `;class of extends ze{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:Et.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||cr.from(Zb,Kb),i),this._colorDirty=!1,this.uvMatrix=new td(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new bt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),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 t=this.texture.baseTexture.alphaMode;bt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class af{constructor(t,e,i){this.geometry=new br,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||J.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}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 t=this.geometry;let e=0;this.indexBuffer=new Bt(_v(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=e,e+=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 Bt(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new Bt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];t.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===J.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];t.addAttribute(a.attributeName,this.staticBuffer,0,a.type===J.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===J.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===J.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.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 Jb=`varying vec2 vTextureCoord;
935
+ `;class rf extends ze{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:Et.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||ur.from(qb,Yb),i),this._colorDirty=!1,this.uvMatrix=new Zu(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new bt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),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 t=this.texture.baseTexture.alphaMode;bt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class sf{constructor(t,e,i){this.geometry=new br,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||J.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}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 t=this.geometry;let e=0;this.indexBuffer=new Bt(gv(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=e,e+=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 Bt(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new Bt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];t.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===J.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];t.addAttribute(a.attributeName,this.staticBuffer,0,a.type===J.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===J.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===J.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.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 Kb=`varying vec2 vTextureCoord;
936
936
  varying vec4 vColor;
937
937
 
938
938
  uniform sampler2D uSampler;
@@ -940,7 +940,7 @@ uniform sampler2D uSampler;
940
940
  void main(void){
941
941
  vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
942
942
  gl_FragColor = color;
943
- }`,Qb=`attribute vec2 aVertexPosition;
943
+ }`,Zb=`attribute vec2 aVertexPosition;
944
944
  attribute vec2 aTextureCoord;
945
945
  attribute vec4 aColor;
946
946
 
@@ -965,8 +965,8 @@ void main(void){
965
965
  vTextureCoord = aTextureCoord;
966
966
  vColor = aColor * uColor;
967
967
  }
968
- `;class lf extends En{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Et,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:J.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=ze.from(Qb,Jb,{}),this.state=Ve.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=wu(t.blendMode,h),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=bt.shared.setValue(t.tintRgb).premultiply(t.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,p=0;f<o;f+=s,p+=1){let m=o-f;m>s&&(m=s),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const _=a[p];_.uploadDynamic(e,f,m);const y=t._bufferUpdateIDs[p]||0;d=d||_._updateID<y,d&&(_._updateID=t._updateID,_.uploadStatic(e,f,m)),n.geometry.bind(_.geometry),c.drawElements(c.TRIANGLES,m*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new af(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new af(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,p=d.scale.x,m=d.scale.y,_=f.trim,y=f.orig;_?(l=_.x-d.anchor.x*y.width,a=l+_.width,c=_.y-d.anchor.y*y.height,h=c+_.height):(a=y.width*(1-d.anchor.x),l=y.width*-d.anchor.x,h=y.height*(1-d.anchor.y),c=y.height*-d.anchor.y),s[o]=l*p,s[o+1]=c*m,s[o+n]=a*p,s[o+n+1]=c*m,s[o+n*2]=a*p,s[o+n*2+1]=h*m,s[o+n*3]=l*p,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=bt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}lf.extension={name:"particle",type:X.RendererPlugin},Y.add(lf);var jn=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(jn||{});const Yn={willReadFrequently:!0},je=class K{static get experimentalLetterSpacingSupported(){let t=K._experimentalLetterSpacingSupported;if(t!==void 0){const e=W.ADAPTER.getCanvasRenderingContext2D().prototype;t=K._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,s=K._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=K.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",Yn);a.font=n;const l=(i?K.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let c=0;for(let p=0;p<l.length;p++){const m=K._measureText(l[p],e.letterSpacing,a);h[p]=m,c=Math.max(c,m)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new K(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,i){let s=!1;K.experimentalLetterSpacingSupported&&(K.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(K.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=K._canvas){const s=i.getContext("2d",Yn);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=K.collapseSpaces(c),d=K.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+h,m=K.tokenize(t);for(let _=0;_<m.length;_++){let y=m[_];if(K.isNewline(y)){if(!d){a+=K.addLine(o),f=!u,o="",n=0;continue}y=" "}if(u){const g=K.isBreakingSpace(y),v=K.isBreakingSpace(o[o.length-1]);if(g&&v)continue}const x=K.getFromCache(y,h,l,s);if(x>p)if(o!==""&&(a+=K.addLine(o),o="",n=0),K.canBreakWords(y,e.breakWords)){const g=K.wordWrapSplit(y);for(let v=0;v<g.length;v++){let w=g[v],I=w,A=1;for(;g[v+A];){const N=g[v+A];if(!K.canBreakChars(I,N,y,v,e.breakWords))w+=N;else break;I=N,A++}v+=A-1;const C=K.getFromCache(w,h,l,s);C+n>p&&(a+=K.addLine(o),f=!1,o="",n=0),o+=w,n+=C}}else{o.length>0&&(a+=K.addLine(o),o="",n=0);const g=_===m.length-1;a+=K.addLine(y,!g),f=!1,o="",n=0}else x+n>p&&(f=!1,a+=K.addLine(o),o="",n=0),(o.length>0||!K.isBreakingSpace(y)||f)&&(o+=y,n+=x)}return a+=K.addLine(o,!1),a}static addLine(t,e=!0){return t=K.trimRight(t),t=e?`${t}
969
- `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=K._measureText(t,e,s)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!K.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:K._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:K._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(K.isBreakingSpace(n,o)||K.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return K.graphemeSegmenter(t)}static measureFont(t){if(K._fonts[t])return K._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=K._canvas,s=K._context;s.font=t;const n=K.METRICS_STRING+K.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(K.BASELINE_SYMBOL).width);const l=Math.ceil(K.HEIGHT_MULTIPLIER*a);if(a=a*K.BASELINE_MULTIPLIER|0,o===0||l===0)return K._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,K._fonts[t]=e,e}static clearMetrics(t=""){t?delete K._fonts[t]:K._fonts={}}static get _canvas(){var t;if(!K.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Yn))!=null&&t.measureText)return K.__canvas=i,i;e=W.ADAPTER.createCanvas()}catch{e=W.ADAPTER.createCanvas()}e.width=e.height=10,K.__canvas=e}return K.__canvas}static get _context(){return K.__context||(K.__context=K._canvas.getContext("2d",Yn)),K.__context}};je.METRICS_STRING="|ÉqÅ",je.BASELINE_SYMBOL="M",je.BASELINE_MULTIPLIER=1.4,je.HEIGHT_MULTIPLIER=2,je.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),je.experimentalLetterSpacing=!1,je._fonts={},je._newlines=[10,13],je._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Ar=je;const tw=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],hf=class Ss{constructor(t){this.styleID=0,this.reset(),Tl(this,t,t)}clone(){const t={};return Tl(t,this,Ss.defaultStyle),new Ss(t)}reset(){Tl(this,Ss.defaultStyle,Ss.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=El(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=El(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){ew(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=El(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!tw.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};hf.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:jn.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 Sr=hf;function El(r){const t=bt.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function ew(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function Tl(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const rw={texture:!0,children:!1,baseTexture:!0},cf=class Hl extends Pi{constructor(t,e,i){let s=!1;i||(i=W.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=q.from(i);n.orig=new at,n.trim=new at,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Hl.defaultResolution??W.RESOLUTION,this._autoResolution=Hl.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Ar.experimentalLetterSpacing}static set experimentalLetterSpacing(t){dt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Ar.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=Ar.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.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=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let m=0;m<p;++m){const _=e.dropShadow&&m===0,y=_?Math.ceil(Math.max(1,o)+e.padding*2):0,x=y*this._resolution;if(_){i.fillStyle="black",i.strokeStyle="black";const v=e.dropShadowColor,w=e.dropShadowBlur*this._resolution,I=e.dropShadowDistance*this._resolution;i.shadowColor=bt.shared.setValue(v).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=w,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*I,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*I+x}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let g=(l-u.fontSize)/2;l-u.fontSize<0&&(g=0);for(let v=0;v<a.length;v++)d=e.strokeThickness/2,f=e.strokeThickness/2+v*l+u.ascent+g,e.align==="right"?d+=c-h[v]:e.align==="center"&&(d+=(c-h[v])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[v],d+e.padding,f+e.padding-y,!0),e.fill&&this.drawLetterSpacing(a[v],d+e.padding,f+e.padding-y)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(Ar.experimentalLetterSpacingSupported&&(Ar.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=Ar.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+n,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=wv(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,c=s.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(s[0]),u.unshift(0),c.push(s[s.length-1]),u.push(1),t.fillGradientType===jn.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,m=i.lineHeight*f;let _=m;f>0&&p>m&&(_=(m+p)/2);const y=m+d,x=i.lineHeight*(f+1);let g=y;f+1<e.length&&x<y&&(g=(y+x)/2);const v=(g-_)/h;for(let w=0;w<c.length;w++){let I=0;typeof u[w]=="number"?I=u[w]:I=w/c.length;let A=Math.min(1,Math.max(0,_/h+I*v));A=Number(A.toFixed(5)),n.addColorStop(A,c[w])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let m;typeof u[p]=="number"?m=u[p]:m=f/d,n.addColorStop(m,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},rw,t),super.destroy(t),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(t){this.updateText(!0);const e=vr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=vr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof Sr?this._style=t:this._style=new Sr(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};cf.defaultAutoResolution=!0;let uf=cf;class iw{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function sw(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof q){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function nw(r,t){if(r.baseTexture instanceof nt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function ow(r,t){if(r._texture&&r._texture instanceof q){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function aw(r,t){return t instanceof uf?(t.updateText(!0),!0):!1}function lw(r,t){if(t instanceof Sr){const e=t.toFontString();return Ar.measureFont(e),!0}return!1}function hw(r,t){if(r instanceof uf){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function cw(r,t){return r instanceof Sr?(t.includes(r)||t.push(r),!0):!1}const df=class Kf{constructor(t){this.limiter=new iw(Kf.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(hw),this.registerFindHook(cw),this.registerFindHook(sw),this.registerFindHook(nw),this.registerFindHook(ow),this.registerUploadHook(aw),this.registerUploadHook(lw)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,le.system.addOnce(this.tick,this,qr.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)le.system.addOnce(this.tick,this,qr.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Te)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&le.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}};df.uploadsPerFrame=4;let Al=df;Object.defineProperties(W,{UPLOADS_PER_FRAME:{get(){return Al.uploadsPerFrame},set(r){dt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Al.uploadsPerFrame=r}}});function ff(r,t){return t instanceof nt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function uw(r,t){if(!(t instanceof vs))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&ff(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function dw(r,t){return r instanceof vs?(t.push(r),!0):!1}class pf extends Al{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(dw),this.registerUploadHook(ff),this.registerUploadHook(uw)}}pf.extension={name:"prepare",type:X.RendererSystem},Y.add(pf);var fw=`#version 300 es
968
+ `;class nf extends xn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Et,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:J.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=ze.from(Zb,Kb,{}),this.state=Ve.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=vu(t.blendMode,h),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=bt.shared.setValue(t.tintRgb).premultiply(t.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,p=0;f<o;f+=s,p+=1){let m=o-f;m>s&&(m=s),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const _=a[p];_.uploadDynamic(e,f,m);const y=t._bufferUpdateIDs[p]||0;d=d||_._updateID<y,d&&(_._updateID=t._updateID,_.uploadStatic(e,f,m)),n.geometry.bind(_.geometry),c.drawElements(c.TRIANGLES,m*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new sf(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new sf(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,p=d.scale.x,m=d.scale.y,_=f.trim,y=f.orig;_?(l=_.x-d.anchor.x*y.width,a=l+_.width,c=_.y-d.anchor.y*y.height,h=c+_.height):(a=y.width*(1-d.anchor.x),l=y.width*-d.anchor.x,h=y.height*(1-d.anchor.y),c=y.height*-d.anchor.y),s[o]=l*p,s[o+1]=c*m,s[o+n]=a*p,s[o+n+1]=c*m,s[o+n*2]=a*p,s[o+n*2+1]=h*m,s[o+n*3]=l*p,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=bt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}nf.extension={name:"particle",type:X.RendererPlugin},Y.add(nf);var Vn=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Vn||{});const zn={willReadFrequently:!0},je=class Z{static get experimentalLetterSpacingSupported(){let t=Z._experimentalLetterSpacingSupported;if(t!==void 0){const e=W.ADAPTER.getCanvasRenderingContext2D().prototype;t=Z._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,s=Z._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=Z.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",zn);a.font=n;const l=(i?Z.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let c=0;for(let p=0;p<l.length;p++){const m=Z._measureText(l[p],e.letterSpacing,a);h[p]=m,c=Math.max(c,m)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new Z(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,i){let s=!1;Z.experimentalLetterSpacingSupported&&(Z.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(Z.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=Z._canvas){const s=i.getContext("2d",zn);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=Z.collapseSpaces(c),d=Z.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+h,m=Z.tokenize(t);for(let _=0;_<m.length;_++){let y=m[_];if(Z.isNewline(y)){if(!d){a+=Z.addLine(o),f=!u,o="",n=0;continue}y=" "}if(u){const g=Z.isBreakingSpace(y),v=Z.isBreakingSpace(o[o.length-1]);if(g&&v)continue}const x=Z.getFromCache(y,h,l,s);if(x>p)if(o!==""&&(a+=Z.addLine(o),o="",n=0),Z.canBreakWords(y,e.breakWords)){const g=Z.wordWrapSplit(y);for(let v=0;v<g.length;v++){let w=g[v],I=w,A=1;for(;g[v+A];){const N=g[v+A];if(!Z.canBreakChars(I,N,y,v,e.breakWords))w+=N;else break;I=N,A++}v+=A-1;const C=Z.getFromCache(w,h,l,s);C+n>p&&(a+=Z.addLine(o),f=!1,o="",n=0),o+=w,n+=C}}else{o.length>0&&(a+=Z.addLine(o),o="",n=0);const g=_===m.length-1;a+=Z.addLine(y,!g),f=!1,o="",n=0}else x+n>p&&(f=!1,a+=Z.addLine(o),o="",n=0),(o.length>0||!Z.isBreakingSpace(y)||f)&&(o+=y,n+=x)}return a+=Z.addLine(o,!1),a}static addLine(t,e=!0){return t=Z.trimRight(t),t=e?`${t}
969
+ `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=Z._measureText(t,e,s)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!Z.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:Z._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:Z._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(Z.isBreakingSpace(n,o)||Z.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return Z.graphemeSegmenter(t)}static measureFont(t){if(Z._fonts[t])return Z._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=Z._canvas,s=Z._context;s.font=t;const n=Z.METRICS_STRING+Z.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(Z.BASELINE_SYMBOL).width);const l=Math.ceil(Z.HEIGHT_MULTIPLIER*a);if(a=a*Z.BASELINE_MULTIPLIER|0,o===0||l===0)return Z._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,Z._fonts[t]=e,e}static clearMetrics(t=""){t?delete Z._fonts[t]:Z._fonts={}}static get _canvas(){var t;if(!Z.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",zn))!=null&&t.measureText)return Z.__canvas=i,i;e=W.ADAPTER.createCanvas()}catch{e=W.ADAPTER.createCanvas()}e.width=e.height=10,Z.__canvas=e}return Z.__canvas}static get _context(){return Z.__context||(Z.__context=Z._canvas.getContext("2d",zn)),Z.__context}};je.METRICS_STRING="|ÉqÅ",je.BASELINE_SYMBOL="M",je.BASELINE_MULTIPLIER=1.4,je.HEIGHT_MULTIPLIER=2,je.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),je.experimentalLetterSpacing=!1,je._fonts={},je._newlines=[10,13],je._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Ar=je;const Jb=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],of=class Ss{constructor(t){this.styleID=0,this.reset(),xl(this,t,t)}clone(){const t={};return xl(t,this,Ss.defaultStyle),new Ss(t)}reset(){xl(this,Ss.defaultStyle,Ss.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=vl(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=vl(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){Qb(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=vl(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Jb.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};of.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Vn.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 Sr=of;function vl(r){const t=bt.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function Qb(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function xl(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const tw={texture:!0,children:!1,baseTexture:!0},af=class Ul extends Pi{constructor(t,e,i){let s=!1;i||(i=W.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=q.from(i);n.orig=new at,n.trim=new at,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Ul.defaultResolution??W.RESOLUTION,this._autoResolution=Ul.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Ar.experimentalLetterSpacing}static set experimentalLetterSpacing(t){dt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Ar.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=Ar.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.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=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let m=0;m<p;++m){const _=e.dropShadow&&m===0,y=_?Math.ceil(Math.max(1,o)+e.padding*2):0,x=y*this._resolution;if(_){i.fillStyle="black",i.strokeStyle="black";const v=e.dropShadowColor,w=e.dropShadowBlur*this._resolution,I=e.dropShadowDistance*this._resolution;i.shadowColor=bt.shared.setValue(v).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=w,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*I,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*I+x}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let g=(l-u.fontSize)/2;l-u.fontSize<0&&(g=0);for(let v=0;v<a.length;v++)d=e.strokeThickness/2,f=e.strokeThickness/2+v*l+u.ascent+g,e.align==="right"?d+=c-h[v]:e.align==="center"&&(d+=(c-h[v])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[v],d+e.padding,f+e.padding-y,!0),e.fill&&this.drawLetterSpacing(a[v],d+e.padding,f+e.padding-y)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(Ar.experimentalLetterSpacingSupported&&(Ar.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=Ar.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+n,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=xv(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,c=s.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(s[0]),u.unshift(0),c.push(s[s.length-1]),u.push(1),t.fillGradientType===Vn.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,m=i.lineHeight*f;let _=m;f>0&&p>m&&(_=(m+p)/2);const y=m+d,x=i.lineHeight*(f+1);let g=y;f+1<e.length&&x<y&&(g=(y+x)/2);const v=(g-_)/h;for(let w=0;w<c.length;w++){let I=0;typeof u[w]=="number"?I=u[w]:I=w/c.length;let A=Math.min(1,Math.max(0,_/h+I*v));A=Number(A.toFixed(5)),n.addColorStop(A,c[w])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let m;typeof u[p]=="number"?m=u[p]:m=f/d,n.addColorStop(m,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},tw,t),super.destroy(t),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(t){this.updateText(!0);const e=vr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=vr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof Sr?this._style=t:this._style=new Sr(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};af.defaultAutoResolution=!0;let lf=af;class ew{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function rw(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof q){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function iw(r,t){if(r.baseTexture instanceof nt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function sw(r,t){if(r._texture&&r._texture instanceof q){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function nw(r,t){return t instanceof lf?(t.updateText(!0),!0):!1}function ow(r,t){if(t instanceof Sr){const e=t.toFontString();return Ar.measureFont(e),!0}return!1}function aw(r,t){if(r instanceof lf){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function lw(r,t){return r instanceof Sr?(t.includes(r)||t.push(r),!0):!1}const hf=class jf{constructor(t){this.limiter=new ew(jf.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(aw),this.registerFindHook(lw),this.registerFindHook(rw),this.registerFindHook(iw),this.registerFindHook(sw),this.registerUploadHook(nw),this.registerUploadHook(ow)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,le.system.addOnce(this.tick,this,qr.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)le.system.addOnce(this.tick,this,qr.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Te)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&le.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}};hf.uploadsPerFrame=4;let bl=hf;Object.defineProperties(W,{UPLOADS_PER_FRAME:{get(){return bl.uploadsPerFrame},set(r){dt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),bl.uploadsPerFrame=r}}});function cf(r,t){return t instanceof nt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function hw(r,t){if(!(t instanceof vs))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&cf(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function cw(r,t){return r instanceof vs?(t.push(r),!0):!1}class uf extends bl{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(cw),this.registerUploadHook(cf),this.registerUploadHook(hw)}}uf.extension={name:"prepare",type:X.RendererSystem},Y.add(uf);var uw=`#version 300 es
970
970
  #define SHADER_NAME Tiling-Sprite-100
971
971
 
972
972
  precision lowp float;
@@ -992,7 +992,7 @@ void main(void)
992
992
 
993
993
  fragmentColor = texSample * uColor;
994
994
  }
995
- `,pw=`#version 300 es
995
+ `,dw=`#version 300 es
996
996
  #define SHADER_NAME Tiling-Sprite-300
997
997
 
998
998
  precision lowp float;
@@ -1012,7 +1012,7 @@ void main(void)
1012
1012
 
1013
1013
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1014
1014
  }
1015
- `,mw=`#version 100
1015
+ `,fw=`#version 100
1016
1016
  #ifdef GL_EXT_shader_texture_lod
1017
1017
  #extension GL_EXT_shader_texture_lod : enable
1018
1018
  #endif
@@ -1045,7 +1045,7 @@ void main(void)
1045
1045
 
1046
1046
  gl_FragColor = texSample * uColor;
1047
1047
  }
1048
- `,mf=`#version 100
1048
+ `,df=`#version 100
1049
1049
  #define SHADER_NAME Tiling-Sprite-100
1050
1050
 
1051
1051
  precision lowp float;
@@ -1065,7 +1065,7 @@ void main(void)
1065
1065
 
1066
1066
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1067
1067
  }
1068
- `,gw=`#version 100
1068
+ `,pw=`#version 100
1069
1069
  #define SHADER_NAME Tiling-Sprite-Simple-100
1070
1070
 
1071
1071
  precision lowp float;
@@ -1080,7 +1080,7 @@ void main(void)
1080
1080
  vec4 texSample = texture2D(uSampler, vTextureCoord);
1081
1081
  gl_FragColor = texSample * uColor;
1082
1082
  }
1083
- `;const qn=new Et;class gf extends En{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new qu,this.state=Ve.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=ze.from(mf,gw,e),this.shader=t.context.webGLVersion>1?ze.from(pw,fw,e):ze.from(mf,mw,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==mr.CLAMP:l.wrapMode===mr.CLAMP&&(l.wrapMode=mr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,_=t._width,y=t._height;qn.set(c.a*p/_,c.b*p/y,c.c*m/_,c.d*m/y,c.tx/_,c.ty/y),qn.invert(),d?qn.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=qn.toArray(!0),f.uniforms.uColor=bt.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=wu(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}gf.extension={name:"tilingSprite",type:X.RendererPlugin},Y.add(gf);const yf=class Is{constructor(t,e,i){this.linkedSheets=[],(t instanceof nt||t instanceof q)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=s instanceof q?s:null,this.baseTexture=s instanceof nt?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;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(t=null){const{scale:e}=this.data.meta;let i=lr(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Is.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Is.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new at(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new at(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 at(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new at(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new q(this.baseTexture,a,c,l,n.rotated?2:0,n.anchor,n.borders),q.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Is.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Is.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};yf.BATCH_SIZE=1e3;let _f=yf;const yw=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function vf(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=Gt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,vf([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const _w={extension:X.Asset,cache:{test:r=>r instanceof _f,getCacheableAssets:(r,t)=>vf(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&yw.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=W.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:X.LoadParser,priority:Ie.Normal},async testParse(r,t){return Gt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var c,u;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=Gt.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=cl(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new _f({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(c=r==null?void 0:r.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let m=o+p;(u=t.data)!=null&&u.ignoreMultiPack||(m=cl(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);l.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==p))})}return l},unload(r){r.destroy(!0)}}};Y.add(_w);class Kn{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Zn{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const c=a[h].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[u]=p}i[o].push(l)}const s=new Kn;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class Sl{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Kn,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.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++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class Il{static test(t){return typeof t=="string"&&t.includes("<font>")?Sl.test(W.ADAPTER.parseXML(t)):!1}static parse(t){return Sl.parse(W.ADAPTER.parseXML(t))}}const Cl=[Zn,Sl,Il];function vw(r){for(let t=0;t<Cl.length;t++)if(Cl[t].test(r))return Cl[t];return null}function xw(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,c=r.width/i-l-h*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let m=1;m<p;++m)f.push(m/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===jn.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let _=0;_<s.length;_++){const y=n.lineHeight*_;for(let x=0;x<d.length;x++){let g=0;typeof f[x]=="number"?g=f[x]:g=x/d.length;const v=y/u+g*m;let w=Math.max(p,v);w=Math.min(w,1),a.addColorStop(w,d[x]),p=w}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let m=1;for(let _=0;_<d.length;_++){let y;typeof f[_]=="number"?y=f[_]:y=m/p,a.addColorStop(y,d[_]),m++}}return a}function bw(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,c=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=xw(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=bt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Jn(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function xf(r){return Array.from?Array.from(r):r.split("")}function ww(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...xf(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Ir=class Ke{constructor(t,e,i){var c;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=lr(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let u=0;u<t.page.length;u++){const{id:d,file:f}=t.page[u];h[d]=e instanceof Array?e[u]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=ie.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=Le.OFF)}for(let u=0;u<t.char.length;u++){const{id:d,page:f}=t.char[u];let{x:p,y:m,width:_,height:y,xoffset:x,yoffset:g,xadvance:v}=t.char[u];p/=l,m/=l,_/=l,y/=l,x/=l,g/=l,v/=l;const w=new at(p+h[f].frame.x/l,m+h[f].frame.y/l,_,y);this.chars[d]={xOffset:x,yOffset:g,xAdvance:v,kerning:{},texture:new q(h[f].baseTexture,w),page:f}}for(let u=0;u<t.kerning.length;u++){let{first:d,second:f,amount:p}=t.kerning[u];d/=l,f/=l,p/=l,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((c=a==null?void 0:a.fieldType)==null?void 0:c.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof Kn)s=t;else{const o=vw(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof q&&(e=[e]);const n=new Ke(s,e,i);return Ke.available[n.font]=n,n}static uninstall(t){const e=Ke.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Ke.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},Ke.defaultOptions,i),c=ww(s),u=e instanceof Sr?e:new Sr(e),d=a,f=new Kn;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,m=0,_,y,x,g=0;const v=[];for(let I=0;I<c.length;I++){_||(_=W.ADAPTER.createCanvas(),_.width=a,_.height=l,y=_.getContext("2d"),x=new nt(_,{resolution:o,...h}),v.push(new q(x)),f.page.push({id:v.length-1,file:""}));const A=c[I],C=Ar.measureText(A,u,!1,_),N=C.width,S=Math.ceil(C.height),R=Math.ceil((u.fontStyle==="italic"?2:1)*N);if(m>=l-S*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${A}')`);--I,_=null,y=null,x=null,m=0,p=0,g=0;continue}if(g=Math.max(S+C.fontProperties.descent,g),R*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${A}')`);--I,m+=g*o,m=Math.ceil(m),p=0,g=0;continue}bw(_,y,C,p,m,o,u);const E=Jn(C.text);f.char.push({id:E,page:v.length-1,x:p/o,y:m/o,width:R,height:S,xoffset:0,yoffset:0,xadvance:N-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(R+2*n)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let I=0,A=c.length;I<A;I++){const C=c[I];for(let N=0;N<A;N++){const S=c[N],R=y.measureText(C).width,E=y.measureText(S).width,b=y.measureText(C+S).width-(R+E);b&&f.kerning.push({first:Jn(C),second:Jn(S),amount:b})}}const w=new Ke(f,v,!0);return Ke.available[t]!==void 0&&Ke.uninstall(t),Ke.available[t]=w,w}};Ir.ALPHA=[["a","z"],["A","Z"]," "],Ir.NUMERIC=[["0","9"]],Ir.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Ir.ASCII=[[" ","~"]],Ir.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Ir.ALPHANUMERIC},Ir.available={};let Cr=Ir;var Ew=`// Pixi texture info\r
1083
+ `;const Wn=new Et;class ff extends xn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Wu,this.state=Ve.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=ze.from(df,pw,e),this.shader=t.context.webGLVersion>1?ze.from(dw,uw,e):ze.from(df,fw,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==gr.CLAMP:l.wrapMode===gr.CLAMP&&(l.wrapMode=gr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,_=t._width,y=t._height;Wn.set(c.a*p/_,c.b*p/y,c.c*m/_,c.d*m/y,c.tx/_,c.ty/y),Wn.invert(),d?Wn.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=Wn.toArray(!0),f.uniforms.uColor=bt.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=vu(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}ff.extension={name:"tilingSprite",type:X.RendererPlugin},Y.add(ff);const pf=class Is{constructor(t,e,i){this.linkedSheets=[],(t instanceof nt||t instanceof q)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=s instanceof q?s:null,this.baseTexture=s instanceof nt?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;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(t=null){const{scale:e}=this.data.meta;let i=hr(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Is.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Is.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new at(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new at(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 at(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new at(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new q(this.baseTexture,a,c,l,n.rotated?2:0,n.anchor,n.borders),q.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Is.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Is.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};pf.BATCH_SIZE=1e3;let mf=pf;const mw=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function gf(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=Gt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,gf([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const gw={extension:X.Asset,cache:{test:r=>r instanceof mf,getCacheableAssets:(r,t)=>gf(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&mw.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=W.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:X.LoadParser,priority:Ie.Normal},async testParse(r,t){return Gt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var c,u;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=Gt.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=ol(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new mf({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(c=r==null?void 0:r.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let m=o+p;(u=t.data)!=null&&u.ignoreMultiPack||(m=ol(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);l.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==p))})}return l},unload(r){r.destroy(!0)}}};Y.add(gw);class jn{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Yn{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const c=a[h].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[u]=p}i[o].push(l)}const s=new jn;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class wl{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new jn,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.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++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class El{static test(t){return typeof t=="string"&&t.includes("<font>")?wl.test(W.ADAPTER.parseXML(t)):!1}static parse(t){return wl.parse(W.ADAPTER.parseXML(t))}}const Tl=[Yn,wl,El];function yw(r){for(let t=0;t<Tl.length;t++)if(Tl[t].test(r))return Tl[t];return null}function _w(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,c=r.width/i-l-h*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let m=1;m<p;++m)f.push(m/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===Vn.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let _=0;_<s.length;_++){const y=n.lineHeight*_;for(let x=0;x<d.length;x++){let g=0;typeof f[x]=="number"?g=f[x]:g=x/d.length;const v=y/u+g*m;let w=Math.max(p,v);w=Math.min(w,1),a.addColorStop(w,d[x]),p=w}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let m=1;for(let _=0;_<d.length;_++){let y;typeof f[_]=="number"?y=f[_]:y=m/p,a.addColorStop(y,d[_]),m++}}return a}function vw(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,c=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=_w(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=bt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function qn(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function yf(r){return Array.from?Array.from(r):r.split("")}function xw(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...yf(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Ir=class Ke{constructor(t,e,i){var c;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=hr(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let u=0;u<t.page.length;u++){const{id:d,file:f}=t.page[u];h[d]=e instanceof Array?e[u]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=ie.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=Le.OFF)}for(let u=0;u<t.char.length;u++){const{id:d,page:f}=t.char[u];let{x:p,y:m,width:_,height:y,xoffset:x,yoffset:g,xadvance:v}=t.char[u];p/=l,m/=l,_/=l,y/=l,x/=l,g/=l,v/=l;const w=new at(p+h[f].frame.x/l,m+h[f].frame.y/l,_,y);this.chars[d]={xOffset:x,yOffset:g,xAdvance:v,kerning:{},texture:new q(h[f].baseTexture,w),page:f}}for(let u=0;u<t.kerning.length;u++){let{first:d,second:f,amount:p}=t.kerning[u];d/=l,f/=l,p/=l,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((c=a==null?void 0:a.fieldType)==null?void 0:c.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof jn)s=t;else{const o=yw(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof q&&(e=[e]);const n=new Ke(s,e,i);return Ke.available[n.font]=n,n}static uninstall(t){const e=Ke.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Ke.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},Ke.defaultOptions,i),c=xw(s),u=e instanceof Sr?e:new Sr(e),d=a,f=new jn;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,m=0,_,y,x,g=0;const v=[];for(let I=0;I<c.length;I++){_||(_=W.ADAPTER.createCanvas(),_.width=a,_.height=l,y=_.getContext("2d"),x=new nt(_,{resolution:o,...h}),v.push(new q(x)),f.page.push({id:v.length-1,file:""}));const A=c[I],C=Ar.measureText(A,u,!1,_),N=C.width,S=Math.ceil(C.height),R=Math.ceil((u.fontStyle==="italic"?2:1)*N);if(m>=l-S*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${A}')`);--I,_=null,y=null,x=null,m=0,p=0,g=0;continue}if(g=Math.max(S+C.fontProperties.descent,g),R*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${A}')`);--I,m+=g*o,m=Math.ceil(m),p=0,g=0;continue}vw(_,y,C,p,m,o,u);const E=qn(C.text);f.char.push({id:E,page:v.length-1,x:p/o,y:m/o,width:R,height:S,xoffset:0,yoffset:0,xadvance:N-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(R+2*n)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let I=0,A=c.length;I<A;I++){const C=c[I];for(let N=0;N<A;N++){const S=c[N],R=y.measureText(C).width,E=y.measureText(S).width,b=y.measureText(C+S).width-(R+E);b&&f.kerning.push({first:qn(C),second:qn(S),amount:b})}}const w=new Ke(f,v,!0);return Ke.available[t]!==void 0&&Ke.uninstall(t),Ke.available[t]=w,w}};Ir.ALPHA=[["a","z"],["A","Z"]," "],Ir.NUMERIC=[["0","9"]],Ir.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Ir.ASCII=[[" ","~"]],Ir.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Ir.ALPHANUMERIC},Ir.available={};let Cr=Ir;var bw=`// Pixi texture info\r
1084
1084
  varying vec2 vTextureCoord;\r
1085
1085
  uniform sampler2D uSampler;\r
1086
1086
  \r
@@ -1118,7 +1118,7 @@ void main(void) {\r
1118
1118
  // NPM Textures, NPM outputs\r
1119
1119
  gl_FragColor = vec4(uColor.rgb, coverage);\r
1120
1120
  }\r
1121
- `,Tw=`// Mesh material default fragment\r
1121
+ `,ww=`// Mesh material default fragment\r
1122
1122
  attribute vec2 aVertexPosition;\r
1123
1123
  attribute vec2 aTextureCoord;\r
1124
1124
  \r
@@ -1134,15 +1134,15 @@ void main(void)\r
1134
1134
  \r
1135
1135
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1136
1136
  }\r
1137
- `;const bf=[],wf=[],Ef=[],Aw=class Zf extends Te{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Zf.styleDefaults,e);if(!Cr.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new bt(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new hr(()=>{this.dirty=!0},this,0,0),this._roundPixels=W.ROUND_PIXELS,this.dirty=!0,this._resolution=W.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var R;const t=Cr.available[this._fontName],e=this.fontSize,i=e/t.size,s=new gt,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1138
- `)||" ",h=xf(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?bf:wf;let d=null,f=0,p=0,m=0,_=-1,y=0,x=0,g=0,v=0;for(let E=0;E<h.length;E++){const b=h[E],D=Jn(b);if(/(?:\s)/.test(b)&&(_=E,y=f,v++),b==="\r"||b===`
1139
- `){o.push(f),a.push(-1),p=Math.max(p,f),++m,++x,s.x=0,s.y+=t.lineHeight,d=null,v=0;continue}const F=t.chars[D];if(!F)continue;d&&F.kerning[d]&&(s.x+=F.kerning[d]);const G=Ef.pop()||{texture:q.EMPTY,line:0,charCode:0,prevSpaces:0,position:new gt};G.texture=F.texture,G.line=m,G.charCode=D,G.position.x=Math.round(s.x+F.xOffset+this._letterSpacing/2),G.position.y=Math.round(s.y+F.yOffset),G.prevSpaces=v,n.push(G),f=G.position.x+Math.max(F.xAdvance-F.xOffset,F.texture.orig.width),s.x+=F.xAdvance+this._letterSpacing,g=Math.max(g,F.yOffset+F.texture.height),d=D,_!==-1&&c>0&&s.x>c&&(++x,Si(n,1+_-x,1+E-_),E=_,_=-1,o.push(y),a.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,y),m++,s.x=0,s.y+=t.lineHeight,d=null,v=0)}const w=h[h.length-1];w!=="\r"&&w!==`
1140
- `&&(/(?:\s)/.test(w)&&(f=y),o.push(f),p=Math.max(p,f),a.push(-1));const I=[];for(let E=0;E<=m;E++){let b=0;this._align==="right"?b=p-o[E]:this._align==="center"?b=(p-o[E])/2:this._align==="justify"&&(b=a[E]<0?0:(p-o[E])/a[E]),I.push(b)}const A=n.length,C={},N=[],S=this._activePagesMeshData;u.push(...S);for(let E=0;E<A;E++){const b=n[E].texture,D=b.baseTexture.uid;if(!C[D]){let F=u.pop();if(!F){const $=new qb;let B,Z;t.distanceFieldType==="none"?(B=new of(q.EMPTY),Z=tt.NORMAL):(B=new of(q.EMPTY,{program:cr.from(Tw,Ew),uniforms:{uFWidth:0}}),Z=tt.NORMAL_NPM);const P=new nf($,B);P.blendMode=Z,F={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:P,vertices:null,uvs:null,indices:null}}F.index=0,F.indexCount=0,F.vertexCount=0,F.uvsCount=0,F.total=0;const{_textureCache:G}=this;G[D]=G[D]||new q(b.baseTexture),F.mesh.texture=G[D],F.mesh.tint=this._tintColor.value,N.push(F),C[D]=F}C[D].total++}for(let E=0;E<S.length;E++)N.includes(S[E])||this.removeChild(S[E].mesh);for(let E=0;E<N.length;E++)N[E].mesh.parent!==this&&this.addChild(N[E].mesh);this._activePagesMeshData=N;for(const E in C){const b=C[E],D=b.total;if(!(((R=b.indices)==null?void 0:R.length)>6*D)||b.vertices.length<nf.BATCHABLE_SIZE*2)b.vertices=new Float32Array(4*2*D),b.uvs=new Float32Array(4*2*D),b.indices=new Uint16Array(6*D);else{const F=b.total,G=b.vertices;for(let $=F*4*2;$<G.length;$++)G[$]=0}b.mesh.size=6*D}for(let E=0;E<A;E++){const b=n[E];let D=b.position.x+I[b.line]*(this._align==="justify"?b.prevSpaces:1);this._roundPixels&&(D=Math.round(D));const F=D*i,G=b.position.y*i,$=b.texture,B=C[$.baseTexture.uid],Z=$.frame,P=$._uvs,U=B.index++;B.indices[U*6+0]=0+U*4,B.indices[U*6+1]=1+U*4,B.indices[U*6+2]=2+U*4,B.indices[U*6+3]=0+U*4,B.indices[U*6+4]=2+U*4,B.indices[U*6+5]=3+U*4,B.vertices[U*8+0]=F,B.vertices[U*8+1]=G,B.vertices[U*8+2]=F+Z.width*i,B.vertices[U*8+3]=G,B.vertices[U*8+4]=F+Z.width*i,B.vertices[U*8+5]=G+Z.height*i,B.vertices[U*8+6]=F,B.vertices[U*8+7]=G+Z.height*i,B.uvs[U*8+0]=P.x0,B.uvs[U*8+1]=P.y0,B.uvs[U*8+2]=P.x1,B.uvs[U*8+3]=P.y1,B.uvs[U*8+4]=P.x2,B.uvs[U*8+5]=P.y2,B.uvs[U*8+6]=P.x3,B.uvs[U*8+7]=P.y3}this._textWidth=p*i,this._textHeight=(s.y+t.lineHeight)*i;for(const E in C){const b=C[E];if(this.anchor.x!==0||this.anchor.y!==0){let $=0;const B=this._textWidth*this.anchor.x,Z=this._textHeight*this.anchor.y;for(let P=0;P<b.total;P++)b.vertices[$++]-=B,b.vertices[$++]-=Z,b.vertices[$++]-=B,b.vertices[$++]-=Z,b.vertices[$++]-=B,b.vertices[$++]-=Z,b.vertices[$++]-=B,b.vertices[$++]-=Z}this._maxLineHeight=g*i;const D=b.mesh.geometry.getBuffer("aVertexPosition"),F=b.mesh.geometry.getBuffer("aTextureCoord"),G=b.mesh.geometry.getIndex();D.data=b.vertices,F.data=b.uvs,G.data=b.indices,D.update(),F.update(),G.update()}for(let E=0;E<n.length;E++)Ef.push(n[E]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=Cr.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=Cr.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!Cr.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Cr.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=Cr.available[this._fontName].distanceFieldType==="none"?bf:wf;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=q.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};Aw.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const Sw=[".xml",".fnt"],Iw={extension:{type:X.LoadParser,priority:Ie.Normal},name:"loadBitmapFont",test(r){return Sw.includes(Gt.extname(r).toLowerCase())},async testParse(r){return Zn.test(r)||Il.test(r)},async parse(r,t,e){const i=Zn.test(r)?Zn.parse(r):Il.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const c=n[h].file;let u=Gt.join(Gt.dirname(s),c);u=cl(u,s),o.push(u)}const a=await e.load(o),l=o.map(h=>a[h]);return Cr.install(i,l,!0)},async load(r,t){return(await W.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};Y.add(Iw);const Rl=class $i extends Sr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new $i(Object.keys($i.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete $i.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=$i;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return W.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,o)=>{const a=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([a,l.result]),l.onerror=o,l.readAsDataURL(s)})).then(async([s,n])=>{const o=Object.assign({family:Gt.basename(t,Gt.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=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(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"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((t,e)=>`${t}
1137
+ `;const _f=[],vf=[],xf=[],Ew=class Yf extends Te{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Yf.styleDefaults,e);if(!Cr.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new bt(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new cr(()=>{this.dirty=!0},this,0,0),this._roundPixels=W.ROUND_PIXELS,this.dirty=!0,this._resolution=W.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var R;const t=Cr.available[this._fontName],e=this.fontSize,i=e/t.size,s=new gt,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1138
+ `)||" ",h=yf(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?_f:vf;let d=null,f=0,p=0,m=0,_=-1,y=0,x=0,g=0,v=0;for(let E=0;E<h.length;E++){const b=h[E],D=qn(b);if(/(?:\s)/.test(b)&&(_=E,y=f,v++),b==="\r"||b===`
1139
+ `){o.push(f),a.push(-1),p=Math.max(p,f),++m,++x,s.x=0,s.y+=t.lineHeight,d=null,v=0;continue}const F=t.chars[D];if(!F)continue;d&&F.kerning[d]&&(s.x+=F.kerning[d]);const G=xf.pop()||{texture:q.EMPTY,line:0,charCode:0,prevSpaces:0,position:new gt};G.texture=F.texture,G.line=m,G.charCode=D,G.position.x=Math.round(s.x+F.xOffset+this._letterSpacing/2),G.position.y=Math.round(s.y+F.yOffset),G.prevSpaces=v,n.push(G),f=G.position.x+Math.max(F.xAdvance-F.xOffset,F.texture.orig.width),s.x+=F.xAdvance+this._letterSpacing,g=Math.max(g,F.yOffset+F.texture.height),d=D,_!==-1&&c>0&&s.x>c&&(++x,Si(n,1+_-x,1+E-_),E=_,_=-1,o.push(y),a.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,y),m++,s.x=0,s.y+=t.lineHeight,d=null,v=0)}const w=h[h.length-1];w!=="\r"&&w!==`
1140
+ `&&(/(?:\s)/.test(w)&&(f=y),o.push(f),p=Math.max(p,f),a.push(-1));const I=[];for(let E=0;E<=m;E++){let b=0;this._align==="right"?b=p-o[E]:this._align==="center"?b=(p-o[E])/2:this._align==="justify"&&(b=a[E]<0?0:(p-o[E])/a[E]),I.push(b)}const A=n.length,C={},N=[],S=this._activePagesMeshData;u.push(...S);for(let E=0;E<A;E++){const b=n[E].texture,D=b.baseTexture.uid;if(!C[D]){let F=u.pop();if(!F){const $=new jb;let B,K;t.distanceFieldType==="none"?(B=new rf(q.EMPTY),K=tt.NORMAL):(B=new rf(q.EMPTY,{program:ur.from(ww,bw),uniforms:{uFWidth:0}}),K=tt.NORMAL_NPM);const P=new ef($,B);P.blendMode=K,F={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:P,vertices:null,uvs:null,indices:null}}F.index=0,F.indexCount=0,F.vertexCount=0,F.uvsCount=0,F.total=0;const{_textureCache:G}=this;G[D]=G[D]||new q(b.baseTexture),F.mesh.texture=G[D],F.mesh.tint=this._tintColor.value,N.push(F),C[D]=F}C[D].total++}for(let E=0;E<S.length;E++)N.includes(S[E])||this.removeChild(S[E].mesh);for(let E=0;E<N.length;E++)N[E].mesh.parent!==this&&this.addChild(N[E].mesh);this._activePagesMeshData=N;for(const E in C){const b=C[E],D=b.total;if(!(((R=b.indices)==null?void 0:R.length)>6*D)||b.vertices.length<ef.BATCHABLE_SIZE*2)b.vertices=new Float32Array(4*2*D),b.uvs=new Float32Array(4*2*D),b.indices=new Uint16Array(6*D);else{const F=b.total,G=b.vertices;for(let $=F*4*2;$<G.length;$++)G[$]=0}b.mesh.size=6*D}for(let E=0;E<A;E++){const b=n[E];let D=b.position.x+I[b.line]*(this._align==="justify"?b.prevSpaces:1);this._roundPixels&&(D=Math.round(D));const F=D*i,G=b.position.y*i,$=b.texture,B=C[$.baseTexture.uid],K=$.frame,P=$._uvs,U=B.index++;B.indices[U*6+0]=0+U*4,B.indices[U*6+1]=1+U*4,B.indices[U*6+2]=2+U*4,B.indices[U*6+3]=0+U*4,B.indices[U*6+4]=2+U*4,B.indices[U*6+5]=3+U*4,B.vertices[U*8+0]=F,B.vertices[U*8+1]=G,B.vertices[U*8+2]=F+K.width*i,B.vertices[U*8+3]=G,B.vertices[U*8+4]=F+K.width*i,B.vertices[U*8+5]=G+K.height*i,B.vertices[U*8+6]=F,B.vertices[U*8+7]=G+K.height*i,B.uvs[U*8+0]=P.x0,B.uvs[U*8+1]=P.y0,B.uvs[U*8+2]=P.x1,B.uvs[U*8+3]=P.y1,B.uvs[U*8+4]=P.x2,B.uvs[U*8+5]=P.y2,B.uvs[U*8+6]=P.x3,B.uvs[U*8+7]=P.y3}this._textWidth=p*i,this._textHeight=(s.y+t.lineHeight)*i;for(const E in C){const b=C[E];if(this.anchor.x!==0||this.anchor.y!==0){let $=0;const B=this._textWidth*this.anchor.x,K=this._textHeight*this.anchor.y;for(let P=0;P<b.total;P++)b.vertices[$++]-=B,b.vertices[$++]-=K,b.vertices[$++]-=B,b.vertices[$++]-=K,b.vertices[$++]-=B,b.vertices[$++]-=K,b.vertices[$++]-=B,b.vertices[$++]-=K}this._maxLineHeight=g*i;const D=b.mesh.geometry.getBuffer("aVertexPosition"),F=b.mesh.geometry.getBuffer("aTextureCoord"),G=b.mesh.geometry.getIndex();D.data=b.vertices,F.data=b.uvs,G.data=b.indices,D.update(),F.update(),G.update()}for(let E=0;E<n.length;E++)xf.push(n[E]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=Cr.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=Cr.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!Cr.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Cr.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=Cr.available[this._fontName].distanceFieldType==="none"?_f:vf;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=q.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};Ew.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const Tw=[".xml",".fnt"],Aw={extension:{type:X.LoadParser,priority:Ie.Normal},name:"loadBitmapFont",test(r){return Tw.includes(Gt.extname(r).toLowerCase())},async testParse(r){return Yn.test(r)||El.test(r)},async parse(r,t,e){const i=Yn.test(r)?Yn.parse(r):El.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const c=n[h].file;let u=Gt.join(Gt.dirname(s),c);u=ol(u,s),o.push(u)}const a=await e.load(o),l=o.map(h=>a[h]);return Cr.install(i,l,!0)},async load(r,t){return(await W.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};Y.add(Aw);const Al=class $i extends Sr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new $i(Object.keys($i.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete $i.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=$i;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return W.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,o)=>{const a=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([a,l.result]),l.onerror=o,l.readAsDataURL(s)})).then(async([s,n])=>{const o=Object.assign({family:Gt.basename(t,Gt.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=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(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"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((t,e)=>`${t}
1141
1141
  @font-face {
1142
1142
  font-family: "${e.family}";
1143
1143
  src: url('${e.dataSrc}');
1144
1144
  font-weight: ${e.weight};
1145
1145
  font-style: ${e.style};
1146
1146
  font-display: ${e.display};
1147
- }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=gv(t)),typeof t=="number"?mv(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,$i.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=W.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};Rl.availableFonts={},Rl.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 Pl=Rl;const Qn=class Hi extends Pi{constructor(t="",e={}){super(q.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,s=q.from(i,{scaleMode:W.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new at,s.trim=new at,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Hi.defaultMaxWidth,this.maxHeight=Hi.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Hi.defaultAutoResolution,this._resolution=Hi.defaultResolution??W.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(c=this._style)==null?void 0:c.toCSS(s)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Hi.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=vr(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=vr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Pl?(this.ownsStyle=!1,this._style=t):t instanceof Sr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Pl.from(t)):(this.ownsStyle=!0,this._style=new Pl(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};Qn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Qn.defaultMaxWidth=2024,Qn.defaultMaxHeight=2024,Qn.defaultAutoResolution=!0;const Cw=16777215,Rw=.25,Pw=16777215,Mw=1.5;let Rr=!1,xs;const Ml=r=>{const t={tint:r!=null&&r.fill?new bt(r.fill).toNumber():Cw,alpha:(r==null?void 0:r.fillOpacity)===void 0?Rw:Math.min(r.fillOpacity,1)},e={tint:r!=null&&r.stroke?new bt(r.stroke).toNumber():Pw,alpha:(r==null?void 0:r.strokeOpacity)===void 0?1:Math.min(r.strokeOpacity,1),lineWidth:(r==null?void 0:r.strokeWidth)===void 0?Mw:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Bl=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=Ml(i),o=new vs;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new vs,l=n.lineWidth===1?1:n.lineWidth/xs;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},Bw=Bl((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),Dw=Bl((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),Ow=Bl((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),Tf=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Af=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Tf(r);(n!==xs||!Rr)&&(Rr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Rr=n===xs,p.width=f/n,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),xs=n;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+s.x*n:-s.x*n,h=-s.y*n;let c,u;a>0&&a<=Math.PI/2?(c=s.height*n,u=0):a>Math.PI/2&&a<=Math.PI?(c=s.width*n,u=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=s.width*n):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},Fw=(r,t)=>{const e=new vs,i=xd({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;xs=Tf(r);const l=(g,v)=>{Rr=!1;const{selector:w}=g.target,I=typeof a=="function"?a(g,v):a;let A;w.type===wt.RECTANGLE?A=Ow(e,w,I):w.type===wt.POLYGON?A=Dw(e,w,I):w.type===wt.ELLIPSE?A=Bw(e,w,I):console.warn(`Unsupported shape type: ${w.type}`),A&&s.set(g.id,{annotation:g,...A})},h=g=>{const v=s.get(g.id);v&&(s.delete(g.id),v.fill.destroy(),v.stroke.destroy())},c=(g,v,w)=>{Rr=!1;const I=s.get(g.id);I&&(s.delete(g.id),I.fill.destroy(),I.stroke.destroy(),l(v,w))},u=(g,v)=>{const w=s.get(g);w&&(s.delete(g),w.fill.destroy(),w.stroke.destroy(),l(w.annotation,v))},d=(g,v)=>{i.resize(g,v),i.render(e)},f=g=>{Rr=!1;const{children:v}=e;s.forEach(({fill:w,stroke:I,annotation:A})=>{const C=g?n.has(A.id)||g(A):!0;C&&!v.includes(w)?(e.addChild(w),e.addChild(I)):!C&&v.includes(w)&&(e.removeChild(w),e.removeChild(I))}),i.render(e)},p=g=>{o!==g&&(o&&u(o,{selected:n.has(o)}),g&&u(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const v=g.selected.map(A=>A.id),w=v.filter(A=>!n.has(A)),I=[...n].filter(A=>!v.includes(A));[...w,...I].forEach(A=>u(A,{selected:v.includes(A),hovered:A===o})),n=new Set(v),i.render(e)},_=g=>{if(typeof g=="function")s.forEach(({annotation:v,fill:w,stroke:I,strokeWidth:A},C)=>{A>1&&(Rr=!1);const N={selected:n.has(v.id),hovered:o===v.id},{fillStyle:S,strokeStyle:R}=Ml(g(v,N));w.tint=S.tint,w.alpha=S.alpha,I.tint=R.tint||16777215,I.alpha=R.alpha,s.set(v.id,{annotation:v,fill:w,stroke:I,strokeWidth:R.lineWidth})});else{const{fillStyle:v,strokeStyle:w}=Ml(g);w.lineWidth>1&&(Rr=!1),s.forEach(({annotation:I,fill:A,stroke:C,strokeWidth:N},S)=>{A.tint=v.tint,A.alpha=v.alpha,C.tint=w.tint||16777215,C.alpha=w.alpha,s.set(I.id,{annotation:I,fill:A,stroke:C,strokeWidth:w.lineWidth})})}a=g,i.render(e),Af(r,e,s,i)()},y=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:Af(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:p,setSelected:m,setStyle:_,setVisible:y,updateAnnotation:c}};function Lw(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:f}=o;Do(r,u,I=>e(11,i=I)),Do(r,d,I=>e(8,s=I));const p=zs();let m,_;const y=I=>{const A=new Nt.Point(I.x,I.y),{x:C,y:N}=l.viewport.pointFromPixel(A);return l.viewport.viewportToImageCoordinates(C,N)},x=I=>{const{x:A,y:C}=I.position;_={x:A,y:C}},g=I=>A=>{const{x:C,y:N}=y(new Nt.Point(A.offsetX,A.offsetY)),S=c.getAt(C,N);S&&(!n||n(S))?(I.classList.add("hover"),i!==S.id&&(u.set(S.id),m.setHovered(S.id))):(I.classList.remove("hover"),i&&(u.set(void 0),m.setHovered(void 0)))},v=I=>{if(!_)return;const A=I.originalEvent,{x:C,y:N}=I.position,S=C-_.x,R=N-_.y;if(Math.sqrt(S*S+R*R)<5){const{x:b,y:D}=y(I.position),F=c.getAt(b,D);F?p("click",{originalEvent:A,annotation:F}):p("click",{originalEvent:A})}_=void 0};let w;return Vs(()=>{var F;const{offsetWidth:I,offsetHeight:A}=l.canvas,C=document.createElement("canvas");C.width=I,C.height=A,C.className="a9s-gl-canvas",(F=l.element.querySelector(".openseadragon-canvas"))==null||F.appendChild(C),e(7,m=Fw(l,C));const N=g(C);C.addEventListener("pointermove",N);const S=new ResizeObserver(G=>{try{const{width:$,height:B}=G[0].contentRect;C.width=$,C.height=B,m.resize($,B)}catch{console.warn("WebGL canvas already disposed")}});S.observe(C);const R=()=>{const G=l.viewport.getBounds();w=l.viewport.viewportToImageRectangle(G);const{x:$,y:B,width:Z,height:P}=w,U=c.getIntersecting($,B,Z,P);f.set(U.map(j=>j.id))};l.addHandler("canvas-press",x),l.addHandler("canvas-release",v),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",R);const E=G=>G.filter($=>Je($)),b=G=>Je(G.oldValue)&&Je(G.newValue),D=G=>{const{created:$,updated:B,deleted:Z}=G.changes;if(E($||[]).forEach(P=>m.addAnnotation(P)),E(Z||[]).forEach(P=>m.removeAnnotation(P)),(B||[]).filter(P=>b(P)).forEach(({oldValue:P,newValue:U})=>m.updateAnnotation(P,U)),w){const{x:P,y:U,width:j,height:rt}=w,Q=c.getIntersecting(P,U,j,rt);f.set(Q.map(H=>H.id))}else f.set(c.all().map(P=>P.id));m.redraw()};return c.observe(D),()=>{var G;C.removeEventListener("pointermove",N),S.disconnect(),l.removeHandler("canvas-press",x),l.removeHandler("canvas-release",v),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",R),c.unobserve(D),m.destroy(),(G=C.parentNode)==null||G.removeChild(C)}}),r.$$set=I=>{"filter"in I&&e(2,n=I.filter),"state"in I&&e(3,o=I.state),"style"in I&&e(4,a=I.style),"viewer"in I&&e(5,l=I.viewer),"visible"in I&&e(6,h=I.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[u,d,n,o,a,l,h,m,s]}class Nw extends ae{constructor(t){super(),oe(this,t,Lw,null,te,{filter:2,state:3,style:4,viewer:5,visible:6})}}for(var Yt=[],Dl=0;Dl<256;++Dl)Yt.push((Dl+256).toString(16).slice(1));function Uw(r,t=0){return(Yt[r[t+0]]+Yt[r[t+1]]+Yt[r[t+2]]+Yt[r[t+3]]+"-"+Yt[r[t+4]]+Yt[r[t+5]]+"-"+Yt[r[t+6]]+Yt[r[t+7]]+"-"+Yt[r[t+8]]+Yt[r[t+9]]+"-"+Yt[r[t+10]]+Yt[r[t+11]]+Yt[r[t+12]]+Yt[r[t+13]]+Yt[r[t+14]]+Yt[r[t+15]]).toLowerCase()}var to,kw=new Uint8Array(16);function Gw(){if(!to&&(to=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!to))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return to(kw)}var $w=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Sf={randomUUID:$w};function Hw(r,t,e){if(Sf.randomUUID&&!t&&!r)return Sf.randomUUID();r=r||{};var i=r.random||(r.rng||Gw)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Uw(i)}var Ui=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Ui||{});const Ol=(r,t)=>t,Xw=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Vw={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};Ol(Ui.ELLIPSE,Vw);const zw={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};Ol(Ui.POLYGON,zw);const Ww={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};Ol(Ui.RECTANGLE,Ww);function If(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Cf(r){let t,e;return t=new bs({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function jw(r){let t,e,i,s,n,o,a,l,h,c,u,d=ui(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=Cf(If(r,d,m));const p=m=>ut(f[m],1,1,()=>{f[m]=null});return{c(){t=Tt("polygon"),s=xe(),n=Tt("polygon"),a=xe();for(let m=0;m<f.length;m+=1)f[m].c();l=er(),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"points",i=r[4].points.map(Rf).join(" ")),M(n,"class","a9s-inner a9s-shape-handle"),M(n,"style",r[1]),M(n,"points",o=r[4].points.map(Pf).join(" "))},m(m,_){ft(m,t,_),ft(m,s,_),ft(m,n,_),ft(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);ft(m,l,_),h=!0,c||(u=[zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(Rf).join(" ")))&&M(t,"points",i),(!h||_&2)&&M(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(Pf).join(" ")))&&M(n,"points",o),_&536){d=ui(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=If(r,d,y);f[y]?(f[y].p(x,_),st(f[y],1)):(f[y]=Cf(x),f[y].c(),st(f[y],1),f[y].m(l.parentNode,l))}for(De(),y=d.length;y<f.length;y+=1)p(y);Oe()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)st(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)ut(f[_]);h=!1},d(m){m&&(ct(t),ct(s),ct(n),ct(a),ct(l)),Oo(f,m),c=!1,Qe(u)}}}function Yw(r){let t,e;return t=new Bf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[jw,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}const Rf=r=>r.join(","),Pf=r=>r.join(",");function qw(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Xw(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Kw extends ae{constructor(t){super(),oe(this,t,qw,Yw,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Zw=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Jw(r){let t,e,i,s,n,o;return{c(){t=Tt("rect"),M(t,"class",e=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(t,"x",i=r[0]-r[5]/2),M(t,"y",s=r[1]-r[5]/2),M(t,"width",r[5]),M(t,"height",r[5])},m(a,l){ft(a,t,l),n||(o=zt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Hs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&M(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&M(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&M(t,"y",s),l&32&&M(t,"width",a[5]),l&32&&M(t,"height",a[5])},d(a){a&&ct(t),n=!1,o()}}}function Qw(r){let t,e,i,s,n,o,a,l,h;return{c(){t=Tt("g"),e=Tt("circle"),s=Tt("rect"),M(e,"cx",r[0]),M(e,"cy",r[1]),M(e,"r",i=r[3]/r[2]),M(e,"class","a9s-touch-halo svelte-1sgkh33"),Xs(e,"touched",r[4]),M(s,"class",n=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(s,"x",o=r[0]-r[5]/2),M(s,"y",a=r[1]-r[5]/2),M(s,"width",r[5]),M(s,"height",r[5]),M(t,"class","a9s-touch-handle")},m(c,u){ft(c,t,u),tr(t,e),tr(t,s),l||(h=[zt(e,"pointerdown",r[10]),zt(e,"pointerdown",r[6]),zt(e,"pointerup",r[7]),zt(s,"pointerdown",r[9]),zt(s,"pointerdown",r[6]),zt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&M(e,"cx",c[0]),u&2&&M(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&M(e,"r",i),u&16&&Xs(e,"touched",c[4]),u&256&&n!==(n=Hs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&M(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&M(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&M(s,"y",a),u&32&&M(s,"width",c[5]),u&32&&M(s,"height",c[5])},d(c){c&&ct(t),l=!1,Qe(h)}}}function tE(r){let t;function e(n,o){return Zw?Qw:Jw}let s=e()(r);return{c(){s.c(),t=er()},m(n,o){s.m(n,o),ft(n,t,o)},p(n,[o]){s.p(n,o)},i:Be,o:Be,d(n){n&&ct(t),s.d(n)}}}function eE(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){rr.call(this,r,p)}function d(p){rr.call(this,r,p)}function f(p){rr.call(this,r,p)}return r.$$set=p=>{e(8,t=Bo(Bo({},t),Kh(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Kh(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class bs extends ae{constructor(t){super(),oe(this,t,eE,tE,te,{x:0,y:1,scale:2,radius:3})}}function rE(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,Z,P,U,j,rt,Q,H,V,lt;return B=new bs({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Kt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new bs({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Kt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new bs({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Kt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new bs({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Kt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=Tt("rect"),a=xe(),l=Tt("rect"),f=xe(),p=Tt("rect"),x=xe(),g=Tt("rect"),A=xe(),C=Tt("rect"),E=xe(),b=Tt("rect"),$=xe(),ee(B.$$.fragment),Z=xe(),ee(P.$$.fragment),U=xe(),ee(j.$$.fragment),rt=xe(),ee(Q.$$.fragment),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"x",i=r[4].x),M(t,"y",s=r[4].y),M(t,"width",n=r[4].w),M(t,"height",o=r[4].h),M(l,"class","a9s-inner a9s-shape-handle"),M(l,"style",r[1]),M(l,"x",h=r[4].x),M(l,"y",c=r[4].y),M(l,"width",u=r[4].w),M(l,"height",d=r[4].h),M(p,"class","a9s-edge-handle a9s-edge-handle-top"),M(p,"x",m=r[4].x),M(p,"y",_=r[4].y),M(p,"height",1),M(p,"width",y=r[4].w),M(g,"class","a9s-edge-handle a9s-edge-handle-right"),M(g,"x",v=r[4].x+r[4].w),M(g,"y",w=r[4].y),M(g,"height",I=r[4].h),M(g,"width",1),M(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),M(C,"x",N=r[4].x),M(C,"y",S=r[4].y+r[4].h),M(C,"height",1),M(C,"width",R=r[4].w),M(b,"class","a9s-edge-handle a9s-edge-handle-left"),M(b,"x",D=r[4].x),M(b,"y",F=r[4].y),M(b,"height",G=r[4].h),M(b,"width",1)},m(L,O){ft(L,t,O),ft(L,a,O),ft(L,l,O),ft(L,f,O),ft(L,p,O),ft(L,x,O),ft(L,g,O),ft(L,A,O),ft(L,C,O),ft(L,E,O),ft(L,b,O),ft(L,$,O),Zt(B,L,O),ft(L,Z,O),Zt(P,L,O),ft(L,U,O),Zt(j,L,O),ft(L,rt,O),Zt(Q,L,O),H=!0,V||(lt=[zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),zt(l,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),zt(p,"pointerdown",function(){Kt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),zt(g,"pointerdown",function(){Kt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),zt(C,"pointerdown",function(){Kt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),zt(b,"pointerdown",function(){Kt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&M(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&M(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&M(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&M(t,"height",o),(!H||O&2)&&M(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&M(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&M(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&M(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&M(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&M(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&M(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&M(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&M(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&M(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&M(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&M(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&M(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&M(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&M(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&M(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&M(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(st(B.$$.fragment,L),st(P.$$.fragment,L),st(j.$$.fragment,L),st(Q.$$.fragment,L),H=!0)},o(L){ut(B.$$.fragment,L),ut(P.$$.fragment,L),ut(j.$$.fragment,L),ut(Q.$$.fragment,L),H=!1},d(L){L&&(ct(t),ct(a),ct(l),ct(f),ct(p),ct(x),ct(g),ct(A),ct(C),ct(E),ct(b),ct($),ct(Z),ct(U),ct(rt)),Jt(B,L),Jt(P,L),Jt(j,L),Jt(Q,L),V=!1,Qe(lt)}}}function iE(r){let t,e;return t=new Bf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[rE,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function sE(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[_,y]=[m.minX,m.minY],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class nE extends ae{constructor(t){super(),oe(this,t,sE,iE,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Ui.RECTANGLE,Ui.POLYGON;const oE=r=>({}),Mf=r=>({grab:r[0]});function aE(r){let t,e,i,s;const n=r[7].default,o=zh(n,r,r[6],Mf);return{c(){t=Tt("g"),o&&o.c(),M(t,"class","a9s-annotation selected")},m(a,l){ft(a,t,l),o&&o.m(t,null),e=!0,i||(s=[zt(t,"pointerup",r[2]),zt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Yh(o,n,a,a[6],e?jh(n,a[6],l,oE):qh(a[6]),Mf)},i(a){e||(st(o,a),e=!0)},o(a){ut(o,a),e=!1},d(a){a&&ct(t),o&&o.d(a),i=!1,Qe(s)}}}function lE(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=zs();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class Bf extends ae{constructor(t){super(),oe(this,t,lE,aE,te,{shape:3,editor:4,transform:5})}}const hE=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function cE(r,t,e){let i;const s=zs();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Vs(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=hE(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[n,o,a,l,h,c,u,i]}class uE extends ae{constructor(t){super(),oe(this,t,cE,null,te,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const dE=r=>({transform:r&2,scale:r&1}),Df=r=>({transform:r[1],scale:r[0]});function fE(r){let t;const e=r[4].default,i=zh(e,r,r[3],Df);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Yh(i,e,s,s[3],t?jh(e,s[3],n,dE):qh(s[3]),Df)},i(s){t||(st(i,s),t=!0)},o(s){ut(i,s),t=!1},d(s){i&&i.d(s)}}}function pE(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,c=n.viewport.getZoom(!0),u=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new Nt.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/n.world.getContentFactor(),p=u?-f:f,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=c*h/n.world.getContentFactor())};return Vs(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class Of extends ae{constructor(t){super(),oe(this,t,pE,fE,te,{viewer:2})}}function mE(r,t,e){const i=zs();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,c;return Vs(()=>{const u=n.closest("svg"),d=[],f=(p,m,_)=>{if(u==null||u.addEventListener(p,m,_),d.push(()=>u==null?void 0:u.removeEventListener(p,m,_)),p==="pointerup"||p==="dblclick"){const y=g=>{const{originalEvent:v}=g;m(v)},x=p==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(x,y),d.push(()=>l.removeHandler(x,y))}else if(p==="pointermove"){const y=x=>{const{originalEvent:g}=x;m(g)};l.addHandler("canvas-drag",y),d.push(()=>l.removeHandler("canvas-drag",y))}};return e(6,c=new o({target:n,props:{addEventListener:f,drawingMode:s,transform:a,viewportScale:h}})),c.$on("create",p=>i("create",p.detail)),()=>{d.forEach(p=>p()),c.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewer"in u&&e(4,l=u.viewer),"viewportScale"in u&&e(5,h=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&c&&c.$set({transform:a}),r.$$.dirty&96&&c&&c.$set({viewportScale:h})},[s,n,o,a,l,h,c]}class gE extends ae{constructor(t){super(),oe(this,t,mE,null,te,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function Ff(r,t,e){const i=r.slice();i[33]=t[e];const s=i[14](i[33].target.selector);return i[34]=s,i}function yE(r){let t=r[2],e,i,s=Lf(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&4&&te(t,t=n[2])?(De(),ut(s,1,1,Be),Oe(),s=Lf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function _E(r){let t,e,i=ui(r[6].filter(r[23])),s=[];for(let o=0;o<i.length;o+=1)s[o]=kf(Ff(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a[0]&24162|a[1]&2){i=ui(o[6].filter(o[23]));let l;for(l=0;l<i.length;l+=1){const h=Ff(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=kf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Oo(s,o)}}}function Lf(r){let t,e;return t=new gE({props:{target:r[5],tool:r[7],drawingMode:r[4],transform:{elementToImage:r[9]},viewer:r[3],viewportScale:r[32]}}),t.$on("create",r[13]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&128&&(n.tool=i[7]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&2&&(n.viewportScale=i[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Nf(r){let t=r[33].id,e,i,s=Uf(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&64&&te(t,t=n[33].id)?(De(),ut(s,1,1,Be),Oe(),s=Uf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function Uf(r){let t,e;return t=new uE({props:{target:r[5],editor:r[14](r[33].target.selector),annotation:r[33],style:r[1],transform:{elementToImage:r[9]},viewportScale:r[32]}}),t.$on("grab",r[10]),t.$on("change",function(){Kt(r[12](r[33]))&&r[12](r[33]).apply(this,arguments)}),t.$on("release",r[11]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&64&&(n.editor=r[14](r[33].target.selector)),s[0]&64&&(n.annotation=r[33]),s[0]&2&&(n.style=r[1]),s[1]&2&&(n.viewportScale=r[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function kf(r){let t,e,i=r[34]&&Nf(r);return{c(){i&&i.c(),t=er()},m(s,n){i&&i.m(s,n),ft(s,t,n),e=!0},p(s,n){s[34]?i?(i.p(s,n),n[0]&64&&st(i,1)):(i=Nf(s),i.c(),st(i,1),i.m(t.parentNode,t)):i&&(De(),ut(i,1,1,()=>{i=null}),Oe())},i(s){e||(st(i),e=!0)},o(s){ut(i),e=!1},d(s){s&&ct(t),i&&i.d(s)}}}function vE(r){let t,e,i,s,n,o;const a=[_E,yE],l=[];function h(c,u){return c[5]&&c[6]?0:c[5]&&c[7]&&c[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=Tt("svg"),e=Tt("g"),s&&s.c(),M(e,"transform",n=r[31]),M(e,"class","svelte-190cqdf"),M(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),Xs(t,"drawing",r[0])},m(c,u){ft(c,t,u),tr(t,e),~i&&l[i].m(e,null),r[24](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(s&&(De(),ut(l[d],1,1,()=>{l[d]=null}),Oe()),~i?(s=l[i],s?s.p(c,u):(s=l[i]=a[i](c),s.c()),st(s,1),s.m(e,null)):s=null),(!o||u[1]&1&&n!==(n=c[31]))&&M(e,"transform",n),(!o||u[0]&1)&&Xs(t,"drawing",c[0])},i(c){o||(st(s),o=!0)},o(c){ut(s),o=!1},d(c){c&&ct(t),~i&&l[i].d(),r[24](null)}}}function xE(r){let t,e;return t=new Of({props:{viewer:r[3],$$slots:{default:[vE,({transform:i,scale:s})=>({31:i,32:s}),({transform:i,scale:s})=>[0,(i?1:0)|(s?2:0)]]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&255|s[1]&67&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function bE(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:c}=t,{style:u=void 0}=t,{toolName:d=Us()[0]}=t,{user:f}=t,{viewer:p}=t;const m=()=>d,_=()=>a,y=navigator.userAgent.match(/firefox|fxios/i);let x;const{store:g,selection:v,hover:w}=c;Do(r,v,B=>e(22,o=B));let I,A,C;const N=B=>{g.unobserve(I);const Z=B.filter(({editable:P})=>P).map(({id:P})=>P);if(Z.length>0){if(e(6,A=Z.map(P=>g.getAnnotation(P))),I=P=>{const{updated:U}=P.changes;e(6,A=(U||[]).map(j=>j.newValue))},g.observe(I,{annotations:Z}),y){const{width:P}=p.viewport.viewerElementToViewportRectangle(new Nt.Rect(0,0,1,1));p.viewport.panBy(new Nt.Point(Math.abs(P/10),0))}}else e(6,A=void 0)},S=(B,Z)=>{const{x:P,y:U}=p.viewport.viewerElementToImageCoordinates(new Nt.Point(B,Z));return[P,U]},R=B=>{p.setMouseNavEnabled(!1),C=B.timeStamp},E=B=>{if(p.setMouseNavEnabled(!0),performance.now()-(C||0)<300){const{offsetX:P,offsetY:U}=B.detail,[j,rt]=S(P,U),Q=g.getAt(j,rt);Q&&(!l||l(Q))&&!A.find(V=>V.id===Q.id)&&(w.set(Q.id),v.setSelected(Q.id))}},b=B=>Z=>{var rt;const{target:P}=B,U=10*60*1e3,j=((rt=P.creator)==null?void 0:rt.id)!==f.id||!P.created||new Date().getTime()-P.created.getTime()>U;g.updateTarget({...P,selector:Z.detail,created:j?P.created:new Date,updated:j?new Date:void 0,updatedBy:j?f:void 0})},D=B=>{const Z=Hw(),P={id:Z,bodies:[],target:{annotation:Z,selector:B.detail,creator:f,created:new Date}};g.addAnnotation(P),v.setSelected(P.id),p.setMouseNavEnabled(!0)},F=B=>gh(B),G=B=>Je(B);function $(B){Ws[B?"unshift":"push"](()=>{x=B,e(5,x)})}return r.$$set=B=>{"drawingEnabled"in B&&e(0,a=B.drawingEnabled),"filter"in B&&e(15,l=B.filter),"preferredDrawingMode"in B&&e(16,h=B.preferredDrawingMode),"state"in B&&e(17,c=B.state),"style"in B&&e(1,u=B.style),"toolName"in B&&e(2,d=B.toolName),"user"in B&&e(18,f=B.user),"viewer"in B&&e(3,p=B.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(7,{tool:i,opts:s}=ks(d)||{tool:void 0,opts:void 0},i,(e(21,s),e(2,d))),r.$$.dirty[0]&2162688&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(a&&n==="drag"?p.setMouseNavEnabled(!1):p.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&v.clear(),r.$$.dirty[0]&4194329&&o.selected.length===0&&n==="drag"&&a&&p.setMouseNavEnabled(!1),r.$$.dirty[0]&4194304&&N(o.selected)},[a,u,d,p,n,x,A,i,v,S,R,E,b,D,F,l,h,c,f,m,_,s,o,G,$]}class wE extends ae{constructor(t){super(),oe(this,t,bE,xE,te,{drawingEnabled:0,filter:15,preferredDrawingMode:16,state:17,style:1,toolName:2,user:18,viewer:3,getDrawingTool:19,isDrawingEnabled:20},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[19]}get isDrawingEnabled(){return this.$$.ctx[20]}}function EE(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=Tt("g"),e=Tt("rect"),a=Tt("text"),h=Fo(l),M(e,"class","a9s-presence-label-bg svelte-1rehw2p"),M(e,"x",r[0]),M(e,"y",i=r[1]-18/r[3]),M(e,"height",s=18/r[3]),M(e,"fill",n=r[2].appearance.color),M(e,"stroke",o=r[2].appearance.color),M(a,"font-size",c=12/r[3]),M(a,"x",u=r[0]+Math.round(5/r[3])),M(a,"y",d=r[1]-5/r[3]),M(a,"class","svelte-1rehw2p"),M(t,"class","a9s-presence-label")},m(f,p){ft(f,t,p),tr(t,e),tr(t,a),tr(a,h),r[6](t)},p(f,[p]){p&1&&M(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&M(e,"y",i),p&8&&s!==(s=18/f[3])&&M(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&M(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&M(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&Jg(h,l),p&8&&c!==(c=12/f[3])&&M(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&M(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&M(a,"y",d)},i:Be,o:Be,d(f){f&&ct(t),r[6](null)}}}function TE(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){Ws[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,s=u.y),"user"in u&&e(2,n=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,c]}class Gf extends ae{constructor(t){super(),oe(this,t,TE,EE,te,{x:0,y:1,user:2,scale:3,hAlign:5})}}function AE(r){let t,e,i,s,n,o;return e=new Gf({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("polygon"),M(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"points",n=r[2].points.map($f).join(" ")),M(t,"class","a9s-presence-overlay")},m(a,l){ft(a,t,l),Zt(e,t,null),tr(t,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]),e.$set(h),(!o||l&1&&s!==(s=a[0].appearance.color))&&M(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map($f).join(" ")))&&M(i,"points",n)},i(a){o||(st(e.$$.fragment,a),o=!0)},o(a){ut(e.$$.fragment,a),o=!1},d(a){a&&ct(t),Jt(e)}}}const $f=r=>r.join(",");function SE(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class IE extends ae{constructor(t){super(),oe(this,t,SE,AE,te,{annotation:4,user:0,scale:1})}}function CE(r){let t,e,i,s,n,o,a,l,h;return e=new Gf({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("rect"),M(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"x",n=r[2].x),M(i,"y",o=r[2].y),M(i,"width",a=r[2].w),M(i,"height",l=r[2].h),M(t,"class","a9s-presence-overlay")},m(c,u){ft(c,t,u),Zt(e,t,null),tr(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&s!==(s=c[0].appearance.color))&&M(i,"stroke",s),(!h||u&4&&n!==(n=c[2].x))&&M(i,"x",n),(!h||u&4&&o!==(o=c[2].y))&&M(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&M(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&M(i,"height",l)},i(c){h||(st(e.$$.fragment,c),h=!0)},o(c){ut(e.$$.fragment,c),h=!1},d(c){c&&ct(t),Jt(e)}}}function RE(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class PE extends ae{constructor(t){super(),oe(this,t,RE,CE,te,{annotation:3,user:0,scale:1})}}const{Boolean:ME}=Kg;function Hf(r,t,e){const i=r.slice();return i[8]=t[e],i}function Xf(r){let t,e;return t=new Of({props:{viewer:r[0],$$slots:{default:[OE,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Vf(r){let t,e,i=ui(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=zf(Hf(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a&132){i=ui(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Hf(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=zf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(ME);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Oo(s,o)}}}function BE(r){let t,e;return t=new IE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function DE(r){let t,e;return t=new PE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function zf(r){let t,e,i,s;const n=[DE,BE],o=[];function a(l,h){return l[8].annotation.target.selector.type===wt.RECTANGLE?0:l[8].annotation.target.selector.type===wt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=er()},m(l,h){~t&&o[t].m(l,h),ft(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(De(),ut(o[c],1,1,()=>{o[c]=null}),Oe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),st(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(st(e),s=!0)},o(l){ut(e),s=!1},d(l){l&&ct(i),~t&&o[t].d(l)}}}function OE(r){let t,e,i,s,n=r[2].length>0&&Vf(r);return{c(){t=Tt("svg"),e=Tt("g"),n&&n.c(),M(e,"transform",i=r[6]),M(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ft(o,t,a),tr(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&st(n,1)):(n=Vf(o),n.c(),st(n,1),n.m(e,null)):n&&(De(),ut(n,1,1,()=>{n=null}),Oe()),(!s||a&64&&i!==(i=o[6]))&&M(e,"transform",i)},i(o){s||(st(n),s=!0)},o(o){ut(n),s=!1},d(o){o&&ct(t),n&&n.d()}}}function FE(r){let t=!!r[1],e,i,s=t&&Xf(r);return{c(){s&&s.c(),e=er()},m(n,o){s&&s.m(n,o),ft(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&st(s,1)):(s=Xf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s&&(De(),ut(s,1,1,()=>{s=null}),Oe())},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s&&s.d(n)}}}function LE(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!p.has(_.id)).map(_=>{const y=(f||[]).find(x=>x.oldValue.id===_.annotation.id);return y?{selectedBy:_.selectedBy,annotation:y.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return ty(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class NE extends ae{constructor(t){super(),oe(this,t,LE,FE,te,{store:3,viewer:0,provider:1})}}const Wf=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=Uh(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},jf=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Je(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:_}=o.target.selector.geometry.bounds,y=m-f,x=_-p,g=f-d*y,v=p-h*x,w=y+(c+d)*y,I=x+(h+u)*x,A=r.viewport.imageToViewportRectangle(g,v,w,I);r.viewport[e](A,s.immediately)},UE=(r,t)=>jf(r,t,"fitBounds"),kE=(r,t)=>jf(r,t,"fitBoundsWithConstraints"),GE=(r,t={})=>{const e=Gh(t,{drawingEnabled:!1,drawingMode:ph?"drag":"click",userSelectAction:ao.EDIT,theme:"light"}),i=Nh(e),{hover:s,selection:n,store:o}=i,a=dp(o),l=fp(i,a,e.adapter,e.autoSave);let h=bp(),c=e.drawingEnabled,u=e.drawingMode;const d=Hh(a,r.element),f=new Nw({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),p=new NE({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),m=new wE({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}});f.$on("click",B=>{const{originalEvent:Z,annotation:P}=B.detail;P&&!(u==="click"&&c)?n.userSelect(P.id,Z):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",B=>{if(s.current){const Z=o.getAnnotation(s.current);l.emit("clickAnnotation",Z,B)}}),Wf(r,e.theme);const _=mp(i,a,e.adapter),y=()=>{m.$set({drawingEnabled:!1}),setTimeout(()=>m.$set({drawingEnabled:!0}),1)},x=()=>{f.$destroy(),p.$destroy(),m.$destroy(),d.destroy(),a.destroy()},g=UE(r,o),v=kE(r,o),w=()=>m.getDrawingTool(),I=()=>h,A=()=>m.isDrawingEnabled(),C=(B,Z,P)=>Eh(B,Z,P),N=(B,Z)=>yh(B,Z),S=B=>{if(!ks(B))throw`No drawing tool named ${B}`;m.$set({toolName:B})},R=B=>{c=B,m.$set({drawingEnabled:c})},E=B=>{f.$set({filter:B}),m.$set({filter:B})},b=B=>{f.$set({style:B}),m.$set({style:B})},D=B=>p.$set({provider:B}),F=B=>Wf(r,B),G=B=>{h=B,m.$set({user:B})},$=B=>f.$set({visible:B});return{..._,cancelDrawing:y,destroy:x,fitBounds:g,fitBoundsWithConstraints:v,getDrawingTool:w,getUser:I,isDrawingEnabled:A,listDrawingTools:Us,on:l.on,off:l.off,registerDrawingTool:C,registerShapeEditor:N,setDrawingEnabled:R,setDrawingTool:S,setFilter:E,setPresenceProvider:D,setStyle:b,setTheme:F,setUser:G,setVisible:$,state:i,viewer:r}};Mt.ShapeType=wt,Mt.UserSelectAction=ao,Mt.W3CImageFormat=Lm,Mt.chainStyles=Sm,Mt.computeStyle=Am,Mt.createBody=ip,Mt.createImageAnnotator=jg,Mt.createOSDAnnotator=GE,Mt.defaultColorProvider=Ep,Object.defineProperty(Mt,Symbol.toStringTag,{value:"Module"})});
1147
+ }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=pv(t)),typeof t=="number"?fv(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,$i.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=W.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};Al.availableFonts={},Al.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 Sl=Al;const Kn=class Hi extends Pi{constructor(t="",e={}){super(q.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,s=q.from(i,{scaleMode:W.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new at,s.trim=new at,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Hi.defaultMaxWidth,this.maxHeight=Hi.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Hi.defaultAutoResolution,this._resolution=Hi.defaultResolution??W.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(c=this._style)==null?void 0:c.toCSS(s)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Hi.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=vr(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=vr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Sl?(this.ownsStyle=!1,this._style=t):t instanceof Sr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Sl.from(t)):(this.ownsStyle=!0,this._style=new Sl(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};Kn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Kn.defaultMaxWidth=2024,Kn.defaultMaxHeight=2024,Kn.defaultAutoResolution=!0;const Sw=16777215,Iw=.25,Cw=16777215,Rw=1.5;let Rr=!1,xs;const Il=r=>{const t={tint:r!=null&&r.fill?new bt(r.fill).toNumber():Sw,alpha:(r==null?void 0:r.fillOpacity)===void 0?Iw:Math.min(r.fillOpacity,1)},e={tint:r!=null&&r.stroke?new bt(r.stroke).toNumber():Cw,alpha:(r==null?void 0:r.strokeOpacity)===void 0?1:Math.min(r.strokeOpacity,1),lineWidth:(r==null?void 0:r.strokeWidth)===void 0?Rw:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Cl=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=Il(i),o=new vs;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new vs,l=n.lineWidth===1?1:n.lineWidth/xs;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},Pw=Cl((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),Mw=Cl((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),Bw=Cl((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),bf=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},wf=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=bf(r);(n!==xs||!Rr)&&(Rr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Rr=n===xs,p.width=f/n,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),xs=n;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+s.x*n:-s.x*n,h=-s.y*n;let c,u;a>0&&a<=Math.PI/2?(c=s.height*n,u=0):a>Math.PI/2&&a<=Math.PI?(c=s.width*n,u=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=s.width*n):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},Dw=(r,t)=>{const e=new vs,i=yd({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;xs=bf(r);const l=(g,v)=>{Rr=!1;const{selector:w}=g.target,I=typeof a=="function"?a(g,v):a;let A;w.type===wt.RECTANGLE?A=Bw(e,w,I):w.type===wt.POLYGON?A=Mw(e,w,I):w.type===wt.ELLIPSE?A=Pw(e,w,I):console.warn(`Unsupported shape type: ${w.type}`),A&&s.set(g.id,{annotation:g,...A})},h=g=>{const v=s.get(g.id);v&&(s.delete(g.id),v.fill.destroy(),v.stroke.destroy())},c=(g,v,w)=>{Rr=!1;const I=s.get(g.id);I&&(s.delete(g.id),I.fill.destroy(),I.stroke.destroy(),l(v,w))},u=(g,v)=>{const w=s.get(g);w&&(s.delete(g),w.fill.destroy(),w.stroke.destroy(),l(w.annotation,v))},d=(g,v)=>{i.resize(g,v),i.render(e)},f=g=>{Rr=!1;const{children:v}=e;s.forEach(({fill:w,stroke:I,annotation:A})=>{const C=g?n.has(A.id)||g(A):!0;C&&!v.includes(w)?(e.addChild(w),e.addChild(I)):!C&&v.includes(w)&&(e.removeChild(w),e.removeChild(I))}),i.render(e)},p=g=>{o!==g&&(o&&u(o,{selected:n.has(o)}),g&&u(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const v=g.selected.map(A=>A.id),w=v.filter(A=>!n.has(A)),I=[...n].filter(A=>!v.includes(A));[...w,...I].forEach(A=>u(A,{selected:v.includes(A),hovered:A===o})),n=new Set(v),i.render(e)},_=g=>{if(typeof g=="function")s.forEach(({annotation:v,fill:w,stroke:I,strokeWidth:A},C)=>{A>1&&(Rr=!1);const N={selected:n.has(v.id),hovered:o===v.id},{fillStyle:S,strokeStyle:R}=Il(g(v,N));w.tint=S.tint,w.alpha=S.alpha,I.tint=R.tint||16777215,I.alpha=R.alpha,s.set(v.id,{annotation:v,fill:w,stroke:I,strokeWidth:R.lineWidth})});else{const{fillStyle:v,strokeStyle:w}=Il(g);w.lineWidth>1&&(Rr=!1),s.forEach(({annotation:I,fill:A,stroke:C,strokeWidth:N},S)=>{A.tint=v.tint,A.alpha=v.alpha,C.tint=w.tint||16777215,C.alpha=w.alpha,s.set(I.id,{annotation:I,fill:A,stroke:C,strokeWidth:w.lineWidth})})}a=g,i.render(e),wf(r,e,s,i)()},y=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:wf(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:p,setSelected:m,setStyle:_,setVisible:y,updateAnnotation:c}};function Ow(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:f}=o;Ro(r,u,I=>e(11,i=I)),Ro(r,d,I=>e(8,s=I));const p=Hs();let m,_;const y=I=>{const A=new Nt.Point(I.x,I.y),{x:C,y:N}=l.viewport.pointFromPixel(A);return l.viewport.viewportToImageCoordinates(C,N)},x=I=>{const{x:A,y:C}=I.position;_={x:A,y:C}},g=I=>A=>{const{x:C,y:N}=y(new Nt.Point(A.offsetX,A.offsetY)),S=c.getAt(C,N);S&&(!n||n(S))?(I.classList.add("hover"),i!==S.id&&(u.set(S.id),m.setHovered(S.id))):(I.classList.remove("hover"),i&&(u.set(void 0),m.setHovered(void 0)))},v=I=>{if(!_)return;const A=I.originalEvent,{x:C,y:N}=I.position,S=C-_.x,R=N-_.y;if(Math.sqrt(S*S+R*R)<5){const{x:b,y:D}=y(I.position),F=c.getAt(b,D);F?p("click",{originalEvent:A,annotation:F}):p("click",{originalEvent:A})}_=void 0};let w;return $s(()=>{var F;const{offsetWidth:I,offsetHeight:A}=l.canvas,C=document.createElement("canvas");C.width=I,C.height=A,C.className="a9s-gl-canvas",(F=l.element.querySelector(".openseadragon-canvas"))==null||F.appendChild(C),e(7,m=Dw(l,C));const N=g(C);C.addEventListener("pointermove",N);const S=new ResizeObserver(G=>{try{const{width:$,height:B}=G[0].contentRect;C.width=$,C.height=B,m.resize($,B)}catch{console.warn("WebGL canvas already disposed")}});S.observe(C);const R=()=>{const G=l.viewport.getBounds();w=l.viewport.viewportToImageRectangle(G);const{x:$,y:B,width:K,height:P}=w,U=c.getIntersecting($,B,K,P);f.set(U.map(j=>j.id))};l.addHandler("canvas-press",x),l.addHandler("canvas-release",v),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",R);const E=G=>G.filter($=>Je($)),b=G=>Je(G.oldValue)&&Je(G.newValue),D=G=>{const{created:$,updated:B,deleted:K}=G.changes;if(E($||[]).forEach(P=>m.addAnnotation(P)),E(K||[]).forEach(P=>m.removeAnnotation(P)),(B||[]).filter(P=>b(P)).forEach(({oldValue:P,newValue:U})=>m.updateAnnotation(P,U)),w){const{x:P,y:U,width:j,height:rt}=w,Q=c.getIntersecting(P,U,j,rt);f.set(Q.map(H=>H.id))}else f.set(c.all().map(P=>P.id));m.redraw()};return c.observe(D),()=>{var G;C.removeEventListener("pointermove",N),S.disconnect(),l.removeHandler("canvas-press",x),l.removeHandler("canvas-release",v),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",R),c.unobserve(D),m.destroy(),(G=C.parentNode)==null||G.removeChild(C)}}),r.$$set=I=>{"filter"in I&&e(2,n=I.filter),"state"in I&&e(3,o=I.state),"style"in I&&e(4,a=I.style),"viewer"in I&&e(5,l=I.viewer),"visible"in I&&e(6,h=I.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[u,d,n,o,a,l,h,m,s]}class Fw extends ae{constructor(t){super(),oe(this,t,Ow,null,te,{filter:2,state:3,style:4,viewer:5,visible:6})}}const Yt=[];for(let r=0;r<256;++r)Yt.push((r+256).toString(16).slice(1));function Lw(r,t=0){return(Yt[r[t+0]]+Yt[r[t+1]]+Yt[r[t+2]]+Yt[r[t+3]]+"-"+Yt[r[t+4]]+Yt[r[t+5]]+"-"+Yt[r[t+6]]+Yt[r[t+7]]+"-"+Yt[r[t+8]]+Yt[r[t+9]]+"-"+Yt[r[t+10]]+Yt[r[t+11]]+Yt[r[t+12]]+Yt[r[t+13]]+Yt[r[t+14]]+Yt[r[t+15]]).toLowerCase()}let Rl;const Nw=new Uint8Array(16);function Uw(){if(!Rl){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Rl=crypto.getRandomValues.bind(crypto)}return Rl(Nw)}const Ef={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function kw(r,t,e){if(Ef.randomUUID&&!t&&!r)return Ef.randomUUID();r=r||{};const i=r.random||(r.rng||Uw)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Lw(i)}var Ui=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Ui||{});const Pl=(r,t)=>t,Gw=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},$w={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};Pl(Ui.ELLIPSE,$w);const Hw={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};Pl(Ui.POLYGON,Hw);const Xw={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};Pl(Ui.RECTANGLE,Xw);function Tf(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Af(r){let t,e;return t=new bs({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Vw(r){let t,e,i,s,n,o,a,l,h,c,u,d=ui(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=Af(Tf(r,d,m));const p=m=>ut(f[m],1,1,()=>{f[m]=null});return{c(){t=Tt("polygon"),s=xe(),n=Tt("polygon"),a=xe();for(let m=0;m<f.length;m+=1)f[m].c();l=er(),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"points",i=r[4].points.map(Sf).join(" ")),M(n,"class","a9s-inner a9s-shape-handle"),M(n,"style",r[1]),M(n,"points",o=r[4].points.map(If).join(" "))},m(m,_){ft(m,t,_),ft(m,s,_),ft(m,n,_),ft(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);ft(m,l,_),h=!0,c||(u=[zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(Sf).join(" ")))&&M(t,"points",i),(!h||_&2)&&M(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(If).join(" ")))&&M(n,"points",o),_&536){d=ui(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=Tf(r,d,y);f[y]?(f[y].p(x,_),st(f[y],1)):(f[y]=Af(x),f[y].c(),st(f[y],1),f[y].m(l.parentNode,l))}for(De(),y=d.length;y<f.length;y+=1)p(y);Oe()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)st(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)ut(f[_]);h=!1},d(m){m&&(ct(t),ct(s),ct(n),ct(a),ct(l)),Po(f,m),c=!1,Qe(u)}}}function zw(r){let t,e;return t=new Rf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Vw,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}const Sf=r=>r.join(","),If=r=>r.join(",");function Ww(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Gw(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class jw extends ae{constructor(t){super(),oe(this,t,Ww,zw,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Yw=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function qw(r){let t,e,i,s,n,o;return{c(){t=Tt("rect"),M(t,"class",e=ks(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(t,"x",i=r[0]-r[5]/2),M(t,"y",s=r[1]-r[5]/2),M(t,"width",r[5]),M(t,"height",r[5])},m(a,l){ft(a,t,l),n||(o=zt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=ks(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&M(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&M(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&M(t,"y",s),l&32&&M(t,"width",a[5]),l&32&&M(t,"height",a[5])},d(a){a&&ct(t),n=!1,o()}}}function Kw(r){let t,e,i,s,n,o,a,l,h;return{c(){t=Tt("g"),e=Tt("circle"),s=Tt("rect"),M(e,"cx",r[0]),M(e,"cy",r[1]),M(e,"r",i=r[3]/r[2]),M(e,"class","a9s-touch-halo svelte-1sgkh33"),Gs(e,"touched",r[4]),M(s,"class",n=ks(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(s,"x",o=r[0]-r[5]/2),M(s,"y",a=r[1]-r[5]/2),M(s,"width",r[5]),M(s,"height",r[5]),M(t,"class","a9s-touch-handle")},m(c,u){ft(c,t,u),tr(t,e),tr(t,s),l||(h=[zt(e,"pointerdown",r[10]),zt(e,"pointerdown",r[6]),zt(e,"pointerup",r[7]),zt(s,"pointerdown",r[9]),zt(s,"pointerdown",r[6]),zt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&M(e,"cx",c[0]),u&2&&M(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&M(e,"r",i),u&16&&Gs(e,"touched",c[4]),u&256&&n!==(n=ks(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&M(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&M(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&M(s,"y",a),u&32&&M(s,"width",c[5]),u&32&&M(s,"height",c[5])},d(c){c&&ct(t),l=!1,Qe(h)}}}function Zw(r){let t;function e(n,o){return Yw?Kw:qw}let s=e()(r);return{c(){s.c(),t=er()},m(n,o){s.m(n,o),ft(n,t,o)},p(n,[o]){s.p(n,o)},i:Be,o:Be,d(n){n&&ct(t),s.d(n)}}}function Jw(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){rr.call(this,r,p)}function d(p){rr.call(this,r,p)}function f(p){rr.call(this,r,p)}return r.$$set=p=>{e(8,t=Co(Co({},t),Wh(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Wh(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class bs extends ae{constructor(t){super(),oe(this,t,Jw,Zw,te,{x:0,y:1,scale:2,radius:3})}}function Qw(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,K,P,U,j,rt,Q,H,V,lt;return B=new bs({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Kt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new bs({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Kt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new bs({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Kt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new bs({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Kt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=Tt("rect"),a=xe(),l=Tt("rect"),f=xe(),p=Tt("rect"),x=xe(),g=Tt("rect"),A=xe(),C=Tt("rect"),E=xe(),b=Tt("rect"),$=xe(),ee(B.$$.fragment),K=xe(),ee(P.$$.fragment),U=xe(),ee(j.$$.fragment),rt=xe(),ee(Q.$$.fragment),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"x",i=r[4].x),M(t,"y",s=r[4].y),M(t,"width",n=r[4].w),M(t,"height",o=r[4].h),M(l,"class","a9s-inner a9s-shape-handle"),M(l,"style",r[1]),M(l,"x",h=r[4].x),M(l,"y",c=r[4].y),M(l,"width",u=r[4].w),M(l,"height",d=r[4].h),M(p,"class","a9s-edge-handle a9s-edge-handle-top"),M(p,"x",m=r[4].x),M(p,"y",_=r[4].y),M(p,"height",1),M(p,"width",y=r[4].w),M(g,"class","a9s-edge-handle a9s-edge-handle-right"),M(g,"x",v=r[4].x+r[4].w),M(g,"y",w=r[4].y),M(g,"height",I=r[4].h),M(g,"width",1),M(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),M(C,"x",N=r[4].x),M(C,"y",S=r[4].y+r[4].h),M(C,"height",1),M(C,"width",R=r[4].w),M(b,"class","a9s-edge-handle a9s-edge-handle-left"),M(b,"x",D=r[4].x),M(b,"y",F=r[4].y),M(b,"height",G=r[4].h),M(b,"width",1)},m(L,O){ft(L,t,O),ft(L,a,O),ft(L,l,O),ft(L,f,O),ft(L,p,O),ft(L,x,O),ft(L,g,O),ft(L,A,O),ft(L,C,O),ft(L,E,O),ft(L,b,O),ft(L,$,O),Zt(B,L,O),ft(L,K,O),Zt(P,L,O),ft(L,U,O),Zt(j,L,O),ft(L,rt,O),Zt(Q,L,O),H=!0,V||(lt=[zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),zt(l,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),zt(p,"pointerdown",function(){Kt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),zt(g,"pointerdown",function(){Kt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),zt(C,"pointerdown",function(){Kt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),zt(b,"pointerdown",function(){Kt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&M(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&M(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&M(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&M(t,"height",o),(!H||O&2)&&M(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&M(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&M(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&M(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&M(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&M(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&M(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&M(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&M(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&M(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&M(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&M(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&M(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&M(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&M(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&M(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&M(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(st(B.$$.fragment,L),st(P.$$.fragment,L),st(j.$$.fragment,L),st(Q.$$.fragment,L),H=!0)},o(L){ut(B.$$.fragment,L),ut(P.$$.fragment,L),ut(j.$$.fragment,L),ut(Q.$$.fragment,L),H=!1},d(L){L&&(ct(t),ct(a),ct(l),ct(f),ct(p),ct(x),ct(g),ct(A),ct(C),ct(E),ct(b),ct($),ct(K),ct(U),ct(rt)),Jt(B,L),Jt(P,L),Jt(j,L),Jt(Q,L),V=!1,Qe(lt)}}}function tE(r){let t,e;return t=new Rf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Qw,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function eE(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[_,y]=[m.minX,m.minY],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class rE extends ae{constructor(t){super(),oe(this,t,eE,tE,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Ui.RECTANGLE,Ui.POLYGON;const iE=r=>({}),Cf=r=>({grab:r[0]});function sE(r){let t,e,i,s;const n=r[7].default,o=$h(n,r,r[6],Cf);return{c(){t=Tt("g"),o&&o.c(),M(t,"class","a9s-annotation selected")},m(a,l){ft(a,t,l),o&&o.m(t,null),e=!0,i||(s=[zt(t,"pointerup",r[2]),zt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Vh(o,n,a,a[6],e?Xh(n,a[6],l,iE):zh(a[6]),Cf)},i(a){e||(st(o,a),e=!0)},o(a){ut(o,a),e=!1},d(a){a&&ct(t),o&&o.d(a),i=!1,Qe(s)}}}function nE(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Hs();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class Rf extends ae{constructor(t){super(),oe(this,t,nE,sE,te,{shape:3,editor:4,transform:5})}}const oE=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function aE(r,t,e){let i;const s=Hs();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return $s(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=oE(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[n,o,a,l,h,c,u,i]}class lE extends ae{constructor(t){super(),oe(this,t,aE,null,te,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const hE=r=>({transform:r&2,scale:r&1}),Pf=r=>({transform:r[1],scale:r[0]});function cE(r){let t;const e=r[4].default,i=$h(e,r,r[3],Pf);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Vh(i,e,s,s[3],t?Xh(e,s[3],n,hE):zh(s[3]),Pf)},i(s){t||(st(i,s),t=!0)},o(s){ut(i,s),t=!1},d(s){i&&i.d(s)}}}function uE(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,c=n.viewport.getZoom(!0),u=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new Nt.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/n.world.getContentFactor(),p=u?-f:f,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=c*h/n.world.getContentFactor())};return $s(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class Mf extends ae{constructor(t){super(),oe(this,t,uE,cE,te,{viewer:2})}}function dE(r,t,e){const i=Hs();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,c;return $s(()=>{const u=n.closest("svg"),d=[],f=(p,m,_)=>{if(u==null||u.addEventListener(p,m,_),d.push(()=>u==null?void 0:u.removeEventListener(p,m,_)),p==="pointerup"||p==="dblclick"){const y=g=>{const{originalEvent:v}=g;m(v)},x=p==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(x,y),d.push(()=>l.removeHandler(x,y))}else if(p==="pointermove"){const y=x=>{const{originalEvent:g}=x;m(g)};l.addHandler("canvas-drag",y),d.push(()=>l.removeHandler("canvas-drag",y))}};return e(6,c=new o({target:n,props:{addEventListener:f,drawingMode:s,transform:a,viewportScale:h}})),c.$on("create",p=>i("create",p.detail)),()=>{d.forEach(p=>p()),c.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewer"in u&&e(4,l=u.viewer),"viewportScale"in u&&e(5,h=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&c&&c.$set({transform:a}),r.$$.dirty&96&&c&&c.$set({viewportScale:h})},[s,n,o,a,l,h,c]}class fE extends ae{constructor(t){super(),oe(this,t,dE,null,te,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function Bf(r,t,e){const i=r.slice();i[33]=t[e];const s=i[14](i[33].target.selector);return i[34]=s,i}function pE(r){let t=r[2],e,i,s=Df(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&4&&te(t,t=n[2])?(De(),ut(s,1,1,Be),Oe(),s=Df(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function mE(r){let t,e,i=ui(r[6].filter(r[23])),s=[];for(let o=0;o<i.length;o+=1)s[o]=Lf(Bf(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a[0]&24162|a[1]&2){i=ui(o[6].filter(o[23]));let l;for(l=0;l<i.length;l+=1){const h=Bf(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=Lf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Po(s,o)}}}function Df(r){let t,e;return t=new fE({props:{target:r[5],tool:r[7],drawingMode:r[4],transform:{elementToImage:r[9]},viewer:r[3],viewportScale:r[32]}}),t.$on("create",r[13]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&128&&(n.tool=i[7]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&2&&(n.viewportScale=i[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Of(r){let t=r[33].id,e,i,s=Ff(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&64&&te(t,t=n[33].id)?(De(),ut(s,1,1,Be),Oe(),s=Ff(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function Ff(r){let t,e;return t=new lE({props:{target:r[5],editor:r[14](r[33].target.selector),annotation:r[33],style:r[1],transform:{elementToImage:r[9]},viewportScale:r[32]}}),t.$on("grab",r[10]),t.$on("change",function(){Kt(r[12](r[33]))&&r[12](r[33]).apply(this,arguments)}),t.$on("release",r[11]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&64&&(n.editor=r[14](r[33].target.selector)),s[0]&64&&(n.annotation=r[33]),s[0]&2&&(n.style=r[1]),s[1]&2&&(n.viewportScale=r[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Lf(r){let t,e,i=r[34]&&Of(r);return{c(){i&&i.c(),t=er()},m(s,n){i&&i.m(s,n),ft(s,t,n),e=!0},p(s,n){s[34]?i?(i.p(s,n),n[0]&64&&st(i,1)):(i=Of(s),i.c(),st(i,1),i.m(t.parentNode,t)):i&&(De(),ut(i,1,1,()=>{i=null}),Oe())},i(s){e||(st(i),e=!0)},o(s){ut(i),e=!1},d(s){s&&ct(t),i&&i.d(s)}}}function gE(r){let t,e,i,s,n,o;const a=[mE,pE],l=[];function h(c,u){return c[5]&&c[6]?0:c[5]&&c[7]&&c[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=Tt("svg"),e=Tt("g"),s&&s.c(),M(e,"transform",n=r[31]),M(e,"class","svelte-190cqdf"),M(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),Gs(t,"drawing",r[0])},m(c,u){ft(c,t,u),tr(t,e),~i&&l[i].m(e,null),r[24](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(s&&(De(),ut(l[d],1,1,()=>{l[d]=null}),Oe()),~i?(s=l[i],s?s.p(c,u):(s=l[i]=a[i](c),s.c()),st(s,1),s.m(e,null)):s=null),(!o||u[1]&1&&n!==(n=c[31]))&&M(e,"transform",n),(!o||u[0]&1)&&Gs(t,"drawing",c[0])},i(c){o||(st(s),o=!0)},o(c){ut(s),o=!1},d(c){c&&ct(t),~i&&l[i].d(),r[24](null)}}}function yE(r){let t,e;return t=new Mf({props:{viewer:r[3],$$slots:{default:[gE,({transform:i,scale:s})=>({31:i,32:s}),({transform:i,scale:s})=>[0,(i?1:0)|(s?2:0)]]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&255|s[1]&67&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function _E(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:c}=t,{style:u=void 0}=t,{toolName:d=Fs()[0]}=t,{user:f}=t,{viewer:p}=t;const m=()=>d,_=()=>a,y=navigator.userAgent.match(/firefox|fxios/i);let x;const{store:g,selection:v,hover:w}=c;Ro(r,v,B=>e(22,o=B));let I,A,C;const N=B=>{g.unobserve(I);const K=B.filter(({editable:P})=>P).map(({id:P})=>P);if(K.length>0){if(e(6,A=K.map(P=>g.getAnnotation(P))),I=P=>{const{updated:U}=P.changes;e(6,A=(U||[]).map(j=>j.newValue))},g.observe(I,{annotations:K}),y){const{width:P}=p.viewport.viewerElementToViewportRectangle(new Nt.Rect(0,0,1,1));p.viewport.panBy(new Nt.Point(Math.abs(P/10),0))}}else e(6,A=void 0)},S=(B,K)=>{const{x:P,y:U}=p.viewport.viewerElementToImageCoordinates(new Nt.Point(B,K));return[P,U]},R=B=>{p.setMouseNavEnabled(!1),C=B.timeStamp},E=B=>{if(p.setMouseNavEnabled(!0),performance.now()-(C||0)<300){const{offsetX:P,offsetY:U}=B.detail,[j,rt]=S(P,U),Q=g.getAt(j,rt);Q&&(!l||l(Q))&&!A.find(V=>V.id===Q.id)&&(w.set(Q.id),v.setSelected(Q.id))}},b=B=>K=>{var rt;const{target:P}=B,U=10*60*1e3,j=((rt=P.creator)==null?void 0:rt.id)!==f.id||!P.created||new Date().getTime()-P.created.getTime()>U;g.updateTarget({...P,selector:K.detail,created:j?P.created:new Date,updated:j?new Date:void 0,updatedBy:j?f:void 0})},D=B=>{const K=kw(),P={id:K,bodies:[],target:{annotation:K,selector:B.detail,creator:f,created:new Date}};g.addAnnotation(P),v.setSelected(P.id),p.setMouseNavEnabled(!0)},F=B=>dh(B),G=B=>Je(B);function $(B){Xs[B?"unshift":"push"](()=>{x=B,e(5,x)})}return r.$$set=B=>{"drawingEnabled"in B&&e(0,a=B.drawingEnabled),"filter"in B&&e(15,l=B.filter),"preferredDrawingMode"in B&&e(16,h=B.preferredDrawingMode),"state"in B&&e(17,c=B.state),"style"in B&&e(1,u=B.style),"toolName"in B&&e(2,d=B.toolName),"user"in B&&e(18,f=B.user),"viewer"in B&&e(3,p=B.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(7,{tool:i,opts:s}=Ls(d)||{tool:void 0,opts:void 0},i,(e(21,s),e(2,d))),r.$$.dirty[0]&2162688&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(a&&n==="drag"?p.setMouseNavEnabled(!1):p.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&v.clear(),r.$$.dirty[0]&4194329&&o.selected.length===0&&n==="drag"&&a&&p.setMouseNavEnabled(!1),r.$$.dirty[0]&4194304&&N(o.selected)},[a,u,d,p,n,x,A,i,v,S,R,E,b,D,F,l,h,c,f,m,_,s,o,G,$]}class vE extends ae{constructor(t){super(),oe(this,t,_E,yE,te,{drawingEnabled:0,filter:15,preferredDrawingMode:16,state:17,style:1,toolName:2,user:18,viewer:3,getDrawingTool:19,isDrawingEnabled:20},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[19]}get isDrawingEnabled(){return this.$$.ctx[20]}}function xE(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=Tt("g"),e=Tt("rect"),a=Tt("text"),h=Mo(l),M(e,"class","a9s-presence-label-bg svelte-1rehw2p"),M(e,"x",r[0]),M(e,"y",i=r[1]-18/r[3]),M(e,"height",s=18/r[3]),M(e,"fill",n=r[2].appearance.color),M(e,"stroke",o=r[2].appearance.color),M(a,"font-size",c=12/r[3]),M(a,"x",u=r[0]+Math.round(5/r[3])),M(a,"y",d=r[1]-5/r[3]),M(a,"class","svelte-1rehw2p"),M(t,"class","a9s-presence-label")},m(f,p){ft(f,t,p),tr(t,e),tr(t,a),tr(a,h),r[6](t)},p(f,[p]){p&1&&M(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&M(e,"y",i),p&8&&s!==(s=18/f[3])&&M(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&M(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&M(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&qg(h,l),p&8&&c!==(c=12/f[3])&&M(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&M(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&M(a,"y",d)},i:Be,o:Be,d(f){f&&ct(t),r[6](null)}}}function bE(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){Xs[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,s=u.y),"user"in u&&e(2,n=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,c]}class Nf extends ae{constructor(t){super(),oe(this,t,bE,xE,te,{x:0,y:1,user:2,scale:3,hAlign:5})}}function wE(r){let t,e,i,s,n,o;return e=new Nf({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("polygon"),M(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"points",n=r[2].points.map(Uf).join(" ")),M(t,"class","a9s-presence-overlay")},m(a,l){ft(a,t,l),Zt(e,t,null),tr(t,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]),e.$set(h),(!o||l&1&&s!==(s=a[0].appearance.color))&&M(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(Uf).join(" ")))&&M(i,"points",n)},i(a){o||(st(e.$$.fragment,a),o=!0)},o(a){ut(e.$$.fragment,a),o=!1},d(a){a&&ct(t),Jt(e)}}}const Uf=r=>r.join(",");function EE(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class TE extends ae{constructor(t){super(),oe(this,t,EE,wE,te,{annotation:4,user:0,scale:1})}}function AE(r){let t,e,i,s,n,o,a,l,h;return e=new Nf({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("rect"),M(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"x",n=r[2].x),M(i,"y",o=r[2].y),M(i,"width",a=r[2].w),M(i,"height",l=r[2].h),M(t,"class","a9s-presence-overlay")},m(c,u){ft(c,t,u),Zt(e,t,null),tr(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&s!==(s=c[0].appearance.color))&&M(i,"stroke",s),(!h||u&4&&n!==(n=c[2].x))&&M(i,"x",n),(!h||u&4&&o!==(o=c[2].y))&&M(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&M(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&M(i,"height",l)},i(c){h||(st(e.$$.fragment,c),h=!0)},o(c){ut(e.$$.fragment,c),h=!1},d(c){c&&ct(t),Jt(e)}}}function SE(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class IE extends ae{constructor(t){super(),oe(this,t,SE,AE,te,{annotation:3,user:0,scale:1})}}const{Boolean:CE}=jg;function kf(r,t,e){const i=r.slice();return i[8]=t[e],i}function Gf(r){let t,e;return t=new Mf({props:{viewer:r[0],$$slots:{default:[ME,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function $f(r){let t,e,i=ui(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Hf(kf(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a&132){i=ui(o[2]);let l;for(l=0;l<i.length;l+=1){const h=kf(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=Hf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(CE);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Po(s,o)}}}function RE(r){let t,e;return t=new TE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function PE(r){let t,e;return t=new IE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Hf(r){let t,e,i,s;const n=[PE,RE],o=[];function a(l,h){return l[8].annotation.target.selector.type===wt.RECTANGLE?0:l[8].annotation.target.selector.type===wt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=er()},m(l,h){~t&&o[t].m(l,h),ft(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(De(),ut(o[c],1,1,()=>{o[c]=null}),Oe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),st(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(st(e),s=!0)},o(l){ut(e),s=!1},d(l){l&&ct(i),~t&&o[t].d(l)}}}function ME(r){let t,e,i,s,n=r[2].length>0&&$f(r);return{c(){t=Tt("svg"),e=Tt("g"),n&&n.c(),M(e,"transform",i=r[6]),M(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ft(o,t,a),tr(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&st(n,1)):(n=$f(o),n.c(),st(n,1),n.m(e,null)):n&&(De(),ut(n,1,1,()=>{n=null}),Oe()),(!s||a&64&&i!==(i=o[6]))&&M(e,"transform",i)},i(o){s||(st(n),s=!0)},o(o){ut(n),s=!1},d(o){o&&ct(t),n&&n.d()}}}function BE(r){let t=!!r[1],e,i,s=t&&Gf(r);return{c(){s&&s.c(),e=er()},m(n,o){s&&s.m(n,o),ft(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&st(s,1)):(s=Gf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s&&(De(),ut(s,1,1,()=>{s=null}),Oe())},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s&&s.d(n)}}}function DE(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!p.has(_.id)).map(_=>{const y=(f||[]).find(x=>x.oldValue.id===_.annotation.id);return y?{selectedBy:_.selectedBy,annotation:y.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return Zg(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class OE extends ae{constructor(t){super(),oe(this,t,DE,BE,te,{store:3,viewer:0,provider:1})}}const Xf=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=Oh(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Vf=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Je(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:_}=o.target.selector.geometry.bounds,y=m-f,x=_-p,g=f-d*y,v=p-h*x,w=y+(c+d)*y,I=x+(h+u)*x,A=r.viewport.imageToViewportRectangle(g,v,w,I);r.viewport[e](A,s.immediately)},FE=(r,t)=>Vf(r,t,"fitBounds"),LE=(r,t)=>Vf(r,t,"fitBoundsWithConstraints"),NE=(r,t={})=>{const e=Lh(t,{drawingEnabled:!1,drawingMode:ch?"drag":"click",userSelectAction:io.EDIT,theme:"light"}),i=Dh(e),{hover:s,selection:n,store:o}=i,a=hp(o),l=cp(i,a,e.adapter,e.autoSave);let h=_p(),c=e.drawingEnabled,u=e.drawingMode;const d=Uh(a,r.element),f=new Fw({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),p=new OE({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),m=new vE({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}});f.$on("click",B=>{const{originalEvent:K,annotation:P}=B.detail;e.modalSelect?n.isEmpty()&&P&&n.userSelect(P.id,K):P&&!(u==="click"&&c)?n.userSelect(P.id,K):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",B=>{if(s.current){const K=o.getAnnotation(s.current);l.emit("clickAnnotation",K,B)}}),Xf(r,e.theme);const _=dp(i,a,e.adapter),y=()=>{m.$set({drawingEnabled:!1}),setTimeout(()=>m.$set({drawingEnabled:!0}),1)},x=()=>{f.$destroy(),p.$destroy(),m.$destroy(),d.destroy(),a.destroy()},g=FE(r,o),v=LE(r,o),w=()=>m.getDrawingTool(),I=()=>h,A=()=>m.isDrawingEnabled(),C=(B,K,P)=>vh(B,K,P),N=(B,K)=>fh(B,K),S=B=>{if(!Ls(B))throw`No drawing tool named ${B}`;m.$set({toolName:B})},R=B=>{c=B,m.$set({drawingEnabled:c})},E=B=>{f.$set({filter:B}),m.$set({filter:B})},b=B=>{f.$set({style:B}),m.$set({style:B})},D=B=>p.$set({provider:B}),F=B=>Xf(r,B),G=B=>{h=B,m.$set({user:B})},$=B=>f.$set({visible:B});return{..._,cancelDrawing:y,destroy:x,fitBounds:g,fitBoundsWithConstraints:v,getDrawingTool:w,getUser:I,isDrawingEnabled:A,listDrawingTools:Fs,on:l.on,off:l.off,registerDrawingTool:C,registerShapeEditor:N,setDrawingEnabled:R,setDrawingTool:S,setFilter:E,setPresenceProvider:D,setStyle:b,setTheme:F,setUser:G,setVisible:$,state:i,viewer:r}};Mt.ShapeType=wt,Mt.UserSelectAction=io,Mt.W3CImageFormat=Dm,Mt.chainStyles=Em,Mt.computeStyle=wm,Mt.createBody=tp,Mt.createImageAnnotator=Vg,Mt.createOSDAnnotator=NE,Mt.defaultColorProvider=xp,Object.defineProperty(Mt,Symbol.toStringTag,{value:"Module"})});
1148
1148
  //# sourceMappingURL=annotorious-openseadragon.js.map