@prefecthq/graphs 2.1.4 → 2.1.5

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,4 +1,4 @@
1
- (function(oe,z){typeof exports=="object"&&typeof module<"u"?z(exports,require("vue"),require("@prefecthq/vue-compositions"),require("@prefecthq/prefect-design")):typeof define=="function"&&define.amd?define(["exports","vue","@prefecthq/vue-compositions","@prefecthq/prefect-design"],z):(oe=typeof globalThis<"u"?globalThis:oe||self,z(oe["prefect-graphs"]={},oe.Vue,oe.vueCompositions,oe.prefectDesign))})(this,function(oe,z,Zi,Vi){"use strict";var _M=Object.defineProperty;var vM=(oe,z,Zi)=>z in oe?_M(oe,z,{enumerable:!0,configurable:!0,writable:!0,value:Zi}):oe[z]=Zi;var lp=(oe,z,Zi)=>(vM(oe,typeof z!="symbol"?z+"":z,Zi),Zi);const yp="nodes-container",Cb="node-container",Ib="edge-container";function ll(r){"@babel/helpers - typeof";return ll=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ll(r)}function bp(r){if(r===null||r===!0||r===!1)return NaN;var t=Number(r);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function Ln(r,t){if(t.length<r)throw new TypeError(r+" argument"+(r>1?"s":"")+" required, but only "+t.length+" present")}function ul(r){Ln(1,arguments);var t=Object.prototype.toString.call(r);return r instanceof Date||ll(r)==="object"&&t==="[object Date]"?new Date(r.getTime()):typeof r=="number"||t==="[object Number]"?new Date(r):((typeof r=="string"||t==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function Ab(r,t){Ln(2,arguments);var e=ul(r).getTime(),i=bp(t);return new Date(e+i)}function Rb(r,t){Ln(2,arguments);var e=bp(t);return Ab(r,e*1e3)}var Mb=1e3,xp=3600;function _p(r,t){return Ln(2,arguments),ul(r).getTime()-ul(t).getTime()}var vp={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},Pb="trunc";function Lb(r){return r?vp[r]:vp[Pb]}function Gb(r,t,e){Ln(2,arguments);var i=_p(r,t)/1e3;return Lb(e==null?void 0:e.roundingMethod)(i)}var qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Nb(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 Yo={exports:{}};Yo.exports,function(r,t){var e=200,i="__lodash_hash_undefined__",s=800,n=16,o=9007199254740991,a="[object Arguments]",h="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",c="[object Date]",d="[object Error]",p="[object Function]",m="[object GeneratorFunction]",f="[object Map]",g="[object Number]",y="[object Null]",_="[object Object]",b="[object Proxy]",v="[object RegExp]",S="[object Set]",E="[object String]",A="[object Undefined]",I="[object WeakMap]",P="[object ArrayBuffer]",B="[object DataView]",G="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",F="[object Int16Array]",X="[object Int32Array]",V="[object Uint8Array]",L="[object Uint8ClampedArray]",k="[object Uint16Array]",K="[object Uint32Array]",D=/[\\^$.*+?()[\]{}|]/g,U=/^\[object .+?Constructor\]$/,j=/^(?:0|[1-9]\d*)$/,q={};q[G]=q[N]=q[C]=q[F]=q[X]=q[V]=q[L]=q[k]=q[K]=!0,q[a]=q[h]=q[P]=q[u]=q[B]=q[c]=q[d]=q[p]=q[f]=q[g]=q[_]=q[v]=q[S]=q[E]=q[I]=!1;var dt=typeof qe=="object"&&qe&&qe.Object===Object&&qe,nt=typeof self=="object"&&self&&self.Object===Object&&self,Et=dt||nt||Function("return this")(),Rt=t&&!t.nodeType&&t,wt=Rt&&!0&&r&&!r.nodeType&&r,Y=wt&&wt.exports===Rt,it=Y&&dt.process,tt=function(){try{var x=wt&&wt.require&&wt.require("util").types;return x||it&&it.binding&&it.binding("util")}catch{}}(),O=tt&&tt.isTypedArray;function bt(x,w,M){switch(M.length){case 0:return x.call(w);case 1:return x.call(w,M[0]);case 2:return x.call(w,M[0],M[1]);case 3:return x.call(w,M[0],M[1],M[2])}return x.apply(w,M)}function mt(x,w){for(var M=-1,Z=Array(x);++M<x;)Z[M]=w(M);return Z}function Mt(x){return function(w){return x(w)}}function Ut(x,w){return x==null?void 0:x[w]}function Ne(x,w){return function(M){return x(w(M))}}var ci=Array.prototype,Id=Function.prototype,yn=Object.prototype,Ao=Et["__core-js_shared__"],bn=Id.toString,di=yn.hasOwnProperty,kh=function(){var x=/[^.]+$/.exec(Ao&&Ao.keys&&Ao.keys.IE_PROTO||"");return x?"Symbol(src)_1."+x:""}(),Oh=yn.toString,Ad=bn.call(Object),xn=RegExp("^"+bn.call(di).replace(D,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),kr=Y?Et.Buffer:void 0,Ro=Et.Symbol,Fe=Et.Uint8Array,Mo=kr?kr.allocUnsafe:void 0,Po=Ne(Object.getPrototypeOf,Object),Wh=Object.create,Bh=yn.propertyIsEnumerable,_n=ci.splice,ki=Ro?Ro.toStringTag:void 0,ws=function(){try{var x=Wo(Object,"defineProperty");return x({},"",{}),x}catch{}}(),Rd=kr?kr.isBuffer:void 0,Oi=Math.max,Uh=Date.now,Xh=Wo(Et,"Map"),Ss=Wo(Object,"create"),Lo=function(){function x(){}return function(w){if(!Ui(w))return{};if(Wh)return Wh(w);x.prototype=w;var M=new x;return x.prototype=void 0,M}}();function De(x){var w=-1,M=x==null?0:x.length;for(this.clear();++w<M;){var Z=x[w];this.set(Z[0],Z[1])}}function Go(){this.__data__=Ss?Ss(null):{},this.size=0}function No(x){var w=this.has(x)&&delete this.__data__[x];return this.size-=w?1:0,w}function Fo(x){var w=this.__data__;if(Ss){var M=w[x];return M===i?void 0:M}return di.call(w,x)?w[x]:void 0}function Es(x){var w=this.__data__;return Ss?w[x]!==void 0:di.call(w,x)}function Md(x,w){var M=this.__data__;return this.size+=this.has(x)?0:1,M[x]=Ss&&w===void 0?i:w,this}De.prototype.clear=Go,De.prototype.delete=No,De.prototype.get=Fo,De.prototype.has=Es,De.prototype.set=Md;function pi(x){var w=-1,M=x==null?0:x.length;for(this.clear();++w<M;){var Z=x[w];this.set(Z[0],Z[1])}}function Pd(){this.__data__=[],this.size=0}function Ld(x){var w=this.__data__,M=vn(w,x);if(M<0)return!1;var Z=w.length-1;return M==Z?w.pop():_n.call(w,M,1),--this.size,!0}function Gd(x){var w=this.__data__,M=vn(w,x);return M<0?void 0:w[M][1]}function Zh(x){return vn(this.__data__,x)>-1}function Do(x,w){var M=this.__data__,Z=vn(M,x);return Z<0?(++this.size,M.push([x,w])):M[Z][1]=w,this}pi.prototype.clear=Pd,pi.prototype.delete=Ld,pi.prototype.get=Gd,pi.prototype.has=Zh,pi.prototype.set=Do;function Ce(x){var w=-1,M=x==null?0:x.length;for(this.clear();++w<M;){var Z=x[w];this.set(Z[0],Z[1])}}function Nd(){this.size=0,this.__data__={hash:new De,map:new(Xh||pi),string:new De}}function Fd(x){var w=wn(this,x).delete(x);return this.size-=w?1:0,w}function Dd(x){return wn(this,x).get(x)}function kd(x){return wn(this,x).has(x)}function Od(x,w){var M=wn(this,x),Z=M.size;return M.set(x,w),this.size+=M.size==Z?0:1,this}Ce.prototype.clear=Nd,Ce.prototype.delete=Fd,Ce.prototype.get=Dd,Ce.prototype.has=kd,Ce.prototype.set=Od;function fe(x){var w=this.__data__=new pi(x);this.size=w.size}function Wd(){this.__data__=new pi,this.size=0}function Bd(x){var w=this.__data__,M=w.delete(x);return this.size=w.size,M}function Ud(x){return this.__data__.get(x)}function Xd(x){return this.__data__.has(x)}function Zd(x,w){var M=this.__data__;if(M instanceof pi){var Z=M.__data__;if(!Xh||Z.length<e-1)return Z.push([x,w]),this.size=++M.size,this;M=this.__data__=new Ce(Z)}return M.set(x,w),this.size=M.size,this}fe.prototype.clear=Wd,fe.prototype.delete=Bd,fe.prototype.get=Ud,fe.prototype.has=Xd,fe.prototype.set=Zd;function ur(x,w){var M=Cn(x),Z=!M&&fi(x),ht=!M&&!Z&&$h(x),pt=!M&&!Z&&!ht&&Wr(x),gt=M||Z||ht||pt,ot=gt?mt(x.length,String):[],_t=ot.length;for(var Ft in x)(w||di.call(x,Ft))&&!(gt&&(Ft=="length"||ht&&(Ft=="offset"||Ft=="parent")||pt&&(Ft=="buffer"||Ft=="byteLength"||Ft=="byteOffset")||jh(Ft,_t)))&&ot.push(Ft);return ot}function ko(x,w,M){(M!==void 0&&!En(x[w],M)||M===void 0&&!(w in x))&&Oo(x,w,M)}function Vd(x,w,M){var Z=x[w];(!(di.call(x,w)&&En(Z,M))||M===void 0&&!(w in x))&&Oo(x,w,M)}function vn(x,w){for(var M=x.length;M--;)if(En(x[M][0],w))return M;return-1}function Oo(x,w,M){w=="__proto__"&&ws?ws(x,w,{configurable:!0,enumerable:!0,value:M,writable:!0}):x[w]=M}var Kd=qd();function cr(x){return x==null?x===void 0?A:y:ki&&ki in Object(x)?tp(x):rp(x)}function Vh(x){return Or(x)&&cr(x)==a}function Hd(x){if(!Ui(x)||Sn(x))return!1;var w=Is(x)?xn:U;return w.test(op(x))}function Wi(x){return Or(x)&&Qh(x.length)&&!!q[cr(x)]}function Yd(x){if(!Ui(x))return ip(x);var w=dr(x),M=[];for(var Z in x)Z=="constructor"&&(w||!di.call(x,Z))||M.push(Z);return M}function Kh(x,w,M,Z,ht){x!==w&&Kd(w,function(pt,gt){if(ht||(ht=new fe),Ui(pt))zd(x,w,gt,M,Kh,Z,ht);else{var ot=Z?Z(Bo(x,gt),pt,gt+"",x,w,ht):void 0;ot===void 0&&(ot=pt),ko(x,gt,ot)}},el)}function zd(x,w,M,Z,ht,pt,gt){var ot=Bo(x,M),_t=Bo(w,M),Ft=gt.get(_t);if(Ft){ko(x,M,Ft);return}var At=pt?pt(ot,_t,M+"",x,w,gt):void 0,ne=At===void 0;if(ne){var me=Cn(_t),$e=!me&&$h(_t),Qe=!me&&!$e&&Wr(_t);At=_t,me||$e||Qe?Cn(ot)?At=ot:In(ot)?At=Cs(ot):$e?(ne=!1,At=$d(_t,!0)):Qe?(ne=!1,At=Qd(_t,!0)):At=[]:qh(_t)||fi(_t)?(At=ot,fi(ot)?At=tl(ot):(!Ui(ot)||Is(ot))&&(At=zh(_t))):ne=!1}ne&&(gt.set(_t,At),ht(At,_t,Z,pt,gt),gt.delete(_t)),ko(x,M,At)}function jd(x,w){return sp(Bi(x,w,T),x+"")}var Jd=ws?function(x,w){return ws(x,"toString",{configurable:!0,enumerable:!1,value:hp(w),writable:!0})}:T;function $d(x,w){if(w)return x.slice();var M=x.length,Z=Mo?Mo(M):new x.constructor(M);return x.copy(Z),Z}function Tn(x){var w=new x.constructor(x.byteLength);return new Fe(w).set(new Fe(x)),w}function Qd(x,w){var M=w?Tn(x.buffer):x.buffer;return new x.constructor(M,x.byteOffset,x.length)}function Cs(x,w){var M=-1,Z=x.length;for(w||(w=Array(Z));++M<Z;)w[M]=x[M];return w}function Hh(x,w,M,Z){var ht=!M;M||(M={});for(var pt=-1,gt=w.length;++pt<gt;){var ot=w[pt],_t=Z?Z(M[ot],x[ot],ot,M,x):void 0;_t===void 0&&(_t=x[ot]),ht?Oo(M,ot,_t):Vd(M,ot,_t)}return M}function Yh(x){return jd(function(w,M){var Z=-1,ht=M.length,pt=ht>1?M[ht-1]:void 0,gt=ht>2?M[2]:void 0;for(pt=x.length>3&&typeof pt=="function"?(ht--,pt):void 0,gt&&ep(M[0],M[1],gt)&&(pt=ht<3?void 0:pt,ht=1),w=Object(w);++Z<ht;){var ot=M[Z];ot&&x(w,ot,Z,pt)}return w})}function qd(x){return function(w,M,Z){for(var ht=-1,pt=Object(w),gt=Z(w),ot=gt.length;ot--;){var _t=gt[x?ot:++ht];if(M(pt[_t],_t,pt)===!1)break}return w}}function wn(x,w){var M=x.__data__;return Jh(w)?M[typeof w=="string"?"string":"hash"]:M.map}function Wo(x,w){var M=Ut(x,w);return Hd(M)?M:void 0}function tp(x){var w=di.call(x,ki),M=x[ki];try{x[ki]=void 0;var Z=!0}catch{}var ht=Oh.call(x);return Z&&(w?x[ki]=M:delete x[ki]),ht}function zh(x){return typeof x.constructor=="function"&&!dr(x)?Lo(Po(x)):{}}function jh(x,w){var M=typeof x;return w=w??o,!!w&&(M=="number"||M!="symbol"&&j.test(x))&&x>-1&&x%1==0&&x<w}function ep(x,w,M){if(!Ui(M))return!1;var Z=typeof w;return(Z=="number"?Uo(M)&&jh(w,M.length):Z=="string"&&w in M)?En(M[w],x):!1}function Jh(x){var w=typeof x;return w=="string"||w=="number"||w=="symbol"||w=="boolean"?x!=="__proto__":x===null}function Sn(x){return!!kh&&kh in x}function dr(x){var w=x&&x.constructor,M=typeof w=="function"&&w.prototype||yn;return x===M}function ip(x){var w=[];if(x!=null)for(var M in Object(x))w.push(M);return w}function rp(x){return Oh.call(x)}function Bi(x,w,M){return w=Oi(w===void 0?x.length-1:w,0),function(){for(var Z=arguments,ht=-1,pt=Oi(Z.length-w,0),gt=Array(pt);++ht<pt;)gt[ht]=Z[w+ht];ht=-1;for(var ot=Array(w+1);++ht<w;)ot[ht]=Z[ht];return ot[w]=M(gt),bt(x,this,ot)}}function Bo(x,w){if(!(w==="constructor"&&typeof x[w]=="function")&&w!="__proto__")return x[w]}var sp=np(Jd);function np(x){var w=0,M=0;return function(){var Z=Uh(),ht=n-(Z-M);if(M=Z,ht>0){if(++w>=s)return arguments[0]}else w=0;return x.apply(void 0,arguments)}}function op(x){if(x!=null){try{return bn.call(x)}catch{}try{return x+""}catch{}}return""}function En(x,w){return x===w||x!==x&&w!==w}var fi=Vh(function(){return arguments}())?Vh:function(x){return Or(x)&&di.call(x,"callee")&&!Bh.call(x,"callee")},Cn=Array.isArray;function Uo(x){return x!=null&&Qh(x.length)&&!Is(x)}function In(x){return Or(x)&&Uo(x)}var $h=Rd||R;function Is(x){if(!Ui(x))return!1;var w=cr(x);return w==p||w==m||w==l||w==b}function Qh(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=o}function Ui(x){var w=typeof x;return x!=null&&(w=="object"||w=="function")}function Or(x){return x!=null&&typeof x=="object"}function qh(x){if(!Or(x)||cr(x)!=_)return!1;var w=Po(x);if(w===null)return!0;var M=di.call(w,"constructor")&&w.constructor;return typeof M=="function"&&M instanceof M&&bn.call(M)==Ad}var Wr=O?Mt(O):Wi;function tl(x){return Hh(x,el(x))}function el(x){return Uo(x)?ur(x,!0):Yd(x)}var ap=Yh(function(x,w,M){Kh(x,w,M)});function hp(x){return function(){return x}}function T(x){return x}function R(){return!1}r.exports=ap}(Yo,Yo.exports);var Fb=Yo.exports;const Db=Gn(Fb);function kb(){const r=new Map;function t(o,a){const h=r.get(o);return h?h.add(a):r.set(o,new Set([a])),()=>i(o,a)}function e(o,a){const h=l=>{i(o,h),a(l)};t(o,h)}function i(o,a){var h;(h=r.get(o))==null||h.delete(a)}function s(o,a){var h;(h=r.get(o))==null||h.forEach(l=>l(a))}function n(){r.clear()}return{on:t,off:i,once:e,emit:s,clear:n}}const xt=kb();function Oe(r){let t;return new Promise(e=>{t=e,xt.on(r,t)}).then(e=>(xt.off(r,t),e))}let Br=null;function Ob(){Br=z.effectScope()}function Wb(){Br==null||Br.stop(),Br=null}async function Bb(){return Br||await Oe("scopeCreated")}let pr=null;const Tp={animationDuration:500,disableAnimationsThreshold:500,disableEdgesThreshold:500,styles:{colorMode:"dark",rowGap:16,columnGap:32,textDefault:"#ffffff",textInverse:"#000000",nodesPadding:16,nodeHeight:32,nodePadding:4,nodeRadius:6,nodeBorderRadius:9,nodeToggleSize:28,nodeToggleBorderRadius:6,nodeToggleBorderColor:"#51525C",nodeSelectedBorderColor:"#3fa2c3",nodeUnselectedAlpha:.2,edgeColor:"#51525C",guideLineWidth:1,guideLineColor:"#51525C",guideTextTopPadding:8,guideTextLeftPadding:8,guideTextSize:12,guideTextColor:"#ADADAD",playheadWidth:2,playheadColor:"#6272FF",node:()=>({background:"#ffffff"})}};function Ub(r){const t=Db({},Tp,r);return t.styles.node=e=>{var i,s;return{...Tp.styles.node(e),...(s=(i=r.styles)==null?void 0:i.node)==null?void 0:s.call(i,e)}},t}async function Xb(r){(await Bb()).run(()=>{z.watch(()=>r.config,e=>{const i=Ub(e);if(!pr){pr=i,xt.emit("configCreated",pr);return}Object.assign(pr,i),xt.emit("configUpdated",pr)},{immediate:!0})})}function Zb(){pr=null}async function ge(){return pr||await Oe("configCreated")}var Ur=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Ur||{}),wp=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(wp||{}),cl=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(cl||{}),ut=(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))(ut||{}),gi=(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))(gi||{}),H=(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))(H||{}),Rs=(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))(Rs||{}),at=(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))(at||{}),$=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))($||{}),Ki=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Ki||{}),Hi=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Hi||{}),yi=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(yi||{}),xe=(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))(xe||{}),bi=(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))(bi||{}),dl=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(dl||{}),We=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(We||{}),jt=(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))(jt||{}),Yt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Yt||{}),xi=(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))(xi||{});const Q={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 pl=/iPhone/i,Sp=/iPod/i,Ep=/iPad/i,Cp=/\biOS-universal(?:.+)Mac\b/i,fl=/\bAndroid(?:.+)Mobile\b/i,Ip=/Android/i,Ms=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,zo=/Silk/i,Yi=/Windows Phone/i,Ap=/\bWindows(?:.+)ARM\b/i,Rp=/BlackBerry/i,Mp=/BB10/i,Pp=/Opera Mini/i,Lp=/\b(CriOS|Chrome)(?:.+)Mobile/i,Gp=/Mobile(?:.+)Firefox\b/i,Np=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Vb(r){return function(t){return t.test(r)}}function Fp(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=Vb(e),n={apple:{phone:s(pl)&&!s(Yi),ipod:s(Sp),tablet:!s(pl)&&(s(Ep)||Np(t))&&!s(Yi),universal:s(Cp),device:(s(pl)||s(Sp)||s(Ep)||s(Cp)||Np(t))&&!s(Yi)},amazon:{phone:s(Ms),tablet:!s(Ms)&&s(zo),device:s(Ms)||s(zo)},android:{phone:!s(Yi)&&s(Ms)||!s(Yi)&&s(fl),tablet:!s(Yi)&&!s(Ms)&&!s(fl)&&(s(zo)||s(Ip)),device:!s(Yi)&&(s(Ms)||s(zo)||s(fl)||s(Ip))||s(/\bokhttp\b/i)},windows:{phone:s(Yi),tablet:s(Ap),device:s(Yi)||s(Ap)},other:{blackberry:s(Rp),blackberry10:s(Mp),opera:s(Pp),firefox:s(Gp),chrome:s(Lp),device:s(Rp)||s(Mp)||s(Pp)||s(Gp)||s(Lp)},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 Kb=Fp.default??Fp,zi=Kb(globalThis.navigator);Q.RETINA_PREFIX=/@([0-9\.]+)x/,Q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Dp={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(h,l,u){this.fn=h,this.context=l,this.once=u||!1}function n(h,l,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,c||h,d),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],p]:h._events[m].push(p):(h._events[m]=p,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,c;if(this._eventsCount===0)return l;for(c in u=this._events)t.call(u,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=e?e+l:l,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,m=new Array(p);d<p;d++)m[d]=c[d].fn;return m},a.prototype.listenerCount=function(l){var u=e?e+l:l,c=this._events[u];return c?c.fn?1:c.length:0},a.prototype.emit=function(l,u,c,d,p,m){var f=e?e+l:l;if(!this._events[f])return!1;var g=this._events[f],y=arguments.length,_,b;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,d),!0;case 5:return g.fn.call(g.context,u,c,d,p),!0;case 6:return g.fn.call(g.context,u,c,d,p,m),!0}for(b=1,_=new Array(y-1);b<y;b++)_[b-1]=arguments[b];g.fn.apply(g.context,_)}else{var v=g.length,S;for(b=0;b<v;b++)switch(g[b].once&&this.removeListener(l,g[b].fn,void 0,!0),y){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,u);break;case 3:g[b].fn.call(g[b].context,u,c);break;case 4:g[b].fn.call(g[b].context,u,c,d);break;default:if(!_)for(S=1,_=new Array(y-1);S<y;S++)_[S-1]=arguments[S];g[b].fn.apply(g[b].context,_)}}return!0},a.prototype.on=function(l,u,c){return n(this,l,u,c,!1)},a.prototype.once=function(l,u,c){return n(this,l,u,c,!0)},a.prototype.removeListener=function(l,u,c,d){var p=e?e+l:l;if(!this._events[p])return this;if(!u)return o(this,p),this;var m=this._events[p];if(m.fn)m.fn===u&&(!d||m.once)&&(!c||m.context===c)&&o(this,p);else{for(var f=0,g=[],y=m.length;f<y;f++)(m[f].fn!==u||d&&!m[f].once||c&&m[f].context!==c)&&g.push(m[f]);g.length?this._events[p]=g.length===1?g[0]:g:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=e?e+l:l,this._events[u]&&o(this,u)):(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})(Dp);var Hb=Dp.exports;const Nn=Gn(Hb);var ml={exports:{}};ml.exports=jo,ml.exports.default=jo;function jo(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=kp(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,h,l,u,c,d,p;if(i&&(n=$b(r,t,n,e)),r.length>80*e){a=l=r[0],h=u=r[1];for(var m=e;m<s;m+=e)c=r[m],d=r[m+1],c<a&&(a=c),d<h&&(h=d),c>l&&(l=c),d>u&&(u=d);p=Math.max(l-a,u-h),p=p!==0?32767/p:0}return Fn(n,o,e,a,h,p,0),o}function kp(r,t,e,i,s){var n,o;if(s===bl(r,t,e,i)>0)for(n=t;n<e;n+=i)o=Bp(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=Bp(n,r[n],r[n+1],o);return o&&Jo(o,o.next)&&(kn(o),o=o.next),o}function Xr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Jo(e,e.next)||Dt(e.prev,e,e.next)===0)){if(kn(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Fn(r,t,e,i,s,n,o){if(r){!o&&n&&ix(r,i,s,n);for(var a=r,h,l;r.prev!==r.next;){if(h=r.prev,l=r.next,n?zb(r,i,s,n):Yb(r)){t.push(h.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),kn(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=jb(Xr(r),t,e),Fn(r,t,e,i,s,n,2)):o===2&&Jb(r,t,e,i,s,n):Fn(Xr(r),t,e,i,s,n,1);break}}}}function Yb(r){var t=r.prev,e=r,i=r.next;if(Dt(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,u=s<n?s<o?s:o:n<o?n:o,c=a<h?a<l?a:l:h<l?h:l,d=s>n?s>o?s:o:n>o?n:o,p=a>h?a>l?a:l:h>l?h:l,m=i.next;m!==t;){if(m.x>=u&&m.x<=d&&m.y>=c&&m.y<=p&&Ps(s,a,n,h,o,l,m.x,m.y)&&Dt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function zb(r,t,e,i){var s=r.prev,n=r,o=r.next;if(Dt(s,n,o)>=0)return!1;for(var a=s.x,h=n.x,l=o.x,u=s.y,c=n.y,d=o.y,p=a<h?a<l?a:l:h<l?h:l,m=u<c?u<d?u:d:c<d?c:d,f=a>h?a>l?a:l:h>l?h:l,g=u>c?u>d?u:d:c>d?c:d,y=gl(p,m,t,e,i),_=gl(f,g,t,e,i),b=r.prevZ,v=r.nextZ;b&&b.z>=y&&v&&v.z<=_;){if(b.x>=p&&b.x<=f&&b.y>=m&&b.y<=g&&b!==s&&b!==o&&Ps(a,u,h,c,l,d,b.x,b.y)&&Dt(b.prev,b,b.next)>=0||(b=b.prevZ,v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&Ps(a,u,h,c,l,d,v.x,v.y)&&Dt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=f&&b.y>=m&&b.y<=g&&b!==s&&b!==o&&Ps(a,u,h,c,l,d,b.x,b.y)&&Dt(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=_;){if(v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&Ps(a,u,h,c,l,d,v.x,v.y)&&Dt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function jb(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Jo(s,n)&&Op(s,i,i.next,n)&&Dn(s,n)&&Dn(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),kn(i),kn(i.next),i=r=n),i=i.next}while(i!==r);return Xr(i)}function Jb(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&nx(o,a)){var h=Wp(o,a);o=Xr(o,o.next),h=Xr(h,h.next),Fn(o,t,e,i,s,n,0),Fn(h,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function $b(r,t,e,i){var s=[],n,o,a,h,l;for(n=0,o=t.length;n<o;n++)a=t[n]*i,h=n<o-1?t[n+1]*i:r.length,l=kp(r,a,h,i,!1),l===l.next&&(l.steiner=!0),s.push(sx(l));for(s.sort(Qb),n=0;n<s.length;n++)e=qb(s[n],e);return e}function Qb(r,t){return r.x-t.x}function qb(r,t){var e=tx(r,t);if(!e)return t;var i=Wp(e,r);return Xr(i,i.next),Xr(e,e.next)}function tx(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 h=o,l=o.x,u=o.y,c=1/0,d;e=o;do i>=e.x&&e.x>=l&&i!==e.x&&Ps(s<u?i:n,s,l,u,s<u?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Dn(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&ex(o,e)))&&(o=e,c=d)),e=e.next;while(e!==h);return o}function ex(r,t){return Dt(r.prev,r,t.prev)<0&&Dt(t.next,r,r.next)<0}function ix(r,t,e,i){var s=r;do s.z===0&&(s.z=gl(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,rx(s)}function rx(r){var t,e,i,s,n,o,a,h,l=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<l&&(a++,i=i.nextZ,!!i);t++);for(h=l;a>0||h>0&&i;)a!==0&&(h===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,h--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,l*=2}while(o>1);return r}function gl(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 sx(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 Ps(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 nx(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!ox(r,t)&&(Dn(r,t)&&Dn(t,r)&&ax(r,t)&&(Dt(r.prev,r,t.prev)||Dt(r,t.prev,t))||Jo(r,t)&&Dt(r.prev,r,r.next)>0&&Dt(t.prev,t,t.next)>0)}function Dt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Jo(r,t){return r.x===t.x&&r.y===t.y}function Op(r,t,e,i){var s=Qo(Dt(r,t,e)),n=Qo(Dt(r,t,i)),o=Qo(Dt(e,i,r)),a=Qo(Dt(e,i,t));return!!(s!==n&&o!==a||s===0&&$o(r,e,t)||n===0&&$o(r,i,t)||o===0&&$o(e,r,i)||a===0&&$o(e,t,i))}function $o(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 Qo(r){return r>0?1:r<0?-1:0}function ox(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&&Op(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Dn(r,t){return Dt(r.prev,r,r.next)<0?Dt(r,t,r.next)>=0&&Dt(r,r.prev,t)>=0:Dt(r,t,r.prev)<0||Dt(r,r.next,t)<0}function ax(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 Wp(r,t){var e=new yl(r.i,r.x,r.y),i=new yl(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 Bp(r,t,e,i){var s=new yl(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 kn(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 yl(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}jo.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(bl(r,0,n,e));if(s)for(var a=0,h=t.length;a<h;a++){var l=t[a]*e,u=a<h-1?t[a+1]*e:r.length;o-=Math.abs(bl(r,l,u,e))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,p=i[a+1]*e,m=i[a+2]*e;c+=Math.abs((r[d]-r[m])*(r[p+1]-r[d+1])-(r[d]-r[p])*(r[m+1]-r[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function bl(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}jo.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 hx=ml.exports;const lx=Gn(hx);var qo={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */qo.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof qe=="object"&&qe;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,h=36,l=1,u=26,c=38,d=700,p=72,m=128,f="-",g=/^xn--/,y=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=h-l,S=Math.floor,E=String.fromCharCode,A;function I(D){throw new RangeError(b[D])}function P(D,U){for(var j=D.length,q=[];j--;)q[j]=U(D[j]);return q}function B(D,U){var j=D.split("@"),q="";j.length>1&&(q=j[0]+"@",D=j[1]),D=D.replace(_,".");var dt=D.split("."),nt=P(dt,U).join(".");return q+nt}function G(D){for(var U=[],j=0,q=D.length,dt,nt;j<q;)dt=D.charCodeAt(j++),dt>=55296&&dt<=56319&&j<q?(nt=D.charCodeAt(j++),(nt&64512)==56320?U.push(((dt&1023)<<10)+(nt&1023)+65536):(U.push(dt),j--)):U.push(dt);return U}function N(D){return P(D,function(U){var j="";return U>65535&&(U-=65536,j+=E(U>>>10&1023|55296),U=56320|U&1023),j+=E(U),j}).join("")}function C(D){return D-48<10?D-22:D-65<26?D-65:D-97<26?D-97:h}function F(D,U){return D+22+75*(D<26)-((U!=0)<<5)}function X(D,U,j){var q=0;for(D=j?S(D/d):D>>1,D+=S(D/U);D>v*u>>1;q+=h)D=S(D/v);return S(q+(v+1)*D/(D+c))}function V(D){var U=[],j=D.length,q,dt=0,nt=m,Et=p,Rt,wt,Y,it,tt,O,bt,mt,Mt;for(Rt=D.lastIndexOf(f),Rt<0&&(Rt=0),wt=0;wt<Rt;++wt)D.charCodeAt(wt)>=128&&I("not-basic"),U.push(D.charCodeAt(wt));for(Y=Rt>0?Rt+1:0;Y<j;){for(it=dt,tt=1,O=h;Y>=j&&I("invalid-input"),bt=C(D.charCodeAt(Y++)),(bt>=h||bt>S((a-dt)/tt))&&I("overflow"),dt+=bt*tt,mt=O<=Et?l:O>=Et+u?u:O-Et,!(bt<mt);O+=h)Mt=h-mt,tt>S(a/Mt)&&I("overflow"),tt*=Mt;q=U.length+1,Et=X(dt-it,q,it==0),S(dt/q)>a-nt&&I("overflow"),nt+=S(dt/q),dt%=q,U.splice(dt++,0,nt)}return N(U)}function L(D){var U,j,q,dt,nt,Et,Rt,wt,Y,it,tt,O=[],bt,mt,Mt,Ut;for(D=G(D),bt=D.length,U=m,j=0,nt=p,Et=0;Et<bt;++Et)tt=D[Et],tt<128&&O.push(E(tt));for(q=dt=O.length,dt&&O.push(f);q<bt;){for(Rt=a,Et=0;Et<bt;++Et)tt=D[Et],tt>=U&&tt<Rt&&(Rt=tt);for(mt=q+1,Rt-U>S((a-j)/mt)&&I("overflow"),j+=(Rt-U)*mt,U=Rt,Et=0;Et<bt;++Et)if(tt=D[Et],tt<U&&++j>a&&I("overflow"),tt==U){for(wt=j,Y=h;it=Y<=nt?l:Y>=nt+u?u:Y-nt,!(wt<it);Y+=h)Ut=wt-it,Mt=h-it,O.push(E(F(it+Ut%Mt,0))),wt=S(Ut/Mt);O.push(E(F(wt,0))),nt=X(j,mt,q==dt),j=0,++q}++j,++U}return O.join("")}function k(D){return B(D,function(U){return g.test(U)?V(U.slice(4).toLowerCase()):U})}function K(D){return B(D,function(U){return y.test(U)?"xn--"+L(U):U})}if(o={version:"1.4.1",ucs2:{decode:G,encode:N},decode:V,encode:L,toASCII:K,toUnicode:k},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})(qe)}(qo,qo.exports);var ux=qo.exports,cx=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},Up=typeof Symbol<"u"&&Symbol,dx=cx,px=function(){return typeof Up!="function"||typeof Symbol!="function"||typeof Up("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:dx()},Xp={foo:{}},fx=Object,mx=function(){return{__proto__:Xp}.foo===Xp.foo&&!({__proto__:null}instanceof fx)},gx="Function.prototype.bind called on incompatible ",xl=Array.prototype.slice,yx=Object.prototype.toString,bx="[object Function]",xx=function(t){var e=this;if(typeof e!="function"||yx.call(e)!==bx)throw new TypeError(gx+e);for(var i=xl.call(arguments,1),s,n=function(){if(this instanceof s){var u=e.apply(this,i.concat(xl.call(arguments)));return Object(u)===u?u:this}else return e.apply(t,i.concat(xl.call(arguments)))},o=Math.max(0,e.length-i.length),a=[],h=0;h<o;h++)a.push("$"+h);if(s=Function("binder","return function ("+a.join(",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var l=function(){};l.prototype=e.prototype,s.prototype=new l,l.prototype=null}return s},_x=xx,_l=Function.prototype.bind||_x,vx=_l,Tx=vx.call(Function.call,Object.prototype.hasOwnProperty),Tt,Ls=SyntaxError,Zp=Function,Gs=TypeError,vl=function(r){try{return Zp('"use strict"; return ('+r+").constructor;")()}catch{}},Zr=Object.getOwnPropertyDescriptor;if(Zr)try{Zr({},"")}catch{Zr=null}var Tl=function(){throw new Gs},wx=Zr?function(){try{return arguments.callee,Tl}catch{try{return Zr(arguments,"callee").get}catch{return Tl}}}():Tl,Ns=px(),Sx=mx(),qt=Object.getPrototypeOf||(Sx?function(r){return r.__proto__}:null),Fs={},Ex=typeof Uint8Array>"u"||!qt?Tt:qt(Uint8Array),Vr={"%AggregateError%":typeof AggregateError>"u"?Tt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Tt:ArrayBuffer,"%ArrayIteratorPrototype%":Ns&&qt?qt([][Symbol.iterator]()):Tt,"%AsyncFromSyncIteratorPrototype%":Tt,"%AsyncFunction%":Fs,"%AsyncGenerator%":Fs,"%AsyncGeneratorFunction%":Fs,"%AsyncIteratorPrototype%":Fs,"%Atomics%":typeof Atomics>"u"?Tt:Atomics,"%BigInt%":typeof BigInt>"u"?Tt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Tt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Tt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Tt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?Tt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Tt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Tt:FinalizationRegistry,"%Function%":Zp,"%GeneratorFunction%":Fs,"%Int8Array%":typeof Int8Array>"u"?Tt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Tt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Tt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ns&&qt?qt(qt([][Symbol.iterator]())):Tt,"%JSON%":typeof JSON=="object"?JSON:Tt,"%Map%":typeof Map>"u"?Tt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ns||!qt?Tt:qt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Tt:Promise,"%Proxy%":typeof Proxy>"u"?Tt:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?Tt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Tt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ns||!qt?Tt:qt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Tt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ns&&qt?qt(""[Symbol.iterator]()):Tt,"%Symbol%":Ns?Symbol:Tt,"%SyntaxError%":Ls,"%ThrowTypeError%":wx,"%TypedArray%":Ex,"%TypeError%":Gs,"%Uint8Array%":typeof Uint8Array>"u"?Tt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Tt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Tt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Tt:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?Tt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Tt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Tt:WeakSet};if(qt)try{null.error}catch(r){var Cx=qt(qt(r));Vr["%Error.prototype%"]=Cx}var Ix=function r(t){var e;if(t==="%AsyncFunction%")e=vl("async function () {}");else if(t==="%GeneratorFunction%")e=vl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=vl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&qt&&(e=qt(s.prototype))}return Vr[t]=e,e},Vp={"%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"]},On=_l,ta=Tx,Ax=On.call(Function.call,Array.prototype.concat),Rx=On.call(Function.apply,Array.prototype.splice),Kp=On.call(Function.call,String.prototype.replace),ea=On.call(Function.call,String.prototype.slice),Mx=On.call(Function.call,RegExp.prototype.exec),Px=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Lx=/\\(\\)?/g,Gx=function(t){var e=ea(t,0,1),i=ea(t,-1);if(e==="%"&&i!=="%")throw new Ls("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new Ls("invalid intrinsic syntax, expected opening `%`");var s=[];return Kp(t,Px,function(n,o,a,h){s[s.length]=a?Kp(h,Lx,"$1"):o||n}),s},Nx=function(t,e){var i=t,s;if(ta(Vp,i)&&(s=Vp[i],i="%"+s[0]+"%"),ta(Vr,i)){var n=Vr[i];if(n===Fs&&(n=Ix(i)),typeof n>"u"&&!e)throw new Gs("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Ls("intrinsic "+t+" does not exist!")},wl=function(t,e){if(typeof t!="string"||t.length===0)throw new Gs("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Gs('"allowMissing" argument must be a boolean');if(Mx(/^%?[^%]*%?$/,t)===null)throw new Ls("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=Gx(t),s=i.length>0?i[0]:"",n=Nx("%"+s+"%",e),o=n.name,a=n.value,h=!1,l=n.alias;l&&(s=l[0],Rx(i,Ax([0,1],l)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],p=ea(d,0,1),m=ea(d,-1);if((p==='"'||p==="'"||p==="`"||m==='"'||m==="'"||m==="`")&&p!==m)throw new Ls("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(h=!0),s+="."+d,o="%"+s+"%",ta(Vr,o))a=Vr[o];else if(a!=null){if(!(d in a)){if(!e)throw new Gs("base intrinsic for "+t+" exists, but the property is not available.");return}if(Zr&&u+1>=i.length){var f=Zr(a,d);c=!!f,c&&"get"in f&&!("originalValue"in f.get)?a=f.get:a=a[d]}else c=ta(a,d),a=a[d];c&&!h&&(Vr[o]=a)}}return a},Hp={exports:{}};(function(r){var t=_l,e=wl,i=e("%Function.prototype.apply%"),s=e("%Function.prototype.call%"),n=e("%Reflect.apply%",!0)||t.call(s,i),o=e("%Object.getOwnPropertyDescriptor%",!0),a=e("%Object.defineProperty%",!0),h=e("%Math.max%");if(a)try{a({},"a",{value:1})}catch{a=null}r.exports=function(c){var d=n(t,s,arguments);if(o&&a){var p=o(d,"length");p.configurable&&a(d,"length",{value:1+h(0,c.length-(arguments.length-1))})}return d};var l=function(){return n(t,i,arguments)};a?a(r.exports,"apply",{value:l}):r.exports.apply=l})(Hp);var Fx=Hp.exports,Yp=wl,zp=Fx,Dx=zp(Yp("String.prototype.indexOf")),kx=function(t,e){var i=Yp(t,!!e);return typeof i=="function"&&Dx(t,".prototype.")>-1?zp(i):i};const Ox=Nb(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Sl=typeof Map=="function"&&Map.prototype,El=Object.getOwnPropertyDescriptor&&Sl?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ia=Sl&&El&&typeof El.get=="function"?El.get:null,jp=Sl&&Map.prototype.forEach,Cl=typeof Set=="function"&&Set.prototype,Il=Object.getOwnPropertyDescriptor&&Cl?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ra=Cl&&Il&&typeof Il.get=="function"?Il.get:null,Jp=Cl&&Set.prototype.forEach,Wx=typeof WeakMap=="function"&&WeakMap.prototype,Wn=Wx?WeakMap.prototype.has:null,Bx=typeof WeakSet=="function"&&WeakSet.prototype,Bn=Bx?WeakSet.prototype.has:null,Ux=typeof WeakRef=="function"&&WeakRef.prototype,$p=Ux?WeakRef.prototype.deref:null,Xx=Boolean.prototype.valueOf,Zx=Object.prototype.toString,Vx=Function.prototype.toString,Kx=String.prototype.match,Al=String.prototype.slice,fr=String.prototype.replace,Hx=String.prototype.toUpperCase,Qp=String.prototype.toLowerCase,qp=RegExp.prototype.test,tf=Array.prototype.concat,_i=Array.prototype.join,Yx=Array.prototype.slice,ef=Math.floor,Rl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ml=Object.getOwnPropertySymbols,Pl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ds=typeof Symbol=="function"&&typeof Symbol.iterator=="object",le=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ds||"symbol")?Symbol.toStringTag:null,rf=Object.prototype.propertyIsEnumerable,sf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function nf(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||qp.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-ef(-r):ef(r);if(i!==r){var s=String(i),n=Al.call(t,s.length+1);return fr.call(s,e,"$&_")+"."+fr.call(fr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fr.call(t,e,"$&_")}var Ll=Ox,of=Ll.custom,af=uf(of)?of:null,zx=function r(t,e,i,s){var n=e||{};if(mr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(mr(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=mr(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(mr(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(mr(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 df(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var h=String(t);return a?nf(t,h):h}if(typeof t=="bigint"){var l=String(t)+"n";return a?nf(t,l):l}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof t=="object")return Gl(t)?"[Array]":"[Object]";var c=d_(n,i);if(typeof s>"u")s=[];else if(cf(s,t)>=0)return"[Circular]";function d(C,F,X){if(F&&(s=Yx.call(s),s.push(F)),X){var V={depth:n.depth};return mr(n,"quoteStyle")&&(V.quoteStyle=n.quoteStyle),r(C,V,i+1,s)}return r(C,n,i+1,s)}if(typeof t=="function"&&!lf(t)){var p=r_(t),m=sa(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(m.length>0?" { "+_i.call(m,", ")+" }":"")}if(uf(t)){var f=Ds?fr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Pl.call(t);return typeof t=="object"&&!Ds?Un(f):f}if(l_(t)){for(var g="<"+Qp.call(String(t.nodeName)),y=t.attributes||[],_=0;_<y.length;_++)g+=" "+y[_].name+"="+hf(jx(y[_].value),"double",n);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+="</"+Qp.call(String(t.nodeName))+">",g}if(Gl(t)){if(t.length===0)return"[]";var b=sa(t,d);return c&&!c_(b)?"["+Fl(b,c)+"]":"[ "+_i.call(b,", ")+" ]"}if($x(t)){var v=sa(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!rf.call(t,"cause")?"{ ["+String(t)+"] "+_i.call(tf.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+_i.call(v,", ")+" }"}if(typeof t=="object"&&o){if(af&&typeof t[af]=="function"&&Ll)return Ll(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(s_(t)){var S=[];return jp&&jp.call(t,function(C,F){S.push(d(F,t,!0)+" => "+d(C,t))}),pf("Map",ia.call(t),S,c)}if(a_(t)){var E=[];return Jp&&Jp.call(t,function(C){E.push(d(C,t))}),pf("Set",ra.call(t),E,c)}if(n_(t))return Nl("WeakMap");if(h_(t))return Nl("WeakSet");if(o_(t))return Nl("WeakRef");if(qx(t))return Un(d(Number(t)));if(e_(t))return Un(d(Rl.call(t)));if(t_(t))return Un(Xx.call(t));if(Qx(t))return Un(d(String(t)));if(!Jx(t)&&!lf(t)){var A=sa(t,d),I=sf?sf(t)===Object.prototype:t instanceof Object||t.constructor===Object,P=t instanceof Object?"":"null prototype",B=!I&&le&&Object(t)===t&&le in t?Al.call(gr(t),8,-1):P?"Object":"",G=I||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",N=G+(B||P?"["+_i.call(tf.call([],B||[],P||[]),": ")+"] ":"");return A.length===0?N+"{}":c?N+"{"+Fl(A,c)+"}":N+"{ "+_i.call(A,", ")+" }"}return String(t)};function hf(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function jx(r){return fr.call(String(r),/"/g,"&quot;")}function Gl(r){return gr(r)==="[object Array]"&&(!le||!(typeof r=="object"&&le in r))}function Jx(r){return gr(r)==="[object Date]"&&(!le||!(typeof r=="object"&&le in r))}function lf(r){return gr(r)==="[object RegExp]"&&(!le||!(typeof r=="object"&&le in r))}function $x(r){return gr(r)==="[object Error]"&&(!le||!(typeof r=="object"&&le in r))}function Qx(r){return gr(r)==="[object String]"&&(!le||!(typeof r=="object"&&le in r))}function qx(r){return gr(r)==="[object Number]"&&(!le||!(typeof r=="object"&&le in r))}function t_(r){return gr(r)==="[object Boolean]"&&(!le||!(typeof r=="object"&&le in r))}function uf(r){if(Ds)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Pl)return!1;try{return Pl.call(r),!0}catch{}return!1}function e_(r){if(!r||typeof r!="object"||!Rl)return!1;try{return Rl.call(r),!0}catch{}return!1}var i_=Object.prototype.hasOwnProperty||function(r){return r in this};function mr(r,t){return i_.call(r,t)}function gr(r){return Zx.call(r)}function r_(r){if(r.name)return r.name;var t=Kx.call(Vx.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function cf(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 s_(r){if(!ia||!r||typeof r!="object")return!1;try{ia.call(r);try{ra.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function n_(r){if(!Wn||!r||typeof r!="object")return!1;try{Wn.call(r,Wn);try{Bn.call(r,Bn)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function o_(r){if(!$p||!r||typeof r!="object")return!1;try{return $p.call(r),!0}catch{}return!1}function a_(r){if(!ra||!r||typeof r!="object")return!1;try{ra.call(r);try{ia.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function h_(r){if(!Bn||!r||typeof r!="object")return!1;try{Bn.call(r,Bn);try{Wn.call(r,Wn)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function l_(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function df(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return df(Al.call(r,0,t.maxStringLength),t)+i}var s=fr.call(fr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,u_);return hf(s,"single",t)}function u_(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":"")+Hx.call(t.toString(16))}function Un(r){return"Object("+r+")"}function Nl(r){return r+" { ? }"}function pf(r,t,e,i){var s=i?Fl(e,i):_i.call(e,", ");return r+" ("+t+") {"+s+"}"}function c_(r){for(var t=0;t<r.length;t++)if(cf(r[t],`
1
+ (function(oe,z){typeof exports=="object"&&typeof module<"u"?z(exports,require("vue"),require("@prefecthq/vue-compositions"),require("@prefecthq/prefect-design")):typeof define=="function"&&define.amd?define(["exports","vue","@prefecthq/vue-compositions","@prefecthq/prefect-design"],z):(oe=typeof globalThis<"u"?globalThis:oe||self,z(oe["prefect-graphs"]={},oe.Vue,oe.vueCompositions,oe.prefectDesign))})(this,function(oe,z,Zi,Vi){"use strict";var _M=Object.defineProperty;var vM=(oe,z,Zi)=>z in oe?_M(oe,z,{enumerable:!0,configurable:!0,writable:!0,value:Zi}):oe[z]=Zi;var lp=(oe,z,Zi)=>(vM(oe,typeof z!="symbol"?z+"":z,Zi),Zi);const yp="nodes-container",Cb="node-container",Ib="edge-container";function ll(r){"@babel/helpers - typeof";return ll=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ll(r)}function bp(r){if(r===null||r===!0||r===!1)return NaN;var t=Number(r);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function Ln(r,t){if(t.length<r)throw new TypeError(r+" argument"+(r>1?"s":"")+" required, but only "+t.length+" present")}function ul(r){Ln(1,arguments);var t=Object.prototype.toString.call(r);return r instanceof Date||ll(r)==="object"&&t==="[object Date]"?new Date(r.getTime()):typeof r=="number"||t==="[object Number]"?new Date(r):((typeof r=="string"||t==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function Ab(r,t){Ln(2,arguments);var e=ul(r).getTime(),i=bp(t);return new Date(e+i)}function Rb(r,t){Ln(2,arguments);var e=bp(t);return Ab(r,e*1e3)}var Mb=1e3,xp=3600;function _p(r,t){return Ln(2,arguments),ul(r).getTime()-ul(t).getTime()}var vp={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},Pb="trunc";function Lb(r){return r?vp[r]:vp[Pb]}function Gb(r,t,e){Ln(2,arguments);var i=_p(r,t)/1e3;return Lb(e==null?void 0:e.roundingMethod)(i)}var qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Nb(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 Yo={exports:{}};Yo.exports,function(r,t){var e=200,i="__lodash_hash_undefined__",s=800,n=16,o=9007199254740991,a="[object Arguments]",h="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",c="[object Date]",d="[object Error]",p="[object Function]",m="[object GeneratorFunction]",f="[object Map]",g="[object Number]",y="[object Null]",_="[object Object]",b="[object Proxy]",v="[object RegExp]",S="[object Set]",E="[object String]",A="[object Undefined]",I="[object WeakMap]",P="[object ArrayBuffer]",B="[object DataView]",G="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",F="[object Int16Array]",X="[object Int32Array]",V="[object Uint8Array]",L="[object Uint8ClampedArray]",k="[object Uint16Array]",K="[object Uint32Array]",D=/[\\^$.*+?()[\]{}|]/g,U=/^\[object .+?Constructor\]$/,j=/^(?:0|[1-9]\d*)$/,q={};q[G]=q[N]=q[C]=q[F]=q[X]=q[V]=q[L]=q[k]=q[K]=!0,q[a]=q[h]=q[P]=q[u]=q[B]=q[c]=q[d]=q[p]=q[f]=q[g]=q[_]=q[v]=q[S]=q[E]=q[I]=!1;var pt=typeof qe=="object"&&qe&&qe.Object===Object&&qe,nt=typeof self=="object"&&self&&self.Object===Object&&self,Et=pt||nt||Function("return this")(),Rt=t&&!t.nodeType&&t,wt=Rt&&!0&&r&&!r.nodeType&&r,Y=wt&&wt.exports===Rt,it=Y&&pt.process,tt=function(){try{var x=wt&&wt.require&&wt.require("util").types;return x||it&&it.binding&&it.binding("util")}catch{}}(),O=tt&&tt.isTypedArray;function bt(x,w,M){switch(M.length){case 0:return x.call(w);case 1:return x.call(w,M[0]);case 2:return x.call(w,M[0],M[1]);case 3:return x.call(w,M[0],M[1],M[2])}return x.apply(w,M)}function gt(x,w){for(var M=-1,Z=Array(x);++M<x;)Z[M]=w(M);return Z}function Mt(x){return function(w){return x(w)}}function Ut(x,w){return x==null?void 0:x[w]}function Ne(x,w){return function(M){return x(w(M))}}var ci=Array.prototype,Id=Function.prototype,yn=Object.prototype,Ao=Et["__core-js_shared__"],bn=Id.toString,di=yn.hasOwnProperty,kh=function(){var x=/[^.]+$/.exec(Ao&&Ao.keys&&Ao.keys.IE_PROTO||"");return x?"Symbol(src)_1."+x:""}(),Oh=yn.toString,Ad=bn.call(Object),xn=RegExp("^"+bn.call(di).replace(D,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),kr=Y?Et.Buffer:void 0,Ro=Et.Symbol,Fe=Et.Uint8Array,Mo=kr?kr.allocUnsafe:void 0,Po=Ne(Object.getPrototypeOf,Object),Wh=Object.create,Bh=yn.propertyIsEnumerable,_n=ci.splice,ki=Ro?Ro.toStringTag:void 0,ws=function(){try{var x=Wo(Object,"defineProperty");return x({},"",{}),x}catch{}}(),Rd=kr?kr.isBuffer:void 0,Oi=Math.max,Uh=Date.now,Xh=Wo(Et,"Map"),Ss=Wo(Object,"create"),Lo=function(){function x(){}return function(w){if(!Ui(w))return{};if(Wh)return Wh(w);x.prototype=w;var M=new x;return x.prototype=void 0,M}}();function De(x){var w=-1,M=x==null?0:x.length;for(this.clear();++w<M;){var Z=x[w];this.set(Z[0],Z[1])}}function Go(){this.__data__=Ss?Ss(null):{},this.size=0}function No(x){var w=this.has(x)&&delete this.__data__[x];return this.size-=w?1:0,w}function Fo(x){var w=this.__data__;if(Ss){var M=w[x];return M===i?void 0:M}return di.call(w,x)?w[x]:void 0}function Es(x){var w=this.__data__;return Ss?w[x]!==void 0:di.call(w,x)}function Md(x,w){var M=this.__data__;return this.size+=this.has(x)?0:1,M[x]=Ss&&w===void 0?i:w,this}De.prototype.clear=Go,De.prototype.delete=No,De.prototype.get=Fo,De.prototype.has=Es,De.prototype.set=Md;function pi(x){var w=-1,M=x==null?0:x.length;for(this.clear();++w<M;){var Z=x[w];this.set(Z[0],Z[1])}}function Pd(){this.__data__=[],this.size=0}function Ld(x){var w=this.__data__,M=vn(w,x);if(M<0)return!1;var Z=w.length-1;return M==Z?w.pop():_n.call(w,M,1),--this.size,!0}function Gd(x){var w=this.__data__,M=vn(w,x);return M<0?void 0:w[M][1]}function Zh(x){return vn(this.__data__,x)>-1}function Do(x,w){var M=this.__data__,Z=vn(M,x);return Z<0?(++this.size,M.push([x,w])):M[Z][1]=w,this}pi.prototype.clear=Pd,pi.prototype.delete=Ld,pi.prototype.get=Gd,pi.prototype.has=Zh,pi.prototype.set=Do;function Ce(x){var w=-1,M=x==null?0:x.length;for(this.clear();++w<M;){var Z=x[w];this.set(Z[0],Z[1])}}function Nd(){this.size=0,this.__data__={hash:new De,map:new(Xh||pi),string:new De}}function Fd(x){var w=wn(this,x).delete(x);return this.size-=w?1:0,w}function Dd(x){return wn(this,x).get(x)}function kd(x){return wn(this,x).has(x)}function Od(x,w){var M=wn(this,x),Z=M.size;return M.set(x,w),this.size+=M.size==Z?0:1,this}Ce.prototype.clear=Nd,Ce.prototype.delete=Fd,Ce.prototype.get=Dd,Ce.prototype.has=kd,Ce.prototype.set=Od;function fe(x){var w=this.__data__=new pi(x);this.size=w.size}function Wd(){this.__data__=new pi,this.size=0}function Bd(x){var w=this.__data__,M=w.delete(x);return this.size=w.size,M}function Ud(x){return this.__data__.get(x)}function Xd(x){return this.__data__.has(x)}function Zd(x,w){var M=this.__data__;if(M instanceof pi){var Z=M.__data__;if(!Xh||Z.length<e-1)return Z.push([x,w]),this.size=++M.size,this;M=this.__data__=new Ce(Z)}return M.set(x,w),this.size=M.size,this}fe.prototype.clear=Wd,fe.prototype.delete=Bd,fe.prototype.get=Ud,fe.prototype.has=Xd,fe.prototype.set=Zd;function ur(x,w){var M=Cn(x),Z=!M&&fi(x),ht=!M&&!Z&&$h(x),ft=!M&&!Z&&!ht&&Wr(x),yt=M||Z||ht||ft,ot=yt?gt(x.length,String):[],_t=ot.length;for(var Ft in x)(w||di.call(x,Ft))&&!(yt&&(Ft=="length"||ht&&(Ft=="offset"||Ft=="parent")||ft&&(Ft=="buffer"||Ft=="byteLength"||Ft=="byteOffset")||jh(Ft,_t)))&&ot.push(Ft);return ot}function ko(x,w,M){(M!==void 0&&!En(x[w],M)||M===void 0&&!(w in x))&&Oo(x,w,M)}function Vd(x,w,M){var Z=x[w];(!(di.call(x,w)&&En(Z,M))||M===void 0&&!(w in x))&&Oo(x,w,M)}function vn(x,w){for(var M=x.length;M--;)if(En(x[M][0],w))return M;return-1}function Oo(x,w,M){w=="__proto__"&&ws?ws(x,w,{configurable:!0,enumerable:!0,value:M,writable:!0}):x[w]=M}var Kd=qd();function cr(x){return x==null?x===void 0?A:y:ki&&ki in Object(x)?tp(x):rp(x)}function Vh(x){return Or(x)&&cr(x)==a}function Hd(x){if(!Ui(x)||Sn(x))return!1;var w=Is(x)?xn:U;return w.test(op(x))}function Wi(x){return Or(x)&&Qh(x.length)&&!!q[cr(x)]}function Yd(x){if(!Ui(x))return ip(x);var w=dr(x),M=[];for(var Z in x)Z=="constructor"&&(w||!di.call(x,Z))||M.push(Z);return M}function Kh(x,w,M,Z,ht){x!==w&&Kd(w,function(ft,yt){if(ht||(ht=new fe),Ui(ft))zd(x,w,yt,M,Kh,Z,ht);else{var ot=Z?Z(Bo(x,yt),ft,yt+"",x,w,ht):void 0;ot===void 0&&(ot=ft),ko(x,yt,ot)}},el)}function zd(x,w,M,Z,ht,ft,yt){var ot=Bo(x,M),_t=Bo(w,M),Ft=yt.get(_t);if(Ft){ko(x,M,Ft);return}var At=ft?ft(ot,_t,M+"",x,w,yt):void 0,ne=At===void 0;if(ne){var me=Cn(_t),$e=!me&&$h(_t),Qe=!me&&!$e&&Wr(_t);At=_t,me||$e||Qe?Cn(ot)?At=ot:In(ot)?At=Cs(ot):$e?(ne=!1,At=$d(_t,!0)):Qe?(ne=!1,At=Qd(_t,!0)):At=[]:qh(_t)||fi(_t)?(At=ot,fi(ot)?At=tl(ot):(!Ui(ot)||Is(ot))&&(At=zh(_t))):ne=!1}ne&&(yt.set(_t,At),ht(At,_t,Z,ft,yt),yt.delete(_t)),ko(x,M,At)}function jd(x,w){return sp(Bi(x,w,T),x+"")}var Jd=ws?function(x,w){return ws(x,"toString",{configurable:!0,enumerable:!1,value:hp(w),writable:!0})}:T;function $d(x,w){if(w)return x.slice();var M=x.length,Z=Mo?Mo(M):new x.constructor(M);return x.copy(Z),Z}function Tn(x){var w=new x.constructor(x.byteLength);return new Fe(w).set(new Fe(x)),w}function Qd(x,w){var M=w?Tn(x.buffer):x.buffer;return new x.constructor(M,x.byteOffset,x.length)}function Cs(x,w){var M=-1,Z=x.length;for(w||(w=Array(Z));++M<Z;)w[M]=x[M];return w}function Hh(x,w,M,Z){var ht=!M;M||(M={});for(var ft=-1,yt=w.length;++ft<yt;){var ot=w[ft],_t=Z?Z(M[ot],x[ot],ot,M,x):void 0;_t===void 0&&(_t=x[ot]),ht?Oo(M,ot,_t):Vd(M,ot,_t)}return M}function Yh(x){return jd(function(w,M){var Z=-1,ht=M.length,ft=ht>1?M[ht-1]:void 0,yt=ht>2?M[2]:void 0;for(ft=x.length>3&&typeof ft=="function"?(ht--,ft):void 0,yt&&ep(M[0],M[1],yt)&&(ft=ht<3?void 0:ft,ht=1),w=Object(w);++Z<ht;){var ot=M[Z];ot&&x(w,ot,Z,ft)}return w})}function qd(x){return function(w,M,Z){for(var ht=-1,ft=Object(w),yt=Z(w),ot=yt.length;ot--;){var _t=yt[x?ot:++ht];if(M(ft[_t],_t,ft)===!1)break}return w}}function wn(x,w){var M=x.__data__;return Jh(w)?M[typeof w=="string"?"string":"hash"]:M.map}function Wo(x,w){var M=Ut(x,w);return Hd(M)?M:void 0}function tp(x){var w=di.call(x,ki),M=x[ki];try{x[ki]=void 0;var Z=!0}catch{}var ht=Oh.call(x);return Z&&(w?x[ki]=M:delete x[ki]),ht}function zh(x){return typeof x.constructor=="function"&&!dr(x)?Lo(Po(x)):{}}function jh(x,w){var M=typeof x;return w=w??o,!!w&&(M=="number"||M!="symbol"&&j.test(x))&&x>-1&&x%1==0&&x<w}function ep(x,w,M){if(!Ui(M))return!1;var Z=typeof w;return(Z=="number"?Uo(M)&&jh(w,M.length):Z=="string"&&w in M)?En(M[w],x):!1}function Jh(x){var w=typeof x;return w=="string"||w=="number"||w=="symbol"||w=="boolean"?x!=="__proto__":x===null}function Sn(x){return!!kh&&kh in x}function dr(x){var w=x&&x.constructor,M=typeof w=="function"&&w.prototype||yn;return x===M}function ip(x){var w=[];if(x!=null)for(var M in Object(x))w.push(M);return w}function rp(x){return Oh.call(x)}function Bi(x,w,M){return w=Oi(w===void 0?x.length-1:w,0),function(){for(var Z=arguments,ht=-1,ft=Oi(Z.length-w,0),yt=Array(ft);++ht<ft;)yt[ht]=Z[w+ht];ht=-1;for(var ot=Array(w+1);++ht<w;)ot[ht]=Z[ht];return ot[w]=M(yt),bt(x,this,ot)}}function Bo(x,w){if(!(w==="constructor"&&typeof x[w]=="function")&&w!="__proto__")return x[w]}var sp=np(Jd);function np(x){var w=0,M=0;return function(){var Z=Uh(),ht=n-(Z-M);if(M=Z,ht>0){if(++w>=s)return arguments[0]}else w=0;return x.apply(void 0,arguments)}}function op(x){if(x!=null){try{return bn.call(x)}catch{}try{return x+""}catch{}}return""}function En(x,w){return x===w||x!==x&&w!==w}var fi=Vh(function(){return arguments}())?Vh:function(x){return Or(x)&&di.call(x,"callee")&&!Bh.call(x,"callee")},Cn=Array.isArray;function Uo(x){return x!=null&&Qh(x.length)&&!Is(x)}function In(x){return Or(x)&&Uo(x)}var $h=Rd||R;function Is(x){if(!Ui(x))return!1;var w=cr(x);return w==p||w==m||w==l||w==b}function Qh(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=o}function Ui(x){var w=typeof x;return x!=null&&(w=="object"||w=="function")}function Or(x){return x!=null&&typeof x=="object"}function qh(x){if(!Or(x)||cr(x)!=_)return!1;var w=Po(x);if(w===null)return!0;var M=di.call(w,"constructor")&&w.constructor;return typeof M=="function"&&M instanceof M&&bn.call(M)==Ad}var Wr=O?Mt(O):Wi;function tl(x){return Hh(x,el(x))}function el(x){return Uo(x)?ur(x,!0):Yd(x)}var ap=Yh(function(x,w,M){Kh(x,w,M)});function hp(x){return function(){return x}}function T(x){return x}function R(){return!1}r.exports=ap}(Yo,Yo.exports);var Fb=Yo.exports;const Db=Gn(Fb);function kb(){const r=new Map;function t(o,a){const h=r.get(o);return h?h.add(a):r.set(o,new Set([a])),()=>i(o,a)}function e(o,a){const h=l=>{i(o,h),a(l)};t(o,h)}function i(o,a){var h;(h=r.get(o))==null||h.delete(a)}function s(o,a){var h;(h=r.get(o))==null||h.forEach(l=>l(a))}function n(){r.clear()}return{on:t,off:i,once:e,emit:s,clear:n}}const xt=kb();function Oe(r){let t;return new Promise(e=>{t=e,xt.on(r,t)}).then(e=>(xt.off(r,t),e))}let Br=null;function Ob(){Br=z.effectScope()}function Wb(){Br==null||Br.stop(),Br=null}async function Bb(){return Br||await Oe("scopeCreated")}let pr=null;const Tp={animationDuration:500,disableAnimationsThreshold:500,disableEdgesThreshold:500,styles:{colorMode:"dark",rowGap:16,columnGap:32,textDefault:"#ffffff",textInverse:"#000000",nodesPadding:16,nodeHeight:32,nodePadding:4,nodeRadius:6,nodeBorderRadius:9,nodeToggleSize:28,nodeToggleBorderRadius:6,nodeToggleBorderColor:"#51525C",nodeSelectedBorderColor:"#3fa2c3",nodeUnselectedAlpha:.2,edgeColor:"#51525C",guideLineWidth:1,guideLineColor:"#51525C",guideTextTopPadding:8,guideTextLeftPadding:8,guideTextSize:12,guideTextColor:"#ADADAD",playheadWidth:2,playheadColor:"#6272FF",node:()=>({background:"#ffffff"})}};function Ub(r){const t=Db({},Tp,r);return t.styles.node=e=>{var i,s;return{...Tp.styles.node(e),...(s=(i=r.styles)==null?void 0:i.node)==null?void 0:s.call(i,e)}},t}async function Xb(r){(await Bb()).run(()=>{z.watch(()=>r.config,e=>{const i=Ub(e);if(!pr){pr=i,xt.emit("configCreated",pr);return}Object.assign(pr,i),xt.emit("configUpdated",pr)},{immediate:!0})})}function Zb(){pr=null}async function ge(){return pr||await Oe("configCreated")}var Ur=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Ur||{}),wp=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(wp||{}),cl=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(cl||{}),ut=(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))(ut||{}),gi=(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))(gi||{}),H=(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))(H||{}),Rs=(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))(Rs||{}),at=(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))(at||{}),$=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))($||{}),Ki=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Ki||{}),Hi=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Hi||{}),yi=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(yi||{}),xe=(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))(xe||{}),bi=(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))(bi||{}),dl=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(dl||{}),We=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(We||{}),jt=(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))(jt||{}),Yt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Yt||{}),xi=(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))(xi||{});const Q={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 pl=/iPhone/i,Sp=/iPod/i,Ep=/iPad/i,Cp=/\biOS-universal(?:.+)Mac\b/i,fl=/\bAndroid(?:.+)Mobile\b/i,Ip=/Android/i,Ms=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,zo=/Silk/i,Yi=/Windows Phone/i,Ap=/\bWindows(?:.+)ARM\b/i,Rp=/BlackBerry/i,Mp=/BB10/i,Pp=/Opera Mini/i,Lp=/\b(CriOS|Chrome)(?:.+)Mobile/i,Gp=/Mobile(?:.+)Firefox\b/i,Np=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Vb(r){return function(t){return t.test(r)}}function Fp(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=Vb(e),n={apple:{phone:s(pl)&&!s(Yi),ipod:s(Sp),tablet:!s(pl)&&(s(Ep)||Np(t))&&!s(Yi),universal:s(Cp),device:(s(pl)||s(Sp)||s(Ep)||s(Cp)||Np(t))&&!s(Yi)},amazon:{phone:s(Ms),tablet:!s(Ms)&&s(zo),device:s(Ms)||s(zo)},android:{phone:!s(Yi)&&s(Ms)||!s(Yi)&&s(fl),tablet:!s(Yi)&&!s(Ms)&&!s(fl)&&(s(zo)||s(Ip)),device:!s(Yi)&&(s(Ms)||s(zo)||s(fl)||s(Ip))||s(/\bokhttp\b/i)},windows:{phone:s(Yi),tablet:s(Ap),device:s(Yi)||s(Ap)},other:{blackberry:s(Rp),blackberry10:s(Mp),opera:s(Pp),firefox:s(Gp),chrome:s(Lp),device:s(Rp)||s(Mp)||s(Pp)||s(Gp)||s(Lp)},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 Kb=Fp.default??Fp,zi=Kb(globalThis.navigator);Q.RETINA_PREFIX=/@([0-9\.]+)x/,Q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Dp={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(h,l,u){this.fn=h,this.context=l,this.once=u||!1}function n(h,l,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,c||h,d),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],p]:h._events[m].push(p):(h._events[m]=p,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,c;if(this._eventsCount===0)return l;for(c in u=this._events)t.call(u,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=e?e+l:l,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,m=new Array(p);d<p;d++)m[d]=c[d].fn;return m},a.prototype.listenerCount=function(l){var u=e?e+l:l,c=this._events[u];return c?c.fn?1:c.length:0},a.prototype.emit=function(l,u,c,d,p,m){var f=e?e+l:l;if(!this._events[f])return!1;var g=this._events[f],y=arguments.length,_,b;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,d),!0;case 5:return g.fn.call(g.context,u,c,d,p),!0;case 6:return g.fn.call(g.context,u,c,d,p,m),!0}for(b=1,_=new Array(y-1);b<y;b++)_[b-1]=arguments[b];g.fn.apply(g.context,_)}else{var v=g.length,S;for(b=0;b<v;b++)switch(g[b].once&&this.removeListener(l,g[b].fn,void 0,!0),y){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,u);break;case 3:g[b].fn.call(g[b].context,u,c);break;case 4:g[b].fn.call(g[b].context,u,c,d);break;default:if(!_)for(S=1,_=new Array(y-1);S<y;S++)_[S-1]=arguments[S];g[b].fn.apply(g[b].context,_)}}return!0},a.prototype.on=function(l,u,c){return n(this,l,u,c,!1)},a.prototype.once=function(l,u,c){return n(this,l,u,c,!0)},a.prototype.removeListener=function(l,u,c,d){var p=e?e+l:l;if(!this._events[p])return this;if(!u)return o(this,p),this;var m=this._events[p];if(m.fn)m.fn===u&&(!d||m.once)&&(!c||m.context===c)&&o(this,p);else{for(var f=0,g=[],y=m.length;f<y;f++)(m[f].fn!==u||d&&!m[f].once||c&&m[f].context!==c)&&g.push(m[f]);g.length?this._events[p]=g.length===1?g[0]:g:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=e?e+l:l,this._events[u]&&o(this,u)):(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})(Dp);var Hb=Dp.exports;const Nn=Gn(Hb);var ml={exports:{}};ml.exports=jo,ml.exports.default=jo;function jo(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=kp(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,h,l,u,c,d,p;if(i&&(n=$b(r,t,n,e)),r.length>80*e){a=l=r[0],h=u=r[1];for(var m=e;m<s;m+=e)c=r[m],d=r[m+1],c<a&&(a=c),d<h&&(h=d),c>l&&(l=c),d>u&&(u=d);p=Math.max(l-a,u-h),p=p!==0?32767/p:0}return Fn(n,o,e,a,h,p,0),o}function kp(r,t,e,i,s){var n,o;if(s===bl(r,t,e,i)>0)for(n=t;n<e;n+=i)o=Bp(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=Bp(n,r[n],r[n+1],o);return o&&Jo(o,o.next)&&(kn(o),o=o.next),o}function Xr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Jo(e,e.next)||Dt(e.prev,e,e.next)===0)){if(kn(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Fn(r,t,e,i,s,n,o){if(r){!o&&n&&ix(r,i,s,n);for(var a=r,h,l;r.prev!==r.next;){if(h=r.prev,l=r.next,n?zb(r,i,s,n):Yb(r)){t.push(h.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),kn(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=jb(Xr(r),t,e),Fn(r,t,e,i,s,n,2)):o===2&&Jb(r,t,e,i,s,n):Fn(Xr(r),t,e,i,s,n,1);break}}}}function Yb(r){var t=r.prev,e=r,i=r.next;if(Dt(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,u=s<n?s<o?s:o:n<o?n:o,c=a<h?a<l?a:l:h<l?h:l,d=s>n?s>o?s:o:n>o?n:o,p=a>h?a>l?a:l:h>l?h:l,m=i.next;m!==t;){if(m.x>=u&&m.x<=d&&m.y>=c&&m.y<=p&&Ps(s,a,n,h,o,l,m.x,m.y)&&Dt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function zb(r,t,e,i){var s=r.prev,n=r,o=r.next;if(Dt(s,n,o)>=0)return!1;for(var a=s.x,h=n.x,l=o.x,u=s.y,c=n.y,d=o.y,p=a<h?a<l?a:l:h<l?h:l,m=u<c?u<d?u:d:c<d?c:d,f=a>h?a>l?a:l:h>l?h:l,g=u>c?u>d?u:d:c>d?c:d,y=gl(p,m,t,e,i),_=gl(f,g,t,e,i),b=r.prevZ,v=r.nextZ;b&&b.z>=y&&v&&v.z<=_;){if(b.x>=p&&b.x<=f&&b.y>=m&&b.y<=g&&b!==s&&b!==o&&Ps(a,u,h,c,l,d,b.x,b.y)&&Dt(b.prev,b,b.next)>=0||(b=b.prevZ,v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&Ps(a,u,h,c,l,d,v.x,v.y)&&Dt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=f&&b.y>=m&&b.y<=g&&b!==s&&b!==o&&Ps(a,u,h,c,l,d,b.x,b.y)&&Dt(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=_;){if(v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&Ps(a,u,h,c,l,d,v.x,v.y)&&Dt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function jb(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Jo(s,n)&&Op(s,i,i.next,n)&&Dn(s,n)&&Dn(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),kn(i),kn(i.next),i=r=n),i=i.next}while(i!==r);return Xr(i)}function Jb(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&nx(o,a)){var h=Wp(o,a);o=Xr(o,o.next),h=Xr(h,h.next),Fn(o,t,e,i,s,n,0),Fn(h,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function $b(r,t,e,i){var s=[],n,o,a,h,l;for(n=0,o=t.length;n<o;n++)a=t[n]*i,h=n<o-1?t[n+1]*i:r.length,l=kp(r,a,h,i,!1),l===l.next&&(l.steiner=!0),s.push(sx(l));for(s.sort(Qb),n=0;n<s.length;n++)e=qb(s[n],e);return e}function Qb(r,t){return r.x-t.x}function qb(r,t){var e=tx(r,t);if(!e)return t;var i=Wp(e,r);return Xr(i,i.next),Xr(e,e.next)}function tx(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 h=o,l=o.x,u=o.y,c=1/0,d;e=o;do i>=e.x&&e.x>=l&&i!==e.x&&Ps(s<u?i:n,s,l,u,s<u?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Dn(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&ex(o,e)))&&(o=e,c=d)),e=e.next;while(e!==h);return o}function ex(r,t){return Dt(r.prev,r,t.prev)<0&&Dt(t.next,r,r.next)<0}function ix(r,t,e,i){var s=r;do s.z===0&&(s.z=gl(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,rx(s)}function rx(r){var t,e,i,s,n,o,a,h,l=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<l&&(a++,i=i.nextZ,!!i);t++);for(h=l;a>0||h>0&&i;)a!==0&&(h===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,h--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,l*=2}while(o>1);return r}function gl(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 sx(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 Ps(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 nx(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!ox(r,t)&&(Dn(r,t)&&Dn(t,r)&&ax(r,t)&&(Dt(r.prev,r,t.prev)||Dt(r,t.prev,t))||Jo(r,t)&&Dt(r.prev,r,r.next)>0&&Dt(t.prev,t,t.next)>0)}function Dt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Jo(r,t){return r.x===t.x&&r.y===t.y}function Op(r,t,e,i){var s=Qo(Dt(r,t,e)),n=Qo(Dt(r,t,i)),o=Qo(Dt(e,i,r)),a=Qo(Dt(e,i,t));return!!(s!==n&&o!==a||s===0&&$o(r,e,t)||n===0&&$o(r,i,t)||o===0&&$o(e,r,i)||a===0&&$o(e,t,i))}function $o(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 Qo(r){return r>0?1:r<0?-1:0}function ox(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&&Op(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Dn(r,t){return Dt(r.prev,r,r.next)<0?Dt(r,t,r.next)>=0&&Dt(r,r.prev,t)>=0:Dt(r,t,r.prev)<0||Dt(r,r.next,t)<0}function ax(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 Wp(r,t){var e=new yl(r.i,r.x,r.y),i=new yl(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 Bp(r,t,e,i){var s=new yl(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 kn(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 yl(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}jo.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(bl(r,0,n,e));if(s)for(var a=0,h=t.length;a<h;a++){var l=t[a]*e,u=a<h-1?t[a+1]*e:r.length;o-=Math.abs(bl(r,l,u,e))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,p=i[a+1]*e,m=i[a+2]*e;c+=Math.abs((r[d]-r[m])*(r[p+1]-r[d+1])-(r[d]-r[p])*(r[m+1]-r[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function bl(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}jo.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 hx=ml.exports;const lx=Gn(hx);var qo={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */qo.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof qe=="object"&&qe;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,h=36,l=1,u=26,c=38,d=700,p=72,m=128,f="-",g=/^xn--/,y=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=h-l,S=Math.floor,E=String.fromCharCode,A;function I(D){throw new RangeError(b[D])}function P(D,U){for(var j=D.length,q=[];j--;)q[j]=U(D[j]);return q}function B(D,U){var j=D.split("@"),q="";j.length>1&&(q=j[0]+"@",D=j[1]),D=D.replace(_,".");var pt=D.split("."),nt=P(pt,U).join(".");return q+nt}function G(D){for(var U=[],j=0,q=D.length,pt,nt;j<q;)pt=D.charCodeAt(j++),pt>=55296&&pt<=56319&&j<q?(nt=D.charCodeAt(j++),(nt&64512)==56320?U.push(((pt&1023)<<10)+(nt&1023)+65536):(U.push(pt),j--)):U.push(pt);return U}function N(D){return P(D,function(U){var j="";return U>65535&&(U-=65536,j+=E(U>>>10&1023|55296),U=56320|U&1023),j+=E(U),j}).join("")}function C(D){return D-48<10?D-22:D-65<26?D-65:D-97<26?D-97:h}function F(D,U){return D+22+75*(D<26)-((U!=0)<<5)}function X(D,U,j){var q=0;for(D=j?S(D/d):D>>1,D+=S(D/U);D>v*u>>1;q+=h)D=S(D/v);return S(q+(v+1)*D/(D+c))}function V(D){var U=[],j=D.length,q,pt=0,nt=m,Et=p,Rt,wt,Y,it,tt,O,bt,gt,Mt;for(Rt=D.lastIndexOf(f),Rt<0&&(Rt=0),wt=0;wt<Rt;++wt)D.charCodeAt(wt)>=128&&I("not-basic"),U.push(D.charCodeAt(wt));for(Y=Rt>0?Rt+1:0;Y<j;){for(it=pt,tt=1,O=h;Y>=j&&I("invalid-input"),bt=C(D.charCodeAt(Y++)),(bt>=h||bt>S((a-pt)/tt))&&I("overflow"),pt+=bt*tt,gt=O<=Et?l:O>=Et+u?u:O-Et,!(bt<gt);O+=h)Mt=h-gt,tt>S(a/Mt)&&I("overflow"),tt*=Mt;q=U.length+1,Et=X(pt-it,q,it==0),S(pt/q)>a-nt&&I("overflow"),nt+=S(pt/q),pt%=q,U.splice(pt++,0,nt)}return N(U)}function L(D){var U,j,q,pt,nt,Et,Rt,wt,Y,it,tt,O=[],bt,gt,Mt,Ut;for(D=G(D),bt=D.length,U=m,j=0,nt=p,Et=0;Et<bt;++Et)tt=D[Et],tt<128&&O.push(E(tt));for(q=pt=O.length,pt&&O.push(f);q<bt;){for(Rt=a,Et=0;Et<bt;++Et)tt=D[Et],tt>=U&&tt<Rt&&(Rt=tt);for(gt=q+1,Rt-U>S((a-j)/gt)&&I("overflow"),j+=(Rt-U)*gt,U=Rt,Et=0;Et<bt;++Et)if(tt=D[Et],tt<U&&++j>a&&I("overflow"),tt==U){for(wt=j,Y=h;it=Y<=nt?l:Y>=nt+u?u:Y-nt,!(wt<it);Y+=h)Ut=wt-it,Mt=h-it,O.push(E(F(it+Ut%Mt,0))),wt=S(Ut/Mt);O.push(E(F(wt,0))),nt=X(j,gt,q==pt),j=0,++q}++j,++U}return O.join("")}function k(D){return B(D,function(U){return g.test(U)?V(U.slice(4).toLowerCase()):U})}function K(D){return B(D,function(U){return y.test(U)?"xn--"+L(U):U})}if(o={version:"1.4.1",ucs2:{decode:G,encode:N},decode:V,encode:L,toASCII:K,toUnicode:k},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})(qe)}(qo,qo.exports);var ux=qo.exports,cx=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},Up=typeof Symbol<"u"&&Symbol,dx=cx,px=function(){return typeof Up!="function"||typeof Symbol!="function"||typeof Up("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:dx()},Xp={foo:{}},fx=Object,mx=function(){return{__proto__:Xp}.foo===Xp.foo&&!({__proto__:null}instanceof fx)},gx="Function.prototype.bind called on incompatible ",xl=Array.prototype.slice,yx=Object.prototype.toString,bx="[object Function]",xx=function(t){var e=this;if(typeof e!="function"||yx.call(e)!==bx)throw new TypeError(gx+e);for(var i=xl.call(arguments,1),s,n=function(){if(this instanceof s){var u=e.apply(this,i.concat(xl.call(arguments)));return Object(u)===u?u:this}else return e.apply(t,i.concat(xl.call(arguments)))},o=Math.max(0,e.length-i.length),a=[],h=0;h<o;h++)a.push("$"+h);if(s=Function("binder","return function ("+a.join(",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var l=function(){};l.prototype=e.prototype,s.prototype=new l,l.prototype=null}return s},_x=xx,_l=Function.prototype.bind||_x,vx=_l,Tx=vx.call(Function.call,Object.prototype.hasOwnProperty),Tt,Ls=SyntaxError,Zp=Function,Gs=TypeError,vl=function(r){try{return Zp('"use strict"; return ('+r+").constructor;")()}catch{}},Zr=Object.getOwnPropertyDescriptor;if(Zr)try{Zr({},"")}catch{Zr=null}var Tl=function(){throw new Gs},wx=Zr?function(){try{return arguments.callee,Tl}catch{try{return Zr(arguments,"callee").get}catch{return Tl}}}():Tl,Ns=px(),Sx=mx(),qt=Object.getPrototypeOf||(Sx?function(r){return r.__proto__}:null),Fs={},Ex=typeof Uint8Array>"u"||!qt?Tt:qt(Uint8Array),Vr={"%AggregateError%":typeof AggregateError>"u"?Tt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Tt:ArrayBuffer,"%ArrayIteratorPrototype%":Ns&&qt?qt([][Symbol.iterator]()):Tt,"%AsyncFromSyncIteratorPrototype%":Tt,"%AsyncFunction%":Fs,"%AsyncGenerator%":Fs,"%AsyncGeneratorFunction%":Fs,"%AsyncIteratorPrototype%":Fs,"%Atomics%":typeof Atomics>"u"?Tt:Atomics,"%BigInt%":typeof BigInt>"u"?Tt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Tt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Tt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Tt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?Tt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Tt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Tt:FinalizationRegistry,"%Function%":Zp,"%GeneratorFunction%":Fs,"%Int8Array%":typeof Int8Array>"u"?Tt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Tt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Tt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ns&&qt?qt(qt([][Symbol.iterator]())):Tt,"%JSON%":typeof JSON=="object"?JSON:Tt,"%Map%":typeof Map>"u"?Tt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ns||!qt?Tt:qt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Tt:Promise,"%Proxy%":typeof Proxy>"u"?Tt:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?Tt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Tt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ns||!qt?Tt:qt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Tt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ns&&qt?qt(""[Symbol.iterator]()):Tt,"%Symbol%":Ns?Symbol:Tt,"%SyntaxError%":Ls,"%ThrowTypeError%":wx,"%TypedArray%":Ex,"%TypeError%":Gs,"%Uint8Array%":typeof Uint8Array>"u"?Tt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Tt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Tt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Tt:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?Tt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Tt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Tt:WeakSet};if(qt)try{null.error}catch(r){var Cx=qt(qt(r));Vr["%Error.prototype%"]=Cx}var Ix=function r(t){var e;if(t==="%AsyncFunction%")e=vl("async function () {}");else if(t==="%GeneratorFunction%")e=vl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=vl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&qt&&(e=qt(s.prototype))}return Vr[t]=e,e},Vp={"%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"]},On=_l,ta=Tx,Ax=On.call(Function.call,Array.prototype.concat),Rx=On.call(Function.apply,Array.prototype.splice),Kp=On.call(Function.call,String.prototype.replace),ea=On.call(Function.call,String.prototype.slice),Mx=On.call(Function.call,RegExp.prototype.exec),Px=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Lx=/\\(\\)?/g,Gx=function(t){var e=ea(t,0,1),i=ea(t,-1);if(e==="%"&&i!=="%")throw new Ls("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new Ls("invalid intrinsic syntax, expected opening `%`");var s=[];return Kp(t,Px,function(n,o,a,h){s[s.length]=a?Kp(h,Lx,"$1"):o||n}),s},Nx=function(t,e){var i=t,s;if(ta(Vp,i)&&(s=Vp[i],i="%"+s[0]+"%"),ta(Vr,i)){var n=Vr[i];if(n===Fs&&(n=Ix(i)),typeof n>"u"&&!e)throw new Gs("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Ls("intrinsic "+t+" does not exist!")},wl=function(t,e){if(typeof t!="string"||t.length===0)throw new Gs("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Gs('"allowMissing" argument must be a boolean');if(Mx(/^%?[^%]*%?$/,t)===null)throw new Ls("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=Gx(t),s=i.length>0?i[0]:"",n=Nx("%"+s+"%",e),o=n.name,a=n.value,h=!1,l=n.alias;l&&(s=l[0],Rx(i,Ax([0,1],l)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],p=ea(d,0,1),m=ea(d,-1);if((p==='"'||p==="'"||p==="`"||m==='"'||m==="'"||m==="`")&&p!==m)throw new Ls("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(h=!0),s+="."+d,o="%"+s+"%",ta(Vr,o))a=Vr[o];else if(a!=null){if(!(d in a)){if(!e)throw new Gs("base intrinsic for "+t+" exists, but the property is not available.");return}if(Zr&&u+1>=i.length){var f=Zr(a,d);c=!!f,c&&"get"in f&&!("originalValue"in f.get)?a=f.get:a=a[d]}else c=ta(a,d),a=a[d];c&&!h&&(Vr[o]=a)}}return a},Hp={exports:{}};(function(r){var t=_l,e=wl,i=e("%Function.prototype.apply%"),s=e("%Function.prototype.call%"),n=e("%Reflect.apply%",!0)||t.call(s,i),o=e("%Object.getOwnPropertyDescriptor%",!0),a=e("%Object.defineProperty%",!0),h=e("%Math.max%");if(a)try{a({},"a",{value:1})}catch{a=null}r.exports=function(c){var d=n(t,s,arguments);if(o&&a){var p=o(d,"length");p.configurable&&a(d,"length",{value:1+h(0,c.length-(arguments.length-1))})}return d};var l=function(){return n(t,i,arguments)};a?a(r.exports,"apply",{value:l}):r.exports.apply=l})(Hp);var Fx=Hp.exports,Yp=wl,zp=Fx,Dx=zp(Yp("String.prototype.indexOf")),kx=function(t,e){var i=Yp(t,!!e);return typeof i=="function"&&Dx(t,".prototype.")>-1?zp(i):i};const Ox=Nb(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Sl=typeof Map=="function"&&Map.prototype,El=Object.getOwnPropertyDescriptor&&Sl?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ia=Sl&&El&&typeof El.get=="function"?El.get:null,jp=Sl&&Map.prototype.forEach,Cl=typeof Set=="function"&&Set.prototype,Il=Object.getOwnPropertyDescriptor&&Cl?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ra=Cl&&Il&&typeof Il.get=="function"?Il.get:null,Jp=Cl&&Set.prototype.forEach,Wx=typeof WeakMap=="function"&&WeakMap.prototype,Wn=Wx?WeakMap.prototype.has:null,Bx=typeof WeakSet=="function"&&WeakSet.prototype,Bn=Bx?WeakSet.prototype.has:null,Ux=typeof WeakRef=="function"&&WeakRef.prototype,$p=Ux?WeakRef.prototype.deref:null,Xx=Boolean.prototype.valueOf,Zx=Object.prototype.toString,Vx=Function.prototype.toString,Kx=String.prototype.match,Al=String.prototype.slice,fr=String.prototype.replace,Hx=String.prototype.toUpperCase,Qp=String.prototype.toLowerCase,qp=RegExp.prototype.test,tf=Array.prototype.concat,_i=Array.prototype.join,Yx=Array.prototype.slice,ef=Math.floor,Rl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ml=Object.getOwnPropertySymbols,Pl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ds=typeof Symbol=="function"&&typeof Symbol.iterator=="object",le=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ds||"symbol")?Symbol.toStringTag:null,rf=Object.prototype.propertyIsEnumerable,sf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function nf(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||qp.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-ef(-r):ef(r);if(i!==r){var s=String(i),n=Al.call(t,s.length+1);return fr.call(s,e,"$&_")+"."+fr.call(fr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fr.call(t,e,"$&_")}var Ll=Ox,of=Ll.custom,af=uf(of)?of:null,zx=function r(t,e,i,s){var n=e||{};if(mr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(mr(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=mr(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(mr(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(mr(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 df(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var h=String(t);return a?nf(t,h):h}if(typeof t=="bigint"){var l=String(t)+"n";return a?nf(t,l):l}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof t=="object")return Gl(t)?"[Array]":"[Object]";var c=d_(n,i);if(typeof s>"u")s=[];else if(cf(s,t)>=0)return"[Circular]";function d(C,F,X){if(F&&(s=Yx.call(s),s.push(F)),X){var V={depth:n.depth};return mr(n,"quoteStyle")&&(V.quoteStyle=n.quoteStyle),r(C,V,i+1,s)}return r(C,n,i+1,s)}if(typeof t=="function"&&!lf(t)){var p=r_(t),m=sa(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(m.length>0?" { "+_i.call(m,", ")+" }":"")}if(uf(t)){var f=Ds?fr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Pl.call(t);return typeof t=="object"&&!Ds?Un(f):f}if(l_(t)){for(var g="<"+Qp.call(String(t.nodeName)),y=t.attributes||[],_=0;_<y.length;_++)g+=" "+y[_].name+"="+hf(jx(y[_].value),"double",n);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+="</"+Qp.call(String(t.nodeName))+">",g}if(Gl(t)){if(t.length===0)return"[]";var b=sa(t,d);return c&&!c_(b)?"["+Fl(b,c)+"]":"[ "+_i.call(b,", ")+" ]"}if($x(t)){var v=sa(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!rf.call(t,"cause")?"{ ["+String(t)+"] "+_i.call(tf.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+_i.call(v,", ")+" }"}if(typeof t=="object"&&o){if(af&&typeof t[af]=="function"&&Ll)return Ll(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(s_(t)){var S=[];return jp&&jp.call(t,function(C,F){S.push(d(F,t,!0)+" => "+d(C,t))}),pf("Map",ia.call(t),S,c)}if(a_(t)){var E=[];return Jp&&Jp.call(t,function(C){E.push(d(C,t))}),pf("Set",ra.call(t),E,c)}if(n_(t))return Nl("WeakMap");if(h_(t))return Nl("WeakSet");if(o_(t))return Nl("WeakRef");if(qx(t))return Un(d(Number(t)));if(e_(t))return Un(d(Rl.call(t)));if(t_(t))return Un(Xx.call(t));if(Qx(t))return Un(d(String(t)));if(!Jx(t)&&!lf(t)){var A=sa(t,d),I=sf?sf(t)===Object.prototype:t instanceof Object||t.constructor===Object,P=t instanceof Object?"":"null prototype",B=!I&&le&&Object(t)===t&&le in t?Al.call(gr(t),8,-1):P?"Object":"",G=I||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",N=G+(B||P?"["+_i.call(tf.call([],B||[],P||[]),": ")+"] ":"");return A.length===0?N+"{}":c?N+"{"+Fl(A,c)+"}":N+"{ "+_i.call(A,", ")+" }"}return String(t)};function hf(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function jx(r){return fr.call(String(r),/"/g,"&quot;")}function Gl(r){return gr(r)==="[object Array]"&&(!le||!(typeof r=="object"&&le in r))}function Jx(r){return gr(r)==="[object Date]"&&(!le||!(typeof r=="object"&&le in r))}function lf(r){return gr(r)==="[object RegExp]"&&(!le||!(typeof r=="object"&&le in r))}function $x(r){return gr(r)==="[object Error]"&&(!le||!(typeof r=="object"&&le in r))}function Qx(r){return gr(r)==="[object String]"&&(!le||!(typeof r=="object"&&le in r))}function qx(r){return gr(r)==="[object Number]"&&(!le||!(typeof r=="object"&&le in r))}function t_(r){return gr(r)==="[object Boolean]"&&(!le||!(typeof r=="object"&&le in r))}function uf(r){if(Ds)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Pl)return!1;try{return Pl.call(r),!0}catch{}return!1}function e_(r){if(!r||typeof r!="object"||!Rl)return!1;try{return Rl.call(r),!0}catch{}return!1}var i_=Object.prototype.hasOwnProperty||function(r){return r in this};function mr(r,t){return i_.call(r,t)}function gr(r){return Zx.call(r)}function r_(r){if(r.name)return r.name;var t=Kx.call(Vx.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function cf(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 s_(r){if(!ia||!r||typeof r!="object")return!1;try{ia.call(r);try{ra.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function n_(r){if(!Wn||!r||typeof r!="object")return!1;try{Wn.call(r,Wn);try{Bn.call(r,Bn)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function o_(r){if(!$p||!r||typeof r!="object")return!1;try{return $p.call(r),!0}catch{}return!1}function a_(r){if(!ra||!r||typeof r!="object")return!1;try{ra.call(r);try{ia.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function h_(r){if(!Bn||!r||typeof r!="object")return!1;try{Bn.call(r,Bn);try{Wn.call(r,Wn)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function l_(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function df(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return df(Al.call(r,0,t.maxStringLength),t)+i}var s=fr.call(fr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,u_);return hf(s,"single",t)}function u_(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":"")+Hx.call(t.toString(16))}function Un(r){return"Object("+r+")"}function Nl(r){return r+" { ? }"}function pf(r,t,e,i){var s=i?Fl(e,i):_i.call(e,", ");return r+" ("+t+") {"+s+"}"}function c_(r){for(var t=0;t<r.length;t++)if(cf(r[t],`
2
2
  `)>=0)return!1;return!0}function d_(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=_i.call(Array(r.indent+1)," ");else return null;return{base:e,prev:_i.call(Array(t+1),e)}}function Fl(r,t){if(r.length===0)return"";var e=`
3
3
  `+t.prev+t.base;return e+_i.call(r,","+e)+`
4
4
  `+t.prev}function sa(r,t){var e=Gl(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=mr(r,s)?t(r[s],r):""}var n=typeof Ml=="function"?Ml(r):[],o;if(Ds){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var h in r)mr(r,h)&&(e&&String(Number(h))===h&&h<r.length||Ds&&o["$"+h]instanceof Symbol||(qp.call(/[^\w$]/,h)?i.push(t(h,r)+": "+t(r[h],r)):i.push(h+": "+t(r[h],r))));if(typeof Ml=="function")for(var l=0;l<n.length;l++)rf.call(r,n[l])&&i.push("["+t(n[l])+"]: "+t(r[n[l]],r));return i}var Dl=wl,ks=kx,p_=zx,f_=Dl("%TypeError%"),na=Dl("%WeakMap%",!0),oa=Dl("%Map%",!0),m_=ks("WeakMap.prototype.get",!0),g_=ks("WeakMap.prototype.set",!0),y_=ks("WeakMap.prototype.has",!0),b_=ks("Map.prototype.get",!0),x_=ks("Map.prototype.set",!0),__=ks("Map.prototype.has",!0),kl=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},v_=function(r,t){var e=kl(r,t);return e&&e.value},T_=function(r,t,e){var i=kl(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},w_=function(r,t){return!!kl(r,t)},S_=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new f_("Side channel does not contain "+p_(n))},get:function(n){if(na&&n&&(typeof n=="object"||typeof n=="function")){if(t)return m_(t,n)}else if(oa){if(e)return b_(e,n)}else if(i)return v_(i,n)},has:function(n){if(na&&n&&(typeof n=="object"||typeof n=="function")){if(t)return y_(t,n)}else if(oa){if(e)return __(e,n)}else if(i)return w_(i,n);return!1},set:function(n,o){na&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new na),g_(t,n,o)):oa?(e||(e=new oa),x_(e,n,o)):(i||(i={key:{},next:null}),T_(i,n,o))}};return s},E_=String.prototype.replace,C_=/%20/g,Ol={RFC1738:"RFC1738",RFC3986:"RFC3986"},Wl={default:Ol.RFC3986,formatters:{RFC1738:function(r){return E_.call(r,C_,"+")},RFC3986:function(r){return String(r)}},RFC1738:Ol.RFC1738,RFC3986:Ol.RFC3986},I_=Wl,Bl=Object.prototype.hasOwnProperty,Kr=Array.isArray,vi=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),A_=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Kr(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},ff=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},R_=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Kr(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!Bl.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 Kr(t)&&!Kr(e)&&(s=ff(t,i)),Kr(t)&&Kr(e)?(e.forEach(function(n,o){if(Bl.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 Bl.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)},P_=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}},L_=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(u){return"%26%23"+parseInt(u.slice(2),16)+"%3B"});for(var a="",h=0;h<o.length;++h){var l=o.charCodeAt(h);if(l===45||l===46||l===95||l===126||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||n===I_.RFC1738&&(l===40||l===41)){a+=o.charAt(h);continue}if(l<128){a=a+vi[l];continue}if(l<2048){a=a+(vi[192|l>>6]+vi[128|l&63]);continue}if(l<55296||l>=57344){a=a+(vi[224|l>>12]+vi[128|l>>6&63]+vi[128|l&63]);continue}h+=1,l=65536+((l&1023)<<10|o.charCodeAt(h)&1023),a+=vi[240|l>>18]+vi[128|l>>12&63]+vi[128|l>>6&63]+vi[128|l&63]}return a},G_=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),h=0;h<a.length;++h){var l=a[h],u=o[l];typeof u=="object"&&u!==null&&i.indexOf(u)===-1&&(e.push({obj:o,prop:l}),i.push(u))}return A_(e),t},N_=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},F_=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},D_=function(t,e){return[].concat(t,e)},k_=function(t,e){if(Kr(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},mf={arrayToObject:ff,assign:M_,combine:D_,compact:G_,decode:P_,encode:L_,isBuffer:F_,isRegExp:N_,maybeMap:k_,merge:R_},gf=S_,aa=mf,Xn=Wl,O_=Object.prototype.hasOwnProperty,yf={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},ji=Array.isArray,W_=Array.prototype.push,bf=function(r,t){W_.apply(r,ji(t)?t:[t])},B_=Date.prototype.toISOString,xf=Xn.default,ue={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:aa.encode,encodeValuesOnly:!1,format:xf,formatter:Xn.formatters[xf],indices:!1,serializeDate:function(t){return B_.call(t)},skipNulls:!1,strictNullHandling:!1},U_=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},Ul={},X_=function r(t,e,i,s,n,o,a,h,l,u,c,d,p,m,f,g){for(var y=t,_=g,b=0,v=!1;(_=_.get(Ul))!==void 0&&!v;){var S=_.get(t);if(b+=1,typeof S<"u"){if(S===b)throw new RangeError("Cyclic object value");v=!0}typeof _.get(Ul)>"u"&&(b=0)}if(typeof h=="function"?y=h(e,y):y instanceof Date?y=c(y):i==="comma"&&ji(y)&&(y=aa.maybeMap(y,function(V){return V instanceof Date?c(V):V})),y===null){if(n)return a&&!m?a(e,ue.encoder,f,"key",d):e;y=""}if(U_(y)||aa.isBuffer(y)){if(a){var E=m?e:a(e,ue.encoder,f,"key",d);return[p(E)+"="+p(a(y,ue.encoder,f,"value",d))]}return[p(e)+"="+p(String(y))]}var A=[];if(typeof y>"u")return A;var I;if(i==="comma"&&ji(y))m&&a&&(y=aa.maybeMap(y,a)),I=[{value:y.length>0?y.join(",")||null:void 0}];else if(ji(h))I=h;else{var P=Object.keys(y);I=l?P.sort(l):P}for(var B=s&&ji(y)&&y.length===1?e+"[]":e,G=0;G<I.length;++G){var N=I[G],C=typeof N=="object"&&typeof N.value<"u"?N.value:y[N];if(!(o&&C===null)){var F=ji(y)?typeof i=="function"?i(B,N):B:B+(u?"."+N:"["+N+"]");g.set(t,b);var X=gf();X.set(Ul,g),bf(A,r(C,F,i,s,n,o,i==="comma"&&m&&ji(y)?null:a,h,l,u,c,d,p,m,f,X))}}return A},Z_=function(t){if(!t)return ue;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||ue.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=Xn.default;if(typeof t.format<"u"){if(!O_.call(Xn.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=Xn.formatters[i],n=ue.filter;return(typeof t.filter=="function"||ji(t.filter))&&(n=t.filter),{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:ue.addQueryPrefix,allowDots:typeof t.allowDots>"u"?ue.allowDots:!!t.allowDots,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:ue.charsetSentinel,delimiter:typeof t.delimiter>"u"?ue.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:ue.encode,encoder:typeof t.encoder=="function"?t.encoder:ue.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:ue.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:ue.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:ue.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:ue.strictNullHandling}},V_=function(r,t){var e=r,i=Z_(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):ji(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a;t&&t.arrayFormat in yf?a=t.arrayFormat:t&&"indices"in t?a=t.indices?"indices":"repeat":a="indices";var h=yf[a];if(t&&"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=h==="comma"&&t&&t.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var u=gf(),c=0;c<s.length;++c){var d=s[c];i.skipNulls&&e[d]===null||bf(o,X_(e[d],d,h,l,i.strictNullHandling,i.skipNulls,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,u))}var p=o.join(i.delimiter),m=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?m+="utf8=%26%2310003%3B&":m+="utf8=%E2%9C%93&"),p.length>0?m+p:""},Os=mf,Xl=Object.prototype.hasOwnProperty,K_=Array.isArray,te={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Os.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},H_=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},_f=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},Y_="utf8=%26%2310003%3B",z_="utf8=%E2%9C%93",j_=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,n),a=-1,h,l=e.charset;if(e.charsetSentinel)for(h=0;h<o.length;++h)o[h].indexOf("utf8=")===0&&(o[h]===z_?l="utf-8":o[h]===Y_&&(l="iso-8859-1"),a=h,h=o.length);for(h=0;h<o.length;++h)if(h!==a){var u=o[h],c=u.indexOf("]="),d=c===-1?u.indexOf("="):c+1,p,m;d===-1?(p=e.decoder(u,te.decoder,l,"key"),m=e.strictNullHandling?null:""):(p=e.decoder(u.slice(0,d),te.decoder,l,"key"),m=Os.maybeMap(_f(u.slice(d+1),e),function(f){return e.decoder(f,te.decoder,l,"value")})),m&&e.interpretNumericEntities&&l==="iso-8859-1"&&(m=H_(m)),u.indexOf("[]=")>-1&&(m=K_(m)?[m]:m),Xl.call(i,p)?i[p]=Os.combine(i[p],m):i[p]=m}return i},J_=function(r,t,e,i){for(var s=i?t:_f(t,e),n=r.length-1;n>=0;--n){var o,a=r[n];if(a==="[]"&&e.parseArrays)o=[].concat(s);else{o=e.plainObjects?Object.create(null):{};var h=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,l=parseInt(h,10);!e.parseArrays&&h===""?o={0:s}:!isNaN(l)&&a!==h&&String(l)===h&&l>=0&&e.parseArrays&&l<=e.arrayLimit?(o=[],o[l]=s):h!=="__proto__"&&(o[h]=s)}s=o}return s},$_=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,h=i.depth>0&&o.exec(n),l=h?n.slice(0,h.index):n,u=[];if(l){if(!i.plainObjects&&Xl.call(Object.prototype,l)&&!i.allowPrototypes)return;u.push(l)}for(var c=0;i.depth>0&&(h=a.exec(n))!==null&&c<i.depth;){if(c+=1,!i.plainObjects&&Xl.call(Object.prototype,h[1].slice(1,-1))&&!i.allowPrototypes)return;u.push(h[1])}return h&&u.push("["+n.slice(h.index)+"]"),J_(u,e,i,s)}},Q_=function(t){if(!t)return te;if(t.decoder!==null&&t.decoder!==void 0&&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"?te.charset:t.charset;return{allowDots:typeof t.allowDots>"u"?te.allowDots:!!t.allowDots,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:te.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:te.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:te.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:te.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:te.comma,decoder:typeof t.decoder=="function"?t.decoder:te.decoder,delimiter:typeof t.delimiter=="string"||Os.isRegExp(t.delimiter)?t.delimiter:te.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:te.depth,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:te.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:te.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:te.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:te.strictNullHandling}},q_=function(r,t){var e=Q_(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?j_(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],h=$_(a,i[a],e,typeof r=="string");s=Os.merge(s,h,e)}return e.allowSparse===!0?s:Os.compact(s)},t1=V_,e1=q_,i1=Wl,r1={formats:i1,parse:e1,stringify:t1},s1=ux;function Ji(){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 n1=/^([a-z0-9.+-]+:)/i,o1=/:[0-9]*$/,a1=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,h1=["<",">",'"',"`"," ","\r",`
@@ -9,7 +9,7 @@ Deprecated since v${r}`):(i=i.split(`
9
9
  Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
10
10
  Deprecated since v${r}`),console.warn(i))),Sf[t]=!0}function ti(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Zn(r){return r.split("?")[0].split("#")[0]}function f1(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function m1(r,t,e){return r.replace(new RegExp(f1(t),"g"),e)}function g1(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 h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),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}}t&&(e.length>0?e+="/..":e="..",i=2)}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 Jt={toPosix(r){return m1(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){ti(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(ti(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Zn(this.toPosix(t??Q.ADAPTER.getBaseUrl())),s=Zn(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Jt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(ti(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=g1(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return ti(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(ti(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.extname(s)?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(ti(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){ti(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){ti(r),t&&ti(t),r=Zn(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 h=r.charCodeAt(n);if(h===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(h===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){ti(r),r=Zn(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){ti(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Zn(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,h=!0,l=r.length-1,u=0;for(;l>=s;--l){if(e=r.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||a===-1||u===0||u===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:":"};let Hl;async function y1(){return Hl??(Hl=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return xe.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 xe.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]?xe.PMA:xe.UNPACK})()),Hl}let Yl;function b1(){return typeof Yl>"u"&&(Yl=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:Q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!Q.ADAPTER.getWebGLRenderingContext())return!1;const e=Q.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}}()),Yl}var x1={grad:.9,turn:360,rad:360/(2*Math.PI)},$i=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},ee=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Be=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Ef=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Cf=function(r){return{r:Be(r.r,0,255),g:Be(r.g,0,255),b:Be(r.b,0,255),a:Be(r.a)}},zl=function(r){return{r:ee(r.r),g:ee(r.g),b:ee(r.b),a:ee(r.a,3)}},_1=/^#([0-9a-f]{3,8})$/i,ha=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},If=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}},Af=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),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:s}},Rf=function(r){return{h:Ef(r.h),s:Be(r.s,0,100),l:Be(r.l,0,100),a:Be(r.a)}},Mf=function(r){return{h:ee(r.h),s:ee(r.s),l:ee(r.l),a:ee(r.a,3)}},Pf=function(r){return Af((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},Vn=function(r){return{h:(t=If(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},v1=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,T1=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,w1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,S1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jl={string:[[function(r){var t=_1.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?ee(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?ee(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=w1.exec(r)||S1.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Cf({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=v1.exec(r)||T1.exec(r);if(!t)return null;var e,i,s=Rf({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(x1[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Pf(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 $i(t)&&$i(e)&&$i(i)?Cf({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(!$i(t)||!$i(e)||!$i(i))return null;var o=Rf({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Pf(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!$i(t)||!$i(e)||!$i(i))return null;var o=function(a){return{h:Ef(a.h),s:Be(a.s,0,100),v:Be(a.v,0,100),a:Be(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Af(o)},"hsv"]]},Lf=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]},E1=function(r){return typeof r=="string"?Lf(r.trim(),jl.string):typeof r=="object"&&r!==null?Lf(r,jl.object):[null,void 0]},Jl=function(r,t){var e=Vn(r);return{h:e.h,s:Be(e.s+100*t,0,100),l:e.l,a:e.a}},$l=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Gf=function(r,t){var e=Vn(r);return{h:e.h,s:e.s,l:Be(e.l+100*t,0,100),a:e.a}},Ql=function(){function r(t){this.parsed=E1(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 ee($l(this.rgba),2)},r.prototype.isDark=function(){return $l(this.rgba)<.5},r.prototype.isLight=function(){return $l(this.rgba)>=.5},r.prototype.toHex=function(){return t=zl(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?ha(ee(255*n)):"","#"+ha(e)+ha(i)+ha(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return zl(this.rgba)},r.prototype.toRgbString=function(){return t=zl(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 Mf(Vn(this.rgba))},r.prototype.toHslString=function(){return t=Mf(Vn(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=If(this.rgba),{h:ee(t.h),s:ee(t.s),v:ee(t.v),a:ee(t.a,3)};var t},r.prototype.invert=function(){return Ti({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),Ti(Jl(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ti(Jl(this.rgba,-t))},r.prototype.grayscale=function(){return Ti(Jl(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Ti(Gf(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Ti(Gf(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"?Ti({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ee(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Vn(this.rgba);return typeof t=="number"?Ti({h:t,s:e.s,l:e.l,a:e.a}):ee(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Ti(t).toHex()},r}(),Ti=function(r){return r instanceof Ql?r:new Ql(r)},Nf=[],C1=function(r){r.forEach(function(t){Nf.indexOf(t)<0&&(t(Ql,jl),Nf.push(t))})};function I1(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,h,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var m in e){var f=(a=u,h=n[m],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));f<c&&(c=f,d=m)}return d}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new r(h).toRgb():null},"name"])}C1([I1]);const Bs=class sl{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 sl)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]=sl.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=sl.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ti(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)}};Bs.shared=new Bs,Bs.temp=new Bs,Bs.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Gt=Bs;function A1(r){return vt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Gt.shared.setValue(r).toHex()}function R1(r){return vt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Gt.shared.setValue(r).toNumber()}function M1(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[ut.NORMAL_NPM]=ut.NORMAL,r[ut.ADD_NPM]=ut.ADD,r[ut.SCREEN_NPM]=ut.SCREEN,t[ut.NORMAL]=ut.NORMAL_NPM,t[ut.ADD]=ut.ADD_NPM,t[ut.SCREEN]=ut.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Ff=M1();function Df(r,t){return Ff[t?1:0][r]}function P1(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 kf(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 la(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 Of(r){return!(r&r-1)&&!!r}function Wf(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 Us(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 yr(r){return r===0?0:r<0?-1:1}let L1=0;function Hr(){return++L1}const ql=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}};ql.EMPTY=new ql(0,0,0,0);let Bf=ql;const Uf={},wi=Object.create(null),br=Object.create(null);class G1{constructor(t,e,i){this._canvas=Q.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||Q.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 Xf(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 Zf(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 N1(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,h=e-1;for(;o<e&&Xf(s,t,o);)++o;if(o===e)return Bf.EMPTY;for(;Xf(s,t,h);)--h;for(;Zf(s,t,n,o,h);)++n;for(;Zf(s,t,a,o,h);)--a;return++a,++h,new Bf(n,o,a,h)}function F1(r){const t=N1(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 D1(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 Qi(r,t=1){var i;const e=(i=Q.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var J=(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))(J||{});const tu=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},Vf=(r,t)=>tu(r).priority??t,et={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(tu).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(tu).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,s=this._queue;i[e]?i[e](t):(s[e]=s[e]||[],s[e].push(t))})}),this},handle(r,t,e){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]&&(n[r].forEach(o=>t(o)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{t[e.name]=e.ref},e=>{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)=>Vf(n,e)-Vf(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class eu{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 k1=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
11
  `);function O1(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 W1(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=k1.replace(/%forloop%/gi,O1(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const iu=0,ru=1,su=2,nu=3,ou=4,au=5;class Si{constructor(){this.data=0,this.blendMode=ut.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<iu)}set blend(t){!!(this.data&1<<iu)!==t&&(this.data^=1<<iu)}get offsets(){return!!(this.data&1<<ru)}set offsets(t){!!(this.data&1<<ru)!==t&&(this.data^=1<<ru)}get culling(){return!!(this.data&1<<su)}set culling(t){!!(this.data&1<<su)!==t&&(this.data^=1<<su)}get depthTest(){return!!(this.data&1<<nu)}set depthTest(t){!!(this.data&1<<nu)!==t&&(this.data^=1<<nu)}get depthMask(){return!!(this.data&1<<au)}set depthMask(t){!!(this.data&1<<au)!==t&&(this.data^=1<<au)}get clockwiseFrontFace(){return!!(this.data&1<<ou)}set clockwiseFrontFace(t){!!(this.data&1<<ou)!==t&&(this.data^=1<<ou)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==ut.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Si;return t.depthTest=!1,t.blend=!0,t}}Si.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const hu=[];function Kf(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=hu.length-1;i>=0;--i){const s=hu[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ei{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][l](t,e,i,s,n,o,a,h);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(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=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(ei.prototype,{dispatch:{value:ei.prototype.emit},run:{value:ei.prototype.emit}});class Kn{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ei("setRealSize"),this.onUpdate=new ei("update"),this.onError=new ei("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 ua extends Kn{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===xe.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 B1={scaleMode:Ki.NEAREST,alphaMode:xe.NPM},lu=class An extends Nn{constructor(t=null,e=null){super(),e=Object.assign({},An.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:h,wrapMode:l,format:u,type:c,target:d,resolution:p,resourceOptions:m}=e;t&&!(t instanceof Kn)&&(t=Kf(t,m),t.internal=!0),this.resolution=p||Q.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((h||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=l,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Hr(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&h>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=Of(this.realWidth)&&Of(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 br[this.cacheId],delete wi[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),An.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=Q.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}_${Hr()}`}n=t._pixiId}let o=br[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new An(t,e),o.cacheId=n,An.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new ua(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=H.RGBA,a=at.FLOAT):t instanceof Int32Array?(o=H.RGBA_INTEGER,a=at.INT):t instanceof Uint32Array?(o=H.RGBA_INTEGER,a=at.UNSIGNED_INT):t instanceof Int16Array?(o=H.RGBA_INTEGER,a=at.SHORT):t instanceof Uint16Array?(o=H.RGBA_INTEGER,a=at.UNSIGNED_SHORT):t instanceof Int8Array?(o=H.RGBA,a=at.BYTE):(o=H.RGBA,a=at.UNSIGNED_BYTE),n.internal=!0,new An(n,Object.assign({},B1,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),br[e]&&br[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),br[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=br[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete br[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete br[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};lu.defaultOptions={mipmap:yi.POW2,anisotropicLevel:0,scaleMode:Ki.LINEAR,wrapMode:Hi.CLAMP,alphaMode:xe.UNPACK,target:Rs.TEXTURE_2D,format:H.RGBA,type:at.UNSIGNED_BYTE},lu._globalBatch=0;let ft=lu;class uu{constructor(){this.texArray=null,this.blend=0,this.type=gi.TRIANGLES,this.start=0,this.size=0,this.data=null}}let U1=0;class Kt{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=U1++,this.disposeRunner=new ei("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?xi.ELEMENT_ARRAY_BUFFER:xi.ARRAY_BUFFER}get index(){return this.type===xi.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Kt(t)}}class ca{constructor(t,e=0,i=!1,s=at.FLOAT,n,o,a,h=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=h}destroy(){this.buffer=null}static from(t,e,i,s,n){return new ca(t,e,i,s,n)}}const X1={Float32Array,Uint32Array,Int32Array,Uint8Array};function Z1(r,t){let e=0,i=0;const s={};for(let h=0;h<r.length;h++)i+=t[h],e+=r[h].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let h=0;h<r.length;h++){const l=t[h],u=r[h],c=kf(u);s[c]||(s[c]=new X1[c](n)),o=s[c];for(let d=0;d<u.length;d++){const p=(d/l|0)*i+a,m=d%l;o[p+m]=u[d]}a+=l}return new Float32Array(n)}const Hf={5126:4,5123:2,5121:1};let V1=0;const K1={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class xr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=V1++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ei("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Kt||(e instanceof Array&&(e=new Float32Array(e)),e=new Kt(e));const l=t.split("|");if(l.length>1){for(let c=0;c<l.length;c++)this.addAttribute(l[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new ca(u,i,s,n,o,a,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Kt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Kt(t)),t.type=xi.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 Kt;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*Hf[n.type]/4),n.buffer=0}for(i.data=Z1(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 xr;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Kt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new ca(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=xi.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new xr,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)s[h]=s[h]||0,s[h]+=o.buffers[h].data.length,n[h]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new K1[kf(o.buffers[a].data)](s[a]),e.buffers[a]=new Kt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)i[h].set(o.buffers[h].data,n[h]),n[h]+=o.buffers[h].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=xi.ELEMENT_ARRAY_BUFFER;let a=0,h=0,l=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(h+=d.size*Hf[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let p=0;p<d.length;p++)e.indexBuffer.data[p+l]+=a;a+=t[c].buffers[u].data.length/h,l+=d.length}}return e}}class Yf extends xr{constructor(t=!1){super(),this._buffer=new Kt(null,t,!1),this._indexBuffer=new Kt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,at.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,at.FLOAT).addAttribute("aColor",this._buffer,4,!0,at.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,at.FLOAT).addIndex(this._indexBuffer)}}const da=Math.PI*2,H1=180/Math.PI,Y1=Math.PI/180;var ae=(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))(ae||{});class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(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}}lt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const pa=[new lt,new lt,new lt,new lt];class ct{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=ae.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 ct(0,0,0,0)}clone(){return new ct(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 I=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=I)return!1;const P=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>P}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=pa[0].set(t.left,t.top),h=pa[1].set(t.left,t.bottom),l=pa[2].set(t.right,t.top),u=pa[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(u,u),Math.max(a.x,h.x,l.x,u.x)<=i||Math.min(a.x,h.x,l.x,u.x)>=s||Math.max(a.y,h.y,l.y,u.y)<=n||Math.min(a.y,h.y,l.y,u.y)>=o))return!1;const d=c*(h.y-a.y),p=c*(a.x-h.x),m=d*i+p*n,f=d*s+p*n,g=d*i+p*o,y=d*s+p*o;if(Math.max(m,f,g,y)<=d*a.x+p*a.y||Math.min(m,f,g,y)>=d*u.x+p*u.y)return!1;const _=c*(a.y-l.y),b=c*(l.x-a.x),v=_*i+b*n,S=_*s+b*n,E=_*i+b*o,A=_*s+b*o;return!(Math.max(v,S,E,A)<=_*a.x+b*a.y||Math.min(v,S,E,A)>=_*u.x+b*u.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}}ct.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class fa{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=ae.CIRC}clone(){return new fa(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 ct(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}fa.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class ma{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=ae.ELIP}clone(){return new ma(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 ct(this.x-this.width,this.y-this.height,this.width,this.height)}}ma.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Yr{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=ae.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Yr(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],h=this.points[n*2+1],l=this.points[o*2],u=this.points[o*2+1];h>e!=u>e&&t<(l-a)*((e-h)/(u-h))+a&&(i=!i)}return i}}Yr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class ga{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=ae.RREC}clone(){return new ga(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}}ga.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Nt{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 lt;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 lt;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,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*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),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(da-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),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 Nt;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 Nt}static get TEMP_MATRIX(){return new Nt}}Nt.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 zr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],jr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Jr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$r=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],cu=[],zf=[],ya=Math.sign;function z1(){for(let r=0;r<16;r++){const t=[];cu.push(t);for(let e=0;e<16;e++){const i=ya(zr[r]*zr[e]+Jr[r]*jr[e]),s=ya(jr[r]*zr[e]+$r[r]*jr[e]),n=ya(zr[r]*Jr[e]+Jr[r]*$r[e]),o=ya(jr[r]*Jr[e]+$r[r]*$r[e]);for(let a=0;a<16;a++)if(zr[a]===i&&jr[a]===s&&Jr[a]===n&&$r[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Nt;t.set(zr[r],jr[r],Jr[r],$r[r],0,0),zf.push(t)}}z1();const kt={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=>zr[r],uY:r=>jr[r],vX:r=>Jr[r],vY:r=>$r[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>cu[r][t],sub:(r,t)=>cu[r][kt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?kt.S:kt.N:Math.abs(t)*2<=Math.abs(r)?r>0?kt.E:kt.W:t>0?r>0?kt.SE:kt.SW:r>0?kt.NE:kt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=zf[kt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class qi{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 qi(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))}}qi.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const du=class{constructor(){this.worldTransform=new Nt,this.localTransform=new Nt,this.position=new qi(this.onChange,this,0,0),this.scale=new qi(this.onChange,this,1,1),this.pivot=new qi(this.onChange,this,0,0),this.skew=new qi(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())}};du.IDENTITY=new du;let pu=du;pu.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 j1=`varying vec2 vTextureCoord;
12
+ else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function W1(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=k1.replace(/%forloop%/gi,O1(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const iu=0,ru=1,su=2,nu=3,ou=4,au=5;class Si{constructor(){this.data=0,this.blendMode=ut.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<iu)}set blend(t){!!(this.data&1<<iu)!==t&&(this.data^=1<<iu)}get offsets(){return!!(this.data&1<<ru)}set offsets(t){!!(this.data&1<<ru)!==t&&(this.data^=1<<ru)}get culling(){return!!(this.data&1<<su)}set culling(t){!!(this.data&1<<su)!==t&&(this.data^=1<<su)}get depthTest(){return!!(this.data&1<<nu)}set depthTest(t){!!(this.data&1<<nu)!==t&&(this.data^=1<<nu)}get depthMask(){return!!(this.data&1<<au)}set depthMask(t){!!(this.data&1<<au)!==t&&(this.data^=1<<au)}get clockwiseFrontFace(){return!!(this.data&1<<ou)}set clockwiseFrontFace(t){!!(this.data&1<<ou)!==t&&(this.data^=1<<ou)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==ut.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Si;return t.depthTest=!1,t.blend=!0,t}}Si.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const hu=[];function Kf(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=hu.length-1;i>=0;--i){const s=hu[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ei{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][l](t,e,i,s,n,o,a,h);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(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=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(ei.prototype,{dispatch:{value:ei.prototype.emit},run:{value:ei.prototype.emit}});class Kn{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ei("setRealSize"),this.onUpdate=new ei("update"),this.onError=new ei("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 ua extends Kn{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===xe.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 B1={scaleMode:Ki.NEAREST,alphaMode:xe.NPM},lu=class An extends Nn{constructor(t=null,e=null){super(),e=Object.assign({},An.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:h,wrapMode:l,format:u,type:c,target:d,resolution:p,resourceOptions:m}=e;t&&!(t instanceof Kn)&&(t=Kf(t,m),t.internal=!0),this.resolution=p||Q.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((h||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=l,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Hr(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&h>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=Of(this.realWidth)&&Of(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 br[this.cacheId],delete wi[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),An.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=Q.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}_${Hr()}`}n=t._pixiId}let o=br[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new An(t,e),o.cacheId=n,An.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new ua(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=H.RGBA,a=at.FLOAT):t instanceof Int32Array?(o=H.RGBA_INTEGER,a=at.INT):t instanceof Uint32Array?(o=H.RGBA_INTEGER,a=at.UNSIGNED_INT):t instanceof Int16Array?(o=H.RGBA_INTEGER,a=at.SHORT):t instanceof Uint16Array?(o=H.RGBA_INTEGER,a=at.UNSIGNED_SHORT):t instanceof Int8Array?(o=H.RGBA,a=at.BYTE):(o=H.RGBA,a=at.UNSIGNED_BYTE),n.internal=!0,new An(n,Object.assign({},B1,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),br[e]&&br[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),br[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=br[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete br[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete br[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};lu.defaultOptions={mipmap:yi.POW2,anisotropicLevel:0,scaleMode:Ki.LINEAR,wrapMode:Hi.CLAMP,alphaMode:xe.UNPACK,target:Rs.TEXTURE_2D,format:H.RGBA,type:at.UNSIGNED_BYTE},lu._globalBatch=0;let mt=lu;class uu{constructor(){this.texArray=null,this.blend=0,this.type=gi.TRIANGLES,this.start=0,this.size=0,this.data=null}}let U1=0;class Kt{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=U1++,this.disposeRunner=new ei("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?xi.ELEMENT_ARRAY_BUFFER:xi.ARRAY_BUFFER}get index(){return this.type===xi.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Kt(t)}}class ca{constructor(t,e=0,i=!1,s=at.FLOAT,n,o,a,h=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=h}destroy(){this.buffer=null}static from(t,e,i,s,n){return new ca(t,e,i,s,n)}}const X1={Float32Array,Uint32Array,Int32Array,Uint8Array};function Z1(r,t){let e=0,i=0;const s={};for(let h=0;h<r.length;h++)i+=t[h],e+=r[h].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let h=0;h<r.length;h++){const l=t[h],u=r[h],c=kf(u);s[c]||(s[c]=new X1[c](n)),o=s[c];for(let d=0;d<u.length;d++){const p=(d/l|0)*i+a,m=d%l;o[p+m]=u[d]}a+=l}return new Float32Array(n)}const Hf={5126:4,5123:2,5121:1};let V1=0;const K1={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class xr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=V1++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ei("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Kt||(e instanceof Array&&(e=new Float32Array(e)),e=new Kt(e));const l=t.split("|");if(l.length>1){for(let c=0;c<l.length;c++)this.addAttribute(l[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new ca(u,i,s,n,o,a,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Kt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Kt(t)),t.type=xi.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 Kt;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*Hf[n.type]/4),n.buffer=0}for(i.data=Z1(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 xr;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Kt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new ca(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=xi.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new xr,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)s[h]=s[h]||0,s[h]+=o.buffers[h].data.length,n[h]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new K1[kf(o.buffers[a].data)](s[a]),e.buffers[a]=new Kt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)i[h].set(o.buffers[h].data,n[h]),n[h]+=o.buffers[h].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=xi.ELEMENT_ARRAY_BUFFER;let a=0,h=0,l=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(h+=d.size*Hf[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let p=0;p<d.length;p++)e.indexBuffer.data[p+l]+=a;a+=t[c].buffers[u].data.length/h,l+=d.length}}return e}}class Yf extends xr{constructor(t=!1){super(),this._buffer=new Kt(null,t,!1),this._indexBuffer=new Kt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,at.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,at.FLOAT).addAttribute("aColor",this._buffer,4,!0,at.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,at.FLOAT).addIndex(this._indexBuffer)}}const da=Math.PI*2,H1=180/Math.PI,Y1=Math.PI/180;var ae=(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))(ae||{});class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(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}}lt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const pa=[new lt,new lt,new lt,new lt];class ct{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=ae.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 ct(0,0,0,0)}clone(){return new ct(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 I=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=I)return!1;const P=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>P}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=pa[0].set(t.left,t.top),h=pa[1].set(t.left,t.bottom),l=pa[2].set(t.right,t.top),u=pa[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(u,u),Math.max(a.x,h.x,l.x,u.x)<=i||Math.min(a.x,h.x,l.x,u.x)>=s||Math.max(a.y,h.y,l.y,u.y)<=n||Math.min(a.y,h.y,l.y,u.y)>=o))return!1;const d=c*(h.y-a.y),p=c*(a.x-h.x),m=d*i+p*n,f=d*s+p*n,g=d*i+p*o,y=d*s+p*o;if(Math.max(m,f,g,y)<=d*a.x+p*a.y||Math.min(m,f,g,y)>=d*u.x+p*u.y)return!1;const _=c*(a.y-l.y),b=c*(l.x-a.x),v=_*i+b*n,S=_*s+b*n,E=_*i+b*o,A=_*s+b*o;return!(Math.max(v,S,E,A)<=_*a.x+b*a.y||Math.min(v,S,E,A)>=_*u.x+b*u.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}}ct.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class fa{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=ae.CIRC}clone(){return new fa(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 ct(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}fa.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class ma{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=ae.ELIP}clone(){return new ma(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 ct(this.x-this.width,this.y-this.height,this.width,this.height)}}ma.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Yr{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=ae.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Yr(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],h=this.points[n*2+1],l=this.points[o*2],u=this.points[o*2+1];h>e!=u>e&&t<(l-a)*((e-h)/(u-h))+a&&(i=!i)}return i}}Yr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class ga{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=ae.RREC}clone(){return new ga(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}}ga.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Nt{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 lt;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 lt;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,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*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),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(da-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),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 Nt;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 Nt}static get TEMP_MATRIX(){return new Nt}}Nt.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 zr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],jr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Jr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$r=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],cu=[],zf=[],ya=Math.sign;function z1(){for(let r=0;r<16;r++){const t=[];cu.push(t);for(let e=0;e<16;e++){const i=ya(zr[r]*zr[e]+Jr[r]*jr[e]),s=ya(jr[r]*zr[e]+$r[r]*jr[e]),n=ya(zr[r]*Jr[e]+Jr[r]*$r[e]),o=ya(jr[r]*Jr[e]+$r[r]*$r[e]);for(let a=0;a<16;a++)if(zr[a]===i&&jr[a]===s&&Jr[a]===n&&$r[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Nt;t.set(zr[r],jr[r],Jr[r],$r[r],0,0),zf.push(t)}}z1();const kt={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=>zr[r],uY:r=>jr[r],vX:r=>Jr[r],vY:r=>$r[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>cu[r][t],sub:(r,t)=>cu[r][kt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?kt.S:kt.N:Math.abs(t)*2<=Math.abs(r)?r>0?kt.E:kt.W:t>0?r>0?kt.SE:kt.SW:r>0?kt.NE:kt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=zf[kt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class qi{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 qi(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))}}qi.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const du=class{constructor(){this.worldTransform=new Nt,this.localTransform=new Nt,this.position=new qi(this.onChange,this,0,0),this.scale=new qi(this.onChange,this,1,1),this.pivot=new qi(this.onChange,this,0,0),this.skew=new qi(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())}};du.IDENTITY=new du;let pu=du;pu.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 j1=`varying vec2 vTextureCoord;
13
13
 
14
14
  uniform sampler2D uSampler;
15
15
 
@@ -342,7 +342,7 @@ void main(void){
342
342
  vTextureId = aTextureId;
343
343
  vColor = aColor * tint;
344
344
  }
345
- `;const Yn=class mi extends va{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Yf,this.vertexSize=6,this.state=Si.for2d(),this.size=mi.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??lv(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??hv(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return vt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return cv}static get defaultFragmentTemplate(){return uv}setShaderGenerator({vertex:t=mi.defaultVertexSrc,fragment:e=mi.defaultFragmentTemplate}={}){this.shaderGenerator=new av(t,e)}contextChange(){const t=this.renderer.gl;Q.PREFER_ENV===Ur.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),mi.defaultMaxTextures),this.maxTextures=W1(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}=mi,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new uu);for(;e.length<s;)e.push(new gu);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=mi._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++ft._globalBatch,h=0,l=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==a&&(l.count>=e&&(s.boundArray(l,n,a,e),this.buildDrawCalls(l,u,c),u=c,l=i[++h],++a),d._batchEnabled=a,d.touched=o,l.elements[l.count++]=d)}l.count>0&&(s.boundArray(l,n,a,e),this.buildDrawCalls(l,u,this._bufferSize),++h,++a);for(let c=0;c<n.length;c++)n[c]=null;ft._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,h=mi._drawCallPool;let l=this._dcIndex,u=this._aIndex,c=this._iIndex,d=h[l];d.start=this._iIndex,d.texArray=t;for(let p=e;p<i;++p){const m=s[p],f=m._texture.baseTexture,g=Ff[f.alphaMode?1:0][m.blendMode];s[p]=null,e<p&&d.blend!==g&&(d.size=c-d.start,e=p,d=h[++l],d.texArray=t,d.start=c),this.packInterleavedGeometry(m,n,o,u,c),u+=m.vertexData.length/2*a,c+=m.indices.length,d.blend=g}e<i&&(d.size=c-d.start,++l),this._dcIndex=l,this._aIndex=u,this._iIndex=c}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;mi.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=mi._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:h,size:l,start:u,blend:c}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),e.drawElements(h,l,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),mi.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=la(Math.ceil(t/8)),i=Wf(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 eu(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=la(Math.ceil(t/12)),i=Wf(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,h=s/this.vertexSize,l=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,p=Math.min(t.worldAlpha,1),m=Gt.shared.setValue(t._tintRGB).toPremultiplied(p,t._texture.baseTexture.alphaMode>0);for(let f=0;f<c.length;f+=2)a[s++]=c[f],a[s++]=c[f+1],a[s++]=l[f],a[s++]=l[f+1],o[s++]=m,a[s++]=d;for(let f=0;f<u.length;f++)i[n++]=h+u[f]}};Yn.defaultBatchSize=4096,Yn.extension={name:"batch",type:J.RendererPlugin},Yn._drawCallPool=[],Yn._textureArrayPool=[];let Qr=Yn;et.add(Qr);var dv=`varying vec2 vTextureCoord;
345
+ `;const Yn=class mi extends va{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Yf,this.vertexSize=6,this.state=Si.for2d(),this.size=mi.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??lv(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??hv(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return vt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return cv}static get defaultFragmentTemplate(){return uv}setShaderGenerator({vertex:t=mi.defaultVertexSrc,fragment:e=mi.defaultFragmentTemplate}={}){this.shaderGenerator=new av(t,e)}contextChange(){const t=this.renderer.gl;Q.PREFER_ENV===Ur.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),mi.defaultMaxTextures),this.maxTextures=W1(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}=mi,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new uu);for(;e.length<s;)e.push(new gu);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=mi._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++mt._globalBatch,h=0,l=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==a&&(l.count>=e&&(s.boundArray(l,n,a,e),this.buildDrawCalls(l,u,c),u=c,l=i[++h],++a),d._batchEnabled=a,d.touched=o,l.elements[l.count++]=d)}l.count>0&&(s.boundArray(l,n,a,e),this.buildDrawCalls(l,u,this._bufferSize),++h,++a);for(let c=0;c<n.length;c++)n[c]=null;mt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,h=mi._drawCallPool;let l=this._dcIndex,u=this._aIndex,c=this._iIndex,d=h[l];d.start=this._iIndex,d.texArray=t;for(let p=e;p<i;++p){const m=s[p],f=m._texture.baseTexture,g=Ff[f.alphaMode?1:0][m.blendMode];s[p]=null,e<p&&d.blend!==g&&(d.size=c-d.start,e=p,d=h[++l],d.texArray=t,d.start=c),this.packInterleavedGeometry(m,n,o,u,c),u+=m.vertexData.length/2*a,c+=m.indices.length,d.blend=g}e<i&&(d.size=c-d.start,++l),this._dcIndex=l,this._aIndex=u,this._iIndex=c}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;mi.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=mi._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:h,size:l,start:u,blend:c}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),e.drawElements(h,l,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),mi.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=la(Math.ceil(t/8)),i=Wf(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 eu(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=la(Math.ceil(t/12)),i=Wf(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,h=s/this.vertexSize,l=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,p=Math.min(t.worldAlpha,1),m=Gt.shared.setValue(t._tintRGB).toPremultiplied(p,t._texture.baseTexture.alphaMode>0);for(let f=0;f<c.length;f+=2)a[s++]=c[f],a[s++]=c[f+1],a[s++]=l[f],a[s++]=l[f+1],o[s++]=m,a[s++]=d;for(let f=0;f<u.length;f++)i[n++]=h+u[f]}};Yn.defaultBatchSize=4096,Yn.extension={name:"batch",type:J.RendererPlugin},Yn._drawCallPool=[],Yn._textureArrayPool=[];let Qr=Yn;et.add(Qr);var dv=`varying vec2 vTextureCoord;
346
346
 
347
347
  uniform sampler2D uSampler;
348
348
 
@@ -375,7 +375,7 @@ void main(void)
375
375
  gl_Position = filterVertexPosition();
376
376
  vTextureCoord = filterTextureCoord();
377
377
  }
378
- `;const yu=class Xo extends Ei{constructor(t,e,i){const s=tr.from(t||Xo.defaultVertexSrc,e||Xo.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=Xo.defaultResolution,this.multisample=Xo.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Si}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 pv}static get defaultFragmentSrc(){return dv}};yu.defaultResolution=1,yu.defaultMultisample=Yt.NONE;let ye=yu;class Ta{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Gt(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(){}}Ta.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Ta.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"background"},et.add(Ta);class rm{constructor(t){this.renderer=t,this.emptyRenderer=new va(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 h=0;for(let l=0;l<a;l++){const u=n[l],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){o[l]=c;continue}for(;h<s;){const d=e[h];if(d&&d._batchEnabled===i&&d._batchLocation===h){h++;continue}o[l]=h,u._batchLocation=h,e[h]=u;break}}}destroy(){this.renderer=null}}rm.extension={type:J.RendererSystem,name:"batch"},et.add(rm);let sm=0;class wa{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=sm++}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=sm++,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(Q.PREFER_ENV>=Ur.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")};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")}}wa.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},wa.extension={type:J.RendererSystem,name:"context"},et.add(wa);class bu{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 ei("disposeFramebuffer"),this.multisample=Yt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new ft(null,{scaleMode:Ki.NEAREST,resolution:1,mipmap:yi.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new ft(null,{scaleMode:Ki.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:yi.OFF,format:H.DEPTH_COMPONENT,type:at.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 nm extends ft{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=Yt.NONE),super(null,t),this.mipmap=yi.OFF,this.valid=!0,this._clear=new Gt([0,0,0,0]),this.framebuffer=new bu(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 _r extends Kn{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.width,s=e.naturalHeight||e.videoHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=D1(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===xe.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 om extends _r{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;_r.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??Q.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===xe.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 xu{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,h=t.x/s+o,l=t.y/n+a;i=kt.add(i,kt.NW),this.x0=h+o*kt.uX(i),this.y0=l+a*kt.uY(i),i=kt.add(i,2),this.x1=h+o*kt.uX(i),this.y1=l+a*kt.uY(i),i=kt.add(i,2),this.x2=h+o*kt.uX(i),this.y2=l+a*kt.uY(i),i=kt.add(i,2),this.x3=h+o*kt.uX(i),this.y3=l+a*kt.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}}xu.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 am=new xu;function Sa(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class rt extends Nn{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new ct(0,0,1,1)),t instanceof rt&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=am,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 lt(o.x,o.y):new lt(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&&wi[e.url]&&rt.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,rt.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 rt(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===am&&(this._uvs=new xu),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=Q.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof ft){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Hr()}`,ft.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Hr()}`}n=t._pixiId}let o=wi[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof ft)?(e.resolution||(e.resolution=Qi(t)),o=new rt(new ft(t,e)),o.baseTexture.cacheId=n,ft.addToCache(o.baseTexture,n),rt.addToCache(o,n)):!o&&t instanceof ft&&(o=new rt(t),rt.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=rt.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 rt(ft.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new ft(t,Object.assign({scaleMode:ft.defaultOptions.scaleMode,resolution:Qi(e)},s)),{resource:o}=n;o instanceof om&&(o.url=e);const a=new rt(n);return i||(i=e),ft.addToCache(a.baseTexture,i),rt.addToCache(a,i),i!==e&&(ft.addToCache(a.baseTexture,e),rt.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(h=>{a.baseTexture.once("loaded",()=>h(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),wi[e]&&wi[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),wi[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=wi[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete wi[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)wi[t.textureCacheIds[e]]===t&&delete wi[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 h=o&&a?"and":"or",l=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${u}`)}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 rt._EMPTY||(rt._EMPTY=new rt(new ft),Sa(rt._EMPTY),Sa(rt._EMPTY.baseTexture)),rt._EMPTY}static get WHITE(){if(!rt._WHITE){const t=Q.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),rt._WHITE=new rt(ft.from(t)),Sa(rt._WHITE),Sa(rt._WHITE.baseTexture)}return rt._WHITE}}class qr extends rt{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 qr(new nm(t))}}class hm{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Yt.NONE){const s=new nm(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new qr(s)}getOptimalTexture(t,e,i=1,s=Yt.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=la(t),e=la(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||Yt.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}}}hm.SCREEN_KEY=-1;class fv extends xr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class lm extends xr{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 Kt(this.vertices),this.uvBuffer=new Kt(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 mv{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Yt.NONE,this.sourceFrame=new ct,this.destinationFrame=new ct,this.bindingSourceFrame=new ct,this.bindingDestinationFrame=new ct,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Ea=[new lt,new lt,new lt,new lt],_u=new Nt;class um{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new hm,this.statePool=[],this.quad=new fv,this.quadUv=new lm,this.tempRect=new ct,this.activeState={},this.globalUniforms=new ii({outputFrame:new ct,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 mv,o=i.renderTexture;let a,h;if(o.current){const g=o.current;a=g.resolution,h=g.multisample}else a=i.resolution,h=i.multisample;let l=e[0].resolution||a,u=e[0].multisample??h,c=e[0].padding,d=e[0].autoFit,p=e[0].legacy??!0;for(let g=1;g<e.length;g++){const y=e[g];l=Math.min(l,y.resolution||a),u=Math.min(u,y.multisample??h),c=this.useMaxPadding?Math.max(c,y.padding):c+y.padding,d=d&&y.autoFit,p=p||(y.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=l,n.multisample=u,n.legacy=p,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const m=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(_u.copyFrom(i.projection.transform).invert(),m),d?(n.sourceFrame.fit(m),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(m)||(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,l,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const f=this.tempRect;f.x=0,f.y=0,f.width=n.sourceFrame.width,f.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,f),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 l=s.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,h.renderTexture,bi.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,u=this.getOptimalFilterTexture(l.width,l.height,e.resolution);u.filterFrame=l.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(l.width,l.height,e.resolution),u.filterFrame=l.filterFrame),i[c].apply(this,l,u,bi.CLEAR,e);const d=l;l=u,u=d}i[c].apply(this,l,h.renderTexture,bi.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=bi.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===bi.CLEAR||e===bi.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(gi.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(gi.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(Nt.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=Yt.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||Yt.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=Ea[0],s=Ea[1],n=Ea[2],o=Ea[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),h=Math.min(i.y,s.y,n.y,o.y),l=Math.max(i.x,s.x,n.x,o.x),u=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=h,e.width=l-a,e.height=u-h}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:h,d:l}=n;if((Math.abs(a)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(l)>1e-4))return}n=n?_u.copyFrom(n):_u.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)}}}um.extension={type:J.RendererSystem,name:"filter"},et.add(um);class gv{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Yt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const yv=new ct;class cm{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new bu(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 ct,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;Q.PREFER_ENV===Ur.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,h=o/e.width;this.setViewport(e.x*h,e.y*h,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=cl.COLOR|cl.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new gv(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],h=a.parentTextureArray||a;this.renderer.texture.bind(h,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,h._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 h=0;h<o;h++){const l=n[h],u=l.parentTextureArray||l;this.renderer.texture.bind(u,0),h===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._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+h,l.target,u._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+h))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const h=t.depthTexture;this.renderer.texture.bind(h,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,h._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let h,l;this.renderer.context.webGLVersion===1?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH_STENCIL):t.depth&&t.stencil?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH24_STENCIL8):t.depth?(h=i.DEPTH_ATTACHMENT,l=i.DEPTH_COMPONENT24):(h=i.STENCIL_ATTACHMENT,l=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,l,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,l,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,h,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=Yt.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=Yt.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 h=s.glFramebuffers[a];if(!h)return;if(!t){if(!h.msaaBuffer)return;const u=s.colorTextures[0];if(!u)return;h.blitFramebuffer||(h.blitFramebuffer=new bu(s.width,s.height),h.blitFramebuffer.addColorTexture(0,u)),t=h.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,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=yv,e.width=s.width,e.height=s.height),i||(i=e);const l=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,h.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,l?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,h;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,h=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,h,i,s):n.renderbufferStorage(n.RENDERBUFFER,h,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new ct}destroy(){this.renderer=null}}cm.extension={type:J.RendererSystem,name:"framebuffer"},et.add(cm);const vu={5126:4,5123:2,5121:1};class dm{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;Q.PREFER_ENV===Ur.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,h)=>i.drawElementsInstancedANGLE(s,n,o,a,h),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 h=this.getSignature(t,a),l=t.glVertexArrayObjects[this.CONTEXT_UID];let u=l[h];if(u)return l[a.id]=u,u;const c=t.buffers,d=t.attributes,p={},m={};for(const f in c)p[f]=0,m[f]=0;for(const f in d)!d[f].size&&a.attributeData[f]?d[f].size=a.attributeData[f].size:d[f].size||console.warn(`PIXI Geometry attribute '${f}' size cannot be determined (likely the bound shader does not have the attribute)`),p[d[f].buffer]+=d[f].size*vu[d[f].type];for(const f in d){const g=d[f],y=g.size;g.stride===void 0&&(p[g.buffer]===y*vu[g.type]?g.stride=0:g.stride=p[g.buffer]),g.start===void 0&&(g.start=m[g.buffer],m[g.buffer]+=y*vu[g.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let f=0;f<c.length;f++){const g=c[f];o.bind(g),i&&g._glBuffers[n].refCount++}return this.activateVao(t,a),l[a.id]=u,l[h]=u,s.bindVertexArray(null),o.unbind(xi.ARRAY_BUFFER),u}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 h=0;h<n.length;h++){const l=n[h]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(n[h],e))}if(!e){for(const h in i)if(h[0]==="g"){const l=i[h];this._activeVao===l&&this.unbind(),s.deleteVertexArray(l)}}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 h=null;for(const l in a){const u=a[l],c=o[u.buffer],d=c._glBuffers[s];if(e.attributeData[l]){h!==d&&(n.bind(c),h=d);const p=e.attributeData[l].location;if(i.enableVertexAttribArray(p),i.vertexAttribPointer(p,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(p,u.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,h=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,h,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,h,(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}}dm.extension={type:J.RendererSystem,name:"geometry"},et.add(dm);const pm=new Nt;class fm{constructor(t,e){this._texture=t,this.mapCoord=new Nt,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&&(pm.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(pm));const o=e.baseTexture,a=this.uClampFrame,h=this.clampMargin/o.resolution,l=this.clampOffset;return a[0]=(e._frame.x+h+l)/o.width,a[1]=(e._frame.y+h+l)/o.height,a[2]=(e._frame.x+e._frame.width-h+l)/o.width,a[3]=(e._frame.y+e._frame.height-h+l)/o.height,this.uClampOffset[0]=l/o.realWidth,this.uClampOffset[1]=l/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var bv=`varying vec2 vMaskCoord;
378
+ `;const yu=class Xo extends Ei{constructor(t,e,i){const s=tr.from(t||Xo.defaultVertexSrc,e||Xo.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=Xo.defaultResolution,this.multisample=Xo.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Si}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 pv}static get defaultFragmentSrc(){return dv}};yu.defaultResolution=1,yu.defaultMultisample=Yt.NONE;let ye=yu;class Ta{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Gt(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(){}}Ta.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Ta.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"background"},et.add(Ta);class rm{constructor(t){this.renderer=t,this.emptyRenderer=new va(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 h=0;for(let l=0;l<a;l++){const u=n[l],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){o[l]=c;continue}for(;h<s;){const d=e[h];if(d&&d._batchEnabled===i&&d._batchLocation===h){h++;continue}o[l]=h,u._batchLocation=h,e[h]=u;break}}}destroy(){this.renderer=null}}rm.extension={type:J.RendererSystem,name:"batch"},et.add(rm);let sm=0;class wa{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=sm++}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=sm++,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(Q.PREFER_ENV>=Ur.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")};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")}}wa.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},wa.extension={type:J.RendererSystem,name:"context"},et.add(wa);class bu{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 ei("disposeFramebuffer"),this.multisample=Yt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new mt(null,{scaleMode:Ki.NEAREST,resolution:1,mipmap:yi.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new mt(null,{scaleMode:Ki.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:yi.OFF,format:H.DEPTH_COMPONENT,type:at.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 nm extends mt{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=Yt.NONE),super(null,t),this.mipmap=yi.OFF,this.valid=!0,this._clear=new Gt([0,0,0,0]),this.framebuffer=new bu(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 _r extends Kn{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.width,s=e.naturalHeight||e.videoHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=D1(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===xe.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 om extends _r{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;_r.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??Q.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===xe.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 xu{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,h=t.x/s+o,l=t.y/n+a;i=kt.add(i,kt.NW),this.x0=h+o*kt.uX(i),this.y0=l+a*kt.uY(i),i=kt.add(i,2),this.x1=h+o*kt.uX(i),this.y1=l+a*kt.uY(i),i=kt.add(i,2),this.x2=h+o*kt.uX(i),this.y2=l+a*kt.uY(i),i=kt.add(i,2),this.x3=h+o*kt.uX(i),this.y3=l+a*kt.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}}xu.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 am=new xu;function Sa(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class rt extends Nn{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new ct(0,0,1,1)),t instanceof rt&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=am,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 lt(o.x,o.y):new lt(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&&wi[e.url]&&rt.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,rt.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 rt(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===am&&(this._uvs=new xu),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=Q.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof mt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Hr()}`,mt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Hr()}`}n=t._pixiId}let o=wi[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof mt)?(e.resolution||(e.resolution=Qi(t)),o=new rt(new mt(t,e)),o.baseTexture.cacheId=n,mt.addToCache(o.baseTexture,n),rt.addToCache(o,n)):!o&&t instanceof mt&&(o=new rt(t),rt.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=rt.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 rt(mt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new mt(t,Object.assign({scaleMode:mt.defaultOptions.scaleMode,resolution:Qi(e)},s)),{resource:o}=n;o instanceof om&&(o.url=e);const a=new rt(n);return i||(i=e),mt.addToCache(a.baseTexture,i),rt.addToCache(a,i),i!==e&&(mt.addToCache(a.baseTexture,e),rt.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(h=>{a.baseTexture.once("loaded",()=>h(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),wi[e]&&wi[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),wi[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=wi[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete wi[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)wi[t.textureCacheIds[e]]===t&&delete wi[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 h=o&&a?"and":"or",l=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${u}`)}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 rt._EMPTY||(rt._EMPTY=new rt(new mt),Sa(rt._EMPTY),Sa(rt._EMPTY.baseTexture)),rt._EMPTY}static get WHITE(){if(!rt._WHITE){const t=Q.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),rt._WHITE=new rt(mt.from(t)),Sa(rt._WHITE),Sa(rt._WHITE.baseTexture)}return rt._WHITE}}class qr extends rt{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 qr(new nm(t))}}class hm{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Yt.NONE){const s=new nm(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new qr(s)}getOptimalTexture(t,e,i=1,s=Yt.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=la(t),e=la(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||Yt.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}}}hm.SCREEN_KEY=-1;class fv extends xr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class lm extends xr{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 Kt(this.vertices),this.uvBuffer=new Kt(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 mv{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Yt.NONE,this.sourceFrame=new ct,this.destinationFrame=new ct,this.bindingSourceFrame=new ct,this.bindingDestinationFrame=new ct,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Ea=[new lt,new lt,new lt,new lt],_u=new Nt;class um{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new hm,this.statePool=[],this.quad=new fv,this.quadUv=new lm,this.tempRect=new ct,this.activeState={},this.globalUniforms=new ii({outputFrame:new ct,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 mv,o=i.renderTexture;let a,h;if(o.current){const g=o.current;a=g.resolution,h=g.multisample}else a=i.resolution,h=i.multisample;let l=e[0].resolution||a,u=e[0].multisample??h,c=e[0].padding,d=e[0].autoFit,p=e[0].legacy??!0;for(let g=1;g<e.length;g++){const y=e[g];l=Math.min(l,y.resolution||a),u=Math.min(u,y.multisample??h),c=this.useMaxPadding?Math.max(c,y.padding):c+y.padding,d=d&&y.autoFit,p=p||(y.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=l,n.multisample=u,n.legacy=p,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const m=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(_u.copyFrom(i.projection.transform).invert(),m),d?(n.sourceFrame.fit(m),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(m)||(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,l,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const f=this.tempRect;f.x=0,f.y=0,f.width=n.sourceFrame.width,f.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,f),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 l=s.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,h.renderTexture,bi.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,u=this.getOptimalFilterTexture(l.width,l.height,e.resolution);u.filterFrame=l.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(l.width,l.height,e.resolution),u.filterFrame=l.filterFrame),i[c].apply(this,l,u,bi.CLEAR,e);const d=l;l=u,u=d}i[c].apply(this,l,h.renderTexture,bi.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=bi.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===bi.CLEAR||e===bi.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(gi.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(gi.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(Nt.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=Yt.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||Yt.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=Ea[0],s=Ea[1],n=Ea[2],o=Ea[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),h=Math.min(i.y,s.y,n.y,o.y),l=Math.max(i.x,s.x,n.x,o.x),u=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=h,e.width=l-a,e.height=u-h}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:h,d:l}=n;if((Math.abs(a)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(l)>1e-4))return}n=n?_u.copyFrom(n):_u.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)}}}um.extension={type:J.RendererSystem,name:"filter"},et.add(um);class gv{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Yt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const yv=new ct;class cm{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new bu(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 ct,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;Q.PREFER_ENV===Ur.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,h=o/e.width;this.setViewport(e.x*h,e.y*h,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=cl.COLOR|cl.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new gv(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],h=a.parentTextureArray||a;this.renderer.texture.bind(h,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,h._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 h=0;h<o;h++){const l=n[h],u=l.parentTextureArray||l;this.renderer.texture.bind(u,0),h===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._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+h,l.target,u._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+h))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const h=t.depthTexture;this.renderer.texture.bind(h,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,h._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let h,l;this.renderer.context.webGLVersion===1?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH_STENCIL):t.depth&&t.stencil?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH24_STENCIL8):t.depth?(h=i.DEPTH_ATTACHMENT,l=i.DEPTH_COMPONENT24):(h=i.STENCIL_ATTACHMENT,l=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,l,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,l,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,h,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=Yt.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=Yt.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 h=s.glFramebuffers[a];if(!h)return;if(!t){if(!h.msaaBuffer)return;const u=s.colorTextures[0];if(!u)return;h.blitFramebuffer||(h.blitFramebuffer=new bu(s.width,s.height),h.blitFramebuffer.addColorTexture(0,u)),t=h.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,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=yv,e.width=s.width,e.height=s.height),i||(i=e);const l=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,h.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,l?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,h;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,h=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,h,i,s):n.renderbufferStorage(n.RENDERBUFFER,h,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new ct}destroy(){this.renderer=null}}cm.extension={type:J.RendererSystem,name:"framebuffer"},et.add(cm);const vu={5126:4,5123:2,5121:1};class dm{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;Q.PREFER_ENV===Ur.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,h)=>i.drawElementsInstancedANGLE(s,n,o,a,h),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 h=this.getSignature(t,a),l=t.glVertexArrayObjects[this.CONTEXT_UID];let u=l[h];if(u)return l[a.id]=u,u;const c=t.buffers,d=t.attributes,p={},m={};for(const f in c)p[f]=0,m[f]=0;for(const f in d)!d[f].size&&a.attributeData[f]?d[f].size=a.attributeData[f].size:d[f].size||console.warn(`PIXI Geometry attribute '${f}' size cannot be determined (likely the bound shader does not have the attribute)`),p[d[f].buffer]+=d[f].size*vu[d[f].type];for(const f in d){const g=d[f],y=g.size;g.stride===void 0&&(p[g.buffer]===y*vu[g.type]?g.stride=0:g.stride=p[g.buffer]),g.start===void 0&&(g.start=m[g.buffer],m[g.buffer]+=y*vu[g.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let f=0;f<c.length;f++){const g=c[f];o.bind(g),i&&g._glBuffers[n].refCount++}return this.activateVao(t,a),l[a.id]=u,l[h]=u,s.bindVertexArray(null),o.unbind(xi.ARRAY_BUFFER),u}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 h=0;h<n.length;h++){const l=n[h]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(n[h],e))}if(!e){for(const h in i)if(h[0]==="g"){const l=i[h];this._activeVao===l&&this.unbind(),s.deleteVertexArray(l)}}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 h=null;for(const l in a){const u=a[l],c=o[u.buffer],d=c._glBuffers[s];if(e.attributeData[l]){h!==d&&(n.bind(c),h=d);const p=e.attributeData[l].location;if(i.enableVertexAttribArray(p),i.vertexAttribPointer(p,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(p,u.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,h=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,h,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,h,(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}}dm.extension={type:J.RendererSystem,name:"geometry"},et.add(dm);const pm=new Nt;class fm{constructor(t,e){this._texture=t,this.mapCoord=new Nt,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&&(pm.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(pm));const o=e.baseTexture,a=this.uClampFrame,h=this.clampMargin/o.resolution,l=this.clampOffset;return a[0]=(e._frame.x+h+l)/o.width,a[1]=(e._frame.y+h+l)/o.height,a[2]=(e._frame.x+e._frame.width-h+l)/o.width,a[3]=(e._frame.y+e._frame.height-h+l)/o.height,this.uClampOffset[0]=l/o.realWidth,this.uClampOffset[1]=l/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var bv=`varying vec2 vMaskCoord;
379
379
  varying vec2 vTextureCoord;
380
380
 
381
381
  uniform sampler2D uSampler;
@@ -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 Gv=0;const Ca={textureCount:0,uboCount:0};class Im{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=Gv++}systemCheck(){if(!sv())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||(Ca.textureCount=0,Ca.uboCount=0,this.syncUniformGroup(t.uniformGroup,Ca)),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]=q1(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,Ca,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]=Lv(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(a.size/4);t.buffer.update(h)}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=Iv(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}}Im.extension={type:J.RendererSystem,name:"shader"},et.add(Im);class Ia{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.3.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Ia.defaultOptions={hello:!1},Ia.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"startup"},et.add(Ia);function Nv(r,t=[]){return t[ut.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.ADD]=[r.ONE,r.ONE],t[ut.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.NONE]=[0,0],t[ut.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[ut.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[ut.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[ut.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[ut.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[ut.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[ut.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[ut.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[ut.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[ut.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const Fv=0,Dv=1,kv=2,Ov=3,Wv=4,Bv=5,Am=class up{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=ut.NONE,this._blendEq=!1,this.map=[],this.map[Fv]=this.setBlend,this.map[Dv]=this.setOffset,this.map[kv]=this.setCullFace,this.map[Ov]=this.setDepthTest,this.map[Wv]=this.setFrontFace,this.map[Bv]=this.setDepthMask,this.checks=[],this.defaultState=new Si,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=Nv(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(up.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(up.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}};Am.extension={type:J.RendererSystem,name:"state"};let Uv=Am;et.add(Uv);class Xv extends Nn{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 ei(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 jn=class ol{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=ol.defaultMaxIdle,this.checkCountMax=ol.defaultCheckCountMax,this.mode=ol.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==dl.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}};jn.defaultMode=dl.AUTO,jn.defaultMaxIdle=60*60,jn.defaultCheckCountMax=60*10,jn.extension={type:J.RendererSystem,name:"textureGC"};let es=jn;et.add(es);class Tu{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=at.UNSIGNED_BYTE,this.internalFormat=H.RGBA,this.samplerType=0}}function Zv(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:$.FLOAT,[r.RGBA]:$.FLOAT,[r.ALPHA]:$.FLOAT,[r.LUMINANCE]:$.FLOAT,[r.LUMINANCE_ALPHA]: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.FLOAT,[r.RGBA]:$.FLOAT,[r.ALPHA]:$.FLOAT,[r.LUMINANCE]:$.FLOAT,[r.LUMINANCE_ALPHA]:$.FLOAT,[r.DEPTH_STENCIL]:$.FLOAT},t}function Vv(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[at.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA8,[H.RGB]:r.RGB8,[H.RG]:r.RG8,[H.RED]:r.R8,[H.RGBA_INTEGER]:r.RGBA8UI,[H.RGB_INTEGER]:r.RGB8UI,[H.RG_INTEGER]:r.RG8UI,[H.RED_INTEGER]:r.R8UI,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[at.BYTE]:{[H.RGBA]:r.RGBA8_SNORM,[H.RGB]:r.RGB8_SNORM,[H.RG]:r.RG8_SNORM,[H.RED]:r.R8_SNORM,[H.RGBA_INTEGER]:r.RGBA8I,[H.RGB_INTEGER]:r.RGB8I,[H.RG_INTEGER]:r.RG8I,[H.RED_INTEGER]:r.R8I},[at.UNSIGNED_SHORT]:{[H.RGBA_INTEGER]:r.RGBA16UI,[H.RGB_INTEGER]:r.RGB16UI,[H.RG_INTEGER]:r.RG16UI,[H.RED_INTEGER]:r.R16UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[at.SHORT]:{[H.RGBA_INTEGER]:r.RGBA16I,[H.RGB_INTEGER]:r.RGB16I,[H.RG_INTEGER]:r.RG16I,[H.RED_INTEGER]:r.R16I},[at.UNSIGNED_INT]:{[H.RGBA_INTEGER]:r.RGBA32UI,[H.RGB_INTEGER]:r.RGB32UI,[H.RG_INTEGER]:r.RG32UI,[H.RED_INTEGER]:r.R32UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[at.INT]:{[H.RGBA_INTEGER]:r.RGBA32I,[H.RGB_INTEGER]:r.RGB32I,[H.RG_INTEGER]:r.RG32I,[H.RED_INTEGER]:r.R32I},[at.FLOAT]:{[H.RGBA]:r.RGBA32F,[H.RGB]:r.RGB32F,[H.RG]:r.RG32F,[H.RED]:r.R32F,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[at.HALF_FLOAT]:{[H.RGBA]:r.RGBA16F,[H.RGB]:r.RGB16F,[H.RG]:r.RG16F,[H.RED]:r.R16F},[at.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB565},[at.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA4},[at.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGB5_A1},[at.UNSIGNED_INT_2_10_10_10_REV]:{[H.RGBA]:r.RGB10_A2,[H.RGBA_INTEGER]:r.RGB10_A2UI},[at.UNSIGNED_INT_10F_11F_11F_REV]:{[H.RGB]:r.R11F_G11F_B10F},[at.UNSIGNED_INT_5_9_9_9_REV]:{[H.RGB]:r.RGB9_E5},[at.UNSIGNED_INT_24_8]:{[H.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[at.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[H.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[at.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA,[H.RGB]:r.RGB,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[at.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB},[at.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA},[at.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGBA}},t}class Rm{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new ft,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=Vv(t),this.samplerTypes=Zv(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 Tu(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 Tu(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!==$.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Tu(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]??$.FLOAT,this.webGLVersion===2&&t.type===at.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!==$.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&&Us(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===yi.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Hi.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!==yi.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===Ki.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Ki.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===Ki.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Ki.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Rm.extension={type:J.RendererSystem,name:"texture"},et.add(Rm);class Mm{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 h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Mm.extension={type:J.RendererSystem,name:"transformFeedback"},et.add(Mm);class Aa{constructor(t){this.renderer=t}init(t){this.screen=new ct(0,0,t.width,t.height),this.element=t.view||Q.ADAPTER.createCanvas(),this.resolution=t.resolution||Q.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}}Aa.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Aa.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"_view"},et.add(Aa),Q.PREFER_ENV=Ur.WEBGL2,Q.STRICT_TEXTURE_CACHE=!1,Q.RENDER_OPTIONS={...wa.defaultOptions,...Ta.defaultOptions,...Aa.defaultOptions,...Ia.defaultOptions},Object.defineProperties(Q,{WRAP_MODE:{get(){return ft.defaultOptions.wrapMode},set(r){vt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),ft.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return ft.defaultOptions.scaleMode},set(r){vt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),ft.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return ft.defaultOptions.mipmap},set(r){vt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),ft.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return ft.defaultOptions.anisotropicLevel},set(r){vt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),ft.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return vt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ye.defaultResolution},set(r){ye.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return vt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ye.defaultMultisample},set(r){ye.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Qr.defaultMaxTextures},set(r){vt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Qr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Qr.defaultBatchSize},set(r){vt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Qr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Qr.canUploadSameBuffer},set(r){vt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Qr.canUploadSameBuffer=r}},GC_MODE:{get(){return es.defaultMode},set(r){vt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),es.defaultMode=r}},GC_MAX_IDLE:{get(){return es.defaultMaxIdle},set(r){vt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),es.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return es.defaultCheckCountMax},set(r){vt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),es.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return tr.defaultVertexPrecision},set(r){vt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),tr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return tr.defaultFragmentPrecision},set(r){vt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),tr.defaultFragmentPrecision=r}}});var is=(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))(is||{});class wu{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 Pm=class ke{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 wu(null,null,1/0),this.deltaMS=1/ke.targetFPMS,this.elapsedMS=1/ke.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=is.NORMAL){return this._addListener(new wu(t,e,i))}addOnce(t,e,i=is.NORMAL){return this._addListener(new wu(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*ke.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,ke.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(!ke._shared){const t=ke._shared=new ke;t.autoStart=!0,t._protected=!0}return ke._shared}static get system(){if(!ke._system){const t=ke._system=new ke;t.autoStart=!0,t._protected=!0}return ke._system}};Pm.targetFPMS=.06;let be=Pm;Object.defineProperties(Q,{TARGET_FPMS:{get(){return be.targetFPMS},set(r){vt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),be.targetFPMS=r}}});class Lm{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,is.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?be.shared:new be,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Lm.extension=J.Application,et.add(Lm);const Gm=[];et.handleByList(J.Renderer,Gm);function Kv(r){for(const t of Gm)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var Hv=`attribute vec2 aVertexPosition;
489
+ `))}}let Gv=0;const Ca={textureCount:0,uboCount:0};class Im{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=Gv++}systemCheck(){if(!sv())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||(Ca.textureCount=0,Ca.uboCount=0,this.syncUniformGroup(t.uniformGroup,Ca)),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]=q1(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,Ca,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]=Lv(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(a.size/4);t.buffer.update(h)}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=Iv(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}}Im.extension={type:J.RendererSystem,name:"shader"},et.add(Im);class Ia{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.3.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Ia.defaultOptions={hello:!1},Ia.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"startup"},et.add(Ia);function Nv(r,t=[]){return t[ut.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.ADD]=[r.ONE,r.ONE],t[ut.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.NONE]=[0,0],t[ut.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[ut.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[ut.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[ut.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[ut.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[ut.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[ut.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[ut.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[ut.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[ut.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[ut.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const Fv=0,Dv=1,kv=2,Ov=3,Wv=4,Bv=5,Am=class up{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=ut.NONE,this._blendEq=!1,this.map=[],this.map[Fv]=this.setBlend,this.map[Dv]=this.setOffset,this.map[kv]=this.setCullFace,this.map[Ov]=this.setDepthTest,this.map[Wv]=this.setFrontFace,this.map[Bv]=this.setDepthMask,this.checks=[],this.defaultState=new Si,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=Nv(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(up.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(up.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}};Am.extension={type:J.RendererSystem,name:"state"};let Uv=Am;et.add(Uv);class Xv extends Nn{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 ei(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 jn=class ol{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=ol.defaultMaxIdle,this.checkCountMax=ol.defaultCheckCountMax,this.mode=ol.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==dl.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}};jn.defaultMode=dl.AUTO,jn.defaultMaxIdle=60*60,jn.defaultCheckCountMax=60*10,jn.extension={type:J.RendererSystem,name:"textureGC"};let es=jn;et.add(es);class Tu{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=at.UNSIGNED_BYTE,this.internalFormat=H.RGBA,this.samplerType=0}}function Zv(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:$.FLOAT,[r.RGBA]:$.FLOAT,[r.ALPHA]:$.FLOAT,[r.LUMINANCE]:$.FLOAT,[r.LUMINANCE_ALPHA]:$.FLOAT,[r.R8]:$.FLOAT,[r.R8_SNORM]:$.FLOAT,[r.RG8]:$.FLOAT,[r.RG8_SNORM]:$.FLOAT,[r.RGB8]:$.FLOAT,[r.RGB8_SNORM]:$.FLOAT,[r.RGB565]:$.FLOAT,[r.RGBA4]:$.FLOAT,[r.RGB5_A1]:$.FLOAT,[r.RGBA8]:$.FLOAT,[r.RGBA8_SNORM]:$.FLOAT,[r.RGB10_A2]:$.FLOAT,[r.RGB10_A2UI]:$.FLOAT,[r.SRGB8]:$.FLOAT,[r.SRGB8_ALPHA8]:$.FLOAT,[r.R16F]:$.FLOAT,[r.RG16F]:$.FLOAT,[r.RGB16F]:$.FLOAT,[r.RGBA16F]:$.FLOAT,[r.R32F]:$.FLOAT,[r.RG32F]:$.FLOAT,[r.RGB32F]:$.FLOAT,[r.RGBA32F]:$.FLOAT,[r.R11F_G11F_B10F]:$.FLOAT,[r.RGB9_E5]:$.FLOAT,[r.R8I]:$.INT,[r.R8UI]:$.UINT,[r.R16I]:$.INT,[r.R16UI]:$.UINT,[r.R32I]:$.INT,[r.R32UI]:$.UINT,[r.RG8I]:$.INT,[r.RG8UI]:$.UINT,[r.RG16I]:$.INT,[r.RG16UI]:$.UINT,[r.RG32I]:$.INT,[r.RG32UI]:$.UINT,[r.RGB8I]:$.INT,[r.RGB8UI]:$.UINT,[r.RGB16I]:$.INT,[r.RGB16UI]:$.UINT,[r.RGB32I]:$.INT,[r.RGB32UI]:$.UINT,[r.RGBA8I]:$.INT,[r.RGBA8UI]:$.UINT,[r.RGBA16I]:$.INT,[r.RGBA16UI]:$.UINT,[r.RGBA32I]:$.INT,[r.RGBA32UI]:$.UINT,[r.DEPTH_COMPONENT16]:$.FLOAT,[r.DEPTH_COMPONENT24]:$.FLOAT,[r.DEPTH_COMPONENT32F]:$.FLOAT,[r.DEPTH_STENCIL]:$.FLOAT,[r.DEPTH24_STENCIL8]:$.FLOAT,[r.DEPTH32F_STENCIL8]:$.FLOAT}:t={[r.RGB]:$.FLOAT,[r.RGBA]:$.FLOAT,[r.ALPHA]:$.FLOAT,[r.LUMINANCE]:$.FLOAT,[r.LUMINANCE_ALPHA]:$.FLOAT,[r.DEPTH_STENCIL]:$.FLOAT},t}function Vv(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[at.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA8,[H.RGB]:r.RGB8,[H.RG]:r.RG8,[H.RED]:r.R8,[H.RGBA_INTEGER]:r.RGBA8UI,[H.RGB_INTEGER]:r.RGB8UI,[H.RG_INTEGER]:r.RG8UI,[H.RED_INTEGER]:r.R8UI,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[at.BYTE]:{[H.RGBA]:r.RGBA8_SNORM,[H.RGB]:r.RGB8_SNORM,[H.RG]:r.RG8_SNORM,[H.RED]:r.R8_SNORM,[H.RGBA_INTEGER]:r.RGBA8I,[H.RGB_INTEGER]:r.RGB8I,[H.RG_INTEGER]:r.RG8I,[H.RED_INTEGER]:r.R8I},[at.UNSIGNED_SHORT]:{[H.RGBA_INTEGER]:r.RGBA16UI,[H.RGB_INTEGER]:r.RGB16UI,[H.RG_INTEGER]:r.RG16UI,[H.RED_INTEGER]:r.R16UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[at.SHORT]:{[H.RGBA_INTEGER]:r.RGBA16I,[H.RGB_INTEGER]:r.RGB16I,[H.RG_INTEGER]:r.RG16I,[H.RED_INTEGER]:r.R16I},[at.UNSIGNED_INT]:{[H.RGBA_INTEGER]:r.RGBA32UI,[H.RGB_INTEGER]:r.RGB32UI,[H.RG_INTEGER]:r.RG32UI,[H.RED_INTEGER]:r.R32UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[at.INT]:{[H.RGBA_INTEGER]:r.RGBA32I,[H.RGB_INTEGER]:r.RGB32I,[H.RG_INTEGER]:r.RG32I,[H.RED_INTEGER]:r.R32I},[at.FLOAT]:{[H.RGBA]:r.RGBA32F,[H.RGB]:r.RGB32F,[H.RG]:r.RG32F,[H.RED]:r.R32F,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[at.HALF_FLOAT]:{[H.RGBA]:r.RGBA16F,[H.RGB]:r.RGB16F,[H.RG]:r.RG16F,[H.RED]:r.R16F},[at.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB565},[at.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA4},[at.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGB5_A1},[at.UNSIGNED_INT_2_10_10_10_REV]:{[H.RGBA]:r.RGB10_A2,[H.RGBA_INTEGER]:r.RGB10_A2UI},[at.UNSIGNED_INT_10F_11F_11F_REV]:{[H.RGB]:r.R11F_G11F_B10F},[at.UNSIGNED_INT_5_9_9_9_REV]:{[H.RGB]:r.RGB9_E5},[at.UNSIGNED_INT_24_8]:{[H.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[at.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[H.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[at.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA,[H.RGB]:r.RGB,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[at.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB},[at.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA},[at.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGBA}},t}class Rm{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new mt,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=Vv(t),this.samplerTypes=Zv(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 Tu(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 Tu(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!==$.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Tu(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]??$.FLOAT,this.webGLVersion===2&&t.type===at.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!==$.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&&Us(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===yi.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Hi.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!==yi.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===Ki.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Ki.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===Ki.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Ki.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Rm.extension={type:J.RendererSystem,name:"texture"},et.add(Rm);class Mm{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 h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Mm.extension={type:J.RendererSystem,name:"transformFeedback"},et.add(Mm);class Aa{constructor(t){this.renderer=t}init(t){this.screen=new ct(0,0,t.width,t.height),this.element=t.view||Q.ADAPTER.createCanvas(),this.resolution=t.resolution||Q.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}}Aa.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Aa.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"_view"},et.add(Aa),Q.PREFER_ENV=Ur.WEBGL2,Q.STRICT_TEXTURE_CACHE=!1,Q.RENDER_OPTIONS={...wa.defaultOptions,...Ta.defaultOptions,...Aa.defaultOptions,...Ia.defaultOptions},Object.defineProperties(Q,{WRAP_MODE:{get(){return mt.defaultOptions.wrapMode},set(r){vt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),mt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return mt.defaultOptions.scaleMode},set(r){vt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),mt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return mt.defaultOptions.mipmap},set(r){vt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),mt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return mt.defaultOptions.anisotropicLevel},set(r){vt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),mt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return vt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ye.defaultResolution},set(r){ye.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return vt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ye.defaultMultisample},set(r){ye.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Qr.defaultMaxTextures},set(r){vt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Qr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Qr.defaultBatchSize},set(r){vt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Qr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Qr.canUploadSameBuffer},set(r){vt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Qr.canUploadSameBuffer=r}},GC_MODE:{get(){return es.defaultMode},set(r){vt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),es.defaultMode=r}},GC_MAX_IDLE:{get(){return es.defaultMaxIdle},set(r){vt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),es.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return es.defaultCheckCountMax},set(r){vt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),es.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return tr.defaultVertexPrecision},set(r){vt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),tr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return tr.defaultFragmentPrecision},set(r){vt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),tr.defaultFragmentPrecision=r}}});var is=(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))(is||{});class wu{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 Pm=class ke{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 wu(null,null,1/0),this.deltaMS=1/ke.targetFPMS,this.elapsedMS=1/ke.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=is.NORMAL){return this._addListener(new wu(t,e,i))}addOnce(t,e,i=is.NORMAL){return this._addListener(new wu(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*ke.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,ke.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(!ke._shared){const t=ke._shared=new ke;t.autoStart=!0,t._protected=!0}return ke._shared}static get system(){if(!ke._system){const t=ke._system=new ke;t.autoStart=!0,t._protected=!0}return ke._system}};Pm.targetFPMS=.06;let be=Pm;Object.defineProperties(Q,{TARGET_FPMS:{get(){return be.targetFPMS},set(r){vt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),be.targetFPMS=r}}});class Lm{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,is.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?be.shared:new be,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Lm.extension=J.Application,et.add(Lm);const Gm=[];et.handleByList(J.Renderer,Gm);function Kv(r){for(const t of Gm)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var Hv=`attribute vec2 aVertexPosition;
490
490
  attribute vec2 aTextureCoord;
491
491
 
492
492
  uniform mat3 projectionMatrix;
@@ -523,7 +523,7 @@ void main(void)
523
523
  gl_Position = filterVertexPosition();
524
524
  vTextureCoord = filterTextureCoord();
525
525
  }
526
- `;const zv=Hv,Nm=Yv;class Fm{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>=Yt.HIGH?this.multisample=Yt.HIGH:e>=Yt.MEDIUM?this.multisample=Yt.MEDIUM:e>=Yt.LOW?this.multisample=Yt.LOW:this.multisample=Yt.NONE}destroy(){}}Fm.extension={type:J.RendererSystem,name:"_multisample"},et.add(Fm);class jv{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Dm{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 jv(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Dm.extension={type:J.RendererSystem,name:"buffer"},et.add(Dm);class km{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 h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}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}}km.extension={type:J.RendererSystem,name:"objectRenderer"},et.add(km);const Ra=class cp extends Xv{constructor(t){super(),this.type=wp.WEBGL,t=Object.assign({},Q.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ii({projectionMatrix:new Nt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:cp.__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&&(vt("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=cp.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:b1()}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 vt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return vt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return vt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return vt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){vt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return vt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){vt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return vt("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)}};Ra.extension={type:J.Renderer,priority:1},Ra.__plugins={},Ra.__systems={};let Su=Ra;et.handleByMap(J.RendererPlugin,Su.__plugins),et.handleByMap(J.RendererSystem,Su.__systems),et.add(Su);class Om extends Kn{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 ft;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 Kn?this.addResourceAt(t[i],i):this.addResourceAt(Kf(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 Jv extends Om{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=Rs.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 h=0;h<s;h++){const l=o[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,i.type,l.resource.source))}return!0}}class $v extends _r{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Wm=class Zo extends Om{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Zo.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Zo.SIDES;a++)this.items[a].target=Rs.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=Rs.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=Rs.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<Zo.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===Zo.SIDES}};Wm.SIDES=6;let Qv=Wm;class Vs extends _r{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Vs.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 Q.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===xe.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 Vs._EMPTY=Vs._EMPTY??Q.ADAPTER.createCanvas(0,0),Vs._EMPTY}}const Eu=class al extends _r{constructor(t,e){e=e||{},super(Q.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)},al.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;_r.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_${Hr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=al.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"&&al.SVG_XML.test(t)}};Eu.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Eu.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Cu=Eu;const Iu=class dp extends _r{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];_r.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:h}=t[n];if(a=a||t[n],a.startsWith("data:"))h=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const l=a.split("?").shift().toLowerCase(),u=l.slice(l.lastIndexOf(".")+1);h=h||dp.MIME_TYPES[u]||`video/${u}`}o.src=a,h&&(o.type=h),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=be.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&&(be.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||(be.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(be.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||dp.TYPES.includes(e)}};Iu.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Iu.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Bm=Iu;hu.push(Vs,om,$v,Bm,Cu,ua,Qv,Jv);class Ma{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?ct.EMPTY:(t=t||new ct(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:h}=t,l=i*e.x+n*e.y+a,u=s*e.x+o*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}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,h=t.c,l=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,m=this.maxX,f=this.maxY,g=o*e+h*i+u,y=a*e+l*i+c;d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,g=o*s+h*i+u,y=a*s+l*i+c,d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,g=o*e+h*n+u,y=a*e+l*n+c,d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,g=o*s+h*n+u,y=a*s+l*n+c,d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,this.minX=d,this.minY=p,this.maxX=m,this.maxY=f}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let h=e;h<i;h+=2){const l=t[h],u=t[h+1];s=l<s?l:s,n=u<n?u:n,o=l>o?l:o,a=u>a?u: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,h=t.b,l=t.c,u=t.d,c=t.tx,d=t.ty;let p=this.minX,m=this.minY,f=this.maxX,g=this.maxY;for(let y=i;y<s;y+=2){const _=e[y],b=e[y+1],v=a*_+l*b+c,S=u*b+h*_+d;p=Math.min(p,v-n),f=Math.max(f,v+n),m=Math.min(m,S-o),g=Math.max(g,S+o)}this.minX=p,this.minY=m,this.maxX=f,this.maxY=g}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,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<h?s:h,this.maxX=n>l?n:l,this.maxY=o>u?o:u}}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,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<h?s:h,this.maxX=n>l?n:l,this.maxY=o>u?o:u}}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 Ot extends Nn{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new pu,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 Ma,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(Ot.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 ct),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new ct),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Ma);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,h=0,l=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=h,this.pivot.y=l,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 qv),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*H1}set angle(t){this.transform.rotation=t*Y1}get zIndex(){return this._zIndex}set 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 qv extends Ot{constructor(){super(...arguments),this.sortDirty=null}}Ot.prototype.displayObjectUpdateTransform=Ot.prototype.updateTransform;const tT=new Nt;function eT(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Um=class pp extends Ot{constructor(){super(),this.children=[],this.sortableChildren=pp.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);Us(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,Us(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,Us(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(eT),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!==pp.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=tT.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 h=this.children[o],l=h.cullable;h.cullable=l||!this.cullArea,h.render(t),h.cullable=l}}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 h=0;h<e.length;h++)e[h].enabled&&this._enabledFilters.push(e[h])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==jt.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 h=0,l=this.children.length;h<l;++h)this.children[h].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}};Um.defaultSortableChildren=!1;let Xt=Um;Xt.prototype.containerUpdateTransform=Xt.prototype.updateTransform,Object.defineProperties(Q,{SORTABLE_CHILDREN:{get(){return Xt.defaultSortableChildren},set(r){vt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Xt.defaultSortableChildren=r}}});const Jn=new lt,iT=new Uint16Array([0,1,2,0,2,3]);class ie extends Xt{constructor(t){super(),this._anchor=new qi(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 Gt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=ut.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||rt.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=iT,this.pluginName="batch",this.isSprite=!0,this._roundPixels=Q.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=yr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=yr(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,h=e.ty,l=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let p=0,m=0,f=0,g=0;if(u?(m=u.x-d._x*c.width,p=m+u.width,g=u.y-d._y*c.height,f=g+u.height):(m=-d._x*c.width,p=m+c.width,g=-d._y*c.height,f=g+c.height),l[0]=i*m+n*g+a,l[1]=o*g+s*m+h,l[2]=i*p+n*g+a,l[3]=o*g+s*p+h,l[4]=i*p+n*f+a,l[5]=o*f+s*p+h,l[6]=i*m+n*f+a,l[7]=o*f+s*m+h,this._roundPixels){const y=Q.RESOLUTION;for(let _=0;_<l.length;++_)l[_]=Math.round(l[_]*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,h=n.c,l=n.d,u=n.tx,c=n.ty,d=-s._x*i.width,p=d+i.width,m=-s._y*i.height,f=m+i.height;if(e[0]=o*d+h*m+u,e[1]=l*m+a*d+c,e[2]=o*p+h*m+u,e[3]=l*m+a*p+c,e[4]=o*p+h*f+u,e[5]=l*f+a*p+c,e[6]=o*d+h*f+u,e[7]=l*f+a*d+c,this._roundPixels){const g=Q.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*g)/g}}_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 Ma),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 ct),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Jn);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return Jn.x>=s&&Jn.x<s+e&&(n=-i*this.anchor.y,Jn.y>=n&&Jn.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 rt?t:rt.from(t,e);return new ie(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=yr(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=yr(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||rt.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Xm=new Nt;Ot.prototype._cacheAsBitmap=!1,Ot.prototype._cacheData=null,Ot.prototype._cacheAsBitmapResolution=null,Ot.prototype._cacheAsBitmapMultisample=null;class rT{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(Ot.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 rT),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)}}}),Ot.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))},Ot.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new ct,!0);if((p=this.filters)!=null&&p.length){const m=this.filters[0].padding;e.pad(m)}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,h=qr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),l=`cacheAsBitmap_${Hr()}`;this._cacheData.textureCacheId=l,ft.addToCache(h.baseTexture,l),rt.addToCache(h,l);const u=this.transform.localTransform.copyTo(Xm).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:h,clear:!0,transform:u,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 c=new ie(h);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Ot.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))},Ot.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new ct,!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=qr.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Hr()}`;this._cacheData.textureCacheId=a,ft.addToCache(o.baseTexture,a),rt.addToCache(o,a);const h=Xm;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:h,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 l=new ie(o);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(t.x/t.width),l.anchor.y=-(t.y/t.height),l.alpha=e,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},Ot.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Ot.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Ot.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,ft.removeFromCache(this._cacheData.textureCacheId),rt.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Ot.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Ot.prototype.name=null,Xt.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},Ot.prototype.getGlobalPosition=function(r=new lt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var sT=`varying vec2 vTextureCoord;
526
+ `;const zv=Hv,Nm=Yv;class Fm{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>=Yt.HIGH?this.multisample=Yt.HIGH:e>=Yt.MEDIUM?this.multisample=Yt.MEDIUM:e>=Yt.LOW?this.multisample=Yt.LOW:this.multisample=Yt.NONE}destroy(){}}Fm.extension={type:J.RendererSystem,name:"_multisample"},et.add(Fm);class jv{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Dm{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 jv(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Dm.extension={type:J.RendererSystem,name:"buffer"},et.add(Dm);class km{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 h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}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}}km.extension={type:J.RendererSystem,name:"objectRenderer"},et.add(km);const Ra=class cp extends Xv{constructor(t){super(),this.type=wp.WEBGL,t=Object.assign({},Q.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ii({projectionMatrix:new Nt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:cp.__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&&(vt("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=cp.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:b1()}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 vt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return vt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return vt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return vt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){vt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return vt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){vt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return vt("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)}};Ra.extension={type:J.Renderer,priority:1},Ra.__plugins={},Ra.__systems={};let Su=Ra;et.handleByMap(J.RendererPlugin,Su.__plugins),et.handleByMap(J.RendererSystem,Su.__systems),et.add(Su);class Om extends Kn{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 mt;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 Kn?this.addResourceAt(t[i],i):this.addResourceAt(Kf(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 Jv extends Om{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=Rs.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 h=0;h<s;h++){const l=o[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,i.type,l.resource.source))}return!0}}class $v extends _r{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Wm=class Zo extends Om{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Zo.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Zo.SIDES;a++)this.items[a].target=Rs.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=Rs.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=Rs.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<Zo.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===Zo.SIDES}};Wm.SIDES=6;let Qv=Wm;class Vs extends _r{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Vs.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 Q.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===xe.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 Vs._EMPTY=Vs._EMPTY??Q.ADAPTER.createCanvas(0,0),Vs._EMPTY}}const Eu=class al extends _r{constructor(t,e){e=e||{},super(Q.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)},al.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;_r.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_${Hr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=al.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"&&al.SVG_XML.test(t)}};Eu.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Eu.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Cu=Eu;const Iu=class dp extends _r{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];_r.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:h}=t[n];if(a=a||t[n],a.startsWith("data:"))h=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const l=a.split("?").shift().toLowerCase(),u=l.slice(l.lastIndexOf(".")+1);h=h||dp.MIME_TYPES[u]||`video/${u}`}o.src=a,h&&(o.type=h),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=be.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&&(be.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||(be.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(be.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||dp.TYPES.includes(e)}};Iu.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Iu.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Bm=Iu;hu.push(Vs,om,$v,Bm,Cu,ua,Qv,Jv);class Ma{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?ct.EMPTY:(t=t||new ct(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:h}=t,l=i*e.x+n*e.y+a,u=s*e.x+o*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}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,h=t.c,l=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,m=this.maxX,f=this.maxY,g=o*e+h*i+u,y=a*e+l*i+c;d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,g=o*s+h*i+u,y=a*s+l*i+c,d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,g=o*e+h*n+u,y=a*e+l*n+c,d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,g=o*s+h*n+u,y=a*s+l*n+c,d=g<d?g:d,p=y<p?y:p,m=g>m?g:m,f=y>f?y:f,this.minX=d,this.minY=p,this.maxX=m,this.maxY=f}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let h=e;h<i;h+=2){const l=t[h],u=t[h+1];s=l<s?l:s,n=u<n?u:n,o=l>o?l:o,a=u>a?u: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,h=t.b,l=t.c,u=t.d,c=t.tx,d=t.ty;let p=this.minX,m=this.minY,f=this.maxX,g=this.maxY;for(let y=i;y<s;y+=2){const _=e[y],b=e[y+1],v=a*_+l*b+c,S=u*b+h*_+d;p=Math.min(p,v-n),f=Math.max(f,v+n),m=Math.min(m,S-o),g=Math.max(g,S+o)}this.minX=p,this.minY=m,this.maxX=f,this.maxY=g}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,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<h?s:h,this.maxX=n>l?n:l,this.maxY=o>u?o:u}}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,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<h?s:h,this.maxX=n>l?n:l,this.maxY=o>u?o:u}}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 Ot extends Nn{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new pu,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 Ma,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(Ot.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 ct),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new ct),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Ma);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,h=0,l=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=h,this.pivot.y=l,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 qv),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*H1}set angle(t){this.transform.rotation=t*Y1}get zIndex(){return this._zIndex}set 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 qv extends Ot{constructor(){super(...arguments),this.sortDirty=null}}Ot.prototype.displayObjectUpdateTransform=Ot.prototype.updateTransform;const tT=new Nt;function eT(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Um=class pp extends Ot{constructor(){super(),this.children=[],this.sortableChildren=pp.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);Us(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,Us(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,Us(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(eT),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!==pp.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=tT.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 h=this.children[o],l=h.cullable;h.cullable=l||!this.cullArea,h.render(t),h.cullable=l}}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 h=0;h<e.length;h++)e[h].enabled&&this._enabledFilters.push(e[h])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==jt.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 h=0,l=this.children.length;h<l;++h)this.children[h].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}};Um.defaultSortableChildren=!1;let Xt=Um;Xt.prototype.containerUpdateTransform=Xt.prototype.updateTransform,Object.defineProperties(Q,{SORTABLE_CHILDREN:{get(){return Xt.defaultSortableChildren},set(r){vt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Xt.defaultSortableChildren=r}}});const Jn=new lt,iT=new Uint16Array([0,1,2,0,2,3]);class ie extends Xt{constructor(t){super(),this._anchor=new qi(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 Gt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=ut.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||rt.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=iT,this.pluginName="batch",this.isSprite=!0,this._roundPixels=Q.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=yr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=yr(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,h=e.ty,l=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let p=0,m=0,f=0,g=0;if(u?(m=u.x-d._x*c.width,p=m+u.width,g=u.y-d._y*c.height,f=g+u.height):(m=-d._x*c.width,p=m+c.width,g=-d._y*c.height,f=g+c.height),l[0]=i*m+n*g+a,l[1]=o*g+s*m+h,l[2]=i*p+n*g+a,l[3]=o*g+s*p+h,l[4]=i*p+n*f+a,l[5]=o*f+s*p+h,l[6]=i*m+n*f+a,l[7]=o*f+s*m+h,this._roundPixels){const y=Q.RESOLUTION;for(let _=0;_<l.length;++_)l[_]=Math.round(l[_]*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,h=n.c,l=n.d,u=n.tx,c=n.ty,d=-s._x*i.width,p=d+i.width,m=-s._y*i.height,f=m+i.height;if(e[0]=o*d+h*m+u,e[1]=l*m+a*d+c,e[2]=o*p+h*m+u,e[3]=l*m+a*p+c,e[4]=o*p+h*f+u,e[5]=l*f+a*p+c,e[6]=o*d+h*f+u,e[7]=l*f+a*d+c,this._roundPixels){const g=Q.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*g)/g}}_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 Ma),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 ct),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Jn);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return Jn.x>=s&&Jn.x<s+e&&(n=-i*this.anchor.y,Jn.y>=n&&Jn.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 rt?t:rt.from(t,e);return new ie(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=yr(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=yr(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||rt.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Xm=new Nt;Ot.prototype._cacheAsBitmap=!1,Ot.prototype._cacheData=null,Ot.prototype._cacheAsBitmapResolution=null,Ot.prototype._cacheAsBitmapMultisample=null;class rT{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(Ot.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 rT),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)}}}),Ot.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))},Ot.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new ct,!0);if((p=this.filters)!=null&&p.length){const m=this.filters[0].padding;e.pad(m)}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,h=qr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),l=`cacheAsBitmap_${Hr()}`;this._cacheData.textureCacheId=l,mt.addToCache(h.baseTexture,l),rt.addToCache(h,l);const u=this.transform.localTransform.copyTo(Xm).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:h,clear:!0,transform:u,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 c=new ie(h);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Ot.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))},Ot.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new ct,!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=qr.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Hr()}`;this._cacheData.textureCacheId=a,mt.addToCache(o.baseTexture,a),rt.addToCache(o,a);const h=Xm;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:h,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 l=new ie(o);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(t.x/t.width),l.anchor.y=-(t.y/t.height),l.alpha=e,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},Ot.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Ot.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Ot.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,mt.removeFromCache(this._cacheData.textureCacheId),rt.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Ot.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Ot.prototype.name=null,Xt.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},Ot.prototype.getGlobalPosition=function(r=new lt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var sT=`varying vec2 vTextureCoord;
527
527
 
528
528
  uniform sampler2D uSampler;
529
529
  uniform float uAlpha;
@@ -863,7 +863,7 @@ void main()
863
863
 
864
864
  gl_FragColor = color;
865
865
  }
866
- `;class _T extends ye{constructor(t=.5,e=Math.random()){super(Nm,xT,{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 Zm={AlphaFilter:nT,BlurFilter:cT,BlurFilterPass:Au,ColorMatrixFilter:Pa,DisplacementFilter:mT,FXAAFilter:bT,NoiseFilter:_T};Object.entries(Zm).forEach(([r,t])=>{Object.defineProperty(Zm,r,{get(){return vt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class vT{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||(be.system.add(this.tickerUpdate,this,is.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(be.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 vr=new vT;class $n{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=$n.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new lt,this.page=new lt,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 La extends $n{constructor(){super(...arguments),this.client=new lt,this.movement=new lt,this.offset=new lt,this.global=new lt,this.screen=new lt}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,h,l,u,c,d,p,m,f){throw new Error("Method not implemented.")}}class ri extends La{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 Ks extends La{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ks.DOM_DELTA_PIXEL=0,Ks.DOM_DELTA_LINE=1,Ks.DOM_DELTA_PAGE=2;const TT=2048,wT=new lt,Ru=new lt;class ST{constructor(t){this.dispatch=new Nn,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){vr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,wT.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<TT&&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")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const m=t.isInteractive();(p.length>0||m)&&(m&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return h&&l&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:h&&!n(t,i)&&s(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let l=h.length-1;l>=0;l--){const u=h[l],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}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,Ru),!t.hitArea.contains(Ru.x,Ru.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 ri)){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 h,l;if(!(t instanceof ri)){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(((h=s.overTargets)==null?void 0:h.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"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(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"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 p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(c)}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=(l=e.target)==null?void 0:l.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 ri)){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 ri)){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 ri)){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 h=i.button===2;this.notifyTarget(i,h?"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 h=s.clicksByButton[t.button];if(h.target===a.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=a.target,h.timeStamp=e,a.detail=h.clickCount,a.pointerType==="mouse"){const l=a.button===2;this.dispatchEvent(a,l?"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 ri)){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 Ks)){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(ri);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(Ks);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(ri);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 ri&&e instanceof ri&&(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 La&&e instanceof La&&(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 ET=1,CT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Mu=class fp{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new ST(null),vr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new ri(null),this.rootWheelEvent=new Ks(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...fp.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,fp._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,vr.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,vr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;vr.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;vr.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=ET),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=CT[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}};Mu.extension={name:"events",type:[J.RendererSystem,J.CanvasRendererSystem]},Mu.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Pu=Mu;et.add(Pu);function Vm(r){return r==="dynamic"||r==="static"}const IT={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??Vm(Pu.defaultEventMode)},set interactive(r){vt("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??Pu.defaultEventMode},set eventMode(r){this._internalInteractive=Vm(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 t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.on(r,t,s)},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 $n))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}};Ot.mixin(IT);const AT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Ot.mixin(AT);const RT=9,Ga=100,MT=0,PT=0,Km=2,Hm=1,LT=-1e3,GT=-1e3,NT=2;class Ym{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,(zi.tablet||zi.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Ga}px`,e.style.height=`${Ga}px`,e.style.position="absolute",e.style.top=`${MT}px`,e.style.left=`${PT}px`,e.style.zIndex=Km.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=`${Hm}px`,t.style.height=`${Hm}px`,t.style.position="absolute",t.style.top=`${LT}px`,t.style.left=`${GT}px`,t.style.zIndex=NT.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(zi.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:h}=this.renderer,l=s/o*h,u=n/a*h;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const p=this.children[d];if(p.renderId!==this.renderId)p._accessibleActive=!1,Us(this.children,d,1),this.div.removeChild(p._accessibleDiv),this.pool.push(p._accessibleDiv),p._accessibleDiv=null,d--;else{c=p._accessibleDiv;let m=p.hitArea;const f=p.worldTransform;p.hitArea?(c.style.left=`${(f.tx+m.x*f.a)*l}px`,c.style.top=`${(f.ty+m.y*f.d)*u}px`,c.style.width=`${m.width*f.a*l}px`,c.style.height=`${m.height*f.d*u}px`):(m=p.getBounds(),this.capHitArea(m),c.style.left=`${m.x*l}px`,c.style.top=`${m.y*u}px`,c.style.width=`${m.width*l}px`,c.style.height=`${m.height*u}px`,c.title!==p.accessibleTitle&&p.accessibleTitle!==null&&(c.title=p.accessibleTitle),c.getAttribute("aria-label")!==p.accessibleHint&&p.accessibleHint!==null&&c.setAttribute("aria-label",p.accessibleHint)),(p.accessibleTitle!==c.title||p.tabIndex!==c.tabIndex)&&(c.title=p.accessibleTitle,c.tabIndex=p.tabIndex,this.debug&&this.updateDebugHTML(c))}}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=`${Ga}px`,e.style.height=`${Ga}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Km.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 $n(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===RT&&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}}Ym.extension={name:"accessibility",type:[J.RendererPlugin,J.CanvasRendererPlugin]},et.add(Ym);const zm=class mp{constructor(t){this.stage=new Xt,t=Object.assign({forceCanvas:!1},t),this.renderer=Kv(t),mp._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=mp._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}};zm._plugins=[];let jm=zm;et.handleByList(J.Application,jm._plugins);class Jm{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}}Jm.extension=J.Application,et.add(Jm);const $m={loader:J.LoadParser,resolver:J.ResolveParser,cache:J.CacheParser,detection:J.DetectionParser};et.handle(J.Asset,r=>{const t=r.ref;Object.entries($m).filter(([e])=>!!t[e]).forEach(([e,i])=>et.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys($m).filter(e=>!!t[e]).forEach(e=>et.remove(t[e]))});class FT{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 Hs(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 Tr(r,t){const e=r.split("?")[0],i=Jt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const si=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Lu=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Qm(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?Qm(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function DT(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)}),Qm(r,s,0,e,i)}else i.push(r);return i}const Na=r=>!Array.isArray(r);class kT{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=si(t);let s;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];if(h.test(e)){s=h.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 rt){const a=e;i.forEach(h=>{a.baseTexture!==rt.EMPTY.baseTexture&&ft.addToCache(a.baseTexture,h),rt.addToCache(a,h)})}}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 rs=new kT;class OT{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 h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((o=l.test)!=null&&o.call(l,t,e,this))){n=l;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 h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((a=l.testParse)==null?void 0:a.call(l,s,e,this))&&(s=await l.parse(s,e,this)||s,i.parser=l)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Na(t),o=si(t,l=>({alias:[l],src:l})),a=o.length,h=o.map(async l=>{const u=Jt.toAbsolute(l.src);if(!s[l.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,l)),s[l.src]=await this.promiseCache[u].promise,e&&e(++i/a)}catch(c){throw delete this.promiseCache[u],delete s[l.src],new Error(`[Loader.load] Failed to load ${u}.
866
+ `;class _T extends ye{constructor(t=.5,e=Math.random()){super(Nm,xT,{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 Zm={AlphaFilter:nT,BlurFilter:cT,BlurFilterPass:Au,ColorMatrixFilter:Pa,DisplacementFilter:mT,FXAAFilter:bT,NoiseFilter:_T};Object.entries(Zm).forEach(([r,t])=>{Object.defineProperty(Zm,r,{get(){return vt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class vT{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||(be.system.add(this.tickerUpdate,this,is.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(be.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 vr=new vT;class $n{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=$n.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new lt,this.page=new lt,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 La extends $n{constructor(){super(...arguments),this.client=new lt,this.movement=new lt,this.offset=new lt,this.global=new lt,this.screen=new lt}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,h,l,u,c,d,p,m,f){throw new Error("Method not implemented.")}}class ri extends La{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 Ks extends La{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ks.DOM_DELTA_PIXEL=0,Ks.DOM_DELTA_LINE=1,Ks.DOM_DELTA_PAGE=2;const TT=2048,wT=new lt,Ru=new lt;class ST{constructor(t){this.dispatch=new Nn,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){vr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,wT.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<TT&&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")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const m=t.isInteractive();(p.length>0||m)&&(m&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return h&&l&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:h&&!n(t,i)&&s(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let l=h.length-1;l>=0;l--){const u=h[l],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}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,Ru),!t.hitArea.contains(Ru.x,Ru.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 ri)){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 h,l;if(!(t instanceof ri)){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(((h=s.overTargets)==null?void 0:h.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"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(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"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 p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(c)}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=(l=e.target)==null?void 0:l.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 ri)){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 ri)){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 ri)){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 h=i.button===2;this.notifyTarget(i,h?"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 h=s.clicksByButton[t.button];if(h.target===a.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=a.target,h.timeStamp=e,a.detail=h.clickCount,a.pointerType==="mouse"){const l=a.button===2;this.dispatchEvent(a,l?"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 ri)){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 Ks)){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(ri);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(Ks);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(ri);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 ri&&e instanceof ri&&(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 La&&e instanceof La&&(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 ET=1,CT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Mu=class fp{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new ST(null),vr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new ri(null),this.rootWheelEvent=new Ks(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...fp.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,fp._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,vr.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,vr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;vr.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;vr.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=ET),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=CT[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}};Mu.extension={name:"events",type:[J.RendererSystem,J.CanvasRendererSystem]},Mu.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Pu=Mu;et.add(Pu);function Vm(r){return r==="dynamic"||r==="static"}const IT={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??Vm(Pu.defaultEventMode)},set interactive(r){vt("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??Pu.defaultEventMode},set eventMode(r){this._internalInteractive=Vm(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 t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.on(r,t,s)},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 $n))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}};Ot.mixin(IT);const AT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Ot.mixin(AT);const RT=9,Ga=100,MT=0,PT=0,Km=2,Hm=1,LT=-1e3,GT=-1e3,NT=2;class Ym{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,(zi.tablet||zi.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Ga}px`,e.style.height=`${Ga}px`,e.style.position="absolute",e.style.top=`${MT}px`,e.style.left=`${PT}px`,e.style.zIndex=Km.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=`${Hm}px`,t.style.height=`${Hm}px`,t.style.position="absolute",t.style.top=`${LT}px`,t.style.left=`${GT}px`,t.style.zIndex=NT.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(zi.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:h}=this.renderer,l=s/o*h,u=n/a*h;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const p=this.children[d];if(p.renderId!==this.renderId)p._accessibleActive=!1,Us(this.children,d,1),this.div.removeChild(p._accessibleDiv),this.pool.push(p._accessibleDiv),p._accessibleDiv=null,d--;else{c=p._accessibleDiv;let m=p.hitArea;const f=p.worldTransform;p.hitArea?(c.style.left=`${(f.tx+m.x*f.a)*l}px`,c.style.top=`${(f.ty+m.y*f.d)*u}px`,c.style.width=`${m.width*f.a*l}px`,c.style.height=`${m.height*f.d*u}px`):(m=p.getBounds(),this.capHitArea(m),c.style.left=`${m.x*l}px`,c.style.top=`${m.y*u}px`,c.style.width=`${m.width*l}px`,c.style.height=`${m.height*u}px`,c.title!==p.accessibleTitle&&p.accessibleTitle!==null&&(c.title=p.accessibleTitle),c.getAttribute("aria-label")!==p.accessibleHint&&p.accessibleHint!==null&&c.setAttribute("aria-label",p.accessibleHint)),(p.accessibleTitle!==c.title||p.tabIndex!==c.tabIndex)&&(c.title=p.accessibleTitle,c.tabIndex=p.tabIndex,this.debug&&this.updateDebugHTML(c))}}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=`${Ga}px`,e.style.height=`${Ga}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Km.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 $n(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===RT&&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}}Ym.extension={name:"accessibility",type:[J.RendererPlugin,J.CanvasRendererPlugin]},et.add(Ym);const zm=class mp{constructor(t){this.stage=new Xt,t=Object.assign({forceCanvas:!1},t),this.renderer=Kv(t),mp._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=mp._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}};zm._plugins=[];let jm=zm;et.handleByList(J.Application,jm._plugins);class Jm{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}}Jm.extension=J.Application,et.add(Jm);const $m={loader:J.LoadParser,resolver:J.ResolveParser,cache:J.CacheParser,detection:J.DetectionParser};et.handle(J.Asset,r=>{const t=r.ref;Object.entries($m).filter(([e])=>!!t[e]).forEach(([e,i])=>et.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys($m).filter(e=>!!t[e]).forEach(e=>et.remove(t[e]))});class FT{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 Hs(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 Tr(r,t){const e=r.split("?")[0],i=Jt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const si=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Lu=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Qm(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?Qm(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function DT(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)}),Qm(r,s,0,e,i)}else i.push(r);return i}const Na=r=>!Array.isArray(r);class kT{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=si(t);let s;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];if(h.test(e)){s=h.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 rt){const a=e;i.forEach(h=>{a.baseTexture!==rt.EMPTY.baseTexture&&mt.addToCache(a.baseTexture,h),rt.addToCache(a,h)})}}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 rs=new kT;class OT{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 h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((o=l.test)!=null&&o.call(l,t,e,this))){n=l;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 h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((a=l.testParse)==null?void 0:a.call(l,s,e,this))&&(s=await l.parse(s,e,this)||s,i.parser=l)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Na(t),o=si(t,l=>({alias:[l],src:l})),a=o.length,h=o.map(async l=>{const u=Jt.toAbsolute(l.src);if(!s[l.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,l)),s[l.src]=await this.promiseCache[u].promise,e&&e(++i/a)}catch(c){throw delete this.promiseCache[u],delete s[l.src],new Error(`[Loader.load] Failed to load ${u}.
867
867
  ${c}`)}});return await Promise.all(h),n?s[o[0].src]:s}async unload(t){const e=si(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=Jt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const h=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,h,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 ni=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(ni||{});const WT=".json",BT="application/json",UT={extension:{type:J.LoadParser,priority:ni.Low},name:"loadJson",test(r){return Hs(r,BT)||Tr(r,WT)},async load(r){return await(await Q.ADAPTER.fetch(r)).json()}};et.add(UT);const XT=".txt",ZT="text/plain",VT={name:"loadTxt",extension:{type:J.LoadParser,priority:ni.Low},test(r){return Hs(r,ZT)||Tr(r,XT)},async load(r){return await(await Q.ADAPTER.fetch(r)).text()}};et.add(VT);const KT=["normal","bold","100","200","300","400","500","600","700","800","900"],HT=[".ttf",".otf",".woff",".woff2"],YT=["font/ttf","font/otf","font/woff","font/woff2"],zT=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function jT(r){const t=Jt.extname(r),e=Jt.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(zT)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const JT=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function $T(r){return JT.test(r)?r:encodeURI(r)}const QT={extension:{type:J.LoadParser,priority:ni.Low},name:"loadWebFont",test(r){return Hs(r,YT)||Tr(r,HT)},async load(r,t){var i,s,n;const e=Q.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??jT(r),h=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>KT.includes(u)))??["normal"],l=t.data??{};for(let u=0;u<h.length;u++){const c=h[u],d=new FontFace(a,`url(${$T(r)})`,{...l,weight:c});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=>Q.ADAPTER.getFontFaceSet().delete(t))}};et.add(QT);let qm=0,Gu;const qT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",tw={id:"checkImageBitmap",code:`
868
868
  async function checkImageBitmap()
869
869
  {
@@ -919,8 +919,8 @@ ${c}`)}});return await Promise.all(h),n?s[o[0].src]:s}async unload(t){const e=si
919
919
  id: event.data.id,
920
920
  });
921
921
  }
922
- };`};let Nu;class iw{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 e=URL.createObjectURL(new Blob([tw.code],{type:"application/javascript"})),i=new Worker(e);i.addEventListener("message",s=>{i.terminate(),URL.revokeObjectURL(e),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Gu===void 0&&(Gu=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Gu&&(Nu||(Nu=URL.createObjectURL(new Blob([ew.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(Nu),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[qm]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:qm++,id:i})}}const tg=new iw;function Qn(r,t,e){r.resource.internal=!0;const i=new rt(r),s=()=>{delete t.promiseCache[e],rs.has(e)&&rs.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 rw=[".jpeg",".jpg",".png",".webp",".avif"],sw=["image/jpeg","image/png","image/webp","image/avif"];async function nw(r){const t=await Q.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 Fa={name:"loadTextures",extension:{type:J.LoadParser,priority:ni.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Hs(r,sw)||Tr(r,rw)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await tg.isImageBitmapSupported()?s=await tg.loadImageBitmap(r):s=await nw(r):s=await new Promise((h,l)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?h(u):(u.onload=()=>h(u),u.onerror=c=>l(c))});const n={...t.data};n.resolution??(n.resolution=Qi(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new ft(s,n);return o.resource.src=r,Qn(o,e,r)},unload(r){r.destroy(!0)}};et.add(Fa);const ow=".svg",aw="image/svg+xml",hw={extension:{type:J.LoadParser,priority:ni.High},name:"loadSVG",test(r){return Hs(r,aw)||Tr(r,ow)},async testParse(r){return Cu.test(r)},async parse(r,t,e){var n;const i=new Cu(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new ft(i,{resolution:Qi(r),...t==null?void 0:t.data});return s.resource.src=t.src,Qn(s,e,t.src)},async load(r,t){return(await Q.ADAPTER.fetch(r)).text()},unload:Fa.unload};et.add(hw);const lw=[".mp4",".m4v",".webm",".ogv"],uw=["video/mp4","video/webm","video/ogg"],cw={name:"loadVideo",extension:{type:J.LoadParser,priority:ni.High},config:{defaultAutoPlay:!0},test(r){return Hs(r,uw)||Tr(r,lw)},async load(r,t,e){var o;let i;const s=await(await Q.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions},h=new Bm(n,a);await h.load();const l=new ft(h,{alphaMode:await y1(),resolution:Qi(r),...t==null?void 0:t.data});l.resource.src=r,i=Qn(l,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};et.add(cw);class dw{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 si(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 h=this._createBundleAssetId(t,o);i.push(h),a=[o,h]}else{const h=o.map(l=>this._createBundleAssetId(t,l));i.push(...h),a=[...o,...h]}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"?(vt("7.2.0",`Assets.add now uses an object instead of individual parameters.
923
- 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=h=>{this.hasKey(h)&&console.warn(`[Resolver] already has key: ${h} overwriting`)},si(o).forEach(h=>{const{src:l,srcs:u}=h;let{data:c,format:d,loadParser:p}=h;const m=si(l||u).map(y=>typeof y=="string"?DT(y):Array.isArray(y)?y:[y]),f=this.getAlias(h);Array.isArray(f)?f.forEach(a):a(f);const g=[];m.forEach(y=>{y.forEach(_=>{let b={};if(typeof _!="object"){b.src=_;for(let v=0;v<this._parsers.length;v++){const S=this._parsers[v];if(S.test(_)){b=S.parse(_);break}}}else c=_.data??c,d=_.format??d,p=_.loadParser??p,b={...b,..._};if(!f)throw new Error(`[Resolver] alias is undefined for this asset: ${b.src}`);b=this.buildResolvedAsset(b,{aliases:f,data:c,format:d,loadParser:p}),g.push(b)})}),f.forEach(y=>{this._assetMap[y]=g})})}resolveBundle(t){const e=Na(t);t=si(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(s,h)]=l}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=Na(t);t=si(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(h=>{a.params[h].forEach(l=>{const u=n.filter(c=>c[h]?c[h]===l:!1);u.length&&(n=u)})}),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=Jt.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??Jt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class pw{constructor(){this._detections=[],this._initialized=!1,this.resolver=new dw,this.loader=new OT,this.cache=rs,this._backgroundLoader=new FT(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 Asset.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=Na(t),s=si(t).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}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,h=0;const l=()=>{e==null||e(++a/h)},u=o.map(c=>{const d=s[c];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(p=>{n[c]=p})});return await Promise.all(u),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 rs.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=rs.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,h)=>{const l=n[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[s[h]]=l,rs.set(u,l)}),o}async unload(t){this._initialized||await this.init();const e=si(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=si(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=>{rs.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 Fa.config.preferWorkers}set preferWorkers(t){vt("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 Da=new pw;et.handleByList(J.LoadParser,Da.loader.parsers).handleByList(J.ResolveParser,Da.resolver.parsers).handleByList(J.CacheParser,Da.cache.parsers).handleByList(J.DetectionParser,Da.detections);const fw={extension:J.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof rt),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};et.add(fw);async function eg(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 mw={extension:{type:J.DetectionParser,priority:1},test:async()=>eg("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};et.add(mw);const gw={extension:{type:J.DetectionParser,priority:0},test:async()=>eg("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};et.add(gw);const ig=["png","jpg","jpeg"],yw={extension:{type:J.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...ig],remove:async r=>r.filter(t=>!ig.includes(t))};et.add(yw);const bw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Fu(r){return bw?!1:document.createElement("video").canPlayType(r)!==""}const xw={extension:{type:J.DetectionParser,priority:0},test:async()=>Fu("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};et.add(xw);const _w={extension:{type:J.DetectionParser,priority:0},test:async()=>Fu("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};et.add(_w);const vw={extension:{type:J.DetectionParser,priority:0},test:async()=>Fu("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};et.add(vw);const Tw={extension:J.ResolveParser,test:Fa.test,parse:r=>{var t;return{resolution:parseFloat(((t=Q.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:Jt.extname(r).slice(1),src:r}}};et.add(Tw);var Ie=(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=35986]="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))(Ie||{});const ka={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,35986:1,34798:1,37808:1};let er,Ys;function rg(){Ys={s3tc:er.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:er.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:er.getExtension("WEBGL_compressed_texture_etc"),etc1:er.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:er.getExtension("WEBGL_compressed_texture_pvrtc")||er.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:er.getExtension("WEBGL_compressed_texture_atc"),astc:er.getExtension("WEBGL_compressed_texture_astc")}}const ww={extension:{type:J.DetectionParser,priority:2},test:async()=>{const r=Q.ADAPTER.createCanvas().getContext("webgl");return r?(er=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Ys||rg();const t=[];for(const e in Ys)Ys[e]&&t.push(e);return[...t,...r]},remove:async r=>(Ys||rg(),r.filter(t=>!(t in Ys)))};et.add(ww);class Sw extends ua{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 eu(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 eu(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class ss extends Sw{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=ss._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ss._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:h,levelHeight:l,levelBuffer:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,h,l,0,u)}return!0}onBlobLoaded(){this._levelBuffers=ss._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>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,i,s,n,o,a){const h=new Array(i);let l=t.byteOffset,u=o,c=a,d=u+s-1&~(s-1),p=c+n-1&~(n-1),m=d*p*ka[e];for(let f=0;f<i;f++)h[f]={levelID:f,levelWidth:i>1?u:d,levelHeight:i>1?c:p,levelBuffer:new Uint8Array(t.buffer,l,m)},l+=m,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),p=c+n-1&~(n-1),m=d*p*ka[e];return h}}const Du=4,Oa=124,Ew=32,sg=20,Cw=542327876,Wa={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},Iw={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},Ba={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Aw=1,Rw=2,Mw=4,Pw=64,Lw=512,Gw=131072,Nw=827611204,Fw=861165636,Dw=894720068,kw=808540228,Ow=4,Ww={[Nw]:Ie.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Fw]:Ie.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Dw]:Ie.COMPRESSED_RGBA_S3TC_DXT5_EXT},Bw={70:Ie.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Ie.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Ie.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Ie.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Ie.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Ie.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Ie.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Ie.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Ie.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function Uw(r){const t=new Uint32Array(r);if(t[0]!==Cw)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Oa/Uint32Array.BYTES_PER_ELEMENT),i=e[Wa.HEIGHT],s=e[Wa.WIDTH],n=e[Wa.MIPMAP_COUNT],o=new Uint32Array(r,Wa.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,Ew/Uint32Array.BYTES_PER_ELEMENT),a=o[Aw];if(a&Mw){const h=o[Iw.FOURCC];if(h!==kw){const _=Ww[h],b=Du+Oa,v=new Uint8Array(r,b);return[new ss(v,{format:_,width:s,height:i,levels:n})]}const l=Du+Oa,u=new Uint32Array(t.buffer,l,sg/Uint32Array.BYTES_PER_ELEMENT),c=u[Ba.DXGI_FORMAT],d=u[Ba.RESOURCE_DIMENSION],p=u[Ba.MISC_FLAG],m=u[Ba.ARRAY_SIZE],f=Bw[c];if(f===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===Ow)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,y=Du+Oa+sg;if(m===1)g.push(new Uint8Array(r,y));else{const _=ka[f];let b=0,v=s,S=i;for(let A=0;A<n;A++){const I=Math.max(1,v+3&-4),P=Math.max(1,S+3&-4),B=I*P*_;b+=B,v=v>>>1,S=S>>>1}let E=y;for(let A=0;A<m;A++)g.push(new Uint8Array(r,E,b)),E+=b}return g.map(_=>new ss(_,{format:f,width:s,height:i,levels:n}))}throw a&Pw?new Error("DDSParser does not support uncompressed texture data."):a&Lw?new Error("DDSParser does not supported YUV uncompressed texture data."):a&Gw?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&Rw?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 ng=[171,75,84,88,32,49,49,187,13,10,26,10],Xw=67305985,oi={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},ku=64,og={[at.UNSIGNED_BYTE]:1,[at.UNSIGNED_SHORT]:2,[at.INT]:4,[at.UNSIGNED_INT]:4,[at.FLOAT]:4,[at.HALF_FLOAT]:8},Zw={[H.RGBA]:4,[H.RGB]:3,[H.RG]:2,[H.RED]:1,[H.LUMINANCE]:1,[H.LUMINANCE_ALPHA]:2,[H.ALPHA]:1},Vw={[at.UNSIGNED_SHORT_4_4_4_4]:2,[at.UNSIGNED_SHORT_5_5_5_1]:2,[at.UNSIGNED_SHORT_5_6_5]:2};function Kw(r,t,e=!1){const i=new DataView(t);if(!Hw(r,i))return null;const s=i.getUint32(oi.ENDIANNESS,!0)===Xw,n=i.getUint32(oi.GL_TYPE,s),o=i.getUint32(oi.GL_FORMAT,s),a=i.getUint32(oi.GL_INTERNAL_FORMAT,s),h=i.getUint32(oi.PIXEL_WIDTH,s),l=i.getUint32(oi.PIXEL_HEIGHT,s)||1,u=i.getUint32(oi.PIXEL_DEPTH,s)||1,c=i.getUint32(oi.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(oi.NUMBER_OF_FACES,s),p=i.getUint32(oi.NUMBER_OF_MIPMAP_LEVELS,s),m=i.getUint32(oi.BYTES_OF_KEY_VALUE_DATA,s);if(l===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const f=4,g=4,y=h+3&-4,_=l+3&-4,b=new Array(c);let v=h*l;n===0&&(v=y*_);let S;if(n!==0?og[n]?S=og[n]*Zw[o]:S=Vw[n]:S=ka[a],S===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const E=e?zw(i,m,s):null;let A=v*S,I=h,P=l,B=y,G=_,N=ku+m;for(let C=0;C<p;C++){const F=i.getUint32(N,s);let X=N+4;for(let V=0;V<c;V++){let L=b[V];L||(L=b[V]=new Array(p)),L[C]={levelID:C,levelWidth:p>1||n!==0?I:B,levelHeight:p>1||n!==0?P:G,levelBuffer:new Uint8Array(t,X,A)},X+=A}N+=F+4,N=N%4!==0?N+4-N%4:N,I=I>>1||1,P=P>>1||1,B=I+f-1&~(f-1),G=P+g-1&~(g-1),A=B*G*S}return n!==0?{uncompressed:b.map(C=>{let F=C[0].levelBuffer,X=!1;return n===at.FLOAT?F=new Float32Array(C[0].levelBuffer.buffer,C[0].levelBuffer.byteOffset,C[0].levelBuffer.byteLength/4):n===at.UNSIGNED_INT?(X=!0,F=new Uint32Array(C[0].levelBuffer.buffer,C[0].levelBuffer.byteOffset,C[0].levelBuffer.byteLength/4)):n===at.INT&&(X=!0,F=new Int32Array(C[0].levelBuffer.buffer,C[0].levelBuffer.byteOffset,C[0].levelBuffer.byteLength/4)),{resource:new ua(F,{width:C[0].levelWidth,height:C[0].levelHeight}),type:n,format:X?Yw(o):o}}),kvData:E}:{compressed:b.map(C=>new ss(null,{format:a,width:h,height:l,levels:p,levelBuffers:C})),kvData:E}}function Hw(r,t){for(let e=0;e<ng.length;e++)if(t.getUint8(e)!==ng[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function Yw(r){switch(r){case H.RGBA:return H.RGBA_INTEGER;case H.RGB:return H.RGB_INTEGER;case H.RG:return H.RG_INTEGER;case H.RED:return H.RED_INTEGER;default:return r}}function zw(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(ku+s,e),o=ku+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&r.getUint8(o+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(r.buffer,o,h)),u=new DataView(r.buffer,o+h+1,n-h-1);i.set(l,u),s+=4+n+a}return i}const jw={extension:{type:J.LoadParser,priority:ni.High},name:"loadDDS",test(r){return Tr(r,".dds")},async load(r,t,e){const i=await(await Q.ADAPTER.fetch(r)).arrayBuffer(),s=Uw(i).map(n=>{const o=new ft(n,{mipmap:yi.OFF,alphaMode:xe.NO_PREMULTIPLIED_ALPHA,resolution:Qi(r),...t.data});return Qn(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};et.add(jw);const Jw={extension:{type:J.LoadParser,priority:ni.High},name:"loadKTX",test(r){return Tr(r,".ktx")},async load(r,t,e){const i=await(await Q.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=Kw(r,i),a=s??n,h={mipmap:yi.OFF,alphaMode:xe.NO_PREMULTIPLIED_ALPHA,resolution:Qi(r),...t.data},l=a.map(u=>{a===n&&Object.assign(h,{type:u.type,format:u.format});const c=u.resource??u,d=new ft(c,h);return d.ktxKeyValueData=o,Qn(d,e,r)});return l.length===1?l[0]:l},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};et.add(Jw);const $w={extension:J.ResolveParser,test:r=>{const t=Jt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var e,i;const t=Jt.extname(r).slice(1);if(t==="ktx"){const s=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(s.some(n=>r.endsWith(n)))return{resolution:parseFloat(((e=Q.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:s.find(n=>r.endsWith(n)),src:r}}return{resolution:parseFloat(((i=Q.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:t,src:r}}};et.add($w);const Ua=new ct,Qw=4,ag=class Vo{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(h=>{if(!h){a(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(h)},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,h)=>{const l=new FileReader;l.onload=()=>a(l.result),l.onerror=h,l.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&&Vo._flipY(i,s,n),a&&Vo._unpremultiplyAlpha(i);const h=new G1(s,n,1),l=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return h.context.putImageData(l,0,0),h.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&Vo._flipY(i,s,n),a&&Vo._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,h=!1;t&&(t instanceof qr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),h=!0,e&&(Ua.width=e.width,Ua.height=e.height,e=Ua)));const l=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===H.RGBA,!h){i.renderTexture.bind(a);const p=a.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,e||(e=Ua,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(Qw*u*c);return l.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,l.RGBA,l.UNSIGNED_BYTE,d),h&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,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 h=a*s,l=(i-a-1)*s;o.set(t.subarray(h,h+s)),t.copyWithin(h,l,l+s),t.set(o,l)}}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}}}};ag.extension={name:"extract",type:J.RendererSystem};let qw=ag;et.add(qw);const Xa={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===ae.CIRC){const m=r.shape;e=m.x,i=m.y,o=a=m.radius,s=n=0}else if(r.type===ae.ELIP){const m=r.shape;e=m.x,i=m.y,o=m.width,a=m.height,s=n=0}else{const m=r.shape,f=m.width/2,g=m.height/2;e=m.x+f,i=m.y+g,o=a=Math.max(0,Math.min(m.radius,Math.min(f,g))),s=f-o,n=g-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(s?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===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 u=0,c=h*4+(s?2:0)+2,d=c,p=l;{const m=s+o,f=n,g=e+m,y=e-m,_=i+f;if(t[u++]=g,t[u++]=_,t[--c]=_,t[--c]=y,n){const b=i-f;t[d++]=y,t[d++]=b,t[--p]=b,t[--p]=g}}for(let m=1;m<h;m++){const f=Math.PI/2*(m/h),g=s+Math.cos(f)*o,y=n+Math.sin(f)*a,_=e+g,b=e-g,v=i+y,S=i-y;t[u++]=_,t[u++]=v,t[--c]=v,t[--c]=b,t[d++]=b,t[d++]=S,t[--p]=S,t[--p]=_}{const m=s,f=n+a,g=e+m,y=e-m,_=i+f,b=i-f;t[u++]=g,t[u++]=_,t[--p]=b,t[--p]=g,s&&(t[u++]=y,t[u++]=_,t[--p]=b,t[--p]=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,h;if(r.type!==ae.RREC){const u=r.shape;a=u.x,h=u.y}else{const u=r.shape;a=u.x+u.width/2,h=u.y+u.height/2}const l=r.matrix;i.push(r.matrix?l.a*a+l.c*h+l.tx:a,r.matrix?l.b*a+l.d*h+l.ty:h),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function hg(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],h=r[s+1];i+=(a-n)*(h+o),n=a,o=h}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,h=n,l=n+1;[r[o],r[h]]=[r[h],r[o]],[r[a],r[l]]=[r[l],r[a]]}}}const lg={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){hg(e,!1);const o=[];for(let l=0;l<i.length;l++){const u=i[l];hg(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=lx(e,o,2);if(!a)return;const h=s.length/2;for(let l=0;l<a.length;l+=3)n.push(a[l]+h),n.push(a[l+1]+h),n.push(a[l+2]+h);for(let l=0;l<e.length;l++)s.push(e[l])}}},tS={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)}},eS={build(r){Xa.build(r)},triangulate(r,t){Xa.triangulate(r,t)}};var Ue=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Ue||{}),wr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(wr||{});const zs={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 ug{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],h=o[o.length-1]-e,l=a-t,u=s-e,c=i-t,d=Math.abs(h*c-l*u);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const p=h*h+l*l,m=u*u+c*c,f=h*u+l*c,g=n*Math.sqrt(p)/d,y=n*Math.sqrt(m)/d,_=g*f/p,b=y*f/m,v=g*c+y*l,S=g*u+y*h,E=l*(y+_),A=h*(y+_),I=c*(g+b),P=u*(g+b),B=Math.atan2(A-S,E-v),G=Math.atan2(P-S,I-v);return{cx:v+t,cy:S+e,radius:n,startAngle:B,endAngle:G,anticlockwise:l*u>c*h}}static arc(t,e,i,s,n,o,a,h,l){const u=a-o,c=zs._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/da)*40),d=u/(c*2),p=d*2,m=Math.cos(d),f=Math.sin(d),g=c-1,y=g%1/g;for(let _=0;_<=g;++_){const b=_+y*_,v=d+o+p*b,S=Math.cos(v),E=-Math.sin(v);l.push((m*S+f*E)*n+i,(m*-E+f*S)*n+s)}}}class iS{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 Ou{static curveLength(t,e,i,s,n,o,a,h){let l=0,u=0,c=0,d=0,p=0,m=0,f=0,g=0,y=0,_=0,b=0,v=t,S=e;for(let E=1;E<=10;++E)u=E/10,c=u*u,d=c*u,p=1-u,m=p*p,f=m*p,g=f*t+3*m*u*i+3*p*c*n+d*a,y=f*e+3*m*u*s+3*p*c*o+d*h,_=v-g,b=S-y,v=g,S=y,l+=Math.sqrt(_*_+b*b);return l}static curveTo(t,e,i,s,n,o,a){const h=a[a.length-2],l=a[a.length-1];a.length-=2;const u=zs._segmentsCount(Ou.curveLength(h,l,t,e,i,s,n,o));let c=0,d=0,p=0,m=0,f=0;a.push(h,l);for(let g=1,y=0;g<=u;++g)y=g/u,c=1-y,d=c*c,p=d*c,m=y*y,f=m*y,a.push(p*h+3*d*y*t+3*c*m*i+f*n,p*l+3*d*y*e+3*c*m*s+f*o)}}function cg(r,t,e,i,s,n,o,a){const h=r-e*s,l=t-i*s,u=r+e*n,c=t+i*n;let d,p;o?(d=i,p=-e):(d=-i,p=e);const m=h+d,f=l+p,g=u+d,y=c+p;return a.push(m,f,g,y),2}function ns(r,t,e,i,s,n,o,a){const h=e-r,l=i-t;let u=Math.atan2(h,l),c=Math.atan2(s-r,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const p=c-u,m=Math.abs(p),f=Math.sqrt(h*h+l*l),g=(15*m*Math.sqrt(f)/Math.PI>>0)+1,y=p/g;if(d+=y,a){o.push(r,t,e,i);for(let _=1,b=d;_<g;_++,b+=y)o.push(r,t,r+Math.sin(b)*f,t+Math.cos(b)*f);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let _=1,b=d;_<g;_++,b+=y)o.push(r+Math.sin(b)*f,t+Math.cos(b)*f,r,t);o.push(s,n,r,t)}return g*2}function rS(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 lt(i[0],i[1]),a=new lt(i[i.length-2],i[i.length-1]),h=e.type!==ae.POLY||e.closeStroke,l=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(h){i=i.slice(),l&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const L=(o.x+a.x)*.5,k=(a.y+o.y)*.5;i.unshift(L,k),i.push(L,k)}const u=t.points,c=i.length/2;let d=i.length;const p=u.length/2,m=n.width/2,f=m*m,g=n.miterLimit*n.miterLimit;let y=i[0],_=i[1],b=i[2],v=i[3],S=0,E=0,A=-(_-v),I=y-b,P=0,B=0,G=Math.sqrt(A*A+I*I);A/=G,I/=G,A*=m,I*=m;const N=n.alignment,C=(1-N)*2,F=N*2;h||(n.cap===wr.ROUND?d+=ns(y-A*(C-F)*.5,_-I*(C-F)*.5,y-A*C,_-I*C,y+A*F,_+I*F,u,!0)+2:n.cap===wr.SQUARE&&(d+=cg(y,_,A,I,C,F,!0,u))),u.push(y-A*C,_-I*C,y+A*F,_+I*F);for(let L=1;L<c-1;++L){y=i[(L-1)*2],_=i[(L-1)*2+1],b=i[L*2],v=i[L*2+1],S=i[(L+1)*2],E=i[(L+1)*2+1],A=-(_-v),I=y-b,G=Math.sqrt(A*A+I*I),A/=G,I/=G,A*=m,I*=m,P=-(v-E),B=b-S,G=Math.sqrt(P*P+B*B),P/=G,B/=G,P*=m,B*=m;const k=b-y,K=_-v,D=b-S,U=E-v,j=k*D+K*U,q=K*D-U*k,dt=q<0;if(Math.abs(q)<.001*Math.abs(j)){u.push(b-A*C,v-I*C,b+A*F,v+I*F),j>=0&&(n.join===Ue.ROUND?d+=ns(b,v,b-A*C,v-I*C,b-P*C,v-B*C,u,!1)+4:d+=2,u.push(b-P*F,v-B*F,b+P*C,v+B*C));continue}const nt=(-A+y)*(-I+v)-(-A+b)*(-I+_),Et=(-P+S)*(-B+v)-(-P+b)*(-B+E),Rt=(k*Et-D*nt)/q,wt=(U*nt-K*Et)/q,Y=(Rt-b)*(Rt-b)+(wt-v)*(wt-v),it=b+(Rt-b)*C,tt=v+(wt-v)*C,O=b-(Rt-b)*F,bt=v-(wt-v)*F,mt=Math.min(k*k+K*K,D*D+U*U),Mt=dt?C:F,Ut=mt+Mt*Mt*f,Ne=Y<=Ut;let ci=n.join;if(ci===Ue.MITER&&Y/f>g&&(ci=Ue.BEVEL),Ne)switch(ci){case Ue.MITER:{u.push(it,tt,O,bt);break}case Ue.BEVEL:{dt?u.push(it,tt,b+A*F,v+I*F,it,tt,b+P*F,v+B*F):u.push(b-A*C,v-I*C,O,bt,b-P*C,v-B*C,O,bt),d+=2;break}case Ue.ROUND:{dt?(u.push(it,tt,b+A*F,v+I*F),d+=ns(b,v,b+A*F,v+I*F,b+P*F,v+B*F,u,!0)+4,u.push(it,tt,b+P*F,v+B*F)):(u.push(b-A*C,v-I*C,O,bt),d+=ns(b,v,b-A*C,v-I*C,b-P*C,v-B*C,u,!1)+4,u.push(b-P*C,v-B*C,O,bt));break}}else{switch(u.push(b-A*C,v-I*C,b+A*F,v+I*F),ci){case Ue.MITER:{dt?u.push(O,bt,O,bt):u.push(it,tt,it,tt),d+=2;break}case Ue.ROUND:{dt?d+=ns(b,v,b+A*F,v+I*F,b+P*F,v+B*F,u,!0)+2:d+=ns(b,v,b-A*C,v-I*C,b-P*C,v-B*C,u,!1)+2;break}}u.push(b-P*C,v-B*C,b+P*F,v+B*F),d+=2}}y=i[(c-2)*2],_=i[(c-2)*2+1],b=i[(c-1)*2],v=i[(c-1)*2+1],A=-(_-v),I=y-b,G=Math.sqrt(A*A+I*I),A/=G,I/=G,A*=m,I*=m,u.push(b-A*C,v-I*C,b+A*F,v+I*F),h||(n.cap===wr.ROUND?d+=ns(b-A*(C-F)*.5,v-I*(C-F)*.5,b-A*C,v-I*C,b+A*F,v+I*F,u,!1)+2:n.cap===wr.SQUARE&&(d+=cg(b,v,A,I,C,F,!1,u)));const X=t.indices,V=zs.epsilon*zs.epsilon;for(let L=p;L<d+p-2;++L)y=u[L*2],_=u[L*2+1],b=u[(L+1)*2],v=u[(L+1)*2+1],S=u[(L+2)*2],E=u[(L+2)*2+1],!(Math.abs(y*(v-E)+b*(E-_)+S*(_-v))<V)&&X.push(L,L+1,L+2)}function sS(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==ae.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,h=s.length/2,l=o.length/2;let u=l;for(o.push(s[0],s[1]),e=1;e<h;e++)o.push(s[e*2],s[e*2+1]),a.push(u,u+1),u++;n&&a.push(u,l)}function dg(r,t){r.lineStyle.native?sS(r,t):rS(r,t)}class Wu{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,h=e-2*s+o,l=2*i-2*t,u=2*s-2*e,c=4*(a*a+h*h),d=4*(a*l+h*u),p=l*l+u*u,m=2*Math.sqrt(c+d+p),f=Math.sqrt(c),g=2*c*f,y=2*Math.sqrt(p),_=d/f;return(g*m+f*d*(m-y)+(4*p*c-d*d)*Math.log((2*f+_+m)/(_+y)))/(4*g)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],h=zs._segmentsCount(Wu.curveLength(o,a,t,e,i,s));let l=0,u=0;for(let c=1;c<=h;++c){const d=c/h;l=o+(t-o)*d,u=a+(e-a)*d,n.push(l+(t+(i-t)*d-l)*d,u+(e+(s-e)*d-u)*d)}}}const Bu={[ae.POLY]:lg,[ae.CIRC]:Xa,[ae.ELIP]:Xa,[ae.RECT]:tS,[ae.RREC]:eS},pg=[],Za=[];class Va{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 Va(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 js=new lt,fg=class Tb extends Yf{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 Ma,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(),Za.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),pg.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 Va(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 Va(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,js):js.copyFrom(t),s.shape.contains(js.x,js.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(js.x,js.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 h=this.shapeIndex;h<e.length;h++){this.shapeIndex++;const l=e[h],u=l.fillStyle,c=l.lineStyle;Bu[l.type].build(l),l.matrix&&this.transformPoints(l.points,l.matrix),(u.visible||c.visible)&&this.processHoles(l.holes);for(let d=0;d<2;d++){const p=d===0?u:c;if(!p.visible)continue;const m=p.texture.baseTexture,f=this.indices.length,g=this.points.length/2;m.wrapMode=Hi.REPEAT,d===0?this.processFill(l):this.processLine(l);const y=this.points.length/2-g;y!==0&&(i&&!this._compareStyles(s,p)&&(i.end(f,g),i=null),i||(i=pg.pop()||new iS,i.begin(p,f,g),this.batches.push(i),s=p),this.addUvs(this.points,t,p.texture,g,y,p.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<Tb.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++ft._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Za.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Za.pop();s||(s=new uu,s.texArray=new gu),s.texArray.count=0,s.start=0,s.size=0,s.type=gi.TRIANGLES;let n=0,o=null,a=0,h=!1,l=gi.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],p=8,m=d.style,f=m.texture.baseTexture;h!==!!m.native&&(h=!!m.native,l=h?gi.LINES:gi.TRIANGLES,o=null,n=p,t++),o!==f&&(o=f,f._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=Za.pop(),s||(s=new uu,s.texArray=new gu),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=l),f.touched=1,f._batchEnabled=t,f._batchLocation=n,f.wrapMode=Hi.REPEAT,s.texArray.elements[s.texArray.count++]=f,n++)),s.size+=d.size,u+=d.size,a=f._batchLocation,this.addColors(e,m.color,m.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}ft._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 h=0;for(let l=0;l<t.length/2;l++)o[h++]=t[l*2],o[h++]=t[l*2+1],o[h++]=e[l*2],o[h++]=e[l*2+1],a[h++]=i[l],o[h++]=s[l];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?lg.triangulate(t,this):Bu[t.type].triangulate(t,this)}processLine(t){dg(t,this);for(let e=0;e<t.holes.length;e++)dg(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Bu[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=Gt.shared.setValue(e).toLittleEndianNumber(),a=Gt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let h=0;h<s;h++)t[n+h]=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 h=e.length,l=i.frame;for(;a<n;){let c=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const p=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=p}a++,e.push(c/l.width,d/l.height)}const u=i.baseTexture;(l.width<u.width||l.height<u.height)&&this.adjustUvs(e,i,h,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,h=e.frame,l=h.width/n.width,u=h.height/n.height;let c=h.x/h.width,d=h.y/h.height,p=Math.floor(t[i]+o),m=Math.floor(t[i+1]+o);for(let f=i+2;f<a;f+=2)p=Math.min(p,Math.floor(t[f]+o)),m=Math.min(m,Math.floor(t[f+1]+o));c-=p,d-=m;for(let f=i;f<a;f+=2)t[f]=(t[f]+c)*l,t[f+1]=(t[f+1]+d)*u}};fg.BATCHABLE_SIZE=100;let nS=fg;class Ka{constructor(){this.color=16777215,this.alpha=1,this.texture=rt.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Ka;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=rt.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Uu extends Ka{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=wr.BUTT,this.join=Ue.MITER,this.miterLimit=10}clone(){const t=new Uu;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=wr.BUTT,this.join=Ue.MITER,this.miterLimit=10}}const Xu={},Zu=class hl extends Xt{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 Ka,this._lineStyle=new Uu,this._matrix=null,this._holeMode=!1,this.state=Si.for2d(),this._geometry=t||new nS,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Gt(16777215),this.blendMode=ut.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new hl(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:rt.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:wr.BUTT,join:Ue.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 Yr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Yr,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),Wu.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),Ou.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=ug.curveTo(t,e,i,s,n,o);if(a){const{cx:h,cy:l,radius:u,startAngle:c,endAngle:d,anticlockwise:p}=a;this.arc(h,l,u,c,d,p)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=da:o&&s<=n&&(s+=da),n-s===0)return this;const a=t+Math.cos(s)*i,h=e+Math.sin(s)*i,l=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-h);c<l&&d<l||u.push(a,h)}else this.moveTo(a,h),u=this.currentPath.points;return ug.arc(a,h,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:rt.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Gt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:rt.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 ct(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new ga(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new fa(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new ma(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 Yr(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===ae.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),h=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),l=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:a,blendMode:e,indices:l,uvs:h,_batchRGB:Gt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_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,Gt.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,h=o.length;a<h;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 h=0;h<a;h++)t.texture.bind(i.elements[h],h);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Xu[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let h=0;h<s;h++)n[h]=h;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new Nt,default:ii.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;Xu[i]=new Ei(a,o)}e=Xu[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,hl._TEMP_POINT),this._geometry.containsPoint(hl._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=Gt.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,h=e.ty,l=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<l.length;d+=2){const p=l[d],m=l[d+1];u[c++]=i*p+n*m+a,u[c++]=o*m+s*p+h}}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)}};Zu.curves=zs,Zu._TEMP_POINT=new lt;let qn=Zu;class oS{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 Vu=new lt,mg=new Yr,gg=class wb extends Xt{constructor(t,e,i,s=gi.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Si.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=Q.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===gi.TRIANGLES&&e.length<wb.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,h=s.d,l=s.tx,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const p=e[d*2],m=e[d*2+1];c[d*2]=n*p+a*m+l,c[d*2+1]=o*p+h*m+u}if(this._roundPixels){const d=Q.RESOLUTION;for(let p=0;p<c.length;++p)c[p]=Math.round(c[p]*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 oS(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,Vu);const e=this.geometry.getBuffer("aVertexPosition").data,i=mg.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 h=s[a]*2,l=s[a+1]*2,u=s[a+2]*2;if(i[0]=e[h],i[1]=e[h+1],i[2]=e[l],i[3]=e[l+1],i[4]=e[u],i[5]=e[u+1],mg.contains(Vu.x,Vu.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}};gg.BATCHABLE_SIZE=100;let Ku=gg;class yg extends xr{constructor(t,e,i){super();const s=new Kt(t),n=new Kt(e,!0),o=new Kt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,at.FLOAT).addAttribute("aTextureCoord",n,2,!1,at.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var aS=`varying vec2 vTextureCoord;
922
+ };`};let Nu;class iw{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 e=URL.createObjectURL(new Blob([tw.code],{type:"application/javascript"})),i=new Worker(e);i.addEventListener("message",s=>{i.terminate(),URL.revokeObjectURL(e),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Gu===void 0&&(Gu=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Gu&&(Nu||(Nu=URL.createObjectURL(new Blob([ew.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(Nu),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[qm]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:qm++,id:i})}}const tg=new iw;function Qn(r,t,e){r.resource.internal=!0;const i=new rt(r),s=()=>{delete t.promiseCache[e],rs.has(e)&&rs.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 rw=[".jpeg",".jpg",".png",".webp",".avif"],sw=["image/jpeg","image/png","image/webp","image/avif"];async function nw(r){const t=await Q.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 Fa={name:"loadTextures",extension:{type:J.LoadParser,priority:ni.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Hs(r,sw)||Tr(r,rw)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await tg.isImageBitmapSupported()?s=await tg.loadImageBitmap(r):s=await nw(r):s=await new Promise((h,l)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?h(u):(u.onload=()=>h(u),u.onerror=c=>l(c))});const n={...t.data};n.resolution??(n.resolution=Qi(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new mt(s,n);return o.resource.src=r,Qn(o,e,r)},unload(r){r.destroy(!0)}};et.add(Fa);const ow=".svg",aw="image/svg+xml",hw={extension:{type:J.LoadParser,priority:ni.High},name:"loadSVG",test(r){return Hs(r,aw)||Tr(r,ow)},async testParse(r){return Cu.test(r)},async parse(r,t,e){var n;const i=new Cu(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new mt(i,{resolution:Qi(r),...t==null?void 0:t.data});return s.resource.src=t.src,Qn(s,e,t.src)},async load(r,t){return(await Q.ADAPTER.fetch(r)).text()},unload:Fa.unload};et.add(hw);const lw=[".mp4",".m4v",".webm",".ogv"],uw=["video/mp4","video/webm","video/ogg"],cw={name:"loadVideo",extension:{type:J.LoadParser,priority:ni.High},config:{defaultAutoPlay:!0},test(r){return Hs(r,uw)||Tr(r,lw)},async load(r,t,e){var o;let i;const s=await(await Q.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions},h=new Bm(n,a);await h.load();const l=new mt(h,{alphaMode:await y1(),resolution:Qi(r),...t==null?void 0:t.data});l.resource.src=r,i=Qn(l,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};et.add(cw);class dw{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 si(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 h=this._createBundleAssetId(t,o);i.push(h),a=[o,h]}else{const h=o.map(l=>this._createBundleAssetId(t,l));i.push(...h),a=[...o,...h]}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"?(vt("7.2.0",`Assets.add now uses an object instead of individual parameters.
923
+ 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=h=>{this.hasKey(h)&&console.warn(`[Resolver] already has key: ${h} overwriting`)},si(o).forEach(h=>{const{src:l,srcs:u}=h;let{data:c,format:d,loadParser:p}=h;const m=si(l||u).map(y=>typeof y=="string"?DT(y):Array.isArray(y)?y:[y]),f=this.getAlias(h);Array.isArray(f)?f.forEach(a):a(f);const g=[];m.forEach(y=>{y.forEach(_=>{let b={};if(typeof _!="object"){b.src=_;for(let v=0;v<this._parsers.length;v++){const S=this._parsers[v];if(S.test(_)){b=S.parse(_);break}}}else c=_.data??c,d=_.format??d,p=_.loadParser??p,b={...b,..._};if(!f)throw new Error(`[Resolver] alias is undefined for this asset: ${b.src}`);b=this.buildResolvedAsset(b,{aliases:f,data:c,format:d,loadParser:p}),g.push(b)})}),f.forEach(y=>{this._assetMap[y]=g})})}resolveBundle(t){const e=Na(t);t=si(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(s,h)]=l}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=Na(t);t=si(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(h=>{a.params[h].forEach(l=>{const u=n.filter(c=>c[h]?c[h]===l:!1);u.length&&(n=u)})}),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=Jt.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??Jt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class pw{constructor(){this._detections=[],this._initialized=!1,this.resolver=new dw,this.loader=new OT,this.cache=rs,this._backgroundLoader=new FT(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 Asset.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=Na(t),s=si(t).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}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,h=0;const l=()=>{e==null||e(++a/h)},u=o.map(c=>{const d=s[c];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(p=>{n[c]=p})});return await Promise.all(u),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 rs.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=rs.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,h)=>{const l=n[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[s[h]]=l,rs.set(u,l)}),o}async unload(t){this._initialized||await this.init();const e=si(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=si(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=>{rs.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 Fa.config.preferWorkers}set preferWorkers(t){vt("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 Da=new pw;et.handleByList(J.LoadParser,Da.loader.parsers).handleByList(J.ResolveParser,Da.resolver.parsers).handleByList(J.CacheParser,Da.cache.parsers).handleByList(J.DetectionParser,Da.detections);const fw={extension:J.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof rt),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};et.add(fw);async function eg(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 mw={extension:{type:J.DetectionParser,priority:1},test:async()=>eg("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};et.add(mw);const gw={extension:{type:J.DetectionParser,priority:0},test:async()=>eg("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};et.add(gw);const ig=["png","jpg","jpeg"],yw={extension:{type:J.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...ig],remove:async r=>r.filter(t=>!ig.includes(t))};et.add(yw);const bw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Fu(r){return bw?!1:document.createElement("video").canPlayType(r)!==""}const xw={extension:{type:J.DetectionParser,priority:0},test:async()=>Fu("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};et.add(xw);const _w={extension:{type:J.DetectionParser,priority:0},test:async()=>Fu("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};et.add(_w);const vw={extension:{type:J.DetectionParser,priority:0},test:async()=>Fu("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};et.add(vw);const Tw={extension:J.ResolveParser,test:Fa.test,parse:r=>{var t;return{resolution:parseFloat(((t=Q.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:Jt.extname(r).slice(1),src:r}}};et.add(Tw);var Ie=(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=35986]="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))(Ie||{});const ka={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,35986:1,34798:1,37808:1};let er,Ys;function rg(){Ys={s3tc:er.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:er.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:er.getExtension("WEBGL_compressed_texture_etc"),etc1:er.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:er.getExtension("WEBGL_compressed_texture_pvrtc")||er.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:er.getExtension("WEBGL_compressed_texture_atc"),astc:er.getExtension("WEBGL_compressed_texture_astc")}}const ww={extension:{type:J.DetectionParser,priority:2},test:async()=>{const r=Q.ADAPTER.createCanvas().getContext("webgl");return r?(er=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Ys||rg();const t=[];for(const e in Ys)Ys[e]&&t.push(e);return[...t,...r]},remove:async r=>(Ys||rg(),r.filter(t=>!(t in Ys)))};et.add(ww);class Sw extends ua{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 eu(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 eu(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class ss extends Sw{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=ss._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ss._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:h,levelHeight:l,levelBuffer:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,h,l,0,u)}return!0}onBlobLoaded(){this._levelBuffers=ss._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>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,i,s,n,o,a){const h=new Array(i);let l=t.byteOffset,u=o,c=a,d=u+s-1&~(s-1),p=c+n-1&~(n-1),m=d*p*ka[e];for(let f=0;f<i;f++)h[f]={levelID:f,levelWidth:i>1?u:d,levelHeight:i>1?c:p,levelBuffer:new Uint8Array(t.buffer,l,m)},l+=m,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),p=c+n-1&~(n-1),m=d*p*ka[e];return h}}const Du=4,Oa=124,Ew=32,sg=20,Cw=542327876,Wa={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},Iw={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},Ba={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Aw=1,Rw=2,Mw=4,Pw=64,Lw=512,Gw=131072,Nw=827611204,Fw=861165636,Dw=894720068,kw=808540228,Ow=4,Ww={[Nw]:Ie.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Fw]:Ie.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Dw]:Ie.COMPRESSED_RGBA_S3TC_DXT5_EXT},Bw={70:Ie.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Ie.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Ie.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Ie.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Ie.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Ie.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Ie.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Ie.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Ie.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function Uw(r){const t=new Uint32Array(r);if(t[0]!==Cw)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Oa/Uint32Array.BYTES_PER_ELEMENT),i=e[Wa.HEIGHT],s=e[Wa.WIDTH],n=e[Wa.MIPMAP_COUNT],o=new Uint32Array(r,Wa.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,Ew/Uint32Array.BYTES_PER_ELEMENT),a=o[Aw];if(a&Mw){const h=o[Iw.FOURCC];if(h!==kw){const _=Ww[h],b=Du+Oa,v=new Uint8Array(r,b);return[new ss(v,{format:_,width:s,height:i,levels:n})]}const l=Du+Oa,u=new Uint32Array(t.buffer,l,sg/Uint32Array.BYTES_PER_ELEMENT),c=u[Ba.DXGI_FORMAT],d=u[Ba.RESOURCE_DIMENSION],p=u[Ba.MISC_FLAG],m=u[Ba.ARRAY_SIZE],f=Bw[c];if(f===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===Ow)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,y=Du+Oa+sg;if(m===1)g.push(new Uint8Array(r,y));else{const _=ka[f];let b=0,v=s,S=i;for(let A=0;A<n;A++){const I=Math.max(1,v+3&-4),P=Math.max(1,S+3&-4),B=I*P*_;b+=B,v=v>>>1,S=S>>>1}let E=y;for(let A=0;A<m;A++)g.push(new Uint8Array(r,E,b)),E+=b}return g.map(_=>new ss(_,{format:f,width:s,height:i,levels:n}))}throw a&Pw?new Error("DDSParser does not support uncompressed texture data."):a&Lw?new Error("DDSParser does not supported YUV uncompressed texture data."):a&Gw?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&Rw?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 ng=[171,75,84,88,32,49,49,187,13,10,26,10],Xw=67305985,oi={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},ku=64,og={[at.UNSIGNED_BYTE]:1,[at.UNSIGNED_SHORT]:2,[at.INT]:4,[at.UNSIGNED_INT]:4,[at.FLOAT]:4,[at.HALF_FLOAT]:8},Zw={[H.RGBA]:4,[H.RGB]:3,[H.RG]:2,[H.RED]:1,[H.LUMINANCE]:1,[H.LUMINANCE_ALPHA]:2,[H.ALPHA]:1},Vw={[at.UNSIGNED_SHORT_4_4_4_4]:2,[at.UNSIGNED_SHORT_5_5_5_1]:2,[at.UNSIGNED_SHORT_5_6_5]:2};function Kw(r,t,e=!1){const i=new DataView(t);if(!Hw(r,i))return null;const s=i.getUint32(oi.ENDIANNESS,!0)===Xw,n=i.getUint32(oi.GL_TYPE,s),o=i.getUint32(oi.GL_FORMAT,s),a=i.getUint32(oi.GL_INTERNAL_FORMAT,s),h=i.getUint32(oi.PIXEL_WIDTH,s),l=i.getUint32(oi.PIXEL_HEIGHT,s)||1,u=i.getUint32(oi.PIXEL_DEPTH,s)||1,c=i.getUint32(oi.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(oi.NUMBER_OF_FACES,s),p=i.getUint32(oi.NUMBER_OF_MIPMAP_LEVELS,s),m=i.getUint32(oi.BYTES_OF_KEY_VALUE_DATA,s);if(l===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const f=4,g=4,y=h+3&-4,_=l+3&-4,b=new Array(c);let v=h*l;n===0&&(v=y*_);let S;if(n!==0?og[n]?S=og[n]*Zw[o]:S=Vw[n]:S=ka[a],S===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const E=e?zw(i,m,s):null;let A=v*S,I=h,P=l,B=y,G=_,N=ku+m;for(let C=0;C<p;C++){const F=i.getUint32(N,s);let X=N+4;for(let V=0;V<c;V++){let L=b[V];L||(L=b[V]=new Array(p)),L[C]={levelID:C,levelWidth:p>1||n!==0?I:B,levelHeight:p>1||n!==0?P:G,levelBuffer:new Uint8Array(t,X,A)},X+=A}N+=F+4,N=N%4!==0?N+4-N%4:N,I=I>>1||1,P=P>>1||1,B=I+f-1&~(f-1),G=P+g-1&~(g-1),A=B*G*S}return n!==0?{uncompressed:b.map(C=>{let F=C[0].levelBuffer,X=!1;return n===at.FLOAT?F=new Float32Array(C[0].levelBuffer.buffer,C[0].levelBuffer.byteOffset,C[0].levelBuffer.byteLength/4):n===at.UNSIGNED_INT?(X=!0,F=new Uint32Array(C[0].levelBuffer.buffer,C[0].levelBuffer.byteOffset,C[0].levelBuffer.byteLength/4)):n===at.INT&&(X=!0,F=new Int32Array(C[0].levelBuffer.buffer,C[0].levelBuffer.byteOffset,C[0].levelBuffer.byteLength/4)),{resource:new ua(F,{width:C[0].levelWidth,height:C[0].levelHeight}),type:n,format:X?Yw(o):o}}),kvData:E}:{compressed:b.map(C=>new ss(null,{format:a,width:h,height:l,levels:p,levelBuffers:C})),kvData:E}}function Hw(r,t){for(let e=0;e<ng.length;e++)if(t.getUint8(e)!==ng[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function Yw(r){switch(r){case H.RGBA:return H.RGBA_INTEGER;case H.RGB:return H.RGB_INTEGER;case H.RG:return H.RG_INTEGER;case H.RED:return H.RED_INTEGER;default:return r}}function zw(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(ku+s,e),o=ku+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&r.getUint8(o+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(r.buffer,o,h)),u=new DataView(r.buffer,o+h+1,n-h-1);i.set(l,u),s+=4+n+a}return i}const jw={extension:{type:J.LoadParser,priority:ni.High},name:"loadDDS",test(r){return Tr(r,".dds")},async load(r,t,e){const i=await(await Q.ADAPTER.fetch(r)).arrayBuffer(),s=Uw(i).map(n=>{const o=new mt(n,{mipmap:yi.OFF,alphaMode:xe.NO_PREMULTIPLIED_ALPHA,resolution:Qi(r),...t.data});return Qn(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};et.add(jw);const Jw={extension:{type:J.LoadParser,priority:ni.High},name:"loadKTX",test(r){return Tr(r,".ktx")},async load(r,t,e){const i=await(await Q.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=Kw(r,i),a=s??n,h={mipmap:yi.OFF,alphaMode:xe.NO_PREMULTIPLIED_ALPHA,resolution:Qi(r),...t.data},l=a.map(u=>{a===n&&Object.assign(h,{type:u.type,format:u.format});const c=u.resource??u,d=new mt(c,h);return d.ktxKeyValueData=o,Qn(d,e,r)});return l.length===1?l[0]:l},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};et.add(Jw);const $w={extension:J.ResolveParser,test:r=>{const t=Jt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var e,i;const t=Jt.extname(r).slice(1);if(t==="ktx"){const s=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(s.some(n=>r.endsWith(n)))return{resolution:parseFloat(((e=Q.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:s.find(n=>r.endsWith(n)),src:r}}return{resolution:parseFloat(((i=Q.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:t,src:r}}};et.add($w);const Ua=new ct,Qw=4,ag=class Vo{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(h=>{if(!h){a(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(h)},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,h)=>{const l=new FileReader;l.onload=()=>a(l.result),l.onerror=h,l.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&&Vo._flipY(i,s,n),a&&Vo._unpremultiplyAlpha(i);const h=new G1(s,n,1),l=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return h.context.putImageData(l,0,0),h.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&Vo._flipY(i,s,n),a&&Vo._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,h=!1;t&&(t instanceof qr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),h=!0,e&&(Ua.width=e.width,Ua.height=e.height,e=Ua)));const l=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===H.RGBA,!h){i.renderTexture.bind(a);const p=a.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,e||(e=Ua,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(Qw*u*c);return l.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,l.RGBA,l.UNSIGNED_BYTE,d),h&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,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 h=a*s,l=(i-a-1)*s;o.set(t.subarray(h,h+s)),t.copyWithin(h,l,l+s),t.set(o,l)}}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}}}};ag.extension={name:"extract",type:J.RendererSystem};let qw=ag;et.add(qw);const Xa={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===ae.CIRC){const m=r.shape;e=m.x,i=m.y,o=a=m.radius,s=n=0}else if(r.type===ae.ELIP){const m=r.shape;e=m.x,i=m.y,o=m.width,a=m.height,s=n=0}else{const m=r.shape,f=m.width/2,g=m.height/2;e=m.x+f,i=m.y+g,o=a=Math.max(0,Math.min(m.radius,Math.min(f,g))),s=f-o,n=g-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(s?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===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 u=0,c=h*4+(s?2:0)+2,d=c,p=l;{const m=s+o,f=n,g=e+m,y=e-m,_=i+f;if(t[u++]=g,t[u++]=_,t[--c]=_,t[--c]=y,n){const b=i-f;t[d++]=y,t[d++]=b,t[--p]=b,t[--p]=g}}for(let m=1;m<h;m++){const f=Math.PI/2*(m/h),g=s+Math.cos(f)*o,y=n+Math.sin(f)*a,_=e+g,b=e-g,v=i+y,S=i-y;t[u++]=_,t[u++]=v,t[--c]=v,t[--c]=b,t[d++]=b,t[d++]=S,t[--p]=S,t[--p]=_}{const m=s,f=n+a,g=e+m,y=e-m,_=i+f,b=i-f;t[u++]=g,t[u++]=_,t[--p]=b,t[--p]=g,s&&(t[u++]=y,t[u++]=_,t[--p]=b,t[--p]=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,h;if(r.type!==ae.RREC){const u=r.shape;a=u.x,h=u.y}else{const u=r.shape;a=u.x+u.width/2,h=u.y+u.height/2}const l=r.matrix;i.push(r.matrix?l.a*a+l.c*h+l.tx:a,r.matrix?l.b*a+l.d*h+l.ty:h),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function hg(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],h=r[s+1];i+=(a-n)*(h+o),n=a,o=h}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,h=n,l=n+1;[r[o],r[h]]=[r[h],r[o]],[r[a],r[l]]=[r[l],r[a]]}}}const lg={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){hg(e,!1);const o=[];for(let l=0;l<i.length;l++){const u=i[l];hg(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=lx(e,o,2);if(!a)return;const h=s.length/2;for(let l=0;l<a.length;l+=3)n.push(a[l]+h),n.push(a[l+1]+h),n.push(a[l+2]+h);for(let l=0;l<e.length;l++)s.push(e[l])}}},tS={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)}},eS={build(r){Xa.build(r)},triangulate(r,t){Xa.triangulate(r,t)}};var Ue=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Ue||{}),wr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(wr||{});const zs={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 ug{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],h=o[o.length-1]-e,l=a-t,u=s-e,c=i-t,d=Math.abs(h*c-l*u);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const p=h*h+l*l,m=u*u+c*c,f=h*u+l*c,g=n*Math.sqrt(p)/d,y=n*Math.sqrt(m)/d,_=g*f/p,b=y*f/m,v=g*c+y*l,S=g*u+y*h,E=l*(y+_),A=h*(y+_),I=c*(g+b),P=u*(g+b),B=Math.atan2(A-S,E-v),G=Math.atan2(P-S,I-v);return{cx:v+t,cy:S+e,radius:n,startAngle:B,endAngle:G,anticlockwise:l*u>c*h}}static arc(t,e,i,s,n,o,a,h,l){const u=a-o,c=zs._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/da)*40),d=u/(c*2),p=d*2,m=Math.cos(d),f=Math.sin(d),g=c-1,y=g%1/g;for(let _=0;_<=g;++_){const b=_+y*_,v=d+o+p*b,S=Math.cos(v),E=-Math.sin(v);l.push((m*S+f*E)*n+i,(m*-E+f*S)*n+s)}}}class iS{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 Ou{static curveLength(t,e,i,s,n,o,a,h){let l=0,u=0,c=0,d=0,p=0,m=0,f=0,g=0,y=0,_=0,b=0,v=t,S=e;for(let E=1;E<=10;++E)u=E/10,c=u*u,d=c*u,p=1-u,m=p*p,f=m*p,g=f*t+3*m*u*i+3*p*c*n+d*a,y=f*e+3*m*u*s+3*p*c*o+d*h,_=v-g,b=S-y,v=g,S=y,l+=Math.sqrt(_*_+b*b);return l}static curveTo(t,e,i,s,n,o,a){const h=a[a.length-2],l=a[a.length-1];a.length-=2;const u=zs._segmentsCount(Ou.curveLength(h,l,t,e,i,s,n,o));let c=0,d=0,p=0,m=0,f=0;a.push(h,l);for(let g=1,y=0;g<=u;++g)y=g/u,c=1-y,d=c*c,p=d*c,m=y*y,f=m*y,a.push(p*h+3*d*y*t+3*c*m*i+f*n,p*l+3*d*y*e+3*c*m*s+f*o)}}function cg(r,t,e,i,s,n,o,a){const h=r-e*s,l=t-i*s,u=r+e*n,c=t+i*n;let d,p;o?(d=i,p=-e):(d=-i,p=e);const m=h+d,f=l+p,g=u+d,y=c+p;return a.push(m,f,g,y),2}function ns(r,t,e,i,s,n,o,a){const h=e-r,l=i-t;let u=Math.atan2(h,l),c=Math.atan2(s-r,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const p=c-u,m=Math.abs(p),f=Math.sqrt(h*h+l*l),g=(15*m*Math.sqrt(f)/Math.PI>>0)+1,y=p/g;if(d+=y,a){o.push(r,t,e,i);for(let _=1,b=d;_<g;_++,b+=y)o.push(r,t,r+Math.sin(b)*f,t+Math.cos(b)*f);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let _=1,b=d;_<g;_++,b+=y)o.push(r+Math.sin(b)*f,t+Math.cos(b)*f,r,t);o.push(s,n,r,t)}return g*2}function rS(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 lt(i[0],i[1]),a=new lt(i[i.length-2],i[i.length-1]),h=e.type!==ae.POLY||e.closeStroke,l=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(h){i=i.slice(),l&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const L=(o.x+a.x)*.5,k=(a.y+o.y)*.5;i.unshift(L,k),i.push(L,k)}const u=t.points,c=i.length/2;let d=i.length;const p=u.length/2,m=n.width/2,f=m*m,g=n.miterLimit*n.miterLimit;let y=i[0],_=i[1],b=i[2],v=i[3],S=0,E=0,A=-(_-v),I=y-b,P=0,B=0,G=Math.sqrt(A*A+I*I);A/=G,I/=G,A*=m,I*=m;const N=n.alignment,C=(1-N)*2,F=N*2;h||(n.cap===wr.ROUND?d+=ns(y-A*(C-F)*.5,_-I*(C-F)*.5,y-A*C,_-I*C,y+A*F,_+I*F,u,!0)+2:n.cap===wr.SQUARE&&(d+=cg(y,_,A,I,C,F,!0,u))),u.push(y-A*C,_-I*C,y+A*F,_+I*F);for(let L=1;L<c-1;++L){y=i[(L-1)*2],_=i[(L-1)*2+1],b=i[L*2],v=i[L*2+1],S=i[(L+1)*2],E=i[(L+1)*2+1],A=-(_-v),I=y-b,G=Math.sqrt(A*A+I*I),A/=G,I/=G,A*=m,I*=m,P=-(v-E),B=b-S,G=Math.sqrt(P*P+B*B),P/=G,B/=G,P*=m,B*=m;const k=b-y,K=_-v,D=b-S,U=E-v,j=k*D+K*U,q=K*D-U*k,pt=q<0;if(Math.abs(q)<.001*Math.abs(j)){u.push(b-A*C,v-I*C,b+A*F,v+I*F),j>=0&&(n.join===Ue.ROUND?d+=ns(b,v,b-A*C,v-I*C,b-P*C,v-B*C,u,!1)+4:d+=2,u.push(b-P*F,v-B*F,b+P*C,v+B*C));continue}const nt=(-A+y)*(-I+v)-(-A+b)*(-I+_),Et=(-P+S)*(-B+v)-(-P+b)*(-B+E),Rt=(k*Et-D*nt)/q,wt=(U*nt-K*Et)/q,Y=(Rt-b)*(Rt-b)+(wt-v)*(wt-v),it=b+(Rt-b)*C,tt=v+(wt-v)*C,O=b-(Rt-b)*F,bt=v-(wt-v)*F,gt=Math.min(k*k+K*K,D*D+U*U),Mt=pt?C:F,Ut=gt+Mt*Mt*f,Ne=Y<=Ut;let ci=n.join;if(ci===Ue.MITER&&Y/f>g&&(ci=Ue.BEVEL),Ne)switch(ci){case Ue.MITER:{u.push(it,tt,O,bt);break}case Ue.BEVEL:{pt?u.push(it,tt,b+A*F,v+I*F,it,tt,b+P*F,v+B*F):u.push(b-A*C,v-I*C,O,bt,b-P*C,v-B*C,O,bt),d+=2;break}case Ue.ROUND:{pt?(u.push(it,tt,b+A*F,v+I*F),d+=ns(b,v,b+A*F,v+I*F,b+P*F,v+B*F,u,!0)+4,u.push(it,tt,b+P*F,v+B*F)):(u.push(b-A*C,v-I*C,O,bt),d+=ns(b,v,b-A*C,v-I*C,b-P*C,v-B*C,u,!1)+4,u.push(b-P*C,v-B*C,O,bt));break}}else{switch(u.push(b-A*C,v-I*C,b+A*F,v+I*F),ci){case Ue.MITER:{pt?u.push(O,bt,O,bt):u.push(it,tt,it,tt),d+=2;break}case Ue.ROUND:{pt?d+=ns(b,v,b+A*F,v+I*F,b+P*F,v+B*F,u,!0)+2:d+=ns(b,v,b-A*C,v-I*C,b-P*C,v-B*C,u,!1)+2;break}}u.push(b-P*C,v-B*C,b+P*F,v+B*F),d+=2}}y=i[(c-2)*2],_=i[(c-2)*2+1],b=i[(c-1)*2],v=i[(c-1)*2+1],A=-(_-v),I=y-b,G=Math.sqrt(A*A+I*I),A/=G,I/=G,A*=m,I*=m,u.push(b-A*C,v-I*C,b+A*F,v+I*F),h||(n.cap===wr.ROUND?d+=ns(b-A*(C-F)*.5,v-I*(C-F)*.5,b-A*C,v-I*C,b+A*F,v+I*F,u,!1)+2:n.cap===wr.SQUARE&&(d+=cg(b,v,A,I,C,F,!1,u)));const X=t.indices,V=zs.epsilon*zs.epsilon;for(let L=p;L<d+p-2;++L)y=u[L*2],_=u[L*2+1],b=u[(L+1)*2],v=u[(L+1)*2+1],S=u[(L+2)*2],E=u[(L+2)*2+1],!(Math.abs(y*(v-E)+b*(E-_)+S*(_-v))<V)&&X.push(L,L+1,L+2)}function sS(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==ae.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,h=s.length/2,l=o.length/2;let u=l;for(o.push(s[0],s[1]),e=1;e<h;e++)o.push(s[e*2],s[e*2+1]),a.push(u,u+1),u++;n&&a.push(u,l)}function dg(r,t){r.lineStyle.native?sS(r,t):rS(r,t)}class Wu{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,h=e-2*s+o,l=2*i-2*t,u=2*s-2*e,c=4*(a*a+h*h),d=4*(a*l+h*u),p=l*l+u*u,m=2*Math.sqrt(c+d+p),f=Math.sqrt(c),g=2*c*f,y=2*Math.sqrt(p),_=d/f;return(g*m+f*d*(m-y)+(4*p*c-d*d)*Math.log((2*f+_+m)/(_+y)))/(4*g)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],h=zs._segmentsCount(Wu.curveLength(o,a,t,e,i,s));let l=0,u=0;for(let c=1;c<=h;++c){const d=c/h;l=o+(t-o)*d,u=a+(e-a)*d,n.push(l+(t+(i-t)*d-l)*d,u+(e+(s-e)*d-u)*d)}}}const Bu={[ae.POLY]:lg,[ae.CIRC]:Xa,[ae.ELIP]:Xa,[ae.RECT]:tS,[ae.RREC]:eS},pg=[],Za=[];class Va{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 Va(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 js=new lt,fg=class Tb extends Yf{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 Ma,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(),Za.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),pg.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 Va(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 Va(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,js):js.copyFrom(t),s.shape.contains(js.x,js.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(js.x,js.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 h=this.shapeIndex;h<e.length;h++){this.shapeIndex++;const l=e[h],u=l.fillStyle,c=l.lineStyle;Bu[l.type].build(l),l.matrix&&this.transformPoints(l.points,l.matrix),(u.visible||c.visible)&&this.processHoles(l.holes);for(let d=0;d<2;d++){const p=d===0?u:c;if(!p.visible)continue;const m=p.texture.baseTexture,f=this.indices.length,g=this.points.length/2;m.wrapMode=Hi.REPEAT,d===0?this.processFill(l):this.processLine(l);const y=this.points.length/2-g;y!==0&&(i&&!this._compareStyles(s,p)&&(i.end(f,g),i=null),i||(i=pg.pop()||new iS,i.begin(p,f,g),this.batches.push(i),s=p),this.addUvs(this.points,t,p.texture,g,y,p.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<Tb.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++mt._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Za.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Za.pop();s||(s=new uu,s.texArray=new gu),s.texArray.count=0,s.start=0,s.size=0,s.type=gi.TRIANGLES;let n=0,o=null,a=0,h=!1,l=gi.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],p=8,m=d.style,f=m.texture.baseTexture;h!==!!m.native&&(h=!!m.native,l=h?gi.LINES:gi.TRIANGLES,o=null,n=p,t++),o!==f&&(o=f,f._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=Za.pop(),s||(s=new uu,s.texArray=new gu),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=l),f.touched=1,f._batchEnabled=t,f._batchLocation=n,f.wrapMode=Hi.REPEAT,s.texArray.elements[s.texArray.count++]=f,n++)),s.size+=d.size,u+=d.size,a=f._batchLocation,this.addColors(e,m.color,m.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}mt._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 h=0;for(let l=0;l<t.length/2;l++)o[h++]=t[l*2],o[h++]=t[l*2+1],o[h++]=e[l*2],o[h++]=e[l*2+1],a[h++]=i[l],o[h++]=s[l];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?lg.triangulate(t,this):Bu[t.type].triangulate(t,this)}processLine(t){dg(t,this);for(let e=0;e<t.holes.length;e++)dg(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Bu[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=Gt.shared.setValue(e).toLittleEndianNumber(),a=Gt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let h=0;h<s;h++)t[n+h]=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 h=e.length,l=i.frame;for(;a<n;){let c=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const p=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=p}a++,e.push(c/l.width,d/l.height)}const u=i.baseTexture;(l.width<u.width||l.height<u.height)&&this.adjustUvs(e,i,h,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,h=e.frame,l=h.width/n.width,u=h.height/n.height;let c=h.x/h.width,d=h.y/h.height,p=Math.floor(t[i]+o),m=Math.floor(t[i+1]+o);for(let f=i+2;f<a;f+=2)p=Math.min(p,Math.floor(t[f]+o)),m=Math.min(m,Math.floor(t[f+1]+o));c-=p,d-=m;for(let f=i;f<a;f+=2)t[f]=(t[f]+c)*l,t[f+1]=(t[f+1]+d)*u}};fg.BATCHABLE_SIZE=100;let nS=fg;class Ka{constructor(){this.color=16777215,this.alpha=1,this.texture=rt.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Ka;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=rt.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Uu extends Ka{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=wr.BUTT,this.join=Ue.MITER,this.miterLimit=10}clone(){const t=new Uu;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=wr.BUTT,this.join=Ue.MITER,this.miterLimit=10}}const Xu={},Zu=class hl extends Xt{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 Ka,this._lineStyle=new Uu,this._matrix=null,this._holeMode=!1,this.state=Si.for2d(),this._geometry=t||new nS,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Gt(16777215),this.blendMode=ut.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new hl(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:rt.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:wr.BUTT,join:Ue.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 Yr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Yr,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),Wu.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),Ou.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=ug.curveTo(t,e,i,s,n,o);if(a){const{cx:h,cy:l,radius:u,startAngle:c,endAngle:d,anticlockwise:p}=a;this.arc(h,l,u,c,d,p)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=da:o&&s<=n&&(s+=da),n-s===0)return this;const a=t+Math.cos(s)*i,h=e+Math.sin(s)*i,l=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-h);c<l&&d<l||u.push(a,h)}else this.moveTo(a,h),u=this.currentPath.points;return ug.arc(a,h,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:rt.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Gt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:rt.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 ct(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new ga(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new fa(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new ma(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 Yr(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===ae.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),h=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),l=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:a,blendMode:e,indices:l,uvs:h,_batchRGB:Gt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_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,Gt.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,h=o.length;a<h;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 h=0;h<a;h++)t.texture.bind(i.elements[h],h);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Xu[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let h=0;h<s;h++)n[h]=h;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new Nt,default:ii.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;Xu[i]=new Ei(a,o)}e=Xu[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,hl._TEMP_POINT),this._geometry.containsPoint(hl._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=Gt.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,h=e.ty,l=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<l.length;d+=2){const p=l[d],m=l[d+1];u[c++]=i*p+n*m+a,u[c++]=o*m+s*p+h}}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)}};Zu.curves=zs,Zu._TEMP_POINT=new lt;let qn=Zu;class oS{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 Vu=new lt,mg=new Yr,gg=class wb extends Xt{constructor(t,e,i,s=gi.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Si.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=Q.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===gi.TRIANGLES&&e.length<wb.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,h=s.d,l=s.tx,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const p=e[d*2],m=e[d*2+1];c[d*2]=n*p+a*m+l,c[d*2+1]=o*p+h*m+u}if(this._roundPixels){const d=Q.RESOLUTION;for(let p=0;p<c.length;++p)c[p]=Math.round(c[p]*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 oS(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,Vu);const e=this.geometry.getBuffer("aVertexPosition").data,i=mg.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 h=s[a]*2,l=s[a+1]*2,u=s[a+2]*2;if(i[0]=e[h],i[1]=e[h+1],i[2]=e[l],i[3]=e[l+1],i[4]=e[u],i[5]=e[u+1],mg.contains(Vu.x,Vu.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}};gg.BATCHABLE_SIZE=100;let Ku=gg;class yg extends xr{constructor(t,e,i){super();const s=new Kt(t),n=new Kt(e,!0),o=new Kt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,at.FLOAT).addAttribute("aTextureCoord",n,2,!1,at.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var aS=`varying vec2 vTextureCoord;
924
924
  uniform vec4 uColor;
925
925
 
926
926
  uniform sampler2D uSampler;
@@ -978,7 +978,7 @@ void main(void){
978
978
  vColor = aColor * uColor;
979
979
  }
980
980
  `;class xg extends va{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Nt,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:at.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Ei.from(dS,cS,{}),this.state=Si.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 h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=Df(t.blendMode,l),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=Gt.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,l).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let p=0,m=0;p<o;p+=s,m+=1){let f=o-p;f>s&&(f=s),m>=a.length&&a.push(this._generateOneMoreBuffer(t));const g=a[m];g.uploadDynamic(e,p,f);const y=t._bufferUpdateIDs[m]||0;d=d||g._updateID<y,d&&(g._updateID=t._updateID,g.uploadStatic(e,p,f)),n.geometry.bind(g.geometry),u.drawElements(u.TRIANGLES,f*6,u.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 bg(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new bg(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,h=0,l=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],p=d._texture,m=d.scale.x,f=d.scale.y,g=p.trim,y=p.orig;g?(h=g.x-d.anchor.x*y.width,a=h+g.width,u=g.y-d.anchor.y*y.height,l=u+g.height):(a=y.width*(1-d.anchor.x),h=y.width*-d.anchor.x,l=y.height*(1-d.anchor.y),u=y.height*-d.anchor.y),s[o]=h*m,s[o+1]=u*f,s[o+n]=a*m,s[o+n+1]=u*f,s[o+n*2]=a*m,s[o+n*2+1]=l*f,s[o+n*3]=h*m,s[o+n*3+1]=l*f,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const h=t[e+a].position;s[o]=h.x,s[o+1]=h.y,s[o+n]=h.x,s[o+n+1]=h.y,s[o+n*2]=h.x,s[o+n*2+1]=h.y,s[o+n*3]=h.x,s[o+n*3+1]=h.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const h=t[e+a].rotation;s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const h=t[e+a]._texture._uvs;h?(s[o]=h.x0,s[o+1]=h.y0,s[o+n]=h.x1,s[o+n+1]=h.y1,s[o+n*2]=h.x2,s[o+n*2+1]=h.y2,s[o+n*3]=h.x3,s[o+n*3+1]=h.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 h=t[e+a],l=Gt.shared.setValue(h._tintRGB).toPremultiplied(h.alpha,h.texture.baseTexture.alphaMode>0);s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}xg.extension={name:"particle",type:J.RendererPlugin},et.add(xg);var Ha=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Ha||{});const Ya={willReadFrequently:!0},Ci=class st{static get experimentalLetterSpacingSupported(){let t=st._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.ADAPTER.getCanvasRenderingContext2D().prototype;t=st._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,h,l){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l}static measureText(t,e,i,s=st._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=st.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",Ya);a.font=n;const h=(i?st.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let u=0;for(let m=0;m<h.length;m++){const f=st._measureText(h[m],e.letterSpacing,a);l[m]=f,u=Math.max(u,f)}let c=u+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let p=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(h.length-1)*(d+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new st(t,e,c,p,h,l,d+e.leading,u,o)}static _measureText(t,e,i){let s=!1;st.experimentalLetterSpacingSupported&&(st.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+=(st.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=st._canvas){const s=i.getContext("2d",Ya);let n=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:u}=e,c=st.collapseSpaces(u),d=st.collapseNewlines(u);let p=!c;const m=e.wordWrapWidth+l,f=st.tokenize(t);for(let g=0;g<f.length;g++){let y=f[g];if(st.isNewline(y)){if(!d){a+=st.addLine(o),p=!c,o="",n=0;continue}y=" "}if(c){const b=st.isBreakingSpace(y),v=st.isBreakingSpace(o[o.length-1]);if(b&&v)continue}const _=st.getFromCache(y,l,h,s);if(_>m)if(o!==""&&(a+=st.addLine(o),o="",n=0),st.canBreakWords(y,e.breakWords)){const b=st.wordWrapSplit(y);for(let v=0;v<b.length;v++){let S=b[v],E=S,A=1;for(;b[v+A];){const P=b[v+A];if(!st.canBreakChars(E,P,y,v,e.breakWords))S+=P;else break;E=P,A++}v+=A-1;const I=st.getFromCache(S,l,h,s);I+n>m&&(a+=st.addLine(o),p=!1,o="",n=0),o+=S,n+=I}}else{o.length>0&&(a+=st.addLine(o),o="",n=0);const b=g===f.length-1;a+=st.addLine(y,!b),p=!1,o="",n=0}else _+n>m&&(p=!1,a+=st.addLine(o),o="",n=0),(o.length>0||!st.isBreakingSpace(y)||p)&&(o+=y,n+=_)}return a+=st.addLine(o,!1),a}static addLine(t,e=!0){return t=st.trimRight(t),t=e?`${t}
981
- `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=st._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(!st.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:st._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:st._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(st.isBreakingSpace(n,o)||st.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 st.graphemeSegmenter(t)}static measureFont(t){if(st._fonts[t])return st._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=st._canvas,s=st._context;s.font=t;const n=st.METRICS_STRING+st.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(st.BASELINE_SYMBOL).width);const h=Math.ceil(st.HEIGHT_MULTIPLIER*a);if(a=a*st.BASELINE_MULTIPLIER|0,o===0||h===0)return st._fonts[t]=e,e;i.width=o,i.height=h,s.fillStyle="#f00",s.fillRect(0,0,o,h),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const l=s.getImageData(0,0,o,h).data,u=l.length,c=o*4;let d=0,p=0,m=!1;for(d=0;d<a;++d){for(let f=0;f<c;f+=4)if(l[p+f]!==255){m=!0;break}if(!m)p+=c;else break}for(e.ascent=a-d,p=u-c,m=!1,d=h;d>a;--d){for(let f=0;f<c;f+=4)if(l[p+f]!==255){m=!0;break}if(!m)p-=c;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,st._fonts[t]=e,e}static clearMetrics(t=""){t?delete st._fonts[t]:st._fonts={}}static get _canvas(){var t;if(!st.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Ya))!=null&&t.measureText)return st.__canvas=i,i;e=Q.ADAPTER.createCanvas()}catch{e=Q.ADAPTER.createCanvas()}e.width=e.height=10,st.__canvas=e}return st.__canvas}static get _context(){return st.__context||(st.__context=st._canvas.getContext("2d",Ya)),st.__context}};Ci.METRICS_STRING="|ÉqÅ",Ci.BASELINE_SYMBOL="M",Ci.BASELINE_MULTIPLIER=1.4,Ci.HEIGHT_MULTIPLIER=2,Ci.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]})(),Ci.experimentalLetterSpacing=!1,Ci._fonts={},Ci._newlines=[10,13],Ci._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Sr=Ci;const pS=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],_g=class Ko{constructor(t){this.styleID=0,this.reset(),zu(this,t,t)}clone(){const t={};return zu(t,this,Ko.defaultStyle),new Ko(t)}reset(){zu(this,Ko.defaultStyle,Ko.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=Yu(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=Yu(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){fS(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=Yu(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)&&!pS.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};_g.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Ha.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 Er=_g;function Yu(r){const t=Gt.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 fS(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 zu(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const mS={texture:!0,children:!1,baseTexture:!0},vg=class gp extends ie{constructor(t,e,i){let s=!1;i||(i=Q.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=rt.from(i);n.orig=new ct,n.trim=new ct,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=gp.defaultResolution??Q.RESOLUTION,this._autoResolution=gp.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 Sr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){vt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Sr.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=Sr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,h=s.lineHeight,l=s.lineWidths,u=s.maxLineWidth,c=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,p;const m=e.dropShadow?2:1;for(let f=0;f<m;++f){const g=e.dropShadow&&f===0,y=g?Math.ceil(Math.max(1,o)+e.padding*2):0,_=y*this._resolution;if(g){i.fillStyle="black",i.strokeStyle="black";const v=e.dropShadowColor,S=e.dropShadowBlur*this._resolution,E=e.dropShadowDistance*this._resolution;i.shadowColor=Gt.shared.setValue(v).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=S,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*E,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*E+_}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 b=(h-c.fontSize)/2;h-c.fontSize<0&&(b=0);for(let v=0;v<a.length;v++)d=e.strokeThickness/2,p=e.strokeThickness/2+v*h+c.ascent+b,e.align==="right"?d+=u-l[v]:e.align==="center"&&(d+=(u-l[v])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[v],d+e.padding,p+e.padding-y,!0),e.fill&&this.drawLetterSpacing(a[v],d+e.padding,p+e.padding-y)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(Sr.experimentalLetterSpacingSupported&&(Sr.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 h=Sr.graphemeSegmenter(t);let l=this.context.measureText(t).width,u=0;for(let c=0;c<h.length;++c){const d=h[c];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let p="";for(let m=c+1;m<h.length;++m)p+=h[m];u=this.context.measureText(p).width,a+=l-u+n,l=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=F1(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,h=this.canvas.width/this._resolution-o-a*2,l=this.canvas.height/this._resolution-o-a*2,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let p=1;p<d;++p)c.push(p/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===Ha.LINEAR_VERTICAL){n=this.context.createLinearGradient(h/2,a,h/2,l+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let p=0;p<e.length;p++){const m=i.lineHeight*(p-1)+d,f=i.lineHeight*p;let g=f;p>0&&m>f&&(g=(f+m)/2);const y=f+d,_=i.lineHeight*(p+1);let b=y;p+1<e.length&&_<y&&(b=(y+_)/2);const v=(b-g)/l;for(let S=0;S<u.length;S++){let E=0;typeof c[S]=="number"?E=c[S]:E=S/u.length;let A=Math.min(1,Math.max(0,g/l+E*v));A=Number(A.toFixed(5)),n.addColorStop(A,u[S])}}}else{n=this.context.createLinearGradient(a,l/2,h+a,l/2);const d=u.length+1;let p=1;for(let m=0;m<u.length;m++){let f;typeof c[m]=="number"?f=c[m]:f=p/d,n.addColorStop(f,u[m]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},mS,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=yr(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=yr(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 Er?this._style=t:this._style=new Er(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)}};vg.defaultAutoResolution=!0;let Tg=vg;class gS{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function yS(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 rt){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function bS(r,t){if(r.baseTexture instanceof ft){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function xS(r,t){if(r._texture&&r._texture instanceof rt){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function _S(r,t){return t instanceof Tg?(t.updateText(!0),!0):!1}function vS(r,t){if(t instanceof Er){const e=t.toFontString();return Sr.measureFont(e),!0}return!1}function TS(r,t){if(r instanceof Tg){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 wS(r,t){return r instanceof Er?(t.includes(r)||t.push(r),!0):!1}const wg=class Sb{constructor(t){this.limiter=new gS(Sb.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(TS),this.registerFindHook(wS),this.registerFindHook(yS),this.registerFindHook(bS),this.registerFindHook(xS),this.registerUploadHook(_S),this.registerUploadHook(vS)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,be.system.addOnce(this.tick,this,is.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)be.system.addOnce(this.tick,this,is.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 Xt)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&be.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}};wg.uploadsPerFrame=4;let ju=wg;Object.defineProperties(Q,{UPLOADS_PER_FRAME:{get(){return ju.uploadsPerFrame},set(r){vt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),ju.uploadsPerFrame=r}}});function Sg(r,t){return t instanceof ft?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function SS(r,t){if(!(t instanceof qn))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&&Sg(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function ES(r,t){return r instanceof qn?(t.push(r),!0):!1}class Eg extends ju{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(ES),this.registerUploadHook(Sg),this.registerUploadHook(SS)}}Eg.extension={name:"prepare",type:J.RendererSystem},et.add(Eg);var CS=`#version 300 es
981
+ `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=st._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(!st.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:st._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:st._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(st.isBreakingSpace(n,o)||st.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 st.graphemeSegmenter(t)}static measureFont(t){if(st._fonts[t])return st._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=st._canvas,s=st._context;s.font=t;const n=st.METRICS_STRING+st.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(st.BASELINE_SYMBOL).width);const h=Math.ceil(st.HEIGHT_MULTIPLIER*a);if(a=a*st.BASELINE_MULTIPLIER|0,o===0||h===0)return st._fonts[t]=e,e;i.width=o,i.height=h,s.fillStyle="#f00",s.fillRect(0,0,o,h),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const l=s.getImageData(0,0,o,h).data,u=l.length,c=o*4;let d=0,p=0,m=!1;for(d=0;d<a;++d){for(let f=0;f<c;f+=4)if(l[p+f]!==255){m=!0;break}if(!m)p+=c;else break}for(e.ascent=a-d,p=u-c,m=!1,d=h;d>a;--d){for(let f=0;f<c;f+=4)if(l[p+f]!==255){m=!0;break}if(!m)p-=c;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,st._fonts[t]=e,e}static clearMetrics(t=""){t?delete st._fonts[t]:st._fonts={}}static get _canvas(){var t;if(!st.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Ya))!=null&&t.measureText)return st.__canvas=i,i;e=Q.ADAPTER.createCanvas()}catch{e=Q.ADAPTER.createCanvas()}e.width=e.height=10,st.__canvas=e}return st.__canvas}static get _context(){return st.__context||(st.__context=st._canvas.getContext("2d",Ya)),st.__context}};Ci.METRICS_STRING="|ÉqÅ",Ci.BASELINE_SYMBOL="M",Ci.BASELINE_MULTIPLIER=1.4,Ci.HEIGHT_MULTIPLIER=2,Ci.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]})(),Ci.experimentalLetterSpacing=!1,Ci._fonts={},Ci._newlines=[10,13],Ci._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Sr=Ci;const pS=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],_g=class Ko{constructor(t){this.styleID=0,this.reset(),zu(this,t,t)}clone(){const t={};return zu(t,this,Ko.defaultStyle),new Ko(t)}reset(){zu(this,Ko.defaultStyle,Ko.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=Yu(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=Yu(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){fS(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=Yu(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)&&!pS.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};_g.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Ha.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 Er=_g;function Yu(r){const t=Gt.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 fS(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 zu(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const mS={texture:!0,children:!1,baseTexture:!0},vg=class gp extends ie{constructor(t,e,i){let s=!1;i||(i=Q.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=rt.from(i);n.orig=new ct,n.trim=new ct,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=gp.defaultResolution??Q.RESOLUTION,this._autoResolution=gp.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 Sr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){vt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Sr.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=Sr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,h=s.lineHeight,l=s.lineWidths,u=s.maxLineWidth,c=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,p;const m=e.dropShadow?2:1;for(let f=0;f<m;++f){const g=e.dropShadow&&f===0,y=g?Math.ceil(Math.max(1,o)+e.padding*2):0,_=y*this._resolution;if(g){i.fillStyle="black",i.strokeStyle="black";const v=e.dropShadowColor,S=e.dropShadowBlur*this._resolution,E=e.dropShadowDistance*this._resolution;i.shadowColor=Gt.shared.setValue(v).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=S,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*E,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*E+_}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 b=(h-c.fontSize)/2;h-c.fontSize<0&&(b=0);for(let v=0;v<a.length;v++)d=e.strokeThickness/2,p=e.strokeThickness/2+v*h+c.ascent+b,e.align==="right"?d+=u-l[v]:e.align==="center"&&(d+=(u-l[v])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[v],d+e.padding,p+e.padding-y,!0),e.fill&&this.drawLetterSpacing(a[v],d+e.padding,p+e.padding-y)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(Sr.experimentalLetterSpacingSupported&&(Sr.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 h=Sr.graphemeSegmenter(t);let l=this.context.measureText(t).width,u=0;for(let c=0;c<h.length;++c){const d=h[c];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let p="";for(let m=c+1;m<h.length;++m)p+=h[m];u=this.context.measureText(p).width,a+=l-u+n,l=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=F1(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,h=this.canvas.width/this._resolution-o-a*2,l=this.canvas.height/this._resolution-o-a*2,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let p=1;p<d;++p)c.push(p/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===Ha.LINEAR_VERTICAL){n=this.context.createLinearGradient(h/2,a,h/2,l+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let p=0;p<e.length;p++){const m=i.lineHeight*(p-1)+d,f=i.lineHeight*p;let g=f;p>0&&m>f&&(g=(f+m)/2);const y=f+d,_=i.lineHeight*(p+1);let b=y;p+1<e.length&&_<y&&(b=(y+_)/2);const v=(b-g)/l;for(let S=0;S<u.length;S++){let E=0;typeof c[S]=="number"?E=c[S]:E=S/u.length;let A=Math.min(1,Math.max(0,g/l+E*v));A=Number(A.toFixed(5)),n.addColorStop(A,u[S])}}}else{n=this.context.createLinearGradient(a,l/2,h+a,l/2);const d=u.length+1;let p=1;for(let m=0;m<u.length;m++){let f;typeof c[m]=="number"?f=c[m]:f=p/d,n.addColorStop(f,u[m]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},mS,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=yr(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=yr(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 Er?this._style=t:this._style=new Er(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)}};vg.defaultAutoResolution=!0;let Tg=vg;class gS{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function yS(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 rt){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function bS(r,t){if(r.baseTexture instanceof mt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function xS(r,t){if(r._texture&&r._texture instanceof rt){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function _S(r,t){return t instanceof Tg?(t.updateText(!0),!0):!1}function vS(r,t){if(t instanceof Er){const e=t.toFontString();return Sr.measureFont(e),!0}return!1}function TS(r,t){if(r instanceof Tg){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 wS(r,t){return r instanceof Er?(t.includes(r)||t.push(r),!0):!1}const wg=class Sb{constructor(t){this.limiter=new gS(Sb.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(TS),this.registerFindHook(wS),this.registerFindHook(yS),this.registerFindHook(bS),this.registerFindHook(xS),this.registerUploadHook(_S),this.registerUploadHook(vS)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,be.system.addOnce(this.tick,this,is.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)be.system.addOnce(this.tick,this,is.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 Xt)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&be.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}};wg.uploadsPerFrame=4;let ju=wg;Object.defineProperties(Q,{UPLOADS_PER_FRAME:{get(){return ju.uploadsPerFrame},set(r){vt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),ju.uploadsPerFrame=r}}});function Sg(r,t){return t instanceof mt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function SS(r,t){if(!(t instanceof qn))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&&Sg(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function ES(r,t){return r instanceof qn?(t.push(r),!0):!1}class Eg extends ju{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(ES),this.registerUploadHook(Sg),this.registerUploadHook(SS)}}Eg.extension={name:"prepare",type:J.RendererSystem},et.add(Eg);var CS=`#version 300 es
982
982
  #define SHADER_NAME Tiling-Sprite-100
983
983
 
984
984
  precision lowp float;
@@ -1092,7 +1092,7 @@ void main(void)
1092
1092
  vec4 texSample = texture2D(uSampler, vTextureCoord);
1093
1093
  gl_FragColor = texSample * uColor;
1094
1094
  }
1095
- `;const za=new Nt;class Ig extends va{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new lm,this.state=Si.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Ei.from(Cg,RS,e),this.shader=t.context.webGLVersion>1?Ei.from(IS,CS,e):Ei.from(Cg,AS,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,h=a.baseTexture,l=h.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=h.isPowerOfTwo&&a.frame.width===h.width&&a.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==Hi.CLAMP:h.wrapMode===Hi.CLAMP&&(h.wrapMode=Hi.REPEAT));const p=d?this.simpleShader:this.shader,m=a.width,f=a.height,g=t._width,y=t._height;za.set(u.a*m/g,u.b*m/y,u.c*f/g,u.d*f/y,u.tx/g,u.ty/y),za.invert(),d?za.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=za.toArray(!0),p.uniforms.uColor=Gt.shared.setValue(t.tint).premultiply(t.worldAlpha,l).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),p.uniforms.uSampler=a,e.shader.bind(p),e.geometry.bind(i),this.state.blendMode=Df(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Ig.extension={name:"tilingSprite",type:J.RendererPlugin},et.add(Ig);const Ag=class Ho{constructor(t,e,i=null){this.linkedSheets=[],this._texture=t instanceof rt?t:null,this.baseTexture=t instanceof ft?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;const s=this.baseTexture.resource;this.resolution=this._updateResolution(i||(s?s.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=Qi(t,null);return i===null&&(i=parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Ho.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Ho.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,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new ct(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?a=new ct(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 ct(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&&(h=new ct(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 rt(this.baseTexture,a,u,h,n.rotated?2:0,n.anchor,n.borders),rt.addToCache(this.textures[s],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*Ho.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ho.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=[]}};Ag.BATCH_SIZE=1e3;let Rg=Ag;const MS=["jpg","png","jpeg","avif","webp"];function Mg(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[s]=t.textures[s]}),!e){const s=Jt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Mg([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const PS={extension:J.Asset,cache:{test:r=>r instanceof Rg,getCacheableAssets:(r,t)=>Mg(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&MS.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=Q.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:J.LoadParser,priority:ni.Normal},async testParse(r,t){return Jt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var h,l;let i=Jt.dirname(t.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");let s=i+r.meta.image;s=Lu(s,t.src);const n=(await e.load([s]))[s],o=new Rg(n.baseTexture,r,t.src);await o.parse();const a=(h=r==null?void 0:r.meta)==null?void 0:h.related_multi_packs;if(Array.isArray(a)){const u=[];for(const d of a){if(typeof d!="string")continue;let p=i+d;(l=t.data)!=null&&l.ignoreMultiPack||(p=Lu(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const c=await Promise.all(u);o.linkedSheets=c,c.forEach(d=>{d.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==d))})}return o},unload(r){r.destroy(!0)}}};et.add(PS);class ja{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Ja{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),h={};for(const l in a){const u=a[l].split("="),c=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),m=isNaN(p)?d:p;h[c]=m}i[o].push(h)}const s=new ja;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 Ju{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 ja,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l<i.length;l++)e.info.push({face:i[l].getAttribute("face"),size:parseInt(i[l].getAttribute("size"),10)});for(let l=0;l<s.length;l++)e.common.push({lineHeight:parseInt(s[l].getAttribute("lineHeight"),10)});for(let l=0;l<n.length;l++)e.page.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});for(let l=0;l<o.length;l++){const u=o[l];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let l=0;l<a.length;l++)e.kerning.push({first:parseInt(a[l].getAttribute("first"),10),second:parseInt(a[l].getAttribute("second"),10),amount:parseInt(a[l].getAttribute("amount"),10)});for(let l=0;l<h.length;l++)e.distanceField.push({fieldType:h[l].getAttribute("fieldType"),distanceRange:parseInt(h[l].getAttribute("distanceRange"),10)});return e}}class $u{static test(t){return typeof t=="string"&&t.includes("<font>")?Ju.test(Q.ADAPTER.parseXML(t)):!1}static parse(t){return Ju.parse(Q.ADAPTER.parseXML(t))}}const Qu=[Ja,Ju,$u];function LS(r){for(let t=0;t<Qu.length;t++)if(Qu[t].test(r))return Qu[t];return null}function GS(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 h=e.dropShadow?e.dropShadowDistance:0,l=e.padding||0,u=r.width/i-h-l*2,c=r.height/i-h-l*2,d=o.slice(),p=e.fillGradientStops.slice();if(!p.length){const m=d.length+1;for(let f=1;f<m;++f)p.push(f/m)}if(d.unshift(o[0]),p.unshift(0),d.push(o[o.length-1]),p.push(1),e.fillGradientType===Ha.LINEAR_VERTICAL){a=t.createLinearGradient(u/2,l,u/2,c+l);let m=0;const f=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let g=0;g<s.length;g++){const y=n.lineHeight*g;for(let _=0;_<d.length;_++){let b=0;typeof p[_]=="number"?b=p[_]:b=_/d.length;const v=y/c+b*f;let S=Math.max(m,v);S=Math.min(S,1),a.addColorStop(S,d[_]),m=S}}}else{a=t.createLinearGradient(l,c/2,u+l,c/2);const m=d.length+1;let f=1;for(let g=0;g<d.length;g++){let y;typeof p[g]=="number"?y=p[g]:y=f/m,a.addColorStop(y,d[g]),f++}}return a}function NS(r,t,e,i,s,n,o){const a=e.text,h=e.fontProperties;t.translate(i,s),t.scale(n,n);const l=o.strokeThickness/2,u=-(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=GS(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*n,p=o.dropShadowDistance*n;t.shadowColor=Gt.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*p,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*p}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,l,u+e.lineHeight-h.descent),o.fill&&t.fillText(a,l,u+e.lineHeight-h.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function $a(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function Pg(r){return Array.from?Array.from(r):r.split("")}function FS(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,h=o;a<=h;a++)t.push(String.fromCharCode(a))}else t.push(...Pg(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Cr=class Xi{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,h=Qi(o.file),l={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/h,this.chars={},this.pageTextures=l;for(let c=0;c<t.page.length;c++){const{id:d,file:p}=t.page[c];l[d]=e instanceof Array?e[c]:e[p],a!=null&&a.fieldType&&a.fieldType!=="none"&&(l[d].baseTexture.alphaMode=xe.NO_PREMULTIPLIED_ALPHA,l[d].baseTexture.mipmap=yi.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:p}=t.char[c];let{x:m,y:f,width:g,height:y,xoffset:_,yoffset:b,xadvance:v}=t.char[c];m/=h,f/=h,g/=h,y/=h,_/=h,b/=h,v/=h;const S=new ct(m+l[p].frame.x/h,f+l[p].frame.y/h,g,y);this.chars[d]={xOffset:_,yOffset:b,xAdvance:v,kerning:{},texture:new rt(l[p].baseTexture,S),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:m}=t.kerning[c];d/=h,p/=h,m/=h,this.chars[p]&&(this.chars[p].kerning[d]=m)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((u=a==null?void 0:a.fieldType)==null?void 0:u.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 ja)s=t;else{const o=LS(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof rt&&(e=[e]);const n=new Xi(s,e,i);return Xi.available[n.font]=n,n}static uninstall(t){const e=Xi.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Xi.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:h,...l}=Object.assign({},Xi.defaultOptions,i),u=FS(s),c=e instanceof Er?e:new Er(e),d=a,p=new ja;p.info[0]={face:c.fontFamily,size:c.fontSize},p.common[0]={lineHeight:c.fontSize};let m=0,f=0,g,y,_,b=0;const v=[];for(let E=0;E<u.length;E++){g||(g=Q.ADAPTER.createCanvas(),g.width=a,g.height=h,y=g.getContext("2d"),_=new ft(g,{resolution:o,...l}),v.push(new rt(_)),p.page.push({id:v.length-1,file:""}));const A=u[E],I=Sr.measureText(A,c,!1,g),P=I.width,B=Math.ceil(I.height),G=Math.ceil((c.fontStyle==="italic"?2:1)*P);if(f>=h-B*o){if(f===0)throw new Error(`[BitmapFont] textureHeight ${h}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${A}')`);--E,g=null,y=null,_=null,f=0,m=0,b=0;continue}if(b=Math.max(B+I.fontProperties.descent,b),G*o+m>=d){if(m===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${A}')`);--E,f+=b*o,f=Math.ceil(f),m=0,b=0;continue}NS(g,y,I,m,f,o,c);const N=$a(I.text);p.char.push({id:N,page:v.length-1,x:m/o,y:f/o,width:G,height:B,xoffset:0,yoffset:0,xadvance:P-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),m+=(G+2*n)*o,m=Math.ceil(m)}if(!(i!=null&&i.skipKerning))for(let E=0,A=u.length;E<A;E++){const I=u[E];for(let P=0;P<A;P++){const B=u[P],G=y.measureText(I).width,N=y.measureText(B).width,C=y.measureText(I+B).width-(G+N);C&&p.kerning.push({first:$a(I),second:$a(B),amount:C})}}const S=new Xi(p,v,!0);return Xi.available[t]!==void 0&&Xi.uninstall(t),Xi.available[t]=S,S}};Cr.ALPHA=[["a","z"],["A","Z"]," "],Cr.NUMERIC=[["0","9"]],Cr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Cr.ASCII=[[" ","~"]],Cr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Cr.ALPHANUMERIC},Cr.available={};let ai=Cr;var DS=`// Pixi texture info\r
1095
+ `;const za=new Nt;class Ig extends va{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new lm,this.state=Si.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Ei.from(Cg,RS,e),this.shader=t.context.webGLVersion>1?Ei.from(IS,CS,e):Ei.from(Cg,AS,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,h=a.baseTexture,l=h.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=h.isPowerOfTwo&&a.frame.width===h.width&&a.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==Hi.CLAMP:h.wrapMode===Hi.CLAMP&&(h.wrapMode=Hi.REPEAT));const p=d?this.simpleShader:this.shader,m=a.width,f=a.height,g=t._width,y=t._height;za.set(u.a*m/g,u.b*m/y,u.c*f/g,u.d*f/y,u.tx/g,u.ty/y),za.invert(),d?za.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=za.toArray(!0),p.uniforms.uColor=Gt.shared.setValue(t.tint).premultiply(t.worldAlpha,l).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),p.uniforms.uSampler=a,e.shader.bind(p),e.geometry.bind(i),this.state.blendMode=Df(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Ig.extension={name:"tilingSprite",type:J.RendererPlugin},et.add(Ig);const Ag=class Ho{constructor(t,e,i=null){this.linkedSheets=[],this._texture=t instanceof rt?t:null,this.baseTexture=t instanceof mt?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;const s=this.baseTexture.resource;this.resolution=this._updateResolution(i||(s?s.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=Qi(t,null);return i===null&&(i=parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Ho.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Ho.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,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new ct(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?a=new ct(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 ct(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&&(h=new ct(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 rt(this.baseTexture,a,u,h,n.rotated?2:0,n.anchor,n.borders),rt.addToCache(this.textures[s],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*Ho.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ho.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=[]}};Ag.BATCH_SIZE=1e3;let Rg=Ag;const MS=["jpg","png","jpeg","avif","webp"];function Mg(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[s]=t.textures[s]}),!e){const s=Jt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Mg([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const PS={extension:J.Asset,cache:{test:r=>r instanceof Rg,getCacheableAssets:(r,t)=>Mg(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&MS.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=Q.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:J.LoadParser,priority:ni.Normal},async testParse(r,t){return Jt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var h,l;let i=Jt.dirname(t.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");let s=i+r.meta.image;s=Lu(s,t.src);const n=(await e.load([s]))[s],o=new Rg(n.baseTexture,r,t.src);await o.parse();const a=(h=r==null?void 0:r.meta)==null?void 0:h.related_multi_packs;if(Array.isArray(a)){const u=[];for(const d of a){if(typeof d!="string")continue;let p=i+d;(l=t.data)!=null&&l.ignoreMultiPack||(p=Lu(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const c=await Promise.all(u);o.linkedSheets=c,c.forEach(d=>{d.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==d))})}return o},unload(r){r.destroy(!0)}}};et.add(PS);class ja{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Ja{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),h={};for(const l in a){const u=a[l].split("="),c=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),m=isNaN(p)?d:p;h[c]=m}i[o].push(h)}const s=new ja;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 Ju{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 ja,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l<i.length;l++)e.info.push({face:i[l].getAttribute("face"),size:parseInt(i[l].getAttribute("size"),10)});for(let l=0;l<s.length;l++)e.common.push({lineHeight:parseInt(s[l].getAttribute("lineHeight"),10)});for(let l=0;l<n.length;l++)e.page.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});for(let l=0;l<o.length;l++){const u=o[l];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let l=0;l<a.length;l++)e.kerning.push({first:parseInt(a[l].getAttribute("first"),10),second:parseInt(a[l].getAttribute("second"),10),amount:parseInt(a[l].getAttribute("amount"),10)});for(let l=0;l<h.length;l++)e.distanceField.push({fieldType:h[l].getAttribute("fieldType"),distanceRange:parseInt(h[l].getAttribute("distanceRange"),10)});return e}}class $u{static test(t){return typeof t=="string"&&t.includes("<font>")?Ju.test(Q.ADAPTER.parseXML(t)):!1}static parse(t){return Ju.parse(Q.ADAPTER.parseXML(t))}}const Qu=[Ja,Ju,$u];function LS(r){for(let t=0;t<Qu.length;t++)if(Qu[t].test(r))return Qu[t];return null}function GS(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 h=e.dropShadow?e.dropShadowDistance:0,l=e.padding||0,u=r.width/i-h-l*2,c=r.height/i-h-l*2,d=o.slice(),p=e.fillGradientStops.slice();if(!p.length){const m=d.length+1;for(let f=1;f<m;++f)p.push(f/m)}if(d.unshift(o[0]),p.unshift(0),d.push(o[o.length-1]),p.push(1),e.fillGradientType===Ha.LINEAR_VERTICAL){a=t.createLinearGradient(u/2,l,u/2,c+l);let m=0;const f=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let g=0;g<s.length;g++){const y=n.lineHeight*g;for(let _=0;_<d.length;_++){let b=0;typeof p[_]=="number"?b=p[_]:b=_/d.length;const v=y/c+b*f;let S=Math.max(m,v);S=Math.min(S,1),a.addColorStop(S,d[_]),m=S}}}else{a=t.createLinearGradient(l,c/2,u+l,c/2);const m=d.length+1;let f=1;for(let g=0;g<d.length;g++){let y;typeof p[g]=="number"?y=p[g]:y=f/m,a.addColorStop(y,d[g]),f++}}return a}function NS(r,t,e,i,s,n,o){const a=e.text,h=e.fontProperties;t.translate(i,s),t.scale(n,n);const l=o.strokeThickness/2,u=-(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=GS(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*n,p=o.dropShadowDistance*n;t.shadowColor=Gt.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*p,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*p}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,l,u+e.lineHeight-h.descent),o.fill&&t.fillText(a,l,u+e.lineHeight-h.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function $a(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function Pg(r){return Array.from?Array.from(r):r.split("")}function FS(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,h=o;a<=h;a++)t.push(String.fromCharCode(a))}else t.push(...Pg(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Cr=class Xi{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,h=Qi(o.file),l={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/h,this.chars={},this.pageTextures=l;for(let c=0;c<t.page.length;c++){const{id:d,file:p}=t.page[c];l[d]=e instanceof Array?e[c]:e[p],a!=null&&a.fieldType&&a.fieldType!=="none"&&(l[d].baseTexture.alphaMode=xe.NO_PREMULTIPLIED_ALPHA,l[d].baseTexture.mipmap=yi.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:p}=t.char[c];let{x:m,y:f,width:g,height:y,xoffset:_,yoffset:b,xadvance:v}=t.char[c];m/=h,f/=h,g/=h,y/=h,_/=h,b/=h,v/=h;const S=new ct(m+l[p].frame.x/h,f+l[p].frame.y/h,g,y);this.chars[d]={xOffset:_,yOffset:b,xAdvance:v,kerning:{},texture:new rt(l[p].baseTexture,S),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:m}=t.kerning[c];d/=h,p/=h,m/=h,this.chars[p]&&(this.chars[p].kerning[d]=m)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((u=a==null?void 0:a.fieldType)==null?void 0:u.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 ja)s=t;else{const o=LS(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof rt&&(e=[e]);const n=new Xi(s,e,i);return Xi.available[n.font]=n,n}static uninstall(t){const e=Xi.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Xi.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:h,...l}=Object.assign({},Xi.defaultOptions,i),u=FS(s),c=e instanceof Er?e:new Er(e),d=a,p=new ja;p.info[0]={face:c.fontFamily,size:c.fontSize},p.common[0]={lineHeight:c.fontSize};let m=0,f=0,g,y,_,b=0;const v=[];for(let E=0;E<u.length;E++){g||(g=Q.ADAPTER.createCanvas(),g.width=a,g.height=h,y=g.getContext("2d"),_=new mt(g,{resolution:o,...l}),v.push(new rt(_)),p.page.push({id:v.length-1,file:""}));const A=u[E],I=Sr.measureText(A,c,!1,g),P=I.width,B=Math.ceil(I.height),G=Math.ceil((c.fontStyle==="italic"?2:1)*P);if(f>=h-B*o){if(f===0)throw new Error(`[BitmapFont] textureHeight ${h}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${A}')`);--E,g=null,y=null,_=null,f=0,m=0,b=0;continue}if(b=Math.max(B+I.fontProperties.descent,b),G*o+m>=d){if(m===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${A}')`);--E,f+=b*o,f=Math.ceil(f),m=0,b=0;continue}NS(g,y,I,m,f,o,c);const N=$a(I.text);p.char.push({id:N,page:v.length-1,x:m/o,y:f/o,width:G,height:B,xoffset:0,yoffset:0,xadvance:P-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),m+=(G+2*n)*o,m=Math.ceil(m)}if(!(i!=null&&i.skipKerning))for(let E=0,A=u.length;E<A;E++){const I=u[E];for(let P=0;P<A;P++){const B=u[P],G=y.measureText(I).width,N=y.measureText(B).width,C=y.measureText(I+B).width-(G+N);C&&p.kerning.push({first:$a(I),second:$a(B),amount:C})}}const S=new Xi(p,v,!0);return Xi.available[t]!==void 0&&Xi.uninstall(t),Xi.available[t]=S,S}};Cr.ALPHA=[["a","z"],["A","Z"]," "],Cr.NUMERIC=[["0","9"]],Cr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Cr.ASCII=[[" ","~"]],Cr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Cr.ALPHANUMERIC},Cr.available={};let ai=Cr;var DS=`// Pixi texture info\r
1096
1096
  varying vec2 vTextureCoord;\r
1097
1097
  uniform sampler2D uSampler;\r
1098
1098
  \r
@@ -1172,6 +1172,6 @@ void main(void)\r
1172
1172
  * Subject to the terms at https://greensock.com/standard-license or for
1173
1173
  * Club GreenSock members, the agreement issued with that membership.
1174
1174
  * @author: Jack Doyle, jack@greensock.com
1175
- */var L0,Lr,sn,Lc,ds,G0,Gc,GE=function(){return typeof window<"u"},sr={},ps=180/Math.PI,nn=Math.PI/180,on=Math.atan2,N0=1e8,Nc=/([A-Z])/g,NE=/(left|right|width|margin|padding|x)/i,FE=/[\s,\(]\S/,Ri={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},Fc=function(t,e){return e.set(e.t,e.p,Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},DE=function(t,e){return e.set(e.t,e.p,t===1?e.e:Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},kE=function(t,e){return e.set(e.t,e.p,t?Math.round((e.s+e.c*t)*1e4)/1e4+e.u:e.b,e)},OE=function(t,e){var i=e.s+e.c*t;e.set(e.t,e.p,~~(i+(i<0?-.5:.5))+e.u,e)},F0=function(t,e){return e.set(e.t,e.p,t?e.e:e.b,e)},D0=function(t,e){return e.set(e.t,e.p,t!==1?e.b:e.e,e)},WE=function(t,e,i){return t.style[e]=i},BE=function(t,e,i){return t.style.setProperty(e,i)},UE=function(t,e,i){return t._gsap[e]=i},XE=function(t,e,i){return t._gsap.scaleX=t._gsap.scaleY=i},ZE=function(t,e,i,s,n){var o=t._gsap;o.scaleX=o.scaleY=i,o.renderTransform(n,o)},VE=function(t,e,i,s,n){var o=t._gsap;o[e]=i,o.renderTransform(n,o)},Bt="transform",hi=Bt+"Origin",KE=function r(t,e){var i=this,s=this.target,n=s.style;if(t in sr&&n){if(this.tfm=this.tfm||{},t!=="transform")t=Ri[t]||t,~t.indexOf(",")?t.split(",").forEach(function(o){return i.tfm[o]=nr(s,o)}):this.tfm[t]=s._gsap.x?s._gsap[t]:nr(s,t);else return Ri.transform.split(",").forEach(function(o){return r.call(i,o,e)});if(this.props.indexOf(Bt)>=0)return;s._gsap.svg&&(this.svgo=s.getAttribute("data-svg-origin"),this.props.push(hi,e,"")),t=Bt}(n||e)&&this.props.push(t,e,n[t])},k0=function(t){t.translate&&(t.removeProperty("translate"),t.removeProperty("scale"),t.removeProperty("rotate"))},HE=function(){var t=this.props,e=this.target,i=e.style,s=e._gsap,n,o;for(n=0;n<t.length;n+=3)t[n+1]?e[t[n]]=t[n+2]:t[n+2]?i[t[n]]=t[n+2]:i.removeProperty(t[n].substr(0,2)==="--"?t[n]:t[n].replace(Nc,"-$1").toLowerCase());if(this.tfm){for(o in this.tfm)s[o]=this.tfm[o];s.svg&&(s.renderTransform(),e.setAttribute("data-svg-origin",this.svgo||"")),n=Gc(),(!n||!n.isStart)&&!i[Bt]&&(k0(i),s.uncache=1)}},O0=function(t,e){var i={target:t,props:[],revert:HE,save:KE};return t._gsap||Se.core.getCache(t),e&&e.split(",").forEach(function(s){return i.save(s)}),i},W0,Dc=function(t,e){var i=Lr.createElementNS?Lr.createElementNS((e||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),t):Lr.createElement(t);return i.style?i:Lr.createElement(t)},Mi=function r(t,e,i){var s=getComputedStyle(t);return s[e]||s.getPropertyValue(e.replace(Nc,"-$1").toLowerCase())||s.getPropertyValue(e)||!i&&r(t,an(e)||e,1)||""},B0="O,Moz,ms,Ms,Webkit".split(","),an=function(t,e,i){var s=e||ds,n=s.style,o=5;if(t in n&&!i)return t;for(t=t.charAt(0).toUpperCase()+t.substr(1);o--&&!(B0[o]+t in n););return o<0?null:(o===3?"ms":o>=0?B0[o]:"")+t},kc=function(){GE()&&window.document&&(L0=window,Lr=L0.document,sn=Lr.documentElement,ds=Dc("div")||{style:{}},Dc("div"),Bt=an(Bt),hi=Bt+"Origin",ds.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",W0=!!an("perspective"),Gc=Se.core.reverting,Lc=1)},Oc=function r(t){var e=Dc("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),i=this.parentNode,s=this.nextSibling,n=this.style.cssText,o;if(sn.appendChild(e),e.appendChild(this),this.style.display="block",t)try{o=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=r}catch{}else this._gsapBBox&&(o=this._gsapBBox());return i&&(s?i.insertBefore(this,s):i.appendChild(this)),sn.removeChild(e),this.style.cssText=n,o},U0=function(t,e){for(var i=e.length;i--;)if(t.hasAttribute(e[i]))return t.getAttribute(e[i])},X0=function(t){var e;try{e=t.getBBox()}catch{e=Oc.call(t,!0)}return e&&(e.width||e.height)||t.getBBox===Oc||(e=Oc.call(t,!0)),e&&!e.width&&!e.x&&!e.y?{x:+U0(t,["x","cx","x1"])||0,y:+U0(t,["y","cy","y1"])||0,width:0,height:0}:e},Z0=function(t){return!!(t.getCTM&&(!t.parentNode||t.ownerSVGElement)&&X0(t))},uo=function(t,e){if(e){var i=t.style;e in sr&&e!==hi&&(e=Bt),i.removeProperty?((e.substr(0,2)==="ms"||e.substr(0,6)==="webkit")&&(e="-"+e),i.removeProperty(e.replace(Nc,"-$1").toLowerCase())):i.removeAttribute(e)}},Gr=function(t,e,i,s,n,o){var a=new we(t._pt,e,i,0,1,o?D0:F0);return t._pt=a,a.b=s,a.e=n,t._props.push(i),a},V0={deg:1,rad:1,turn:1},YE={grid:1,flex:1},Nr=function r(t,e,i,s){var n=parseFloat(i)||0,o=(i+"").trim().substr((n+"").length)||"px",a=ds.style,h=NE.test(e),l=t.tagName.toLowerCase()==="svg",u=(l?"client":"offset")+(h?"Width":"Height"),c=100,d=s==="px",p=s==="%",m,f,g,y;return s===o||!n||V0[s]||V0[o]?n:(o!=="px"&&!d&&(n=r(t,e,i,"px")),y=t.getCTM&&Z0(t),(p||o==="%")&&(sr[e]||~e.indexOf("adius"))?(m=y?t.getBBox()[h?"width":"height"]:t[u],Ht(p?n/m*c:n/100*m)):(a[h?"width":"height"]=c+(d?o:s),f=~e.indexOf("adius")||s==="em"&&t.appendChild&&!l?t:t.parentNode,y&&(f=(t.ownerSVGElement||{}).parentNode),(!f||f===Lr||!f.appendChild)&&(f=Lr.body),g=f._gsap,g&&p&&g.width&&h&&g.time===Pe.time&&!g.uncache?Ht(n/g.width*c):((p||o==="%")&&!YE[Mi(f,"display")]&&(a.position=Mi(t,"position")),f===t&&(a.position="static"),f.appendChild(ds),m=ds[u],f.removeChild(ds),a.position="absolute",h&&p&&(g=os(f),g.time=Pe.time,g.width=f[u]),Ht(d?m*n/c:m&&n?c/m*n:0))))},nr=function(t,e,i,s){var n;return Lc||kc(),e in Ri&&e!=="transform"&&(e=Ri[e],~e.indexOf(",")&&(e=e.split(",")[0])),sr[e]&&e!=="transform"?(n=po(t,s),n=e!=="transformOrigin"?n[e]:n.svg?n.origin:ph(Mi(t,hi))+" "+n.zOrigin+"px"):(n=t.style[e],(!n||n==="auto"||s||~(n+"").indexOf("calc("))&&(n=dh[e]&&dh[e](t,e,i)||Mi(t,e)||zg(t,e)||(e==="opacity"?1:0))),i&&!~(n+"").trim().indexOf(" ")?Nr(t,e,n,i)+i:n},zE=function(t,e,i,s){if(!i||i==="none"){var n=an(e,t,1),o=n&&Mi(t,n,1);o&&o!==i?(e=n,i=o):e==="borderColor"&&(i=Mi(t,"borderTopColor"))}var a=new we(this._pt,t.style,e,0,1,A0),h=0,l=0,u,c,d,p,m,f,g,y,_,b,v,S;if(a.b=i,a.e=s,i+="",s+="",s==="auto"&&(t.style[e]=s,s=Mi(t,e)||s,t.style[e]=i),u=[i,s],b0(u),i=u[0],s=u[1],d=i.match($s)||[],S=s.match($s)||[],S.length){for(;c=$s.exec(s);)g=c[0],_=s.substring(h,c.index),m?m=(m+1)%5:(_.substr(-5)==="rgba("||_.substr(-5)==="hsla(")&&(m=1),g!==(f=d[l++]||"")&&(p=parseFloat(f)||0,v=f.substr((p+"").length),g.charAt(1)==="="&&(g=Qs(p,g)+v),y=parseFloat(g),b=g.substr((y+"").length),h=$s.lastIndex-b.length,b||(b=b||Ae.units[e]||v,h===s.length&&(s+=b,a.e+=b)),v!==b&&(p=Nr(t,e,f,b)||0),a._pt={_next:a._pt,p:_||l===1?_:",",s:p,c:y-p,m:m&&m<4||e==="zIndex"?Math.round:0});a.c=h<s.length?s.substring(h,s.length):""}else a.r=e==="display"&&s==="none"?D0:F0;return Ug.test(s)&&(a.e=0),this._pt=a,a},K0={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},jE=function(t){var e=t.split(" "),i=e[0],s=e[1]||"50%";return(i==="top"||i==="bottom"||s==="left"||s==="right")&&(t=i,i=s,s=t),e[0]=K0[i]||i,e[1]=K0[s]||s,e.join(" ")},JE=function(t,e){if(e.tween&&e.tween._time===e.tween._dur){var i=e.t,s=i.style,n=e.u,o=i._gsap,a,h,l;if(n==="all"||n===!0)s.cssText="",h=1;else for(n=n.split(","),l=n.length;--l>-1;)a=n[l],sr[a]&&(h=1,a=a==="transformOrigin"?hi:Bt),uo(i,a);h&&(uo(i,Bt),o&&(o.svg&&i.removeAttribute("transform"),po(i,1),o.uncache=1,k0(s)))}},dh={clearProps:function(t,e,i,s,n){if(n.data!=="isFromStart"){var o=t._pt=new we(t._pt,e,i,0,0,JE);return o.u=s,o.pr=-10,o.tween=n,t._props.push(i),1}}},co=[1,0,0,1,0,0],H0={},Y0=function(t){return t==="matrix(1, 0, 0, 1, 0, 0)"||t==="none"||!t},z0=function(t){var e=Mi(t,Bt);return Y0(e)?co:e.substr(7).match(Bg).map(Ht)},Wc=function(t,e){var i=t._gsap||os(t),s=t.style,n=z0(t),o,a,h,l;return i.svg&&t.getAttribute("transform")?(h=t.transform.baseVal.consolidate().matrix,n=[h.a,h.b,h.c,h.d,h.e,h.f],n.join(",")==="1,0,0,1,0,0"?co:n):(n===co&&!t.offsetParent&&t!==sn&&!i.svg&&(h=s.display,s.display="block",o=t.parentNode,(!o||!t.offsetParent)&&(l=1,a=t.nextElementSibling,sn.appendChild(t)),n=z0(t),h?s.display=h:uo(t,"display"),l&&(a?o.insertBefore(t,a):o?o.appendChild(t):sn.removeChild(t))),e&&n.length>6?[n[0],n[1],n[4],n[5],n[12],n[13]]:n)},Bc=function(t,e,i,s,n,o){var a=t._gsap,h=n||Wc(t,!0),l=a.xOrigin||0,u=a.yOrigin||0,c=a.xOffset||0,d=a.yOffset||0,p=h[0],m=h[1],f=h[2],g=h[3],y=h[4],_=h[5],b=e.split(" "),v=parseFloat(b[0])||0,S=parseFloat(b[1])||0,E,A,I,P;i?h!==co&&(A=p*g-m*f)&&(I=v*(g/A)+S*(-f/A)+(f*_-g*y)/A,P=v*(-m/A)+S*(p/A)-(p*_-m*y)/A,v=I,S=P):(E=X0(t),v=E.x+(~b[0].indexOf("%")?v/100*E.width:v),S=E.y+(~(b[1]||b[0]).indexOf("%")?S/100*E.height:S)),s||s!==!1&&a.smooth?(y=v-l,_=S-u,a.xOffset=c+(y*p+_*f)-y,a.yOffset=d+(y*m+_*g)-_):a.xOffset=a.yOffset=0,a.xOrigin=v,a.yOrigin=S,a.smooth=!!s,a.origin=e,a.originIsAbsolute=!!i,t.style[hi]="0px 0px",o&&(Gr(o,a,"xOrigin",l,v),Gr(o,a,"yOrigin",u,S),Gr(o,a,"xOffset",c,a.xOffset),Gr(o,a,"yOffset",d,a.yOffset)),t.setAttribute("data-svg-origin",v+" "+S)},po=function(t,e){var i=t._gsap||new T0(t);if("x"in i&&!e&&!i.uncache)return i;var s=t.style,n=i.scaleX<0,o="px",a="deg",h=getComputedStyle(t),l=Mi(t,hi)||"0",u,c,d,p,m,f,g,y,_,b,v,S,E,A,I,P,B,G,N,C,F,X,V,L,k,K,D,U,j,q,dt,nt;return u=c=d=f=g=y=_=b=v=0,p=m=1,i.svg=!!(t.getCTM&&Z0(t)),h.translate&&((h.translate!=="none"||h.scale!=="none"||h.rotate!=="none")&&(s[Bt]=(h.translate!=="none"?"translate3d("+(h.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(h.rotate!=="none"?"rotate("+h.rotate+") ":"")+(h.scale!=="none"?"scale("+h.scale.split(" ").join(",")+") ":"")+(h[Bt]!=="none"?h[Bt]:"")),s.scale=s.rotate=s.translate="none"),A=Wc(t,i.svg),i.svg&&(i.uncache?(k=t.getBBox(),l=i.xOrigin-k.x+"px "+(i.yOrigin-k.y)+"px",L=""):L=!e&&t.getAttribute("data-svg-origin"),Bc(t,L||l,!!L||i.originIsAbsolute,i.smooth!==!1,A)),S=i.xOrigin||0,E=i.yOrigin||0,A!==co&&(G=A[0],N=A[1],C=A[2],F=A[3],u=X=A[4],c=V=A[5],A.length===6?(p=Math.sqrt(G*G+N*N),m=Math.sqrt(F*F+C*C),f=G||N?on(N,G)*ps:0,_=C||F?on(C,F)*ps+f:0,_&&(m*=Math.abs(Math.cos(_*nn))),i.svg&&(u-=S-(S*G+E*C),c-=E-(S*N+E*F))):(nt=A[6],q=A[7],D=A[8],U=A[9],j=A[10],dt=A[11],u=A[12],c=A[13],d=A[14],I=on(nt,j),g=I*ps,I&&(P=Math.cos(-I),B=Math.sin(-I),L=X*P+D*B,k=V*P+U*B,K=nt*P+j*B,D=X*-B+D*P,U=V*-B+U*P,j=nt*-B+j*P,dt=q*-B+dt*P,X=L,V=k,nt=K),I=on(-C,j),y=I*ps,I&&(P=Math.cos(-I),B=Math.sin(-I),L=G*P-D*B,k=N*P-U*B,K=C*P-j*B,dt=F*B+dt*P,G=L,N=k,C=K),I=on(N,G),f=I*ps,I&&(P=Math.cos(I),B=Math.sin(I),L=G*P+N*B,k=X*P+V*B,N=N*P-G*B,V=V*P-X*B,G=L,X=k),g&&Math.abs(g)+Math.abs(f)>359.9&&(g=f=0,y=180-y),p=Ht(Math.sqrt(G*G+N*N+C*C)),m=Ht(Math.sqrt(V*V+nt*nt)),I=on(X,V),_=Math.abs(I)>2e-4?I*ps:0,v=dt?1/(dt<0?-dt:dt):0),i.svg&&(L=t.getAttribute("transform"),i.forceCSS=t.setAttribute("transform","")||!Y0(Mi(t,Bt)),L&&t.setAttribute("transform",L))),Math.abs(_)>90&&Math.abs(_)<270&&(n?(p*=-1,_+=f<=0?180:-180,f+=f<=0?180:-180):(m*=-1,_+=_<=0?180:-180)),e=e||i.uncache,i.x=u-((i.xPercent=u&&(!e&&i.xPercent||(Math.round(t.offsetWidth/2)===Math.round(-u)?-50:0)))?t.offsetWidth*i.xPercent/100:0)+o,i.y=c-((i.yPercent=c&&(!e&&i.yPercent||(Math.round(t.offsetHeight/2)===Math.round(-c)?-50:0)))?t.offsetHeight*i.yPercent/100:0)+o,i.z=d+o,i.scaleX=Ht(p),i.scaleY=Ht(m),i.rotation=Ht(f)+a,i.rotationX=Ht(g)+a,i.rotationY=Ht(y)+a,i.skewX=_+a,i.skewY=b+a,i.transformPerspective=v+o,(i.zOrigin=parseFloat(l.split(" ")[2])||0)&&(s[hi]=ph(l)),i.xOffset=i.yOffset=0,i.force3D=Ae.force3D,i.renderTransform=i.svg?QE:W0?j0:$E,i.uncache=0,i},ph=function(t){return(t=t.split(" "))[0]+" "+t[1]},Uc=function(t,e,i){var s=pe(e);return Ht(parseFloat(e)+parseFloat(Nr(t,"x",i+"px",s)))+s},$E=function(t,e){e.z="0px",e.rotationY=e.rotationX="0deg",e.force3D=0,j0(t,e)},fs="0deg",fo="0px",ms=") ",j0=function(t,e){var i=e||this,s=i.xPercent,n=i.yPercent,o=i.x,a=i.y,h=i.z,l=i.rotation,u=i.rotationY,c=i.rotationX,d=i.skewX,p=i.skewY,m=i.scaleX,f=i.scaleY,g=i.transformPerspective,y=i.force3D,_=i.target,b=i.zOrigin,v="",S=y==="auto"&&t&&t!==1||y===!0;if(b&&(c!==fs||u!==fs)){var E=parseFloat(u)*nn,A=Math.sin(E),I=Math.cos(E),P;E=parseFloat(c)*nn,P=Math.cos(E),o=Uc(_,o,A*P*-b),a=Uc(_,a,-Math.sin(E)*-b),h=Uc(_,h,I*P*-b+b)}g!==fo&&(v+="perspective("+g+ms),(s||n)&&(v+="translate("+s+"%, "+n+"%) "),(S||o!==fo||a!==fo||h!==fo)&&(v+=h!==fo||S?"translate3d("+o+", "+a+", "+h+") ":"translate("+o+", "+a+ms),l!==fs&&(v+="rotate("+l+ms),u!==fs&&(v+="rotateY("+u+ms),c!==fs&&(v+="rotateX("+c+ms),(d!==fs||p!==fs)&&(v+="skew("+d+", "+p+ms),(m!==1||f!==1)&&(v+="scale("+m+", "+f+ms),_.style[Bt]=v||"translate(0, 0)"},QE=function(t,e){var i=e||this,s=i.xPercent,n=i.yPercent,o=i.x,a=i.y,h=i.rotation,l=i.skewX,u=i.skewY,c=i.scaleX,d=i.scaleY,p=i.target,m=i.xOrigin,f=i.yOrigin,g=i.xOffset,y=i.yOffset,_=i.forceCSS,b=parseFloat(o),v=parseFloat(a),S,E,A,I,P;h=parseFloat(h),l=parseFloat(l),u=parseFloat(u),u&&(u=parseFloat(u),l+=u,h+=u),h||l?(h*=nn,l*=nn,S=Math.cos(h)*c,E=Math.sin(h)*c,A=Math.sin(h-l)*-d,I=Math.cos(h-l)*d,l&&(u*=nn,P=Math.tan(l-u),P=Math.sqrt(1+P*P),A*=P,I*=P,u&&(P=Math.tan(u),P=Math.sqrt(1+P*P),S*=P,E*=P)),S=Ht(S),E=Ht(E),A=Ht(A),I=Ht(I)):(S=c,I=d,E=A=0),(b&&!~(o+"").indexOf("px")||v&&!~(a+"").indexOf("px"))&&(b=Nr(p,"x",o,"px"),v=Nr(p,"y",a,"px")),(m||f||g||y)&&(b=Ht(b+m-(m*S+f*A)+g),v=Ht(v+f-(m*E+f*I)+y)),(s||n)&&(P=p.getBBox(),b=Ht(b+s/100*P.width),v=Ht(v+n/100*P.height)),P="matrix("+S+","+E+","+A+","+I+","+b+","+v+")",p.setAttribute("transform",P),_&&(p.style[Bt]=P)},qE=function(t,e,i,s,n){var o=360,a=re(n),h=parseFloat(n)*(a&&~n.indexOf("rad")?ps:1),l=h-s,u=s+l+"deg",c,d;return a&&(c=n.split("_")[1],c==="short"&&(l%=o,l!==l%(o/2)&&(l+=l<0?o:-o)),c==="cw"&&l<0?l=(l+o*N0)%o-~~(l/o)*o:c==="ccw"&&l>0&&(l=(l-o*N0)%o-~~(l/o)*o)),t._pt=d=new we(t._pt,e,i,s,l,DE),d.e=u,d.u="deg",t._props.push(i),d},J0=function(t,e){for(var i in e)t[i]=e[i];return t},tC=function(t,e,i){var s=J0({},i._gsap),n="perspective,force3D,transformOrigin,svgOrigin",o=i.style,a,h,l,u,c,d,p,m;s.svg?(l=i.getAttribute("transform"),i.setAttribute("transform",""),o[Bt]=e,a=po(i,1),uo(i,Bt),i.setAttribute("transform",l)):(l=getComputedStyle(i)[Bt],o[Bt]=e,a=po(i,1),o[Bt]=l);for(h in sr)l=s[h],u=a[h],l!==u&&n.indexOf(h)<0&&(p=pe(l),m=pe(u),c=p!==m?Nr(i,h,l,m):parseFloat(l),d=parseFloat(u),t._pt=new we(t._pt,a,h,c,d-c,Fc),t._pt.u=m||0,t._props.push(h));J0(a,s)};ve("padding,margin,Width,Radius",function(r,t){var e="Top",i="Right",s="Bottom",n="Left",o=(t<3?[e,i,s,n]:[e+n,e+i,s+i,s+n]).map(function(a){return t<2?r+a:"border"+a+r});dh[t>1?"border"+r:r]=function(a,h,l,u,c){var d,p;if(arguments.length<4)return d=o.map(function(m){return nr(a,m,l)}),p=d.join(" "),p.split(d[0]).length===5?d[0]:p;d=(u+"").split(" "),p={},o.forEach(function(m,f){return p[m]=d[f]=d[f]||d[(f-1)/2|0]}),a.init(h,p,c)}});var $0={name:"css",register:kc,targetTest:function(t){return t.style&&t.nodeType},init:function(t,e,i,s,n){var o=this._props,a=t.style,h=i.vars.startAt,l,u,c,d,p,m,f,g,y,_,b,v,S,E,A,I;Lc||kc(),this.styles=this.styles||O0(t),I=this.styles.props,this.tween=i;for(f in e)if(f!=="autoRound"&&(u=e[f],!(Me[f]&&w0(f,e,i,s,t,n)))){if(p=typeof u,m=dh[f],p==="function"&&(u=u.call(i,s,t,n),p=typeof u),p==="string"&&~u.indexOf("random(")&&(u=so(u)),m)m(this,t,f,u,i)&&(A=1);else if(f.substr(0,2)==="--")l=(getComputedStyle(t).getPropertyValue(f)+"").trim(),u+="",Mr.lastIndex=0,Mr.test(l)||(g=pe(l),y=pe(u)),y?g!==y&&(l=Nr(t,f,l,y)+y):g&&(u+=g),this.add(a,"setProperty",l,u,s,n,0,0,f),o.push(f),I.push(f,0,a[f]);else if(p!=="undefined"){if(h&&f in h?(l=typeof h[f]=="function"?h[f].call(i,s,t,n):h[f],re(l)&&~l.indexOf("random(")&&(l=so(l)),pe(l+"")||(l+=Ae.units[f]||pe(nr(t,f))||""),(l+"").charAt(1)==="="&&(l=nr(t,f))):l=nr(t,f),d=parseFloat(l),_=p==="string"&&u.charAt(1)==="="&&u.substr(0,2),_&&(u=u.substr(2)),c=parseFloat(u),f in Ri&&(f==="autoAlpha"&&(d===1&&nr(t,"visibility")==="hidden"&&c&&(d=0),I.push("visibility",0,a.visibility),Gr(this,a,"visibility",d?"inherit":"hidden",c?"inherit":"hidden",!c)),f!=="scale"&&f!=="transform"&&(f=Ri[f],~f.indexOf(",")&&(f=f.split(",")[0]))),b=f in sr,b){if(this.styles.save(f),v||(S=t._gsap,S.renderTransform&&!e.parseTransform||po(t,e.parseTransform),E=e.smoothOrigin!==!1&&S.smooth,v=this._pt=new we(this._pt,a,Bt,0,1,S.renderTransform,S,0,-1),v.dep=1),f==="scale")this._pt=new we(this._pt,S,"scaleY",S.scaleY,(_?Qs(S.scaleY,_+c):c)-S.scaleY||0,Fc),this._pt.u=0,o.push("scaleY",f),f+="X";else if(f==="transformOrigin"){I.push(hi,0,a[hi]),u=jE(u),S.svg?Bc(t,u,0,E,0,this):(y=parseFloat(u.split(" ")[2])||0,y!==S.zOrigin&&Gr(this,S,"zOrigin",S.zOrigin,y),Gr(this,a,f,ph(l),ph(u)));continue}else if(f==="svgOrigin"){Bc(t,u,1,E,0,this);continue}else if(f in H0){qE(this,S,f,d,_?Qs(d,_+u):u);continue}else if(f==="smoothOrigin"){Gr(this,S,"smooth",S.smooth,u);continue}else if(f==="force3D"){S[f]=u;continue}else if(f==="transform"){tC(this,u,t);continue}}else f in a||(f=an(f)||f);if(b||(c||c===0)&&(d||d===0)&&!FE.test(u)&&f in a)g=(l+"").substr((d+"").length),c||(c=0),y=pe(u)||(f in Ae.units?Ae.units[f]:g),g!==y&&(d=Nr(t,f,l,y)),this._pt=new we(this._pt,b?S:a,f,d,(_?Qs(d,_+c):c)-d,!b&&(y==="px"||f==="zIndex")&&e.autoRound!==!1?OE:Fc),this._pt.u=y||0,g!==y&&y!=="%"&&(this._pt.b=l,this._pt.r=kE);else if(f in a)zE.call(this,t,f,l,_?_+u:u);else if(f in t)this.add(t,f,l||t[f],_?_+u:u,s,n);else if(f!=="parseTransform"){lc(f,u);continue}b||(f in a?I.push(f,0,a[f]):I.push(f,1,l||t[f])),o.push(f)}}A&&R0(this)},render:function(t,e){if(e.tween._time||!Gc())for(var i=e._pt;i;)i.r(t,i.d),i=i._next;else e.styles.revert()},get:nr,aliases:Ri,getSetter:function(t,e,i){var s=Ri[e];return s&&s.indexOf(",")<0&&(e=s),e in sr&&e!==hi&&(t._gsap.x||nr(t,"x"))?i&&G0===i?e==="scale"?XE:UE:(G0=i||{})&&(e==="scale"?ZE:VE):t.style&&!rc(t.style[e])?WE:~e.indexOf("-")?BE:Ic(t,e)},core:{_removeProperty:uo,_getMatrix:Wc}};Se.utils.checkPrefix=an,Se.core.getStyleSaver=O0,function(r,t,e,i){var s=ve(r+","+t+","+e,function(n){sr[n]=1});ve(t,function(n){Ae.units[n]="deg",H0[n]=1}),Ri[s[13]]=r+","+t,ve(i,function(n){var o=n.split(":");Ri[o[1]]=s[o[0]]})}("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY"),ve("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(r){Ae.units[r]="px"}),Se.registerPlugin($0);var Q0=Se.registerPlugin($0)||Se;Q0.core.Tween;const gs=new ct;class eC{constructor(t={}){this._recursive=typeof t.recursive=="boolean"?t.recursive:!0,this._toggle=t.toggle||"visible",this._targetList=new Set}add(t){return this._targetList.add(t),this}addAll(t){for(let e=0,i=t.length;e<i;e++)this._targetList.add(t[e]);return this}remove(t){return this._targetList.delete(t),this}removeAll(t){for(let e=0,i=t.length;e<i;e++)this._targetList.delete(t[e]);return this}clear(){return this._targetList.clear(),this}cull(t,e=!1){return e||this.uncull(),this._targetList.forEach(i=>{e||i.getBounds(!1,gs),this._recursive?this.cullRecursive(t,i,e):(e&&i._bounds.getRectangle(t),i[this._toggle]=gs.right>t.left&&gs.left<t.right&&gs.bottom>t.top&&gs.top<t.bottom)}),this}uncull(){return this._targetList.forEach(t=>{this._recursive?this.uncullRecursive(t):t[this._toggle]=!1}),this}cullRecursive(t,e,i){const s=i?e._bounds.getRectangle(gs):e.getBounds(!0,gs);if(e[this._toggle]=s.right>t.left&&s.left<t.right&&s.bottom>t.top&&s.top<t.bottom,!(s.left>=t.left&&s.top>=t.top&&s.right<=t.right&&s.bottom<=t.bottom)&&e[this._toggle]&&e.children&&e.children.length){const o=e.children;for(let a=0,h=o.length;a<h;a++)this.cullRecursive(t,o[a])}}uncullRecursive(t){if(t[this._toggle]=!0,t.children&&t.children.length){const e=t.children;for(let i=0,s=e.length;i<s;i++)this.uncullRecursive(e[i])}}}let Pi=null;const q0=new ResizeObserver(()=>{Pi&&xt.emit("stageUpdated",Pi)});function iC(r){Pi=r,q0.observe(Pi),xt.emit("stageCreated",Pi)}function rC(){Pi&&q0.unobserve(Pi),Pi=null}async function Xc(){return Pi||await Oe("stageCreated")}let Le=null;async function sC(){const r=await Xc();oC(r),xt.on("stageUpdated",aC)}function nC(){Le&&(Le.destroy(!0,{children:!0}),Le=null)}function oC(r){Le=new jm({backgroundAlpha:0,resizeTo:r,antialias:!0,resolution:window.devicePixelRatio}),Le.stage.sortableChildren=!0,r.appendChild(Le.view),xt.emit("applicationCreated",Le),process.env.NODE_ENV==="development"&&(globalThis.__PIXI_APP__=Le)}async function li(){return Le||await Oe("applicationCreated")}function aC(r){Le&&(Le.resizeTo=r,xt.emit("applicationResized",Le))}var fh={exports:{}};fh.exports,function(r,t){var e=200,i="__lodash_hash_undefined__",s=1,n=2,o=9007199254740991,a="[object Arguments]",h="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",c="[object Date]",d="[object Error]",p="[object Function]",m="[object GeneratorFunction]",f="[object Map]",g="[object Number]",y="[object Null]",_="[object Object]",b="[object Promise]",v="[object Proxy]",S="[object RegExp]",E="[object Set]",A="[object String]",I="[object Symbol]",P="[object Undefined]",B="[object WeakMap]",G="[object ArrayBuffer]",N="[object DataView]",C="[object Float32Array]",F="[object Float64Array]",X="[object Int8Array]",V="[object Int16Array]",L="[object Int32Array]",k="[object Uint8Array]",K="[object Uint8ClampedArray]",D="[object Uint16Array]",U="[object Uint32Array]",j=/[\\^$.*+?()[\]{}|]/g,q=/^\[object .+?Constructor\]$/,dt=/^(?:0|[1-9]\d*)$/,nt={};nt[C]=nt[F]=nt[X]=nt[V]=nt[L]=nt[k]=nt[K]=nt[D]=nt[U]=!0,nt[a]=nt[h]=nt[G]=nt[u]=nt[N]=nt[c]=nt[d]=nt[p]=nt[f]=nt[g]=nt[_]=nt[S]=nt[E]=nt[A]=nt[B]=!1;var Et=typeof qe=="object"&&qe&&qe.Object===Object&&qe,Rt=typeof self=="object"&&self&&self.Object===Object&&self,wt=Et||Rt||Function("return this")(),Y=t&&!t.nodeType&&t,it=Y&&!0&&r&&!r.nodeType&&r,tt=it&&it.exports===Y,O=tt&&Et.process,bt=function(){try{return O&&O.binding&&O.binding("util")}catch{}}(),mt=bt&&bt.isTypedArray;function Mt(T,R){for(var x=-1,w=T==null?0:T.length,M=0,Z=[];++x<w;){var ht=T[x];R(ht,x,T)&&(Z[M++]=ht)}return Z}function Ut(T,R){for(var x=-1,w=R.length,M=T.length;++x<w;)T[M+x]=R[x];return T}function Ne(T,R){for(var x=-1,w=T==null?0:T.length;++x<w;)if(R(T[x],x,T))return!0;return!1}function ci(T,R){for(var x=-1,w=Array(T);++x<T;)w[x]=R(x);return w}function Id(T){return function(R){return T(R)}}function yn(T,R){return T.has(R)}function Ao(T,R){return T==null?void 0:T[R]}function bn(T){var R=-1,x=Array(T.size);return T.forEach(function(w,M){x[++R]=[M,w]}),x}function di(T,R){return function(x){return T(R(x))}}function kh(T){var R=-1,x=Array(T.size);return T.forEach(function(w){x[++R]=w}),x}var Oh=Array.prototype,Ad=Function.prototype,xn=Object.prototype,kr=wt["__core-js_shared__"],Ro=Ad.toString,Fe=xn.hasOwnProperty,Mo=function(){var T=/[^.]+$/.exec(kr&&kr.keys&&kr.keys.IE_PROTO||"");return T?"Symbol(src)_1."+T:""}(),Po=xn.toString,Wh=RegExp("^"+Ro.call(Fe).replace(j,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Bh=tt?wt.Buffer:void 0,_n=wt.Symbol,ki=wt.Uint8Array,ws=xn.propertyIsEnumerable,Rd=Oh.splice,Oi=_n?_n.toStringTag:void 0,Uh=Object.getOwnPropertySymbols,Xh=Bh?Bh.isBuffer:void 0,Ss=di(Object.keys,Object),Lo=dr(wt,"DataView"),De=dr(wt,"Map"),Go=dr(wt,"Promise"),No=dr(wt,"Set"),Fo=dr(wt,"WeakMap"),Es=dr(Object,"create"),Md=fi(Lo),pi=fi(De),Pd=fi(Go),Ld=fi(No),Gd=fi(Fo),Zh=_n?_n.prototype:void 0,Do=Zh?Zh.valueOf:void 0;function Ce(T){var R=-1,x=T==null?0:T.length;for(this.clear();++R<x;){var w=T[R];this.set(w[0],w[1])}}function Nd(){this.__data__=Es?Es(null):{},this.size=0}function Fd(T){var R=this.has(T)&&delete this.__data__[T];return this.size-=R?1:0,R}function Dd(T){var R=this.__data__;if(Es){var x=R[T];return x===i?void 0:x}return Fe.call(R,T)?R[T]:void 0}function kd(T){var R=this.__data__;return Es?R[T]!==void 0:Fe.call(R,T)}function Od(T,R){var x=this.__data__;return this.size+=this.has(T)?0:1,x[T]=Es&&R===void 0?i:R,this}Ce.prototype.clear=Nd,Ce.prototype.delete=Fd,Ce.prototype.get=Dd,Ce.prototype.has=kd,Ce.prototype.set=Od;function fe(T){var R=-1,x=T==null?0:T.length;for(this.clear();++R<x;){var w=T[R];this.set(w[0],w[1])}}function Wd(){this.__data__=[],this.size=0}function Bd(T){var R=this.__data__,x=Tn(R,T);if(x<0)return!1;var w=R.length-1;return x==w?R.pop():Rd.call(R,x,1),--this.size,!0}function Ud(T){var R=this.__data__,x=Tn(R,T);return x<0?void 0:R[x][1]}function Xd(T){return Tn(this.__data__,T)>-1}function Zd(T,R){var x=this.__data__,w=Tn(x,T);return w<0?(++this.size,x.push([T,R])):x[w][1]=R,this}fe.prototype.clear=Wd,fe.prototype.delete=Bd,fe.prototype.get=Ud,fe.prototype.has=Xd,fe.prototype.set=Zd;function ur(T){var R=-1,x=T==null?0:T.length;for(this.clear();++R<x;){var w=T[R];this.set(w[0],w[1])}}function ko(){this.size=0,this.__data__={hash:new Ce,map:new(De||fe),string:new Ce}}function Vd(T){var R=Sn(this,T).delete(T);return this.size-=R?1:0,R}function vn(T){return Sn(this,T).get(T)}function Oo(T){return Sn(this,T).has(T)}function Kd(T,R){var x=Sn(this,T),w=x.size;return x.set(T,R),this.size+=x.size==w?0:1,this}ur.prototype.clear=ko,ur.prototype.delete=Vd,ur.prototype.get=vn,ur.prototype.has=Oo,ur.prototype.set=Kd;function cr(T){var R=-1,x=T==null?0:T.length;for(this.__data__=new ur;++R<x;)this.add(T[R])}function Vh(T){return this.__data__.set(T,i),this}function Hd(T){return this.__data__.has(T)}cr.prototype.add=cr.prototype.push=Vh,cr.prototype.has=Hd;function Wi(T){var R=this.__data__=new fe(T);this.size=R.size}function Yd(){this.__data__=new fe,this.size=0}function Kh(T){var R=this.__data__,x=R.delete(T);return this.size=R.size,x}function zd(T){return this.__data__.get(T)}function jd(T){return this.__data__.has(T)}function Jd(T,R){var x=this.__data__;if(x instanceof fe){var w=x.__data__;if(!De||w.length<e-1)return w.push([T,R]),this.size=++x.size,this;x=this.__data__=new ur(w)}return x.set(T,R),this.size=x.size,this}Wi.prototype.clear=Yd,Wi.prototype.delete=Kh,Wi.prototype.get=zd,Wi.prototype.has=jd,Wi.prototype.set=Jd;function $d(T,R){var x=In(T),w=!x&&Uo(T),M=!x&&!w&&Is(T),Z=!x&&!w&&!M&&tl(T),ht=x||w||M||Z,pt=ht?ci(T.length,String):[],gt=pt.length;for(var ot in T)(R||Fe.call(T,ot))&&!(ht&&(ot=="length"||M&&(ot=="offset"||ot=="parent")||Z&&(ot=="buffer"||ot=="byteLength"||ot=="byteOffset")||Bo(ot,gt)))&&pt.push(ot);return pt}function Tn(T,R){for(var x=T.length;x--;)if(Cn(T[x][0],R))return x;return-1}function Qd(T,R,x){var w=R(T);return In(T)?w:Ut(w,x(T))}function Cs(T){return T==null?T===void 0?P:y:Oi&&Oi in Object(T)?ip(T):En(T)}function Hh(T){return Wr(T)&&Cs(T)==a}function Yh(T,R,x,w,M){return T===R?!0:T==null||R==null||!Wr(T)&&!Wr(R)?T!==T&&R!==R:qd(T,R,x,w,Yh,M)}function qd(T,R,x,w,M,Z){var ht=In(T),pt=In(R),gt=ht?h:Bi(T),ot=pt?h:Bi(R);gt=gt==a?_:gt,ot=ot==a?_:ot;var _t=gt==_,Ft=ot==_,At=gt==ot;if(At&&Is(T)){if(!Is(R))return!1;ht=!0,_t=!1}if(At&&!_t)return Z||(Z=new Wi),ht||tl(T)?zh(T,R,x,w,M,Z):jh(T,R,gt,x,w,M,Z);if(!(x&s)){var ne=_t&&Fe.call(T,"__wrapped__"),me=Ft&&Fe.call(R,"__wrapped__");if(ne||me){var $e=ne?T.value():T,Qe=me?R.value():R;return Z||(Z=new Wi),M($e,Qe,x,w,Z)}}return At?(Z||(Z=new Wi),ep(T,R,x,w,M,Z)):!1}function wn(T){if(!qh(T)||np(T))return!1;var R=Ui(T)?Wh:q;return R.test(fi(T))}function Wo(T){return Wr(T)&&Or(T.length)&&!!nt[Cs(T)]}function tp(T){if(!op(T))return Ss(T);var R=[];for(var x in Object(T))Fe.call(T,x)&&x!="constructor"&&R.push(x);return R}function zh(T,R,x,w,M,Z){var ht=x&s,pt=T.length,gt=R.length;if(pt!=gt&&!(ht&&gt>pt))return!1;var ot=Z.get(T);if(ot&&Z.get(R))return ot==R;var _t=-1,Ft=!0,At=x&n?new cr:void 0;for(Z.set(T,R),Z.set(R,T);++_t<pt;){var ne=T[_t],me=R[_t];if(w)var $e=ht?w(me,ne,_t,R,T,Z):w(ne,me,_t,T,R,Z);if($e!==void 0){if($e)continue;Ft=!1;break}if(At){if(!Ne(R,function(Qe,As){if(!yn(At,As)&&(ne===Qe||M(ne,Qe,x,w,Z)))return At.push(As)})){Ft=!1;break}}else if(!(ne===me||M(ne,me,x,w,Z))){Ft=!1;break}}return Z.delete(T),Z.delete(R),Ft}function jh(T,R,x,w,M,Z,ht){switch(x){case N:if(T.byteLength!=R.byteLength||T.byteOffset!=R.byteOffset)return!1;T=T.buffer,R=R.buffer;case G:return!(T.byteLength!=R.byteLength||!Z(new ki(T),new ki(R)));case u:case c:case g:return Cn(+T,+R);case d:return T.name==R.name&&T.message==R.message;case S:case A:return T==R+"";case f:var pt=bn;case E:var gt=w&s;if(pt||(pt=kh),T.size!=R.size&&!gt)return!1;var ot=ht.get(T);if(ot)return ot==R;w|=n,ht.set(T,R);var _t=zh(pt(T),pt(R),w,M,Z,ht);return ht.delete(T),_t;case I:if(Do)return Do.call(T)==Do.call(R)}return!1}function ep(T,R,x,w,M,Z){var ht=x&s,pt=Jh(T),gt=pt.length,ot=Jh(R),_t=ot.length;if(gt!=_t&&!ht)return!1;for(var Ft=gt;Ft--;){var At=pt[Ft];if(!(ht?At in R:Fe.call(R,At)))return!1}var ne=Z.get(T);if(ne&&Z.get(R))return ne==R;var me=!0;Z.set(T,R),Z.set(R,T);for(var $e=ht;++Ft<gt;){At=pt[Ft];var Qe=T[At],As=R[At];if(w)var vb=ht?w(As,Qe,At,R,T,Z):w(Qe,As,At,T,R,Z);if(!(vb===void 0?Qe===As||M(Qe,As,x,w,Z):vb)){me=!1;break}$e||($e=At=="constructor")}if(me&&!$e){var il=T.constructor,rl=R.constructor;il!=rl&&"constructor"in T&&"constructor"in R&&!(typeof il=="function"&&il instanceof il&&typeof rl=="function"&&rl instanceof rl)&&(me=!1)}return Z.delete(T),Z.delete(R),me}function Jh(T){return Qd(T,el,rp)}function Sn(T,R){var x=T.__data__;return sp(R)?x[typeof R=="string"?"string":"hash"]:x.map}function dr(T,R){var x=Ao(T,R);return wn(x)?x:void 0}function ip(T){var R=Fe.call(T,Oi),x=T[Oi];try{T[Oi]=void 0;var w=!0}catch{}var M=Po.call(T);return w&&(R?T[Oi]=x:delete T[Oi]),M}var rp=Uh?function(T){return T==null?[]:(T=Object(T),Mt(Uh(T),function(R){return ws.call(T,R)}))}:ap,Bi=Cs;(Lo&&Bi(new Lo(new ArrayBuffer(1)))!=N||De&&Bi(new De)!=f||Go&&Bi(Go.resolve())!=b||No&&Bi(new No)!=E||Fo&&Bi(new Fo)!=B)&&(Bi=function(T){var R=Cs(T),x=R==_?T.constructor:void 0,w=x?fi(x):"";if(w)switch(w){case Md:return N;case pi:return f;case Pd:return b;case Ld:return E;case Gd:return B}return R});function Bo(T,R){return R=R??o,!!R&&(typeof T=="number"||dt.test(T))&&T>-1&&T%1==0&&T<R}function sp(T){var R=typeof T;return R=="string"||R=="number"||R=="symbol"||R=="boolean"?T!=="__proto__":T===null}function np(T){return!!Mo&&Mo in T}function op(T){var R=T&&T.constructor,x=typeof R=="function"&&R.prototype||xn;return T===x}function En(T){return Po.call(T)}function fi(T){if(T!=null){try{return Ro.call(T)}catch{}try{return T+""}catch{}}return""}function Cn(T,R){return T===R||T!==T&&R!==R}var Uo=Hh(function(){return arguments}())?Hh:function(T){return Wr(T)&&Fe.call(T,"callee")&&!ws.call(T,"callee")},In=Array.isArray;function $h(T){return T!=null&&Or(T.length)&&!Ui(T)}var Is=Xh||hp;function Qh(T,R){return Yh(T,R)}function Ui(T){if(!qh(T))return!1;var R=Cs(T);return R==p||R==m||R==l||R==v}function Or(T){return typeof T=="number"&&T>-1&&T%1==0&&T<=o}function qh(T){var R=typeof T;return T!=null&&(R=="object"||R=="function")}function Wr(T){return T!=null&&typeof T=="object"}var tl=mt?Id(mt):Wo;function el(T){return $h(T)?$d(T):tp(T)}function ap(){return[]}function hp(){return!1}r.exports=Qh}(fh,fh.exports);var hC=fh.exports;const ty=Gn(hC);var lC=Object.defineProperty,uC=(r,t,e)=>t in r?lC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W=(r,t,e)=>(uC(r,typeof t!="symbol"?t+"":t,e),e);class ze{constructor(t){W(this,"parent"),W(this,"paused"),this.parent=t,this.paused=!1}destroy(){}down(t){return!1}move(t){return!1}up(t){return!1}wheel(t){return!1}update(t){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var cC=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ey={exports:{}};(function(r,t){(function(){var e,i;i=function(s){return r.exports=s},e={linear:function(s,n,o,a){return o*s/a+n},easeInQuad:function(s,n,o,a){return o*(s/=a)*s+n},easeOutQuad:function(s,n,o,a){return-o*(s/=a)*(s-2)+n},easeInOutQuad:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s+n:-o/2*(--s*(s-2)-1)+n},easeInCubic:function(s,n,o,a){return o*(s/=a)*s*s+n},easeOutCubic:function(s,n,o,a){return o*((s=s/a-1)*s*s+1)+n},easeInOutCubic:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s*s+n:o/2*((s-=2)*s*s+2)+n},easeInQuart:function(s,n,o,a){return o*(s/=a)*s*s*s+n},easeOutQuart:function(s,n,o,a){return-o*((s=s/a-1)*s*s*s-1)+n},easeInOutQuart:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s*s*s+n:-o/2*((s-=2)*s*s*s-2)+n},easeInQuint:function(s,n,o,a){return o*(s/=a)*s*s*s*s+n},easeOutQuint:function(s,n,o,a){return o*((s=s/a-1)*s*s*s*s+1)+n},easeInOutQuint:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s*s*s*s+n:o/2*((s-=2)*s*s*s*s+2)+n},easeInSine:function(s,n,o,a){return-o*Math.cos(s/a*(Math.PI/2))+o+n},easeOutSine:function(s,n,o,a){return o*Math.sin(s/a*(Math.PI/2))+n},easeInOutSine:function(s,n,o,a){return-o/2*(Math.cos(Math.PI*s/a)-1)+n},easeInExpo:function(s,n,o,a){return s===0?n:o*Math.pow(2,10*(s/a-1))+n},easeOutExpo:function(s,n,o,a){return s===a?n+o:o*(-Math.pow(2,-10*s/a)+1)+n},easeInOutExpo:function(s,n,o,a){return(s/=a/2)<1?o/2*Math.pow(2,10*(s-1))+n:o/2*(-Math.pow(2,-10*--s)+2)+n},easeInCirc:function(s,n,o,a){return-o*(Math.sqrt(1-(s/=a)*s)-1)+n},easeOutCirc:function(s,n,o,a){return o*Math.sqrt(1-(s=s/a-1)*s)+n},easeInOutCirc:function(s,n,o,a){return(s/=a/2)<1?-o/2*(Math.sqrt(1-s*s)-1)+n:o/2*(Math.sqrt(1-(s-=2)*s)+1)+n},easeInElastic:function(s,n,o,a){var h,l,u;return u=1.70158,l=0,h=o,s===0||(s/=a),l||(l=a*.3),h<Math.abs(o)?(h=o,u=l/4):u=l/(2*Math.PI)*Math.asin(o/h),-(h*Math.pow(2,10*(s-=1))*Math.sin((s*a-u)*(2*Math.PI)/l))+n},easeOutElastic:function(s,n,o,a){var h,l,u;return u=1.70158,l=0,h=o,s===0||(s/=a),l||(l=a*.3),h<Math.abs(o)?(h=o,u=l/4):u=l/(2*Math.PI)*Math.asin(o/h),h*Math.pow(2,-10*s)*Math.sin((s*a-u)*(2*Math.PI)/l)+o+n},easeInOutElastic:function(s,n,o,a){var h,l,u;return u=1.70158,l=0,h=o,s===0||(s/=a/2),l||(l=a*(.3*1.5)),h<Math.abs(o)?(h=o,u=l/4):u=l/(2*Math.PI)*Math.asin(o/h),s<1?-.5*(h*Math.pow(2,10*(s-=1))*Math.sin((s*a-u)*(2*Math.PI)/l))+n:h*Math.pow(2,-10*(s-=1))*Math.sin((s*a-u)*(2*Math.PI)/l)*.5+o+n},easeInBack:function(s,n,o,a,h){return h===void 0&&(h=1.70158),o*(s/=a)*s*((h+1)*s-h)+n},easeOutBack:function(s,n,o,a,h){return h===void 0&&(h=1.70158),o*((s=s/a-1)*s*((h+1)*s+h)+1)+n},easeInOutBack:function(s,n,o,a,h){return h===void 0&&(h=1.70158),(s/=a/2)<1?o/2*(s*s*(((h*=1.525)+1)*s-h))+n:o/2*((s-=2)*s*(((h*=1.525)+1)*s+h)+2)+n},easeInBounce:function(s,n,o,a){var h;return h=e.easeOutBounce(a-s,0,o,a),o-h+n},easeOutBounce:function(s,n,o,a){return(s/=a)<1/2.75?o*(7.5625*s*s)+n:s<2/2.75?o*(7.5625*(s-=1.5/2.75)*s+.75)+n:s<2.5/2.75?o*(7.5625*(s-=2.25/2.75)*s+.9375)+n:o*(7.5625*(s-=2.625/2.75)*s+.984375)+n},easeInOutBounce:function(s,n,o,a){var h;return s<a/2?(h=e.easeInBounce(s*2,0,o,a),h*.5+n):(h=e.easeOutBounce(s*2-a,0,o,a),h*.5+o*.5+n)}},i(e)}).call(cC)})(ey);const iy=ey.exports;function mh(r,t){if(r){if(typeof r=="function")return r;if(typeof r=="string")return iy[r]}else return iy[t]}const dC={removeOnInterrupt:!1,ease:"linear",time:1e3};class pC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"startX"),W(this,"startY"),W(this,"deltaX"),W(this,"deltaY"),W(this,"keepCenter"),W(this,"startWidth",null),W(this,"startHeight",null),W(this,"deltaWidth",null),W(this,"deltaHeight",null),W(this,"width",null),W(this,"height",null),W(this,"time",0),this.options=Object.assign({},dC,e),this.options.ease=mh(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),!this.keepCenter&&this.options.position&&this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(t){if(this.paused)return;this.time+=t;const e=new lt(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const i=this.parent.width,s=this.parent.height;this.complete(),(i!==this.parent.width||s!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const i=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const s=this.startWidth,n=this.deltaWidth;this.parent.fitWidth(s+n*i,this.keepCenter,this.height===null)}if(this.height!==null){const s=this.startHeight,n=this.deltaHeight;this.parent.fitHeight(s+n*i,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const s=this.startX,n=this.startY,o=this.deltaX,a=this.deltaY,h=new lt(this.parent.x,this.parent.y);this.parent.moveCenter(s+o*i,n+a*i),this.parent.emit("moved",{viewport:this.parent,original:h,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}}const fC={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class mC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"left"),W(this,"top"),W(this,"right"),W(this,"bottom"),W(this,"underflowX"),W(this,"underflowY"),W(this,"ease"),W(this,"toX"),W(this,"toY"),this.options=Object.assign({},fC,e),this.ease=mh(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const i=this.options.underflow.toLowerCase();i==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=i.indexOf("left")!==-1?-1:i.indexOf("right")!==-1?1:0,this.underflowY=i.indexOf("top")!==-1?-1:i.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}oob(){const t=this.options.bounceBox;if(t){const e=typeof t.x>"u"?0:t.x,i=typeof t.y>"u"?0:t.y,s=typeof t.width>"u"?this.parent.worldWidth:t.width,n=typeof t.height>"u"?this.parent.worldHeight:t.height;return{left:this.parent.left<e,right:this.parent.right>s,top:this.parent.top<i,bottom:this.parent.bottom>n,topLeft:new lt(e*this.parent.scale.x,i*this.parent.scale.y),bottomRight:new lt(s*this.parent.scale.x-this.parent.screenWidth,n*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new lt(0,0),bottomRight:new lt(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var t,e;if(this.paused)return;let i,s=this.parent.plugins.get("decelerate",!0);s&&(s.x||s.y)&&(s.x&&s.percentChangeX===((t=s.options)==null?void 0:t.friction)||s.y&&s.percentChangeY===((e=s.options)==null?void 0:e.friction))&&(i=this.oob(),(i.left&&this.left||i.right&&this.right)&&(s.percentChangeX=this.options.friction),(i.top&&this.top||i.bottom&&this.bottom)&&(s.percentChangeY=this.options.friction));const n=this.parent.plugins.get("drag",!0)||{},o=this.parent.plugins.get("pinch",!0)||{};if(s=s||{},!(n!=null&&n.active)&&!(o!=null&&o.active)&&(!this.toX||!this.toY)&&(!s.x||!s.y)){i=i||this.oob();const a=i.topLeft,h=i.bottomRight;if(!this.toX&&!s.x){let l=null;i.left&&this.left?l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-a.x:i.right&&this.right&&(l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-h.x),l!==null&&this.parent.x!==l&&(this.toX={time:0,start:this.parent.x,delta:l-this.parent.x,end:l},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!s.y){let l=null;i.top&&this.top?l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-a.y:i.bottom&&this.bottom&&(l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-h.y),l!==null&&this.parent.y!==l&&(this.toY={time:0,start:this.parent.y,delta:l-this.parent.y,end:l},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const gC={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class yC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"last"),W(this,"noUnderflow"),W(this,"underflowX"),W(this,"underflowY"),this.options=Object.assign({},gC,e),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="none"?this.noUnderflow=!0:t==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const t=new lt(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,i=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,i=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,i=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,e.x=0,i=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,i=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,i=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,i=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,e.y=0,i=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const bC={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class xC extends ze{constructor(t,e={}){super(t),W(this,"options"),this.options=Object.assign({},bC,e),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&t<this.options.minWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&t>this.options.maxWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&e<this.options.minHeight){const i=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&e>this.options.maxHeight){const i=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/i,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},e={x:null,y:null};if(typeof this.options.minScale=="number")t.x=this.options.minScale,t.y=this.options.minScale;else if(this.options.minScale!==null){const n=this.options.minScale;t.x=typeof n.x>"u"?null:n.x,t.y=typeof n.y>"u"?null:n.y}if(typeof this.options.maxScale=="number")e.x=this.options.maxScale,e.y=this.options.maxScale;else if(this.options.maxScale!==null){const n=this.options.maxScale;e.x=typeof n.x>"u"?null:n.x,e.y=typeof n.y>"u"?null:n.y}let i=this.parent.scale.x,s=this.parent.scale.y;t.x!==null&&i<t.x&&(i=t.x),e.x!==null&&i>e.x&&(i=e.x),t.y!==null&&s<t.y&&(s=t.y),e.y!==null&&s>e.y&&(s=e.y),(i!==this.parent.scale.x||s!==this.parent.scale.y)&&(this.parent.scale.set(i,s),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const _C={friction:.98,bounce:.8,minSpeed:.01},Fr=16;class vC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"x"),W(this,"y"),W(this,"percentChangeX"),W(this,"percentChangeY"),W(this,"saved"),W(this,"timeSinceRelease"),this.options=Object.assign({},_C,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",i=>this.handleMoved(i))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const t=this.parent.input.count();return(t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}handleMoved(t){if(this.saved.length){const e=this.saved[this.saved.length-1];t.type==="clamp-x"&&t.original?e.x===t.original.x&&(e.x=this.parent.x):t.type==="clamp-y"&&t.original&&e.y===t.original.y&&(e.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const t=performance.now();for(const e of this.saved)if(e.time>=t-100){const i=t-e.time;this.x=(this.parent.x-e.x)/i,this.y=(this.parent.y-e.y)/i,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){t=t||{},typeof t.x<"u"&&(this.x=t.x,this.percentChangeX=this.options.friction),typeof t.y<"u"&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;const e=this.x||this.y,i=this.timeSinceRelease,s=this.timeSinceRelease+t;if(this.x){const n=this.percentChangeX,o=Math.log(n);this.parent.x+=this.x*Fr/o*(Math.pow(n,s/Fr)-Math.pow(n,i/Fr)),this.x*=Math.pow(this.percentChangeX,t/Fr)}if(this.y){const n=this.percentChangeY,o=Math.log(n);this.parent.y+=this.y*Fr/o*(Math.pow(n,s/Fr)-Math.pow(n,i/Fr)),this.y*=Math.pow(this.percentChangeY,t/Fr)}this.timeSinceRelease+=t,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const TC={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class wC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"moved"),W(this,"reverse"),W(this,"xDirection"),W(this,"yDirection"),W(this,"keyIsPressed"),W(this,"mouse"),W(this,"underflowX"),W(this,"underflowY"),W(this,"last"),W(this,"current"),W(this,"windowEventHandlers",[]),this.options=Object.assign({},TC,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){const e=s=>{t.includes(s.code)&&(this.keyIsPressed=!0)},i=s=>{t.includes(s.code)&&(this.keyIsPressed=!1)};this.addWindowEventHandler("keyup",i),this.addWindowEventHandler("keydown",e)}addWindowEventHandler(t,e){window.addEventListener(t,e),this.windowEventHandlers.push({event:t,handler:e})}destroy(){this.windowEventHandlers.forEach(({event:t,handler:e})=>{window.removeEventListener(t,e)})}mouseButtons(t){!t||t==="all"?this.mouse=[!0,!0,!0]:this.mouse=[t.indexOf("left")!==-1,t.indexOf("middle")!==-1,t.indexOf("right")!==-1]}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(t.includes("left")?this.underflowX=-1:t.includes("right")?this.underflowX=1:this.underflowX=0,t.includes("top")?this.underflowY=-1:t.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(t){const e=t.pointerType==="mouse",i=this.parent.input.count();return!!((i===1||i>1&&!this.parent.plugins.get("pinch",!0))&&(!e||this.mouse[t.button]))}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&t.data.pointerType==="touch"}down(t){return this.paused||!this.options.pressDrag?!1:this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.global.x,y:t.global.y},this.current=t.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(t){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===t.data.pointerId){const e=t.global.x,i=t.global.y,s=this.parent.input.count();if(s===1||s>1&&!this.parent.plugins.get("pinch",!0)){const n=e-this.last.x,o=i-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(n)||this.yDirection&&this.parent.input.checkThreshold(o)){const a={x:e,y:i};return this.xDirection&&(this.parent.x+=(a.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(a.y-this.last.y)*this.options.factor),this.last=a,this.moved||this.parent.emit("drag-start",{event:t,screen:new lt(this.last.x,this.last.y),world:this.parent.toWorld(new lt(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(t){if(this.paused)return!1;const e=this.parent.input.touches;if(e.length===1){const i=e[0];return i.last&&(this.last={x:i.last.x,y:i.last.y},this.current=i.id),this.moved=!1,!0}else if(this.last&&this.moved){const i=new lt(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:i,world:this.parent.toWorld(i),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!t.ctrlKey){const i=t.deltaMode?this.options.lineHeight:1,s=[t.deltaX,t.deltaY],[n,o]=this.options.wheelSwapAxes?s.reverse():s;return this.xDirection&&(this.parent.x+=n*i*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=o*i*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||t.preventDefault(),this.parent.options.stopPropagation&&t.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,t.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,t.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const SC={speed:0,acceleration:null,radius:null};class EC extends ze{constructor(t,e,i={}){super(t),W(this,"options"),W(this,"target"),W(this,"velocity"),this.target=e,this.options=Object.assign({},SC,i),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const e=this.parent.center;let i=this.target.x,s=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius){const a=Math.atan2(this.target.y-e.y,this.target.x-e.x);i=this.target.x-Math.cos(a)*this.options.radius,s=this.target.y-Math.sin(a)*this.options.radius}else return;const n=i-e.x,o=s-e.y;if(n||o)if(this.options.speed)if(this.options.acceleration){const a=Math.atan2(s-e.y,i-e.x),h=Math.sqrt(Math.pow(n,2)+Math.pow(o,2));if(h){const l=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);h>l?this.velocity={x:Math.min(this.velocity.x+(this.options.acceleration*t,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration*t,this.options.speed))}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(a)*this.velocity.x,c=Math.sin(a)*this.velocity.y,d=Math.abs(u)>Math.abs(n)?i:e.x+u,p=Math.abs(c)>Math.abs(o)?s:e.y+c;this.parent.moveCenter(d,p),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const a=Math.atan2(s-e.y,i-e.x),h=Math.cos(a)*this.options.speed,l=Math.sin(a)*this.options.speed,u=Math.abs(h)>Math.abs(n)?i:e.x+h,c=Math.abs(l)>Math.abs(o)?s:e.y+l;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(i,s),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const CC={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class IC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"reverse"),W(this,"radiusSquared"),W(this,"left"),W(this,"top"),W(this,"right"),W(this,"bottom"),W(this,"horizontal"),W(this,"vertical"),this.options=Object.assign({},CC,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;t!==null?(this.left=t,this.top=t,this.right=this.parent.screenWidth-t,this.bottom=this.parent.screenHeight-t):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(t){if(this.paused||t.pointerType!=="mouse"&&t.pointerId!==1||!this.options.allowButtons&&t.buttons!==0)return!1;const e=t.global.x,i=t.global.y;if(this.radiusSquared){const s=this.parent.toScreen(this.parent.center);if(Math.pow(s.x-e,2)+Math.pow(s.y-i,2)>=this.radiusSquared){const n=Math.atan2(s.y-i,s.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(n))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(n))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(n)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(n)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&i<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&i>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate",!0);this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate",!0);this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const AC={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class RC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"active",!1),W(this,"pinching",!1),W(this,"moved",!1),W(this,"lastCenter"),this.options=Object.assign({},AC,e)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(t){if(this.paused||!this.active)return!1;const e=t.global.x,i=t.global.y,s=this.parent.input.touches;if(s.length>=2){const n=s[0],o=s[1],a=n.last&&o.last?Math.sqrt(Math.pow(o.last.x-n.last.x,2)+Math.pow(o.last.y-n.last.y,2)):null;if(n.id===t.pointerId?n.last={x:e,y:i,data:t}:o.id===t.pointerId&&(o.last={x:e,y:i,data:t}),a){let h;const l=new lt(n.last.x+(o.last.x-n.last.x)/2,n.last.y+(o.last.y-n.last.y)/2);this.options.center||(h=this.parent.toLocal(l));let u=Math.sqrt(Math.pow(o.last.x-n.last.x,2)+Math.pow(o.last.y-n.last.y,2));u=u===0?u=1e-10:u;const c=(1-a/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=c),this.isAxisY()&&(this.parent.scale.y+=c),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:l});const d=this.parent.plugins.get("clamp-zoom",!0);if(d&&d.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const p=this.parent.toGlobal(h);this.parent.x+=(l.x-p.x)*this.options.factor,this.parent.y+=(l.y-p.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(l.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(l.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=l,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const MC={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class PC extends ze{constructor(t,e,i,s={}){super(t),W(this,"options"),W(this,"ease"),W(this,"x"),W(this,"y"),W(this,"percent"),W(this,"snapping"),W(this,"deltaX"),W(this,"deltaY"),W(this,"startX"),W(this,"startY"),this.options=Object.assign({},MC,s),this.ease=mh(s.ease,"easeInOutSine"),this.x=e,this.y=i,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const t=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-t.x,this.deltaY=this.y-t.y,this.startX=t.x,this.startY=t.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const t=this.parent.plugins.get("decelerate",!0);t&&(t.x||t.y)&&(t.percentChangeX=t.percentChangeY=this.options.friction)}return!1}update(t){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const e=this.snapping;e.time+=t;let i,s,n;const o=this.startX,a=this.startY,h=this.deltaX,l=this.deltaY;if(e.time>this.options.time)i=!0,s=o+h,n=a+l;else{const u=this.ease(e.time,0,1,this.options.time);s=o+h*u,n=a+l*u}this.options.topLeft?this.parent.moveCorner(s,n):this.parent.moveCenter(s,n),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),i&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const e=this.options.topLeft?this.parent.corner:this.parent.center;(e.x!==this.x||e.y!==this.y)&&this.snapStart()}}}const LC={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class GC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"ease"),W(this,"xScale"),W(this,"yScale"),W(this,"xIndependent"),W(this,"yIndependent"),W(this,"snapping"),this.options=Object.assign({},LC,e),this.ease=mh(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=t.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,i=this.parent.screenWidth/this.xScale,s=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:e,deltaX:i-t,deltaY:s-e},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(t){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const i=this.snapping;if(i.time+=t,i.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const n=this.snapping,o=this.ease(n.time,n.startX,n.deltaX,this.options.time),a=this.ease(n.time,n.startY,n.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/o,this.parent.scale.y=this.parent.screenHeight/a}const s=this.parent.plugins.get("clamp-zoom",!0);s&&s.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}resume(){this.snapping=null,super.resume()}}const NC={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class FC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"smoothing"),W(this,"smoothingCenter"),W(this,"smoothingCount"),W(this,"keyIsPressed"),this.options=Object.assign({},NC,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",e=>{t.includes(e.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",e=>{t.includes(e.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const t=this.smoothingCenter,e=this.smoothing;let i;this.options.center||(i=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const n=this.parent.toGlobal(i);this.parent.x+=t.x-n.x,this.parent.y+=t.y-n.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(t){if(this.paused)return;const e=this.parent.input.getPointerPosition(t),i=-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/200,s=Math.pow(2,(1+this.options.percent)*i);let n;this.options.center||(n=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.toGlobal(n);this.parent.x+=e.x-a.x,this.parent.y+=e.y-a.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}wheel(t){if(this.paused||!this.checkKeyPress())return!1;if(t.ctrlKey&&this.options.trackpadPinch)this.pinch(t);else if(this.options.wheelZoom){const e=this.parent.input.getPointerPosition(t),i=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,s=Math.pow(2,(1+this.options.percent)*i);if(this.options.smooth){const n={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+n.x)*s-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+n.y)*s-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let n;this.options.center||(n=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.toGlobal(n);this.parent.x+=e.x-a.x,this.parent.y+=e.y-a.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}return!this.parent.options.passiveWheel}}class DC{constructor(t){W(this,"viewport"),W(this,"clickedAvailable"),W(this,"isMouseDown"),W(this,"last"),W(this,"wheelFunction"),W(this,"touches"),this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new ct(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,this):this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(t){if(!(this.viewport.pause||!this.viewport.worldVisible)){if(t.pointerType==="mouse"?this.isMouseDown=!0:this.get(t.pointerId)||this.touches.push({id:t.pointerId,last:null}),this.count()===1){this.last=t.global.clone();const e=this.viewport.plugins.get("decelerate",!0),i=this.viewport.plugins.get("bounce",!0);(!e||!e.isActive())&&(!i||!i.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const i=t.global.x-this.last.x,s=t.global.y-this.last.y;(this.checkThreshold(i)||this.checkThreshold(s))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;t.pointerType==="mouse"&&(this.isMouseDown=!1),t.pointerType!=="mouse"&&this.remove(t.pointerId);const e=this.viewport.plugins.up(t);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const e=new lt;return this.viewport.options.events.mapPositionToPoint(e,t.clientX,t.clientY),e}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(t));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom&&this.viewport.plugins.wheel(t)&&!this.viewport.options.passiveWheel&&t.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(const e of this.touches)if(e.id===t)return e;return null}remove(t){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===t){this.touches.splice(e,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}const mo=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class kC{constructor(t){W(this,"plugins"),W(this,"list"),W(this,"viewport"),this.viewport=t,this.list=[],this.plugins={}}add(t,e,i=mo.length){const s=this.plugins[t];s&&s.destroy(),this.plugins[t]=e;const n=mo.indexOf(t);n!==-1&&mo.splice(n,1),mo.splice(i,0,t),this.sort()}get(t,e){var i;return e&&(i=this.plugins[t])!=null&&i.paused?null:this.plugins[t]}update(t){for(const e of this.list)e.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.list.forEach(t=>{t.destroy()}),this.plugins={},this.sort()}remove(t){var e;this.plugins[t]&&((e=this.plugins[t])==null||e.destroy(),delete this.plugins[t],this.viewport.emit("plugin-remove",t),this.sort())}pause(t){var e;(e=this.plugins[t])==null||e.pause()}resume(t){var e;(e=this.plugins[t])==null||e.resume()}sort(){this.list=[];for(const t of mo)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let e=!1;for(const i of this.list)i.down(t)&&(e=!0);return e}move(t){let e=!1;for(const i of this.viewport.plugins.list)i.move(t)&&(e=!0);return e}up(t){let e=!1;for(const i of this.list)i.up(t)&&(e=!0);return e}wheel(t){let e=!1;for(const i of this.list)i.wheel(t)&&(e=!0);return e}}const OC={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:be.shared,allowPreserveDragOutside:!1};class WC extends Xt{constructor(t){super(),W(this,"moving"),W(this,"screenWidth"),W(this,"screenHeight"),W(this,"threshold"),W(this,"input"),W(this,"plugins"),W(this,"zooming"),W(this,"lastViewport"),W(this,"options"),W(this,"_dirty"),W(this,"_forceHitArea"),W(this,"_hitAreaDefault"),W(this,"_pause"),W(this,"tickerFunction"),W(this,"_worldWidth"),W(this,"_worldHeight"),W(this,"_disableOnContextMenu",e=>e.preventDefault()),this.options={...OC,...t},this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new DC(this),this.plugins=new kC(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new ct(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=window.innerWidth,e=window.innerHeight,i,s){this.screenWidth=t,this.screenHeight=e,typeof i<"u"&&(this._worldWidth=i),typeof s<"u"&&(this._worldHeight=s),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new ct(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,e){return arguments.length===2?this.toLocal(new lt(t,e)):this.toLocal(t)}toScreen(t,e){return arguments.length===2?this.toGlobal(new lt(t,e)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new lt(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(...t){let e,i;typeof t[0]=="number"?(e=t[0],i=t[1]):(e=t[0].x,i=t[0].y);const s=(this.worldScreenWidth/2-e)*this.scale.x,n=(this.worldScreenHeight/2-i)*this.scale.y;return(this.x!==s||this.y!==n)&&(this.position.set(s,n),this.plugins.reset(),this.dirty=!0),this}get corner(){return new lt(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let e,i;return t.length===1?(e=-t[0].x*this.scale.x,i=-t[0].y*this.scale.y):(e=-t[0]*this.scale.x,i=-t[1]*this.scale.y),(e!==this.x||i!==this.y)&&(this.position.set(e,i),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(t){return this.screenWidth/t}findFitHeight(t){return this.screenHeight/t}findFit(t,e){const i=this.screenWidth/t,s=this.screenHeight/e;return Math.min(i,s)}findCover(t,e){const i=this.screenWidth/t,s=this.screenHeight/e;return Math.max(i,s)}fitWidth(t=this.worldWidth,e,i=!0,s){let n;e&&(n=this.center),this.scale.x=this.screenWidth/t,i&&(this.scale.y=this.scale.x);const o=this.plugins.get("clamp-zoom",!0);return!s&&o&&o.clamp(),e&&n&&this.moveCenter(n),this}fitHeight(t=this.worldHeight,e,i=!0,s){let n;e&&(n=this.center),this.scale.y=this.screenHeight/t,i&&(this.scale.x=this.scale.y);const o=this.plugins.get("clamp-zoom",!0);return!s&&o&&o.clamp(),e&&n&&this.moveCenter(n),this}fitWorld(t){let e;t&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),t&&e&&this.moveCenter(e),this}fit(t,e=this.worldWidth,i=this.worldHeight){let s;t&&(s=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/i,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const n=this.plugins.get("clamp-zoom",!0);return n&&n.clamp(),t&&s&&this.moveCenter(s),this}setZoom(t,e){let i;e&&(i=this.center),this.scale.set(t);const s=this.plugins.get("clamp-zoom",!0);return s&&s.clamp(),e&&i&&this.moveCenter(i),this}zoomPercent(t,e){return this.setZoom(this.scale.x+this.scale.x*t,e)}zoom(t,e){return this.fitWidth(t+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new GC(this,t)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new lt(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new ct(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new wC(this,t)),this}clamp(t){return this.plugins.add("clamp",new yC(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new vC(this,t)),this}bounce(t){return this.plugins.add("bounce",new mC(this,t)),this}pinch(t){return this.plugins.add("pinch",new RC(this,t)),this}snap(t,e,i){return this.plugins.add("snap",new PC(this,t,e,i)),this}follow(t,e){return this.plugins.add("follow",new EC(this,t,e)),this}wheel(t){return this.plugins.add("wheel",new FC(this,t)),this}animate(t){return this.plugins.add("animate",new pC(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new xC(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new IC(this,t)),this}get pause(){return!!this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,e,i,s,n){n&&(i>this.worldScreenWidth||s>this.worldScreenHeight)&&(this.fit(!0,i,s),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let o=!1;t<this.left?(this.left=t,o=!0):t+i>this.right&&(this.right=t+i,o=!0),e<this.top?(this.top=e,o=!0):e+s>this.bottom&&(this.bottom=e+s,o=!0),o&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}function gh(r,t){return r==null||t==null?NaN:r<t?-1:r>t?1:r>=t?0:NaN}function BC(r,t){return r==null||t==null?NaN:t<r?-1:t>r?1:t>=r?0:NaN}function Zc(r){let t,e,i;r.length!==2?(t=gh,e=(a,h)=>gh(r(a),h),i=(a,h)=>r(a)-h):(t=r===gh||r===BC?r:UC,e=r,i=r);function s(a,h,l=0,u=a.length){if(l<u){if(t(h,h)!==0)return u;do{const c=l+u>>>1;e(a[c],h)<0?l=c+1:u=c}while(l<u)}return l}function n(a,h,l=0,u=a.length){if(l<u){if(t(h,h)!==0)return u;do{const c=l+u>>>1;e(a[c],h)<=0?l=c+1:u=c}while(l<u)}return l}function o(a,h,l=0,u=a.length){const c=s(a,h,l,u-1);return c>l&&i(a[c-1],h)>-i(a[c],h)?c-1:c}return{left:s,center:o,right:n}}function UC(){return 0}function XC(r){return r===null?NaN:+r}const ZC=Zc(gh).right;Zc(XC).center;const VC=ZC,KC=Math.sqrt(50),HC=Math.sqrt(10),YC=Math.sqrt(2);function yh(r,t,e){const i=(t-r)/Math.max(0,e),s=Math.floor(Math.log10(i)),n=i/Math.pow(10,s),o=n>=KC?10:n>=HC?5:n>=YC?2:1;let a,h,l;return s<0?(l=Math.pow(10,-s)/o,a=Math.round(r*l),h=Math.round(t*l),a/l<r&&++a,h/l>t&&--h,l=-l):(l=Math.pow(10,s)*o,a=Math.round(r/l),h=Math.round(t/l),a*l<r&&++a,h*l>t&&--h),h<a&&.5<=e&&e<2?yh(r,t,e*2):[a,h,l]}function zC(r,t,e){if(t=+t,r=+r,e=+e,!(e>0))return[];if(r===t)return[r];const i=t<r,[s,n,o]=i?yh(t,r,e):yh(r,t,e);if(!(n>=s))return[];const a=n-s+1,h=new Array(a);if(i)if(o<0)for(let l=0;l<a;++l)h[l]=(n-l)/-o;else for(let l=0;l<a;++l)h[l]=(n-l)*o;else if(o<0)for(let l=0;l<a;++l)h[l]=(s+l)/-o;else for(let l=0;l<a;++l)h[l]=(s+l)*o;return h}function Vc(r,t,e){return t=+t,r=+r,e=+e,yh(r,t,e)[2]}function Kc(r,t,e){t=+t,r=+r,e=+e;const i=t<r,s=i?Vc(t,r,e):Vc(r,t,e);return(i?-1:1)*(s<0?1/-s:s)}function Hc(r,t,e){r.prototype=t.prototype=e,e.constructor=r}function ry(r,t){var e=Object.create(r.prototype);for(var i in t)e[i]=t[i];return e}function go(){}var yo=.7,bh=1/yo,hn="\\s*([+-]?\\d+)\\s*",bo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Li="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",jC=/^#([0-9a-f]{3,8})$/,JC=new RegExp(`^rgb\\(${hn},${hn},${hn}\\)$`),$C=new RegExp(`^rgb\\(${Li},${Li},${Li}\\)$`),QC=new RegExp(`^rgba\\(${hn},${hn},${hn},${bo}\\)$`),qC=new RegExp(`^rgba\\(${Li},${Li},${Li},${bo}\\)$`),tI=new RegExp(`^hsl\\(${bo},${Li},${Li}\\)$`),eI=new RegExp(`^hsla\\(${bo},${Li},${Li},${bo}\\)$`),sy={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Hc(go,xo,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ny,formatHex:ny,formatHex8:iI,formatHsl:rI,formatRgb:oy,toString:oy});function ny(){return this.rgb().formatHex()}function iI(){return this.rgb().formatHex8()}function rI(){return cy(this).formatHsl()}function oy(){return this.rgb().formatRgb()}function xo(r){var t,e;return r=(r+"").trim().toLowerCase(),(t=jC.exec(r))?(e=t[1].length,t=parseInt(t[1],16),e===6?ay(t):e===3?new Ee(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):e===8?xh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):e===4?xh(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=JC.exec(r))?new Ee(t[1],t[2],t[3],1):(t=$C.exec(r))?new Ee(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=QC.exec(r))?xh(t[1],t[2],t[3],t[4]):(t=qC.exec(r))?xh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=tI.exec(r))?uy(t[1],t[2]/100,t[3]/100,1):(t=eI.exec(r))?uy(t[1],t[2]/100,t[3]/100,t[4]):sy.hasOwnProperty(r)?ay(sy[r]):r==="transparent"?new Ee(NaN,NaN,NaN,0):null}function ay(r){return new Ee(r>>16&255,r>>8&255,r&255,1)}function xh(r,t,e,i){return i<=0&&(r=t=e=NaN),new Ee(r,t,e,i)}function sI(r){return r instanceof go||(r=xo(r)),r?(r=r.rgb(),new Ee(r.r,r.g,r.b,r.opacity)):new Ee}function Yc(r,t,e,i){return arguments.length===1?sI(r):new Ee(r,t,e,i??1)}function Ee(r,t,e,i){this.r=+r,this.g=+t,this.b=+e,this.opacity=+i}Hc(Ee,Yc,ry(go,{brighter(r){return r=r==null?bh:Math.pow(bh,r),new Ee(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?yo:Math.pow(yo,r),new Ee(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new Ee(ys(this.r),ys(this.g),ys(this.b),_h(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:hy,formatHex:hy,formatHex8:nI,formatRgb:ly,toString:ly}));function hy(){return`#${bs(this.r)}${bs(this.g)}${bs(this.b)}`}function nI(){return`#${bs(this.r)}${bs(this.g)}${bs(this.b)}${bs((isNaN(this.opacity)?1:this.opacity)*255)}`}function ly(){const r=_h(this.opacity);return`${r===1?"rgb(":"rgba("}${ys(this.r)}, ${ys(this.g)}, ${ys(this.b)}${r===1?")":`, ${r})`}`}function _h(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function ys(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function bs(r){return r=ys(r),(r<16?"0":"")+r.toString(16)}function uy(r,t,e,i){return i<=0?r=t=e=NaN:e<=0||e>=1?r=t=NaN:t<=0&&(r=NaN),new ui(r,t,e,i)}function cy(r){if(r instanceof ui)return new ui(r.h,r.s,r.l,r.opacity);if(r instanceof go||(r=xo(r)),!r)return new ui;if(r instanceof ui)return r;r=r.rgb();var t=r.r/255,e=r.g/255,i=r.b/255,s=Math.min(t,e,i),n=Math.max(t,e,i),o=NaN,a=n-s,h=(n+s)/2;return a?(t===n?o=(e-i)/a+(e<i)*6:e===n?o=(i-t)/a+2:o=(t-e)/a+4,a/=h<.5?n+s:2-n-s,o*=60):a=h>0&&h<1?0:o,new ui(o,a,h,r.opacity)}function oI(r,t,e,i){return arguments.length===1?cy(r):new ui(r,t,e,i??1)}function ui(r,t,e,i){this.h=+r,this.s=+t,this.l=+e,this.opacity=+i}Hc(ui,oI,ry(go,{brighter(r){return r=r==null?bh:Math.pow(bh,r),new ui(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?yo:Math.pow(yo,r),new ui(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,t=isNaN(r)||isNaN(this.s)?0:this.s,e=this.l,i=e+(e<.5?e:1-e)*t,s=2*e-i;return new Ee(zc(r>=240?r-240:r+120,s,i),zc(r,s,i),zc(r<120?r+240:r-120,s,i),this.opacity)},clamp(){return new ui(dy(this.h),vh(this.s),vh(this.l),_h(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=_h(this.opacity);return`${r===1?"hsl(":"hsla("}${dy(this.h)}, ${vh(this.s)*100}%, ${vh(this.l)*100}%${r===1?")":`, ${r})`}`}}));function dy(r){return r=(r||0)%360,r<0?r+360:r}function vh(r){return Math.max(0,Math.min(1,r||0))}function zc(r,t,e){return(r<60?t+(e-t)*r/60:r<180?e:r<240?t+(e-t)*(240-r)/60:t)*255}const jc=r=>()=>r;function aI(r,t){return function(e){return r+e*t}}function hI(r,t,e){return r=Math.pow(r,e),t=Math.pow(t,e)-r,e=1/e,function(i){return Math.pow(r+i*t,e)}}function lI(r){return(r=+r)==1?py:function(t,e){return e-t?hI(t,e,r):jc(isNaN(t)?e:t)}}function py(r,t){var e=t-r;return e?aI(r,e):jc(isNaN(r)?t:r)}const fy=function r(t){var e=lI(t);function i(s,n){var o=e((s=Yc(s)).r,(n=Yc(n)).r),a=e(s.g,n.g),h=e(s.b,n.b),l=py(s.opacity,n.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=h(u),s.opacity=l(u),s+""}}return i.gamma=r,i}(1);function uI(r,t){t||(t=[]);var e=r?Math.min(t.length,r.length):0,i=t.slice(),s;return function(n){for(s=0;s<e;++s)i[s]=r[s]*(1-n)+t[s]*n;return i}}function cI(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function dI(r,t){var e=t?t.length:0,i=r?Math.min(e,r.length):0,s=new Array(i),n=new Array(e),o;for(o=0;o<i;++o)s[o]=Qc(r[o],t[o]);for(;o<e;++o)n[o]=t[o];return function(a){for(o=0;o<i;++o)n[o]=s[o](a);return n}}function pI(r,t){var e=new Date;return r=+r,t=+t,function(i){return e.setTime(r*(1-i)+t*i),e}}function Th(r,t){return r=+r,t=+t,function(e){return r*(1-e)+t*e}}function fI(r,t){var e={},i={},s;(r===null||typeof r!="object")&&(r={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in r?e[s]=Qc(r[s],t[s]):i[s]=t[s];return function(n){for(s in e)i[s]=e[s](n);return i}}var Jc=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$c=new RegExp(Jc.source,"g");function mI(r){return function(){return r}}function gI(r){return function(t){return r(t)+""}}function yI(r,t){var e=Jc.lastIndex=$c.lastIndex=0,i,s,n,o=-1,a=[],h=[];for(r=r+"",t=t+"";(i=Jc.exec(r))&&(s=$c.exec(t));)(n=s.index)>e&&(n=t.slice(e,n),a[o]?a[o]+=n:a[++o]=n),(i=i[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,h.push({i:o,x:Th(i,s)})),e=$c.lastIndex;return e<t.length&&(n=t.slice(e),a[o]?a[o]+=n:a[++o]=n),a.length<2?h[0]?gI(h[0].x):mI(t):(t=h.length,function(l){for(var u=0,c;u<t;++u)a[(c=h[u]).i]=c.x(l);return a.join("")})}function Qc(r,t){var e=typeof t,i;return t==null||e==="boolean"?jc(t):(e==="number"?Th:e==="string"?(i=xo(t))?(t=i,fy):yI:t instanceof xo?fy:t instanceof Date?pI:cI(t)?uI:Array.isArray(t)?dI:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?fI:Th)(r,t)}function bI(r,t){return r=+r,t=+t,function(e){return Math.round(r*(1-e)+t*e)}}function xI(r){return Math.abs(r=Math.round(r))>=1e21?r.toLocaleString("en").replace(/,/g,""):r.toString(10)}function wh(r,t){if((e=(r=t?r.toExponential(t-1):r.toExponential()).indexOf("e"))<0)return null;var e,i=r.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+r.slice(e+1)]}function ln(r){return r=wh(Math.abs(r)),r?r[1]:NaN}function _I(r,t){return function(e,i){for(var s=e.length,n=[],o=0,a=r[0],h=0;s>0&&a>0&&(h+a+1>i&&(a=Math.max(1,i-h)),n.push(e.substring(s-=a,s+a)),!((h+=a+1)>i));)a=r[o=(o+1)%r.length];return n.reverse().join(t)}}function vI(r){return function(t){return t.replace(/[0-9]/g,function(e){return r[+e]})}}var TI=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Sh(r){if(!(t=TI.exec(r)))throw new Error("invalid format: "+r);var t;return new qc({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Sh.prototype=qc.prototype;function qc(r){this.fill=r.fill===void 0?" ":r.fill+"",this.align=r.align===void 0?">":r.align+"",this.sign=r.sign===void 0?"-":r.sign+"",this.symbol=r.symbol===void 0?"":r.symbol+"",this.zero=!!r.zero,this.width=r.width===void 0?void 0:+r.width,this.comma=!!r.comma,this.precision=r.precision===void 0?void 0:+r.precision,this.trim=!!r.trim,this.type=r.type===void 0?"":r.type+""}qc.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function wI(r){t:for(var t=r.length,e=1,i=-1,s;e<t;++e)switch(r[e]){case".":i=s=e;break;case"0":i===0&&(i=e),s=e;break;default:if(!+r[e])break t;i>0&&(i=0);break}return i>0?r.slice(0,i)+r.slice(s+1):r}var my;function SI(r,t){var e=wh(r,t);if(!e)return r+"";var i=e[0],s=e[1],n=s-(my=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,o=i.length;return n===o?i:n>o?i+new Array(n-o+1).join("0"):n>0?i.slice(0,n)+"."+i.slice(n):"0."+new Array(1-n).join("0")+wh(r,Math.max(0,t+n-1))[0]}function gy(r,t){var e=wh(r,t);if(!e)return r+"";var i=e[0],s=e[1];return s<0?"0."+new Array(-s).join("0")+i:i.length>s+1?i.slice(0,s+1)+"."+i.slice(s+1):i+new Array(s-i.length+2).join("0")}const yy={"%":(r,t)=>(r*100).toFixed(t),b:r=>Math.round(r).toString(2),c:r=>r+"",d:xI,e:(r,t)=>r.toExponential(t),f:(r,t)=>r.toFixed(t),g:(r,t)=>r.toPrecision(t),o:r=>Math.round(r).toString(8),p:(r,t)=>gy(r*100,t),r:gy,s:SI,X:r=>Math.round(r).toString(16).toUpperCase(),x:r=>Math.round(r).toString(16)};function by(r){return r}var xy=Array.prototype.map,_y=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function EI(r){var t=r.grouping===void 0||r.thousands===void 0?by:_I(xy.call(r.grouping,Number),r.thousands+""),e=r.currency===void 0?"":r.currency[0]+"",i=r.currency===void 0?"":r.currency[1]+"",s=r.decimal===void 0?".":r.decimal+"",n=r.numerals===void 0?by:vI(xy.call(r.numerals,String)),o=r.percent===void 0?"%":r.percent+"",a=r.minus===void 0?"−":r.minus+"",h=r.nan===void 0?"NaN":r.nan+"";function l(c){c=Sh(c);var d=c.fill,p=c.align,m=c.sign,f=c.symbol,g=c.zero,y=c.width,_=c.comma,b=c.precision,v=c.trim,S=c.type;S==="n"?(_=!0,S="g"):yy[S]||(b===void 0&&(b=12),v=!0,S="g"),(g||d==="0"&&p==="=")&&(g=!0,d="0",p="=");var E=f==="$"?e:f==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",A=f==="$"?i:/[%p]/.test(S)?o:"",I=yy[S],P=/[defgprs%]/.test(S);b=b===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,b)):Math.max(0,Math.min(20,b));function B(G){var N=E,C=A,F,X,V;if(S==="c")C=I(G)+C,G="";else{G=+G;var L=G<0||1/G<0;if(G=isNaN(G)?h:I(Math.abs(G),b),v&&(G=wI(G)),L&&+G==0&&m!=="+"&&(L=!1),N=(L?m==="("?m:a:m==="-"||m==="("?"":m)+N,C=(S==="s"?_y[8+my/3]:"")+C+(L&&m==="("?")":""),P){for(F=-1,X=G.length;++F<X;)if(V=G.charCodeAt(F),48>V||V>57){C=(V===46?s+G.slice(F+1):G.slice(F))+C,G=G.slice(0,F);break}}}_&&!g&&(G=t(G,1/0));var k=N.length+G.length+C.length,K=k<y?new Array(y-k+1).join(d):"";switch(_&&g&&(G=t(K+G,K.length?y-C.length:1/0),K=""),p){case"<":G=N+G+C+K;break;case"=":G=N+K+G+C;break;case"^":G=K.slice(0,k=K.length>>1)+N+G+C+K.slice(k);break;default:G=K+N+G+C;break}return n(G)}return B.toString=function(){return c+""},B}function u(c,d){var p=l((c=Sh(c),c.type="f",c)),m=Math.max(-8,Math.min(8,Math.floor(ln(d)/3)))*3,f=Math.pow(10,-m),g=_y[8+m/3];return function(y){return p(f*y)+g}}return{format:l,formatPrefix:u}}var Eh,vy,Ty;CI({thousands:",",grouping:[3],currency:["$",""]});function CI(r){return Eh=EI(r),vy=Eh.format,Ty=Eh.formatPrefix,Eh}function II(r){return Math.max(0,-ln(Math.abs(r)))}function AI(r,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ln(t)/3)))*3-ln(Math.abs(r)))}function RI(r,t){return r=Math.abs(r),t=Math.abs(t)-r,Math.max(0,ln(t)-ln(r))+1}function wy(r,t){switch(arguments.length){case 0:break;case 1:this.range(r);break;default:this.range(t).domain(r);break}return this}function MI(r){return function(){return r}}function PI(r){return+r}var Sy=[0,1];function un(r){return r}function td(r,t){return(t-=r=+r)?function(e){return(e-r)/t}:MI(isNaN(t)?NaN:.5)}function LI(r,t){var e;return r>t&&(e=r,r=t,t=e),function(i){return Math.max(r,Math.min(t,i))}}function GI(r,t,e){var i=r[0],s=r[1],n=t[0],o=t[1];return s<i?(i=td(s,i),n=e(o,n)):(i=td(i,s),n=e(n,o)),function(a){return n(i(a))}}function NI(r,t,e){var i=Math.min(r.length,t.length)-1,s=new Array(i),n=new Array(i),o=-1;for(r[i]<r[0]&&(r=r.slice().reverse(),t=t.slice().reverse());++o<i;)s[o]=td(r[o],r[o+1]),n[o]=e(t[o],t[o+1]);return function(a){var h=VC(r,a,1,i)-1;return n[h](s[h](a))}}function Ey(r,t){return t.domain(r.domain()).range(r.range()).interpolate(r.interpolate()).clamp(r.clamp()).unknown(r.unknown())}function FI(){var r=Sy,t=Sy,e=Qc,i,s,n,o=un,a,h,l;function u(){var d=Math.min(r.length,t.length);return o!==un&&(o=LI(r[0],r[d-1])),a=d>2?NI:GI,h=l=null,c}function c(d){return d==null||isNaN(d=+d)?n:(h||(h=a(r.map(i),t,e)))(i(o(d)))}return c.invert=function(d){return o(s((l||(l=a(t,r.map(i),Th)))(d)))},c.domain=function(d){return arguments.length?(r=Array.from(d,PI),u()):r.slice()},c.range=function(d){return arguments.length?(t=Array.from(d),u()):t.slice()},c.rangeRound=function(d){return t=Array.from(d),e=bI,u()},c.clamp=function(d){return arguments.length?(o=d?!0:un,u()):o!==un},c.interpolate=function(d){return arguments.length?(e=d,u()):e},c.unknown=function(d){return arguments.length?(n=d,c):n},function(d,p){return i=d,s=p,u()}}function Cy(){return FI()(un,un)}function DI(r,t,e,i){var s=Kc(r,t,e),n;switch(i=Sh(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(r),Math.abs(t));return i.precision==null&&!isNaN(n=AI(s,o))&&(i.precision=n),Ty(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(n=RI(s,Math.max(Math.abs(r),Math.abs(t))))&&(i.precision=n-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(n=II(s))&&(i.precision=n-(i.type==="%")*2);break}}return vy(i)}function kI(r){var t=r.domain;return r.ticks=function(e){var i=t();return zC(i[0],i[i.length-1],e??10)},r.tickFormat=function(e,i){var s=t();return DI(s[0],s[s.length-1],e??10,i)},r.nice=function(e){e==null&&(e=10);var i=t(),s=0,n=i.length-1,o=i[s],a=i[n],h,l,u=10;for(a<o&&(l=o,o=a,a=l,l=s,s=n,n=l);u-- >0;){if(l=Vc(o,a,e),l===h)return i[s]=o,i[n]=a,t(i);if(l>0)o=Math.floor(o/l)*l,a=Math.ceil(a/l)*l;else if(l<0)o=Math.ceil(o*l)/l,a=Math.floor(a*l)/l;else break;h=l}return r},r}function Iy(){var r=Cy();return r.copy=function(){return Ey(r,Iy())},wy.apply(r,arguments),kI(r)}function OI(r,t){r=r.slice();var e=0,i=r.length-1,s=r[e],n=r[i],o;return n<s&&(o=e,e=i,i=o,o=s,s=n,n=o),r[e]=t.floor(s),r[i]=t.ceil(n),r}const ed=new Date,id=new Date;function $t(r,t,e,i){function s(n){return r(n=arguments.length===0?new Date:new Date(+n)),n}return s.floor=n=>(r(n=new Date(+n)),n),s.ceil=n=>(r(n=new Date(n-1)),t(n,1),r(n),n),s.round=n=>{const o=s(n),a=s.ceil(n);return n-o<a-n?o:a},s.offset=(n,o)=>(t(n=new Date(+n),o==null?1:Math.floor(o)),n),s.range=(n,o,a)=>{const h=[];if(n=s.ceil(n),a=a==null?1:Math.floor(a),!(n<o)||!(a>0))return h;let l;do h.push(l=new Date(+n)),t(n,a),r(n);while(l<n&&n<o);return h},s.filter=n=>$t(o=>{if(o>=o)for(;r(o),!n(o);)o.setTime(o-1)},(o,a)=>{if(o>=o)if(a<0)for(;++a<=0;)for(;t(o,-1),!n(o););else for(;--a>=0;)for(;t(o,1),!n(o););}),e&&(s.count=(n,o)=>(ed.setTime(+n),id.setTime(+o),r(ed),r(id),Math.floor(e(ed,id))),s.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?s.filter(i?o=>i(o)%n===0:o=>s.count(0,o)%n===0):s)),s}const Ch=$t(()=>{},(r,t)=>{r.setTime(+r+t)},(r,t)=>t-r);Ch.every=r=>(r=Math.floor(r),!isFinite(r)||!(r>0)?null:r>1?$t(t=>{t.setTime(Math.floor(t/r)*r)},(t,e)=>{t.setTime(+t+e*r)},(t,e)=>(e-t)/r):Ch),Ch.range;const or=1e3,je=or*60,ar=je*60,hr=ar*24,rd=hr*7,Ay=hr*30,sd=hr*365,cn=$t(r=>{r.setTime(r-r.getMilliseconds())},(r,t)=>{r.setTime(+r+t*or)},(r,t)=>(t-r)/or,r=>r.getUTCSeconds());cn.range;const nd=$t(r=>{r.setTime(r-r.getMilliseconds()-r.getSeconds()*or)},(r,t)=>{r.setTime(+r+t*je)},(r,t)=>(t-r)/je,r=>r.getMinutes());nd.range,$t(r=>{r.setUTCSeconds(0,0)},(r,t)=>{r.setTime(+r+t*je)},(r,t)=>(t-r)/je,r=>r.getUTCMinutes()).range;const od=$t(r=>{r.setTime(r-r.getMilliseconds()-r.getSeconds()*or-r.getMinutes()*je)},(r,t)=>{r.setTime(+r+t*ar)},(r,t)=>(t-r)/ar,r=>r.getHours());od.range,$t(r=>{r.setUTCMinutes(0,0,0)},(r,t)=>{r.setTime(+r+t*ar)},(r,t)=>(t-r)/ar,r=>r.getUTCHours()).range;const _o=$t(r=>r.setHours(0,0,0,0),(r,t)=>r.setDate(r.getDate()+t),(r,t)=>(t-r-(t.getTimezoneOffset()-r.getTimezoneOffset())*je)/hr,r=>r.getDate()-1);_o.range;const ad=$t(r=>{r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCDate(r.getUTCDate()+t)},(r,t)=>(t-r)/hr,r=>r.getUTCDate()-1);ad.range,$t(r=>{r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCDate(r.getUTCDate()+t)},(r,t)=>(t-r)/hr,r=>Math.floor(r/hr)).range;function xs(r){return $t(t=>{t.setDate(t.getDate()-(t.getDay()+7-r)%7),t.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+e*7)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*je)/rd)}const Ih=xs(0),Ah=xs(1),WI=xs(2),BI=xs(3),dn=xs(4),UI=xs(5),XI=xs(6);Ih.range,Ah.range,WI.range,BI.range,dn.range,UI.range,XI.range;function _s(r){return $t(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-r)%7),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e*7)},(t,e)=>(e-t)/rd)}const Ry=_s(0),Rh=_s(1),ZI=_s(2),VI=_s(3),pn=_s(4),KI=_s(5),HI=_s(6);Ry.range,Rh.range,ZI.range,VI.range,pn.range,KI.range,HI.range;const hd=$t(r=>{r.setDate(1),r.setHours(0,0,0,0)},(r,t)=>{r.setMonth(r.getMonth()+t)},(r,t)=>t.getMonth()-r.getMonth()+(t.getFullYear()-r.getFullYear())*12,r=>r.getMonth());hd.range,$t(r=>{r.setUTCDate(1),r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCMonth(r.getUTCMonth()+t)},(r,t)=>t.getUTCMonth()-r.getUTCMonth()+(t.getUTCFullYear()-r.getUTCFullYear())*12,r=>r.getUTCMonth()).range;const lr=$t(r=>{r.setMonth(0,1),r.setHours(0,0,0,0)},(r,t)=>{r.setFullYear(r.getFullYear()+t)},(r,t)=>t.getFullYear()-r.getFullYear(),r=>r.getFullYear());lr.every=r=>!isFinite(r=Math.floor(r))||!(r>0)?null:$t(t=>{t.setFullYear(Math.floor(t.getFullYear()/r)*r),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e*r)}),lr.range;const vs=$t(r=>{r.setUTCMonth(0,1),r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCFullYear(r.getUTCFullYear()+t)},(r,t)=>t.getUTCFullYear()-r.getUTCFullYear(),r=>r.getUTCFullYear());vs.every=r=>!isFinite(r=Math.floor(r))||!(r>0)?null:$t(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/r)*r),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e*r)}),vs.range;function YI(r,t,e,i,s,n){const o=[[cn,1,or],[cn,5,5*or],[cn,15,15*or],[cn,30,30*or],[n,1,je],[n,5,5*je],[n,15,15*je],[n,30,30*je],[s,1,ar],[s,3,3*ar],[s,6,6*ar],[s,12,12*ar],[i,1,hr],[i,2,2*hr],[e,1,rd],[t,1,Ay],[t,3,3*Ay],[r,1,sd]];function a(l,u,c){const d=u<l;d&&([l,u]=[u,l]);const p=c&&typeof c.range=="function"?c:h(l,u,c),m=p?p.range(l,+u+1):[];return d?m.reverse():m}function h(l,u,c){const d=Math.abs(u-l)/c,p=Zc(([,,g])=>g).right(o,d);if(p===o.length)return r.every(Kc(l/sd,u/sd,c));if(p===0)return Ch.every(Math.max(Kc(l,u,c),1));const[m,f]=o[d/o[p-1][2]<o[p][2]/d?p-1:p];return m.every(f)}return[a,h]}const[zI,jI]=YI(lr,hd,Ih,_o,od,nd);function ld(r){if(0<=r.y&&r.y<100){var t=new Date(-1,r.m,r.d,r.H,r.M,r.S,r.L);return t.setFullYear(r.y),t}return new Date(r.y,r.m,r.d,r.H,r.M,r.S,r.L)}function ud(r){if(0<=r.y&&r.y<100){var t=new Date(Date.UTC(-1,r.m,r.d,r.H,r.M,r.S,r.L));return t.setUTCFullYear(r.y),t}return new Date(Date.UTC(r.y,r.m,r.d,r.H,r.M,r.S,r.L))}function vo(r,t,e){return{y:r,m:t,d:e,H:0,M:0,S:0,L:0}}function JI(r){var t=r.dateTime,e=r.date,i=r.time,s=r.periods,n=r.days,o=r.shortDays,a=r.months,h=r.shortMonths,l=To(s),u=wo(s),c=To(n),d=wo(n),p=To(o),m=wo(o),f=To(a),g=wo(a),y=To(h),_=wo(h),b={a:L,A:k,b:K,B:D,c:null,d:Fy,e:Fy,f:xA,g:RA,G:PA,H:gA,I:yA,j:bA,L:Dy,m:_A,M:vA,p:U,q:j,Q:Xy,s:Zy,S:TA,u:wA,U:SA,V:EA,w:CA,W:IA,x:null,X:null,y:AA,Y:MA,Z:LA,"%":Uy},v={a:q,A:dt,b:nt,B:Et,c:null,d:Oy,e:Oy,f:DA,g:HA,G:zA,H:GA,I:NA,j:FA,L:Wy,m:kA,M:OA,p:Rt,q:wt,Q:Xy,s:Zy,S:WA,u:BA,U:UA,V:XA,w:ZA,W:VA,x:null,X:null,y:KA,Y:YA,Z:jA,"%":Uy},S={a:B,A:G,b:N,B:C,c:F,d:Gy,e:Gy,f:dA,g:Ly,G:Py,H:Ny,I:Ny,j:hA,L:cA,m:aA,M:lA,p:P,q:oA,Q:fA,s:mA,S:uA,u:eA,U:iA,V:rA,w:tA,W:sA,x:X,X:V,y:Ly,Y:Py,Z:nA,"%":pA};b.x=E(e,b),b.X=E(i,b),b.c=E(t,b),v.x=E(e,v),v.X=E(i,v),v.c=E(t,v);function E(Y,it){return function(tt){var O=[],bt=-1,mt=0,Mt=Y.length,Ut,Ne,ci;for(tt instanceof Date||(tt=new Date(+tt));++bt<Mt;)Y.charCodeAt(bt)===37&&(O.push(Y.slice(mt,bt)),(Ne=My[Ut=Y.charAt(++bt)])!=null?Ut=Y.charAt(++bt):Ne=Ut==="e"?" ":"0",(ci=it[Ut])&&(Ut=ci(tt,Ne)),O.push(Ut),mt=bt+1);return O.push(Y.slice(mt,bt)),O.join("")}}function A(Y,it){return function(tt){var O=vo(1900,void 0,1),bt=I(O,Y,tt+="",0),mt,Mt;if(bt!=tt.length)return null;if("Q"in O)return new Date(O.Q);if("s"in O)return new Date(O.s*1e3+("L"in O?O.L:0));if(it&&!("Z"in O)&&(O.Z=0),"p"in O&&(O.H=O.H%12+O.p*12),O.m===void 0&&(O.m="q"in O?O.q:0),"V"in O){if(O.V<1||O.V>53)return null;"w"in O||(O.w=1),"Z"in O?(mt=ud(vo(O.y,0,1)),Mt=mt.getUTCDay(),mt=Mt>4||Mt===0?Rh.ceil(mt):Rh(mt),mt=ad.offset(mt,(O.V-1)*7),O.y=mt.getUTCFullYear(),O.m=mt.getUTCMonth(),O.d=mt.getUTCDate()+(O.w+6)%7):(mt=ld(vo(O.y,0,1)),Mt=mt.getDay(),mt=Mt>4||Mt===0?Ah.ceil(mt):Ah(mt),mt=_o.offset(mt,(O.V-1)*7),O.y=mt.getFullYear(),O.m=mt.getMonth(),O.d=mt.getDate()+(O.w+6)%7)}else("W"in O||"U"in O)&&("w"in O||(O.w="u"in O?O.u%7:"W"in O?1:0),Mt="Z"in O?ud(vo(O.y,0,1)).getUTCDay():ld(vo(O.y,0,1)).getDay(),O.m=0,O.d="W"in O?(O.w+6)%7+O.W*7-(Mt+5)%7:O.w+O.U*7-(Mt+6)%7);return"Z"in O?(O.H+=O.Z/100|0,O.M+=O.Z%100,ud(O)):ld(O)}}function I(Y,it,tt,O){for(var bt=0,mt=it.length,Mt=tt.length,Ut,Ne;bt<mt;){if(O>=Mt)return-1;if(Ut=it.charCodeAt(bt++),Ut===37){if(Ut=it.charAt(bt++),Ne=S[Ut in My?it.charAt(bt++):Ut],!Ne||(O=Ne(Y,tt,O))<0)return-1}else if(Ut!=tt.charCodeAt(O++))return-1}return O}function P(Y,it,tt){var O=l.exec(it.slice(tt));return O?(Y.p=u.get(O[0].toLowerCase()),tt+O[0].length):-1}function B(Y,it,tt){var O=p.exec(it.slice(tt));return O?(Y.w=m.get(O[0].toLowerCase()),tt+O[0].length):-1}function G(Y,it,tt){var O=c.exec(it.slice(tt));return O?(Y.w=d.get(O[0].toLowerCase()),tt+O[0].length):-1}function N(Y,it,tt){var O=y.exec(it.slice(tt));return O?(Y.m=_.get(O[0].toLowerCase()),tt+O[0].length):-1}function C(Y,it,tt){var O=f.exec(it.slice(tt));return O?(Y.m=g.get(O[0].toLowerCase()),tt+O[0].length):-1}function F(Y,it,tt){return I(Y,t,it,tt)}function X(Y,it,tt){return I(Y,e,it,tt)}function V(Y,it,tt){return I(Y,i,it,tt)}function L(Y){return o[Y.getDay()]}function k(Y){return n[Y.getDay()]}function K(Y){return h[Y.getMonth()]}function D(Y){return a[Y.getMonth()]}function U(Y){return s[+(Y.getHours()>=12)]}function j(Y){return 1+~~(Y.getMonth()/3)}function q(Y){return o[Y.getUTCDay()]}function dt(Y){return n[Y.getUTCDay()]}function nt(Y){return h[Y.getUTCMonth()]}function Et(Y){return a[Y.getUTCMonth()]}function Rt(Y){return s[+(Y.getUTCHours()>=12)]}function wt(Y){return 1+~~(Y.getUTCMonth()/3)}return{format:function(Y){var it=E(Y+="",b);return it.toString=function(){return Y},it},parse:function(Y){var it=A(Y+="",!1);return it.toString=function(){return Y},it},utcFormat:function(Y){var it=E(Y+="",v);return it.toString=function(){return Y},it},utcParse:function(Y){var it=A(Y+="",!0);return it.toString=function(){return Y},it}}}var My={"-":"",_:" ",0:"0"},se=/^\s*\d+/,$I=/^%/,QI=/[\\^$*+?|[\]().{}]/g;function It(r,t,e){var i=r<0?"-":"",s=(i?-r:r)+"",n=s.length;return i+(n<e?new Array(e-n+1).join(t)+s:s)}function qI(r){return r.replace(QI,"\\$&")}function To(r){return new RegExp("^(?:"+r.map(qI).join("|")+")","i")}function wo(r){return new Map(r.map((t,e)=>[t.toLowerCase(),e]))}function tA(r,t,e){var i=se.exec(t.slice(e,e+1));return i?(r.w=+i[0],e+i[0].length):-1}function eA(r,t,e){var i=se.exec(t.slice(e,e+1));return i?(r.u=+i[0],e+i[0].length):-1}function iA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.U=+i[0],e+i[0].length):-1}function rA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.V=+i[0],e+i[0].length):-1}function sA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.W=+i[0],e+i[0].length):-1}function Py(r,t,e){var i=se.exec(t.slice(e,e+4));return i?(r.y=+i[0],e+i[0].length):-1}function Ly(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.y=+i[0]+(+i[0]>68?1900:2e3),e+i[0].length):-1}function nA(r,t,e){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(e,e+6));return i?(r.Z=i[1]?0:-(i[2]+(i[3]||"00")),e+i[0].length):-1}function oA(r,t,e){var i=se.exec(t.slice(e,e+1));return i?(r.q=i[0]*3-3,e+i[0].length):-1}function aA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.m=i[0]-1,e+i[0].length):-1}function Gy(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.d=+i[0],e+i[0].length):-1}function hA(r,t,e){var i=se.exec(t.slice(e,e+3));return i?(r.m=0,r.d=+i[0],e+i[0].length):-1}function Ny(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.H=+i[0],e+i[0].length):-1}function lA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.M=+i[0],e+i[0].length):-1}function uA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.S=+i[0],e+i[0].length):-1}function cA(r,t,e){var i=se.exec(t.slice(e,e+3));return i?(r.L=+i[0],e+i[0].length):-1}function dA(r,t,e){var i=se.exec(t.slice(e,e+6));return i?(r.L=Math.floor(i[0]/1e3),e+i[0].length):-1}function pA(r,t,e){var i=$I.exec(t.slice(e,e+1));return i?e+i[0].length:-1}function fA(r,t,e){var i=se.exec(t.slice(e));return i?(r.Q=+i[0],e+i[0].length):-1}function mA(r,t,e){var i=se.exec(t.slice(e));return i?(r.s=+i[0],e+i[0].length):-1}function Fy(r,t){return It(r.getDate(),t,2)}function gA(r,t){return It(r.getHours(),t,2)}function yA(r,t){return It(r.getHours()%12||12,t,2)}function bA(r,t){return It(1+_o.count(lr(r),r),t,3)}function Dy(r,t){return It(r.getMilliseconds(),t,3)}function xA(r,t){return Dy(r,t)+"000"}function _A(r,t){return It(r.getMonth()+1,t,2)}function vA(r,t){return It(r.getMinutes(),t,2)}function TA(r,t){return It(r.getSeconds(),t,2)}function wA(r){var t=r.getDay();return t===0?7:t}function SA(r,t){return It(Ih.count(lr(r)-1,r),t,2)}function ky(r){var t=r.getDay();return t>=4||t===0?dn(r):dn.ceil(r)}function EA(r,t){return r=ky(r),It(dn.count(lr(r),r)+(lr(r).getDay()===4),t,2)}function CA(r){return r.getDay()}function IA(r,t){return It(Ah.count(lr(r)-1,r),t,2)}function AA(r,t){return It(r.getFullYear()%100,t,2)}function RA(r,t){return r=ky(r),It(r.getFullYear()%100,t,2)}function MA(r,t){return It(r.getFullYear()%1e4,t,4)}function PA(r,t){var e=r.getDay();return r=e>=4||e===0?dn(r):dn.ceil(r),It(r.getFullYear()%1e4,t,4)}function LA(r){var t=r.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+It(t/60|0,"0",2)+It(t%60,"0",2)}function Oy(r,t){return It(r.getUTCDate(),t,2)}function GA(r,t){return It(r.getUTCHours(),t,2)}function NA(r,t){return It(r.getUTCHours()%12||12,t,2)}function FA(r,t){return It(1+ad.count(vs(r),r),t,3)}function Wy(r,t){return It(r.getUTCMilliseconds(),t,3)}function DA(r,t){return Wy(r,t)+"000"}function kA(r,t){return It(r.getUTCMonth()+1,t,2)}function OA(r,t){return It(r.getUTCMinutes(),t,2)}function WA(r,t){return It(r.getUTCSeconds(),t,2)}function BA(r){var t=r.getUTCDay();return t===0?7:t}function UA(r,t){return It(Ry.count(vs(r)-1,r),t,2)}function By(r){var t=r.getUTCDay();return t>=4||t===0?pn(r):pn.ceil(r)}function XA(r,t){return r=By(r),It(pn.count(vs(r),r)+(vs(r).getUTCDay()===4),t,2)}function ZA(r){return r.getUTCDay()}function VA(r,t){return It(Rh.count(vs(r)-1,r),t,2)}function KA(r,t){return It(r.getUTCFullYear()%100,t,2)}function HA(r,t){return r=By(r),It(r.getUTCFullYear()%100,t,2)}function YA(r,t){return It(r.getUTCFullYear()%1e4,t,4)}function zA(r,t){var e=r.getUTCDay();return r=e>=4||e===0?pn(r):pn.ceil(r),It(r.getUTCFullYear()%1e4,t,4)}function jA(){return"+0000"}function Uy(){return"%"}function Xy(r){return+r}function Zy(r){return Math.floor(+r/1e3)}var fn,Vy;JA({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function JA(r){return fn=JI(r),Vy=fn.format,fn.parse,fn.utcFormat,fn.utcParse,fn}function $A(r){return new Date(r)}function QA(r){return r instanceof Date?+r:+new Date(+r)}function Ky(r,t,e,i,s,n,o,a,h,l){var u=Cy(),c=u.invert,d=u.domain,p=l(".%L"),m=l(":%S"),f=l("%I:%M"),g=l("%I %p"),y=l("%a %d"),_=l("%b %d"),b=l("%B"),v=l("%Y");function S(E){return(h(E)<E?p:a(E)<E?m:o(E)<E?f:n(E)<E?g:i(E)<E?s(E)<E?y:_:e(E)<E?b:v)(E)}return u.invert=function(E){return new Date(c(E))},u.domain=function(E){return arguments.length?d(Array.from(E,QA)):d().map($A)},u.ticks=function(E){var A=d();return r(A[0],A[A.length-1],E??10)},u.tickFormat=function(E,A){return A==null?S:l(A)},u.nice=function(E){var A=d();return(!E||typeof E.range!="function")&&(E=t(A[0],A[A.length-1],E??10)),E?d(OI(A,E)):u},u.copy=function(){return Ey(u,Ky(r,t,e,i,s,n,o,a,h,l))},u}function qA(){return wy.apply(Ky(zI,jI,lr,hd,Ih,_o,od,nd,cn,Vy).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function So(r,t,e){this.k=r,this.x=t,this.y=e}So.prototype={constructor:So,scale:function(r){return r===1?this:new So(this.k*r,this.x,this.y)},translate:function(r,t){return r===0&t===0?this:new So(this.k,this.x+this.k*r,this.y+this.k*t)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},So.prototype;function Hy(r){return r.mode==="temporal"||r.mode==="left-aligned"?tR(r):eR(r)}function tR({domain:r,range:t}){return qA().domain(r).range(t)}function eR({domain:r,range:t}){return Iy().domain(r).range(t)}function cd(r){return{mode:yt.horizontal,range:lM(),domain:uM(r)}}function iR(){return{mode:yt.vertical}}let mn=null;async function rR(){const r=await Sd();Yy(r.start_time),xt.on("layoutSettingsUpdated",()=>Yy(r.start_time))}function sR(){mn=null}async function Eo(){return mn||await Oe("scaleCreated")}async function Yy(r){await Di();const t=mn?"scaleUpdated":"scaleCreated",e=cd(r);mn=Hy(e),xt.emit(t,mn)}let Ge=null,dd=null;async function nR(){const r=await li(),t=await Xc();Ge=new WC({screenHeight:t.clientHeight,screenWidth:t.clientWidth,events:r.renderer.events,passiveWheel:!1}),Ge.zIndex=1,Ge.drag().pinch().wheel({trackpadPinch:!0}).decelerate({friction:.9}).clampZoom({minWidth:t.clientWidth/2}),r.stage.addChild(Ge),xt.emit("viewportCreated",Ge),xt.on("applicationResized",uR),xt.on("scaleUpdated",()=>Mh()),hR()}function oR(){Ge=null,dd=null}async function pd({animate:r}={}){const t=await Je(),e=await ge(),i=t.getChildByName(yp);if(!i)throw new Error("Nodes container not found");const s=e.styles.guideTextSize+e.styles.guideTextTopPadding;pR();const{x:n,y:o,width:a,height:h}=i.getLocalBounds(),l=a+e.styles.columnGap*2,u=h+e.styles.rowGap*2+s*2,c=t.findFit(l,u);!a||!h||t.animate({position:{x:n+a/2,y:o+h/2-s},scale:Math.min(c,1),time:r?e.animationDuration:0,ease:"easeInOutQuad",removeOnInterrupt:!0,callbackOnComplete:()=>{fd(),Mh()}})}async function Je(){return Ge||await Oe("viewportCreated")}function zy(r){ty(dd,r)||(dd=r,xt.emit("viewportDateRangeUpdated",r))}function aR({xOffset:r,yOffset:t}){if(!Ge)return;const{x:e,y:i}=Ge.transform.position;Ge.setTransform(e+r,i+t,Ge.transform.scale.x,Ge.transform.scale.y)}async function hR(){const r=await Je();Mh(),r.on("moved",()=>Mh())}async function Mh(){const r=await jy();r&&zy(r)}async function jy(){const r=await Je(),t=await Eo(),e=t.invert(r.left),i=t.invert(r.right);return e instanceof Date&&i instanceof Date?[e,i]:null}async function lR(r){const t=await jy(),e=await Di();if(r===void 0||e.isDependency()||ty(r,t))return;const i=await Je(),s=await Eo(),[n,o]=r,a=s(n),h=s(o),l=a+(h-a)/2;zy(r),i.fitWidth(h-a,!0),i.moveCenter(l,i.center.y)}async function uR(){const r=await li(),t=await Je(),e=await Xc(),i=t.screenWidth,s=t.screenHeight,n=e.clientWidth,o=e.clientHeight,a=(n-i)/2,h=(o-s)/2;t.resize(r.screen.width,r.screen.height),aR({xOffset:a,yOffset:h})}class Jy{constructor(){lp(this,"status","visible");lp(this,"labels",new Set)}get visible(){return this.status==="visible"}get hidden(){return this.status==="hidden"}show(){if(this.status!=="visible"){for(const t of this.labels)t.visible=!0;this.status="visible"}}hide(){if(this.status!=="hidden"){for(const t of this.labels)t.visible=!1;this.status="hidden"}}toggle(t){t?this.show():this.hide()}add(t){this.labels.add(t),t.visible=this.visible}clear(){this.labels.clear()}}let Gi=null,Ni=null,Fi=null;async function cR(){const r=await Je(),t=await li();Gi=new eC({toggle:"renderable"}),Ni=new Jy,Fi=new Jy,t.ticker.add(()=>{if(r.dirty){const e=r.scale.x>.1,i=r.scale.x>.2;Fi==null||Fi.toggle(e),Ni==null||Ni.toggle(i),Gi==null||Gi.cull(t.renderer.screen),r.dirty=!1}}),xt.emit("cullCreated",Gi)}function dR(){Gi=null,Ni==null||Ni.clear(),Ni=null,Fi==null||Fi.clear(),Fi=null}async function fd(){const r=await Je();r.dirty=!0}function pR(){Gi&&Gi.uncull()}async function $y(){return Gi||await Oe("cullCreated")}async function fR(){return Fi||await Oe("edgeCullCreated")}async function mR(){return Ni||await Oe("labelCullCreated")}async function Qy(){const r=await Di(),t=await ge();function e(i,s,n){const a=r.disableAnimations||n?0:t.animationDuration/1e3;return Q0.to(i,{...s,duration:a,ease:"power1.out",onUpdate:()=>{fd()}})}return{animate:e}}let md=[];function gR(){md.forEach(r=>r.unsubscribe()),md=[]}async function gd(r,t){const e=Zi.useSubscription(r,t);return md.push(e),await e.promise(),e.response}async function yR({size:r,stroke:t=1,radius:e=0}){const i=await li(),s=new qn;return s.lineStyle(t,"#fff",1,0),s.drawRoundedRect(0,0,r*2,r*2,e),i.renderer.generateTexture(s,{region:new ct(0,0,r,r),resolution:10})}async function qy(r){return await gd(yR,[r])}var Ph=(r=>(r[r.Up=0]="Up",r[r.Down=180]="Down",r[r.Left=270]="Left",r[r.Right=90]="Right",r))(Ph||{});function tb(){const r=new ie;async function t(e){const{rotate:i=0}=e,s={size:e.size,radius:e.radius,stroke:e.stroke},n=await qy(s);return r.texture=n,r.anchor.set(.5,.5),r.angle=45+i,r}return{element:r,render:t}}async function bR(){const r=await li(),t=new qn;return t.beginFill("#fff"),t.drawRect(0,0,1,1),t.endFill(),r.renderer.generateTexture(t)}async function yd(){return await gd(bR,[])}function bd(r,t){return Array.from({length:r},(e,i)=>t(i))}const xR=8,_R=2;async function vR(){const r=await ge(),t=await $y(),e=await fR(),{animate:i}=await Qy(),s=new Xt,{element:n,render:o}=await tb(),a=await yd(),h=bd(20,()=>new lt),l=new uS(a,h);let u=!1;s.name=Ib,s.addChild(n),s.addChild(l),t.addAll([n,l]),e.add(s);async function c(){return await o({size:10,rotate:Ph.Right}),n.tint=r.styles.edgeColor,l.tint=r.styles.edgeColor,s}async function d(m,f){const g=p(f);u||await c();for(const[y,_]of h.entries()){const{x:b,y:v}=g[y];i(_,{x:b,y:v},!u)}i(s,{x:m.x,y:m.y},!u),i(n,{x:f.x-xR,y:f.y},!u),u=!0}function p({x:m,y:f}){const g=[],y={x:0,y:0},_={x:m-_R,y:f},b={x:eb(y.x,{source:y,target:_}),y:y.y},v={x:eb(_.x,{source:y,target:_},!0),y:_.y};for(const[S]of h.entries()){if(S===h.length-1){g[S]=_;continue}const E=TR(S,{source:y,target:_,sourceBezier:b,targetBezier:v});g[S]=E}return g}return{element:s,render:c,setPosition:d}}function eb(r,{source:t,target:e},i){const s=(e.x-t.x)/2;return r+(s>64?s:64)*(i?-1:1)}function TR(r,t){const e=r/20,{source:i,target:s,sourceBezier:n,targetBezier:o}=t,a=i.x+(n.x-i.x)*e,h=i.y+(n.y-i.y)*e,l=n.x+(o.x-n.x)*e,u=n.y+(o.y-n.y)*e,c=o.x+(s.x-o.x)*e,d=o.y+(s.y-o.y)*e,p=a+(l-a)*e,m=h+(u-h)*e,f=l+(c-l)*e,g=u+(d-u)*e,y=p+(f-p)*e,_=m+(g-m)*e;return{x:y,y:_}}function xd(){const r=new Xt,t=new ie,e=new ie,i=new ie,s=new ie,n=new ie,o=new ie,a=new ie,h=new ie;t.name="border-corner-top-left",e.name="border-corner-top-right",i.name="border-corner-bottom-left",s.name="border-corner-bottom-right",n.name="border-corner-left",o.name="border-corner-right",a.name="border-corner-top",h.name="border-corner-bottom",e.anchor.x=1,e.scale.x=-1,i.anchor.y=1,i.scale.y=-1,s.anchor.x=1,s.scale.x=-1,s.anchor.y=1,s.scale.y=-1,r.addChild(t),r.addChild(e),r.addChild(i),r.addChild(s),r.addChild(n),r.addChild(o),r.addChild(a),r.addChild(h);async function l(p){const{radius:m=0,color:f="#fff",stroke:g,width:y,height:_}=p,b=Math.min(y,_),v=m*2>b?b/2:m,E=await qy({size:v,radius:m,stroke:g}),A=await yd();return u({texture:E,width:y,height:_,size:v}),c({texture:A,width:y,height:_,size:v,stroke:g}),d(f),r}function u({texture:p,width:m,height:f,size:g}){t.texture=p,e.texture=p,i.texture=p,s.texture=p,t.position.set(0,0),e.position.set(m-g,0),i.position.set(0,f-g),s.position.set(m-g,f-g)}function c({texture:p,size:m,width:f,height:g,stroke:y}){const _=Math.max(g-m*2,0),b=Math.max(f-m*2,0);a.texture=p,n.texture=p,o.texture=p,h.texture=p,n.position.set(0,m),n.height=_,n.width=y,o.position.set(f-y,m),o.height=_,o.width=y,a.position.set(m,0),a.width=b,a.height=y,h.position.set(m,g-y),h.width=b,h.height=y}function d(p){t.tint=p,e.tint=p,i.tint=p,s.tint=p,a.tint=p,n.tint=p,o.tint=p,h.tint=p}return{element:r,render:l}}var ib={exports:{}};(function(r){(function(){function t(f,g){document.addEventListener?f.addEventListener("scroll",g,!1):f.attachEvent("scroll",g)}function e(f){document.body?f():document.addEventListener?document.addEventListener("DOMContentLoaded",function g(){document.removeEventListener("DOMContentLoaded",g),f()}):document.attachEvent("onreadystatechange",function g(){(document.readyState=="interactive"||document.readyState=="complete")&&(document.detachEvent("onreadystatechange",g),f())})}function i(f){this.g=document.createElement("div"),this.g.setAttribute("aria-hidden","true"),this.g.appendChild(document.createTextNode(f)),this.h=document.createElement("span"),this.i=document.createElement("span"),this.m=document.createElement("span"),this.j=document.createElement("span"),this.l=-1,this.h.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.i.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.j.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.m.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.h.appendChild(this.m),this.i.appendChild(this.j),this.g.appendChild(this.h),this.g.appendChild(this.i)}function s(f,g){f.g.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:"+g+";"}function n(f){var g=f.g.offsetWidth,y=g+100;return f.j.style.width=y+"px",f.i.scrollLeft=y,f.h.scrollLeft=f.h.scrollWidth+100,f.l!==g?(f.l=g,!0):!1}function o(f,g){function y(){var b=_;n(b)&&b.g.parentNode!==null&&g(b.l)}var _=f;t(f.h,y),t(f.i,y),n(f)}function a(f,g,y){g=g||{},y=y||window,this.family=f,this.style=g.style||"normal",this.weight=g.weight||"normal",this.stretch=g.stretch||"normal",this.context=y}var h=null,l=null,u=null,c=null;function d(f){return l===null&&(p(f)&&/Apple/.test(window.navigator.vendor)?(f=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent),l=!!f&&603>parseInt(f[1],10)):l=!1),l}function p(f){return c===null&&(c=!!f.document.fonts),c}function m(f,g){var y=f.style,_=f.weight;if(u===null){var b=document.createElement("div");try{b.style.font="condensed 100px sans-serif"}catch{}u=b.style.font!==""}return[y,_,u?f.stretch:"","100px",g].join(" ")}a.prototype.load=function(f,g){var y=this,_=f||"BESbswy",b=0,v=g||3e3,S=new Date().getTime();return new Promise(function(E,A){if(p(y.context)&&!d(y.context)){var I=new Promise(function(B,G){function N(){new Date().getTime()-S>=v?G(Error(""+v+"ms timeout exceeded")):y.context.document.fonts.load(m(y,'"'+y.family+'"'),_).then(function(C){1<=C.length?B():setTimeout(N,25)},G)}N()}),P=new Promise(function(B,G){b=setTimeout(function(){G(Error(""+v+"ms timeout exceeded"))},v)});Promise.race([P,I]).then(function(){clearTimeout(b),E(y)},A)}else e(function(){function B(){var j;(j=X!=-1&&V!=-1||X!=-1&&L!=-1||V!=-1&&L!=-1)&&((j=X!=V&&X!=L&&V!=L)||(h===null&&(j=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),h=!!j&&(536>parseInt(j[1],10)||parseInt(j[1],10)===536&&11>=parseInt(j[2],10))),j=h&&(X==k&&V==k&&L==k||X==K&&V==K&&L==K||X==D&&V==D&&L==D)),j=!j),j&&(U.parentNode!==null&&U.parentNode.removeChild(U),clearTimeout(b),E(y))}function G(){if(new Date().getTime()-S>=v)U.parentNode!==null&&U.parentNode.removeChild(U),A(Error(""+v+"ms timeout exceeded"));else{var j=y.context.document.hidden;(j===!0||j===void 0)&&(X=N.g.offsetWidth,V=C.g.offsetWidth,L=F.g.offsetWidth,B()),b=setTimeout(G,50)}}var N=new i(_),C=new i(_),F=new i(_),X=-1,V=-1,L=-1,k=-1,K=-1,D=-1,U=document.createElement("div");U.dir="ltr",s(N,m(y,"sans-serif")),s(C,m(y,"serif")),s(F,m(y,"monospace")),U.appendChild(N.g),U.appendChild(C.g),U.appendChild(F.g),y.context.document.body.appendChild(U),k=N.g.offsetWidth,K=C.g.offsetWidth,D=F.g.offsetWidth,G(),o(N,function(j){X=j,B()}),s(N,m(y,'"'+y.family+'",sans-serif')),o(C,function(j){V=j,B()}),s(C,m(y,'"'+y.family+'",serif')),o(F,function(j){L=j,B()}),s(F,m(y,'"'+y.family+'",monospace'))})})},r.exports=a})()})(ib);var wR=ib.exports;const SR=Gn(wR),rb={inter:{fontFamily:"InterVariable",fontSize:16,lineHeight:20,fill:16777215}},sb={resolution:4,chars:ai.ASCII},nb="sans-serif",ob={inter:AR(rb.inter)};let _d=!1;async function ER(){const r=Object.values(rb);await Promise.all(r.map(t=>CR(t))),_d=!0,xt.emit("fontsLoaded",ob)}async function CR(r){const{fontFamily:t,...e}=r,i=new SR(t);try{await i.load()}catch(s){console.error(s),console.warn(`fonts: font ${t} failed to load, falling back to ${nb}`),ai.from(t,{fontFamily:nb,...e},sb);return}ai.from(t,r,sb)}function IR(){_d=!1}async function ab(){return _d?ob:await Oe("fontsLoaded")}function AR(r){const{fontFamily:t,...e}=r,i={fontName:t,...e};return s=>new OS(s,i)}async function hb(){const{inter:r}=await ab(),t=await mR(),e=r("");t.add(e);async function i(s){return e.text=s,await e}return{element:e,render:i}}async function RR({height:r,radius:t}){const e=await li(),i=new qn;return i.beginFill("#fff"),i.drawRoundedRect(0,0,t*2,r,t),i.endFill(),e.renderer.generateTexture(i,{region:new ct(0,0,t,r),resolution:10})}async function MR(r){return await gd(RR,[r])}function PR(){const r=new ie,t=new ie;async function e(i){const s=await MR(i);return r.texture=s,t.texture=s,t.anchor.x=1,t.scale.x=-1,{left:r,right:t}}return{left:r,right:t,render:e}}async function vd(){const r=await yd();return new ie(r)}async function lb(){const r=new Xt,t=await vd(),{left:e,right:i,render:s}=await PR();r.addChild(t),r.addChild(e),r.addChild(i);async function n(h){const{width:l,x:u,visible:c}=a(h);return await s({height:h.height,radius:h.radius}),t.visible=c,t.width=l,t.height=h.height,t.x=u,e.visible=o(h.capLeft,h.radius),i.visible=o(h.capRight,h.radius),i.x=h.radius+l,t.tint=h.background,e.tint=h.background,i.tint=h.background,r}function o(h,l){return l===0?!1:h??!0}function a(h){const l=o(h.capLeft,h.radius),u=o(h.capRight,h.radius);let c=0;l&&(c+=h.radius),u&&(c+=h.radius);const d=Math.max(h.width-c,0),p=d>0,m=l?h.radius:0;return{width:d,visible:p,x:m}}return{element:r,render:n}}async function LR(){const r=await ge(),t=new Xt,{element:e,render:i}=await tb(),{element:s,render:n}=await lb(),{element:o,render:a}=await xd(),h=new Pa;t.eventMode="static",t.cursor="pointer",t.addChild(s),t.addChild(e),t.addChild(o),t.on("mouseover",u),t.on("mouseout",c),s.filters=[h],o.visible=!1;async function l({inside:d,isOpen:p,background:m}){const f={size:10,stroke:2,rotate:p?Ph.Up:Ph.Down},g=await i(f),y={width:r.styles.nodeToggleSize,height:r.styles.nodeToggleSize,background:d?m:"#333",radius:r.styles.nodeToggleBorderRadius},_=await n(y),b=await a({width:y.width,height:y.height,radius:y.radius,stroke:1,color:r.styles.nodeToggleBorderColor});b.alpha=d?0:1;const v={y:_.height/2,x:_.width/2},S=f.size/4;return g.x=v.x,g.y=p?v.y+S:v.y-S,t}function u(){h.brightness(.5,!1),o.visible=!0}function c(){h.brightness(1,!1),o.visible=!1}return{element:t,render:l}}let gn=null,Lh=!1;async function GR(){const r=await Je();r.on("click",()=>Td(null)),r.on("drag-start",()=>{Lh=!0}),r.on("drag-end",()=>{setTimeout(()=>{Lh=!1})})}function NR(){gn=null,Lh=!1}function Td(r){if(Lh||wd(r))return;if(gn=r,r===null){xt.emit("nodeSelected",null);return}const{id:t,kind:e}=r;xt.emit("nodeSelected",{id:t,kind:e})}function wd(r){return(r==null?void 0:r.id)===(gn==null?void 0:gn.id)}function FR(){return gn}const Gh=4,DR=2;async function ub(){const r=await ge(),t=await Di(),e=new Xt,{element:i,render:s}=await lb(),{element:n,render:o}=await xd();e.addChild(i),n.position.set(-Gh,-Gh);async function a(u){const{background:c="#fff"}=r.styles.node(u),{nodeHeight:d,nodeRadius:p}=r.styles,m=l(u,p),f=u.state_type!=="RUNNING"||t.isDependency();return await s({width:m,height:d,radius:p,background:c,capRight:f}),await h(u,m,d),i}async function h(u,c,d){if(!wd(u)){e.removeChild(n);return}e.addChild(n),await o({stroke:DR,radius:r.styles.nodeBorderRadius,width:c+Gh*2,height:d+Gh*2,color:r.styles.nodeSelectedBorderColor})}function l(u,c){const d=Ed();if(yt.isTemporal()||yt.isLeftAligned()){const p=u.start_time,m=u.end_time??new Date,g=_p(m,p)/Mb*d;return Math.max(g,c*2)}return d}return{element:e,render:a}}class cb extends Xt{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)this.children[t].updateTransform()}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(const t of this.children)if(t.calculateBounds(),t._mask){const e=t._mask.isMaskData?t._mask.maskObject:t._mask;e?(e.calculateBounds(),this._bounds.addBoundsMask(t._bounds,e._bounds)):this._bounds.addBounds(t._bounds)}else t.filterArea?this._bounds.addBoundsArea(t._bounds,t.filterArea):this._bounds.addBounds(t._bounds);this._bounds.updateID=this._boundsID}}async function kR(r){const t=new cb,e=await ge(),{element:i,render:s}=await ub(),{element:n,render:o}=await hb(),{element:a,render:h,getSize:l}=await bb(),{element:u,render:c}=await LR(),{element:d,render:p}=await xd(),{start:m,stop:f}=await Dg(r.id,G=>{h(G)});let g=r,y=!1;t.addChild(d),t.addChild(i),t.addChild(n),t.addChild(u),u.on("click",G=>{G.stopPropagation(),b()}),a.position={x:0,y:e.styles.nodeHeight+e.styles.nodesPadding},a.on("rendered",()=>{fd(),P()});async function _(G){return g=G,await s(G),await A(G),await I(G),await v(G),t}async function b(){y?await E():await S()}async function v(G){const{background:N="#fff"}=e.styles.node(G),C=4,{width:F,height:X}=l(),V=X+e.styles.nodeHeight+e.styles.nodesPadding*2+C*2,L=e.styles.nodeHeight,k=y?-C:C,K=Math.max(i.width,F),D=y?K+C*2:i.width-C*2;(await p({width:D,height:y?V:L,stroke:y?2:1,radius:e.styles.nodeBorderRadius,color:N})).position.set(k,k)}async function S(){y=!0,t.addChild(a),await Promise.all([m(),_(g)]),P()}async function E(){y=!1,t.removeChild(a),await Promise.all([f(),_(g)]),P()}async function A(G){const N=e.styles.nodeToggleSize,C=e.styles.nodeHeight-N,F=i.width>N,{background:X="#fff"}=e.styles.node(G),V=await c({background:X,inside:F,isOpen:y});return V.x=F?C/2:i.width+e.styles.nodePadding,V.y=C/2,V}async function I(G){const N=await o(G.label),C=e.styles.colorMode==="dark"?e.styles.textDefault:e.styles.textInverse,F=e.styles.nodePadding,X=u.x+u.width+F,V=i.width+F,L=i.width>X+N.width+F,k=e.styles.nodeHeight/2-N.height/2,K=L?X:Math.max(V,X);return N.position={x:K,y:k},N.tint=L?C:e.styles.textDefault,N}function P(){v(g);const G=B();t.emit("resized",G)}function B(){const G=l(),N=y?G.height+e.styles.nodesPadding*2:0,C=y?G.width:0;return{height:e.styles.nodeHeight+N,width:Math.max(C,t.width)}}return{kind:"flow-run",element:t,bar:i,render:_}}async function OR(){const r=await ge(),t=new cb,{element:e,render:i}=await hb(),{element:s,render:n}=await ub();t.addChild(s),t.addChild(e);async function o(h){return await Promise.all([n(h),i(h.label)]),a(),t}function a(){const h=r.styles.colorMode==="dark"?r.styles.textDefault:r.styles.textInverse,l=r.styles.nodePadding,u=s.width>l+e.width+l,c=u?l:s.width+l,d=r.styles.nodeHeight/2-e.height/2;e.position={x:c,y:d},e.tint=u?h:r.styles.textDefault}return{kind:"task-run",element:t,render:o,bar:s}}async function WR(){const r=await li(),t=await Je(),e=await Di(),i=await ge(),{inter:s}=await ab(),n=new Xt,o=await vd();n.addChild(o);const a=s("");n.addChild(a);let h=await Eo(),l,u;xt.on("scaleUpdated",f=>h=f),r.ticker.add(()=>{e.disableGuides||(m(),n.height!==r.screen.height&&d())});function c(f,g){l=f,u=g,d(),p(f)}function d(){o.width=i.styles.guideLineWidth,o.height=r.screen.height,o.tint=i.styles.guideLineColor}function p(f){a.text=u(f),a.fontSize=i.styles.guideTextSize,a.tint=i.styles.guideTextColor,a.position.set(i.styles.guideTextLeftPadding,i.styles.guideTextTopPadding)}function m(){l!==void 0&&(n.position.x=h(l)*t.scale._x+t.worldTransform.tx)}return{element:n,render:c}}class db extends Error{constructor(){super("Layout is not temporal")}}function BR(r){return r.toLocaleTimeString()}function pb(r){const t=navigator.language;return new Intl.DateTimeFormat(t,{timeStyle:"short"}).format(r)}function UR(r){const t=navigator.language;return new Intl.DateTimeFormat(t,{dateStyle:"short"}).format(r)}function XR(r){return r.getHours()===0&&r.getMinutes()===0?`${Nh.date(r)}
1176
- ${pb(r)}`:pb(r)}const Nh={timeBySeconds:BR,timeByMinutesWithDates:XR,date:UR},Qt={seconds:"seconds",minutes:"minutes",date:"date"},Co={day:r=>{const t=new Date(r.getTime());return t.setHours(0,0,0,0),t.getTime()},week:r=>{const t=new Date(r.getTime());return t.setHours(0,0,0,0),t.setDate(r.getDate()-r.getDay()+1),t.getTime()}},Ct={second:1e3,minute:1e3*60,hour:1e3*60*60,day:1e3*60*60*24,week:1e3*60*60*24*7},fb=[{ceiling:Ct.second*4,increment:Ct.second,labelFormat:Qt.seconds},{ceiling:Ct.second*8,increment:Ct.second*5,labelFormat:Qt.seconds},{ceiling:Ct.second*13,increment:Ct.second*10,labelFormat:Qt.seconds},{ceiling:Ct.second*20,increment:Ct.second*15,labelFormat:Qt.seconds},{ceiling:Ct.second*45,increment:Ct.second*30,labelFormat:Qt.seconds},{ceiling:Ct.minute*4,increment:Ct.minute,labelFormat:Qt.minutes},{ceiling:Ct.minute*8,increment:Ct.minute*5,labelFormat:Qt.minutes},{ceiling:Ct.minute*13,increment:Ct.minute*10,labelFormat:Qt.minutes},{ceiling:Ct.minute*28,increment:Ct.minute*15,labelFormat:Qt.minutes},{ceiling:Ct.hour*1.24,increment:Ct.minute*30,labelFormat:Qt.minutes},{ceiling:Ct.hour*3,increment:Ct.hour,labelFormat:Qt.minutes},{ceiling:Ct.hour*8,increment:Ct.hour*2,getAnchor:Co.day,labelFormat:Qt.minutes},{ceiling:Ct.hour*13,increment:Ct.hour*6,getAnchor:Co.day,labelFormat:Qt.minutes},{ceiling:Ct.hour*22,increment:Ct.hour*12,getAnchor:Co.day,labelFormat:Qt.minutes},{ceiling:Ct.day*4,increment:Ct.day,getAnchor:Co.day,labelFormat:Qt.date},{ceiling:Ct.week*2,increment:Ct.week,getAnchor:Co.week,labelFormat:Qt.date},{ceiling:1/0,increment:Ct.week*4,labelFormat:Qt.date}],ZR=300;async function VR(){const r=await Je(),t=await Di(),e=new Xt,i=new Map;let s=await Eo();xt.on("scaleUpdated",d=>s=d),await o();function n(){if(e.visible=!t.disableGuides,!t.disableGuides)try{const{anchor:d,increment:p,labelFormat:m}=a(),f=c(d,p);u(f,m)}catch(d){if(d instanceof db)return;console.error(d)}}async function o(){const d=[];bd(30,async p=>{const m=WR();d.push(m);const f=await m;e.addChild(f.element),i.set(p,f)}),await Promise.all(d)}function a(){const d=r.left-ZR,p=s.invert(d),m=s.invert(d+260/r.scale.x);if(!(p instanceof Date)||!(m instanceof Date))throw new db;const f=m.getTime()-p.getTime(),{increment:g,getAnchor:y,labelFormat:_}=h(f);return{anchor:y(p),increment:g,labelFormat:l(_)}}function h(d){const p=fb.find(m=>m.ceiling>d)??fb[0];return p.getAnchor||(p.getAnchor=m=>Math.floor(m.getTime()/p.increment)*p.increment),p}function l(d){switch(d){case Qt.minutes:return Nh.timeByMinutesWithDates;case Qt.date:return Nh.date;default:return Nh.timeBySeconds}}function u(d,p){const m=new Map(i.entries()),f=Array.from(m.keys()).filter(g=>!d.includes(g));i.clear();for(const g of d){if(m.has(g)){const _=m.get(g);i.set(g,_),_.render(new Date(g),p);continue}const y=m.get(f.pop()??-1);if(y===void 0){console.warn("Guides: No unused guides available to render.");continue}y.render(new Date(g),p),i.set(g,y)}}function c(d,p){return bd(30,m=>d+p*m)}return{element:e,render:n}}async function KR(){const r=await li(),{element:t,render:e}=await VR();r.stage.addChild(t),e(),xt.on("viewportDateRangeUpdated",()=>e()),xt.on("layoutSettingsUpdated",()=>e()),xt.on("configUpdated",()=>e())}function XM(){}const HR=80;async function YR(){const r=await li(),t=await Je(),e=await Di(),i=await ge(),s=await vd();let n=await Eo();xt.on("scaleUpdated",h=>n=h);function o(){if(!e.isTemporal()){s.visible=!1;return}s.width=i.styles.playheadWidth,s.height=r.stage.height,s.tint=i.styles.playheadColor,s.position.x=n(new Date)*t.scale.x+t.worldTransform.tx,a()}function a(){if(t.moving||!(s.position.x>0&&s.position.x<r.screen.width)||!(s.position.x>r.screen.width-HR))return;const u=t.left;t.zoomPercent(-.1,!0),t.left=u}return{element:s,render:o}}async function zR(){const r=await li(),t=await Sd(),{element:e,render:i}=await YR();t.end_time||(r.stage.addChild(e),r.ticker.add(i)),xt.on("runDataUpdated",({end_time:s})=>{s&&(r.ticker.remove(i),r.stage.removeChild(e))})}function ZM(){}function jR({stage:r,props:t}){sC(),nR(),rR(),KR(),eM(),zR(),Ob(),ER(),iC(r),Xb(t),cR(),aM(),GR()}function JR(){xt.clear();try{nC(),oR(),sR(),rC(),iM(),Zb(),Wb(),IR(),dR(),hM(),NR(),gR()}catch(r){console.error(r)}}async function $R(r){const t=await ge(),e=await li(),i=await $y(),{animate:s}=await Qy(),{element:n,render:o,bar:a}=await g(r);let h=r,l=null,u=!1,c=!1;i.add(n),n.eventMode="static",n.cursor="pointer",n.name=Cb,n.on("click",b=>{b.stopPropagation(),Td(h)}),r.end_time||p(),xt.on("nodeSelected",()=>{const b=wd(r);b!==u&&(u=b,o(h))});async function d(b){h=b;const v=y(b);return v===l||(l=v,await o(b),b.end_time&&m()),n}function p(){e.ticker.add(f)}function m(){e.ticker.remove(f)}function f(){d(r)}async function g(b){const{kind:v}=b;switch(v){case"task-run":return await OR();case"flow-run":return await kR(b);default:const S=v;throw new Error(`switch does not have case for value: ${S}`)}}function y(b){const v=b.end_time??new Date;return[b.state_type,v.getTime(),yt.horizontal,yt.horizontalScaleMultiplier,t.styles.colorMode].join("-")}function _({x:b,y:v}){s(n,{x:b,y:v},!c),c=!0}return{element:n,render:d,bar:a,setPosition:_}}function mb({gap:r=0,minimum:t=0}={}){const e=new Map;function i(u){const c=e.get(u)??[];return Math.max(...c.values(),z.toValue(t))+z.toValue(r)}function s(u){let c=0;for(let d=0;d<u;d++)c+=i(d);return c}function n(u){return s(u+1)-z.toValue(r)}function o({axis:u,nodeId:c,offset:d}){const p=e.get(u)??new Map;p.set(c,d),e.set(u,p)}function a({axis:u,nodeId:c}){let d,p;for(const[m,f]of e.entries())if(f.has(c)){d=m,p=f.get(c);break}d===u||d===void 0||p===void 0||(h({axis:d,nodeId:c}),o({axis:u,nodeId:c,offset:p}))}function h({axis:u,nodeId:c}){var d;(d=e.get(u))==null||d.delete(c)}function l(){e.clear()}return{getOffset:i,getTotalOffset:s,getTotalValue:n,setOffset:o,updateNodeAxis:a,removeOffset:h,clear:l}}function QR(r){throw new Error(`switch does not have case for value: ${r}`)}const gb="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIEtlKG4pe3Rocm93IG5ldyBFcnJvcihgc3dpdGNoIGRvZXMgbm90IGhhdmUgY2FzZSBmb3IgdmFsdWU6ICR7bn1gKX1mdW5jdGlvbiBDbihuLGUpe3JldHVybiBuPT1udWxsfHxlPT1udWxsP05hTjpuPGU/LTE6bj5lPzE6bj49ZT8wOk5hTn1mdW5jdGlvbiBudChuLGUpe3JldHVybiBuPT1udWxsfHxlPT1udWxsP05hTjplPG4/LTE6ZT5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VsfWApO2NvbnRpbnVlfWlmKGc9PT12b2lkIDApe2NvbnNvbGUud2FybihgTm9kZUlkIG5vdCBmb3VuZCBpbiB2ZXJ0aWNhbCBsYXlvdXQ6IFNraXBwaW5nICR7bC5sYWJlbH1gKTtjb250aW51ZX1pPU1hdGgubWF4KGksZyksYT1NYXRoLm1heChhLGYuY29sdW1uKSxvLnNldCh1LHsuLi5mLHk6Zyxyb3c6Z30pfWtvKHt0eXBlOiJsYXlvdXQiLGxheW91dDp7bWF4Um93OmksbWF4Q29sdW1uOmEscG9zaXRpb25zOm99fSl9fSkoKTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cnVuR3JhcGgud29ya2VyLTdjMzNlM2VlLmpzLm1hcAo=",yb=typeof window<"u"&&window.Blob&&new Blob([atob(gb)],{type:"text/javascript;charset=utf-8"});function qR(){let r;try{if(r=yb&&(window.URL||window.webkitURL).createObjectURL(yb),!r)throw"";return new Worker(r)}catch{return new Worker("data:application/javascript;base64,"+gb)}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}function tM(r){const t=new qR;return t.onmessage=r,t}async function bb(){const r=tM(P),t=new Map,e=new Map,i=new Xt,s=new Xt,n=await ge(),o=mb({gap:()=>n.styles.rowGap,minimum:()=>n.styles.nodeHeight}),a=mb({gap:()=>n.styles.columnGap,minimum:()=>Ed()});let h=null,l=null;i.name=yp,xt.on("layoutUpdated",()=>{o.clear(),a.clear()}),xt.on("layoutSettingsUpdated",()=>{l&&i.parent&&u(l),G()}),xt.on("nodeSelected",()=>{G()});async function u(L){l=L,h=null,await Promise.all([c(L),p(L)]),f(L)}async function c(L){const k=[];for(const K of L.nodes.values())k.push(d(K));await Promise.all(k)}async function d(L){const{render:k}=await _(L);return await k(L)}async function p(L){if((await Di()).disableEdges){i.removeChild(s);return}i.addChildAt(s,0);const K=[];for(const[D,{children:U}]of L.nodes)for(const{id:j}of U)K.push(m(D,j));await Promise.all(K)}async function m(L,k){const K=`${L}_${k}`;if(e.has(K))return;const D=await vR();e.has(K)||(e.set(K,D),s.addChild(D.element))}function f(L){const k=new Map;for(const[K,{element:D}]of t)k.set(K,D.width);r.postMessage({type:"layout",data:L,widths:k,horizontalSettings:cd(L.start_time),verticalSettings:iR()})}function g(){if(h)for(const[L,k]of e){const[K,D]=L.split("_"),U=h.positions.get(K),j=h.positions.get(D),q=t.get(K);if(!U||!j){console.warn(`Could not find edge in layout: Skipping ${L}`);continue}if(!q){console.warn(`Could not find parent node in nodes: Skipping ${K}`);continue}const dt=q.bar.width,nt=v(U),Et={x:nt.x+dt,y:nt.y+n.styles.nodeHeight/2},Rt=v(j),wt={x:Rt.x-Et.x,y:Rt.y-Et.y+n.styles.nodeHeight/2};k.setPosition(Et,wt)}}function y(){if(h){for(const[L,k]of t){const K=h.positions.get(L);if(!K){console.warn(`Could not find node in layout: Skipping ${L}`);continue}const D=v(K);k.setPosition(D),o.updateNodeAxis({nodeId:L,axis:K.y}),a.updateNodeAxis({nodeId:L,axis:K.column})}g(),i.emit("rendered"),i.emit("resized",I())}}async function _(L){const k=t.get(L.id);if(k)return k;const K=await $R(L);return K.element.on("resized",D=>b(L.id,D)),t.set(L.id,K),i.addChild(K.element),K}function b(L,k){if(!h)return;const K=t.get(L),D=h.positions.get(L);!K||!D||(o.setOffset({nodeId:L,axis:D.y,offset:k.height}),a.setOffset({nodeId:L,axis:D.column,offset:k.width}),y())}function v(L){const k=o.getTotalOffset(L.y);return{x:S(L),y:k}}function S(L){return yt.isDependency()?a.getTotalOffset(L.column):L.x}function E(){return h?o.getTotalValue(h.maxRow):0}function A(){if(!h||!l)return 0;if(yt.isDependency())return a.getTotalValue(h.maxColumn);const L=cd(l.start_time),k=Hy(L),K=k(l.end_time??new Date),D=k(l.start_time);return K-D}function I(){return{width:A(),height:E()}}function P({data:L}){const{type:k}=L;switch(k){case"layout":B(L);return;default:QR(k)}}function B(L){h=L.layout,y()}async function G(){const L=await Di(),k=FR();if(!k||L.disableEdges){N([]);return}const K=X(k.id);N(K)}function N(L){C(L),F(L)}function C(L){for(const[k,{element:K}]of t){if(L.length===0||L.includes(k)){K.alpha=1;continue}K.alpha=n.styles.nodeUnselectedAlpha}}function F(L){for(const[k,{element:K}]of e){const[D,U]=k.split("_");if(L.length===0||L.includes(D)&&L.includes(U)){K.alpha=1;continue}K.alpha=n.styles.nodeUnselectedAlpha}}function X(L){const k=V(L,"parents"),K=V(L,"children");return[L,...k,...K]}function V(L,k){const K=l==null?void 0:l.nodes.get(L);if(!K)return[];const D=[];for(const{id:U}of K[k])D.push(U),D.push(...V(U,k));return D}return{element:i,getSize:I,render:u}}let Io=null,Dr=null,Ts=null;async function eM(){const r=await Je(),t=await ge(),{element:e,render:i}=await bb();r.addChild(e),e.alpha=0;const s=await Dg(t.runId,async n=>{const o=Dr?"runDataUpdated":"runDataCreated";Dr=n,xt.emit(o,Dr),await Di(),i(n)});xt.on("configUpdated",()=>{Dr&&i(Dr)}),Ts=e,Io=s.stop,Ts.once("rendered",()=>rM()),xt.on("layoutUpdated",()=>sM()),s.start()}function iM(){Io==null||Io(),Io=null,Ts=null,Dr=null}async function Sd(){return Dr||await Oe("runDataCreated")}function rM(){pd(),be.shared.addOnce(()=>{Ts&&(Ts.alpha=1)})}async function sM(){if(!Ts)return;const r=await ge();Ts.once("rendered",()=>{setTimeout(()=>{pd({animate:!0})},r.animationDuration)})}function nM(r){let t=0;for(const[,{children:e}]of r)t+=e.length;return t}function oM({start_time:r,end_time:t}){const e=Gb(t??new Date,r);return e<xp?2:e<xp*6?1:.1}async function aM(){const r=await Sd(),t=await ge(),e=oM(r);Fh(e,!0),r.nodes.size>t.disableAnimationsThreshold&&(yt.disableAnimations=!0),nM(r.nodes)>t.disableEdgesThreshold&&(yt.disableEdges=!0)}function hM(){yt.horizontalScaleMultiplierDefault=0,yt.horizontalScaleMultiplier=0}const yt=z.reactive({horizontal:"temporal",vertical:"nearest-parent",horizontalScaleMultiplierDefault:0,horizontalScaleMultiplier:0,disableAnimations:!1,disableEdges:!1,disableGuides:!1,isTemporal(){return this.horizontal==="temporal"},isDependency(){return this.horizontal==="dependency"},isWaterfall(){return this.vertical==="waterfall"},isNearestParent(){return this.vertical==="nearest-parent"},isLeftAligned(){return this.horizontal==="left-aligned"}});async function Di(){return Cd()?yt:await Oe("layoutSettingsCreated")}function Ed(){return yt.isDependency()?200:20*yt.horizontalScaleMultiplier}function lM(){return[0,Ed()]}function uM(r){if(yt.isDependency())return[0,1];const t=r,e=Rb(t,1);return[t,e]}function Fh(r,t=!1){if(yt.horizontalScaleMultiplier===r)return;const e=Dh();yt.horizontalScaleMultiplier=r,t&&(yt.horizontalScaleMultiplierDefault=r),e()}function cM(){Fh(yt.horizontalScaleMultiplierDefault)}function dM(r){if(yt.horizontal===r)return;const t=Dh();yt.horizontal=r,yt.disableGuides=yt.isDependency()||yt.isLeftAligned(),t()}function pM(r){if(yt.vertical===r)return;const t=Dh();yt.vertical=r,t()}function fM(r){if(yt.disableEdges===r)return;const t=Dh();yt.disableEdges=r,t()}function Dh(){const r=Cd()?"layoutSettingsUpdated":"layoutSettingsCreated",{horizontal:t,vertical:e}=yt;return()=>{Cd()&&xt.emit(r,yt),(t!==yt.horizontal||e!==yt.vertical)&&xt.emit("layoutUpdated")}}function Cd(){return yt.horizontalScaleMultiplier!==0}function xb(r){if(!(r instanceof HTMLElement))return!1;const t=r.tagName.toLowerCase();return["input","textarea"].includes(t)}const mM={class:"flex items-center gap-2"},gM=z.defineComponent({__name:"RunGraphSettings",setup(r){const t=[Vi.positions.topRight,Vi.positions.bottomRight,Vi.positions.topLeft,Vi.positions.bottomLeft],e=[{label:"Temporal dependency",value:"temporal_nearest-parent"},{label:"Temporal sequence",value:"temporal_waterfall"},{label:"Dependency grid",value:"dependency_nearest-parent"},{label:"Sequential grid",value:"dependency_waterfall"},{label:"Comparative duration",value:"left-aligned_duration-sorted"}],i=z.computed({get(){return`${yt.horizontal}_${yt.vertical}`},set(l){const[u,c]=l.split("_");dM(u),pM(c)}}),s=z.computed({get(){return yt.disableEdges},set(l){fM(l)}});function n(){const u=yt.horizontalScaleMultiplier*1.25;Fh(u)}function o(){const l=Math.abs(-.75),u=yt.horizontalScaleMultiplier*l;Fh(u)}Zi.useKeyDown(["-","="],a);function a(l){if(!(xb(l.target)||l.metaKey||l.ctrlKey))switch(l.key){case"-":o();break;case"=":n();break}}function h(){cM()}return(l,u)=>{const c=z.resolveComponent("p-radio-group"),d=z.resolveComponent("p-label"),p=z.resolveComponent("p-divider"),m=z.resolveComponent("p-checkbox"),f=z.resolveComponent("p-overflow-menu");return z.openBlock(),z.createBlock(z.unref(Vi.PPopOver),{class:"run-graph-settings","auto-close":"",placement:t},{target:z.withCtx(({toggle:g})=>[z.createVNode(z.unref(Vi.PButton),{"aria-label":"Run Graph Options",icon:"CogIcon",flat:"",onClick:g},null,8,["onClick"])]),default:z.withCtx(()=>[z.createVNode(f,{class:"run-graph-settings__menu"},{default:z.withCtx(()=>[z.createVNode(d,{label:"Layout"},{default:z.withCtx(()=>[z.createVNode(c,{modelValue:i.value,"onUpdate:modelValue":u[0]||(u[0]=g=>i.value=g),options:e},{label:z.withCtx(({option:g})=>[z.createTextVNode(z.toDisplayString(g.label),1)]),_:1},8,["modelValue"])]),_:1}),z.unref(yt).isTemporal()||z.unref(yt).isLeftAligned()?(z.openBlock(),z.createElementBlock(z.Fragment,{key:0},[z.createVNode(p),z.createVNode(d,{label:"Scaling"},{default:z.withCtx(()=>[z.createElementVNode("div",mM,[z.createVNode(z.unref(Vi.PButton),{title:"Decrease scale (-)",small:"",icon:"MinusIcon",onClick:o}),z.createVNode(z.unref(Vi.PButton),{title:"Increase scale (+)",small:"",icon:"PlusIcon",onClick:n}),z.createVNode(z.unref(Vi.PButton),{small:"",onClick:h},{default:z.withCtx(()=>[z.createTextVNode(" Reset ")]),_:1})])]),_:1})],64)):z.createCommentVNode("",!0),z.createVNode(p),z.createVNode(m,{modelValue:s.value,"onUpdate:modelValue":u[1]||(u[1]=g=>s.value=g),label:"Hide dependency arrows"},null,8,["modelValue"])]),_:1})]),_:1})}}}),VM="",yM={class:"run-graph__actions"},bM=z.defineComponent({__name:"RunGraph",props:{config:{},viewport:{},fullscreen:{type:[Boolean,null],default:null},selected:{default:null}},emits:["update:viewport","update:fullscreen","update:selected"],setup(r,{emit:t}){const e=r,i=z.ref(),s=z.ref(!1),n=z.computed({get(){return e.fullscreen??s.value},set(u){s.value=u,t("update:fullscreen",u)}});z.watch(()=>e.selected,u=>Td(u)),xt.on("nodeSelected",u=>t("update:selected",u)),z.watch(()=>e.viewport,u=>lR(u));const o=z.computed(()=>({root:{"run-graph--fullscreen":n.value}}));xt.on("viewportDateRangeUpdated",u=>t("update:viewport",u));function a(){pd({animate:!0})}function h(){n.value=!n.value}z.onMounted(()=>{if(!i.value)throw new Error("Stage does not exist");jR({stage:i.value,props:e})}),z.onBeforeUnmount(()=>{JR()}),Zi.useKeyDown(["c","f","Escape"],l);function l(u){if(!(xb(u.target)||u.metaKey||u.ctrlKey))switch(u.key){case"c":a();break;case"f":h();break;case"Escape":n.value&&h();break}}return(u,c)=>{const d=z.resolveComponent("p-button");return z.openBlock(),z.createElementBlock("div",{class:z.normalizeClass(["run-graph",o.value.root])},[z.createElementVNode("div",{ref_key:"stage",ref:i,class:"run-graph__stage"},null,512),z.createElementVNode("div",yM,[z.createVNode(d,{title:"Recenter graph (c)",icon:"Target",flat:"",onClick:a}),z.createVNode(d,{title:"Toggle fullscreen (f)",icon:"ArrowsPointingOutIcon",flat:"",onClick:h}),z.createVNode(gM)])],2)}}}),KM="",_b=["flow-run","task-run"];function xM(r){return _b.includes(r)}oe.RunGraph=bM,oe.isRunGraphNodeType=xM,oe.runGraphNodeKinds=_b,Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"})});
1175
+ */var L0,Lr,sn,Lc,ds,G0,Gc,GE=function(){return typeof window<"u"},sr={},ps=180/Math.PI,nn=Math.PI/180,on=Math.atan2,N0=1e8,Nc=/([A-Z])/g,NE=/(left|right|width|margin|padding|x)/i,FE=/[\s,\(]\S/,Ri={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},Fc=function(t,e){return e.set(e.t,e.p,Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},DE=function(t,e){return e.set(e.t,e.p,t===1?e.e:Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},kE=function(t,e){return e.set(e.t,e.p,t?Math.round((e.s+e.c*t)*1e4)/1e4+e.u:e.b,e)},OE=function(t,e){var i=e.s+e.c*t;e.set(e.t,e.p,~~(i+(i<0?-.5:.5))+e.u,e)},F0=function(t,e){return e.set(e.t,e.p,t?e.e:e.b,e)},D0=function(t,e){return e.set(e.t,e.p,t!==1?e.b:e.e,e)},WE=function(t,e,i){return t.style[e]=i},BE=function(t,e,i){return t.style.setProperty(e,i)},UE=function(t,e,i){return t._gsap[e]=i},XE=function(t,e,i){return t._gsap.scaleX=t._gsap.scaleY=i},ZE=function(t,e,i,s,n){var o=t._gsap;o.scaleX=o.scaleY=i,o.renderTransform(n,o)},VE=function(t,e,i,s,n){var o=t._gsap;o[e]=i,o.renderTransform(n,o)},Bt="transform",hi=Bt+"Origin",KE=function r(t,e){var i=this,s=this.target,n=s.style;if(t in sr&&n){if(this.tfm=this.tfm||{},t!=="transform")t=Ri[t]||t,~t.indexOf(",")?t.split(",").forEach(function(o){return i.tfm[o]=nr(s,o)}):this.tfm[t]=s._gsap.x?s._gsap[t]:nr(s,t);else return Ri.transform.split(",").forEach(function(o){return r.call(i,o,e)});if(this.props.indexOf(Bt)>=0)return;s._gsap.svg&&(this.svgo=s.getAttribute("data-svg-origin"),this.props.push(hi,e,"")),t=Bt}(n||e)&&this.props.push(t,e,n[t])},k0=function(t){t.translate&&(t.removeProperty("translate"),t.removeProperty("scale"),t.removeProperty("rotate"))},HE=function(){var t=this.props,e=this.target,i=e.style,s=e._gsap,n,o;for(n=0;n<t.length;n+=3)t[n+1]?e[t[n]]=t[n+2]:t[n+2]?i[t[n]]=t[n+2]:i.removeProperty(t[n].substr(0,2)==="--"?t[n]:t[n].replace(Nc,"-$1").toLowerCase());if(this.tfm){for(o in this.tfm)s[o]=this.tfm[o];s.svg&&(s.renderTransform(),e.setAttribute("data-svg-origin",this.svgo||"")),n=Gc(),(!n||!n.isStart)&&!i[Bt]&&(k0(i),s.uncache=1)}},O0=function(t,e){var i={target:t,props:[],revert:HE,save:KE};return t._gsap||Se.core.getCache(t),e&&e.split(",").forEach(function(s){return i.save(s)}),i},W0,Dc=function(t,e){var i=Lr.createElementNS?Lr.createElementNS((e||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),t):Lr.createElement(t);return i.style?i:Lr.createElement(t)},Mi=function r(t,e,i){var s=getComputedStyle(t);return s[e]||s.getPropertyValue(e.replace(Nc,"-$1").toLowerCase())||s.getPropertyValue(e)||!i&&r(t,an(e)||e,1)||""},B0="O,Moz,ms,Ms,Webkit".split(","),an=function(t,e,i){var s=e||ds,n=s.style,o=5;if(t in n&&!i)return t;for(t=t.charAt(0).toUpperCase()+t.substr(1);o--&&!(B0[o]+t in n););return o<0?null:(o===3?"ms":o>=0?B0[o]:"")+t},kc=function(){GE()&&window.document&&(L0=window,Lr=L0.document,sn=Lr.documentElement,ds=Dc("div")||{style:{}},Dc("div"),Bt=an(Bt),hi=Bt+"Origin",ds.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",W0=!!an("perspective"),Gc=Se.core.reverting,Lc=1)},Oc=function r(t){var e=Dc("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),i=this.parentNode,s=this.nextSibling,n=this.style.cssText,o;if(sn.appendChild(e),e.appendChild(this),this.style.display="block",t)try{o=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=r}catch{}else this._gsapBBox&&(o=this._gsapBBox());return i&&(s?i.insertBefore(this,s):i.appendChild(this)),sn.removeChild(e),this.style.cssText=n,o},U0=function(t,e){for(var i=e.length;i--;)if(t.hasAttribute(e[i]))return t.getAttribute(e[i])},X0=function(t){var e;try{e=t.getBBox()}catch{e=Oc.call(t,!0)}return e&&(e.width||e.height)||t.getBBox===Oc||(e=Oc.call(t,!0)),e&&!e.width&&!e.x&&!e.y?{x:+U0(t,["x","cx","x1"])||0,y:+U0(t,["y","cy","y1"])||0,width:0,height:0}:e},Z0=function(t){return!!(t.getCTM&&(!t.parentNode||t.ownerSVGElement)&&X0(t))},uo=function(t,e){if(e){var i=t.style;e in sr&&e!==hi&&(e=Bt),i.removeProperty?((e.substr(0,2)==="ms"||e.substr(0,6)==="webkit")&&(e="-"+e),i.removeProperty(e.replace(Nc,"-$1").toLowerCase())):i.removeAttribute(e)}},Gr=function(t,e,i,s,n,o){var a=new we(t._pt,e,i,0,1,o?D0:F0);return t._pt=a,a.b=s,a.e=n,t._props.push(i),a},V0={deg:1,rad:1,turn:1},YE={grid:1,flex:1},Nr=function r(t,e,i,s){var n=parseFloat(i)||0,o=(i+"").trim().substr((n+"").length)||"px",a=ds.style,h=NE.test(e),l=t.tagName.toLowerCase()==="svg",u=(l?"client":"offset")+(h?"Width":"Height"),c=100,d=s==="px",p=s==="%",m,f,g,y;return s===o||!n||V0[s]||V0[o]?n:(o!=="px"&&!d&&(n=r(t,e,i,"px")),y=t.getCTM&&Z0(t),(p||o==="%")&&(sr[e]||~e.indexOf("adius"))?(m=y?t.getBBox()[h?"width":"height"]:t[u],Ht(p?n/m*c:n/100*m)):(a[h?"width":"height"]=c+(d?o:s),f=~e.indexOf("adius")||s==="em"&&t.appendChild&&!l?t:t.parentNode,y&&(f=(t.ownerSVGElement||{}).parentNode),(!f||f===Lr||!f.appendChild)&&(f=Lr.body),g=f._gsap,g&&p&&g.width&&h&&g.time===Pe.time&&!g.uncache?Ht(n/g.width*c):((p||o==="%")&&!YE[Mi(f,"display")]&&(a.position=Mi(t,"position")),f===t&&(a.position="static"),f.appendChild(ds),m=ds[u],f.removeChild(ds),a.position="absolute",h&&p&&(g=os(f),g.time=Pe.time,g.width=f[u]),Ht(d?m*n/c:m&&n?c/m*n:0))))},nr=function(t,e,i,s){var n;return Lc||kc(),e in Ri&&e!=="transform"&&(e=Ri[e],~e.indexOf(",")&&(e=e.split(",")[0])),sr[e]&&e!=="transform"?(n=po(t,s),n=e!=="transformOrigin"?n[e]:n.svg?n.origin:ph(Mi(t,hi))+" "+n.zOrigin+"px"):(n=t.style[e],(!n||n==="auto"||s||~(n+"").indexOf("calc("))&&(n=dh[e]&&dh[e](t,e,i)||Mi(t,e)||zg(t,e)||(e==="opacity"?1:0))),i&&!~(n+"").trim().indexOf(" ")?Nr(t,e,n,i)+i:n},zE=function(t,e,i,s){if(!i||i==="none"){var n=an(e,t,1),o=n&&Mi(t,n,1);o&&o!==i?(e=n,i=o):e==="borderColor"&&(i=Mi(t,"borderTopColor"))}var a=new we(this._pt,t.style,e,0,1,A0),h=0,l=0,u,c,d,p,m,f,g,y,_,b,v,S;if(a.b=i,a.e=s,i+="",s+="",s==="auto"&&(t.style[e]=s,s=Mi(t,e)||s,t.style[e]=i),u=[i,s],b0(u),i=u[0],s=u[1],d=i.match($s)||[],S=s.match($s)||[],S.length){for(;c=$s.exec(s);)g=c[0],_=s.substring(h,c.index),m?m=(m+1)%5:(_.substr(-5)==="rgba("||_.substr(-5)==="hsla(")&&(m=1),g!==(f=d[l++]||"")&&(p=parseFloat(f)||0,v=f.substr((p+"").length),g.charAt(1)==="="&&(g=Qs(p,g)+v),y=parseFloat(g),b=g.substr((y+"").length),h=$s.lastIndex-b.length,b||(b=b||Ae.units[e]||v,h===s.length&&(s+=b,a.e+=b)),v!==b&&(p=Nr(t,e,f,b)||0),a._pt={_next:a._pt,p:_||l===1?_:",",s:p,c:y-p,m:m&&m<4||e==="zIndex"?Math.round:0});a.c=h<s.length?s.substring(h,s.length):""}else a.r=e==="display"&&s==="none"?D0:F0;return Ug.test(s)&&(a.e=0),this._pt=a,a},K0={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},jE=function(t){var e=t.split(" "),i=e[0],s=e[1]||"50%";return(i==="top"||i==="bottom"||s==="left"||s==="right")&&(t=i,i=s,s=t),e[0]=K0[i]||i,e[1]=K0[s]||s,e.join(" ")},JE=function(t,e){if(e.tween&&e.tween._time===e.tween._dur){var i=e.t,s=i.style,n=e.u,o=i._gsap,a,h,l;if(n==="all"||n===!0)s.cssText="",h=1;else for(n=n.split(","),l=n.length;--l>-1;)a=n[l],sr[a]&&(h=1,a=a==="transformOrigin"?hi:Bt),uo(i,a);h&&(uo(i,Bt),o&&(o.svg&&i.removeAttribute("transform"),po(i,1),o.uncache=1,k0(s)))}},dh={clearProps:function(t,e,i,s,n){if(n.data!=="isFromStart"){var o=t._pt=new we(t._pt,e,i,0,0,JE);return o.u=s,o.pr=-10,o.tween=n,t._props.push(i),1}}},co=[1,0,0,1,0,0],H0={},Y0=function(t){return t==="matrix(1, 0, 0, 1, 0, 0)"||t==="none"||!t},z0=function(t){var e=Mi(t,Bt);return Y0(e)?co:e.substr(7).match(Bg).map(Ht)},Wc=function(t,e){var i=t._gsap||os(t),s=t.style,n=z0(t),o,a,h,l;return i.svg&&t.getAttribute("transform")?(h=t.transform.baseVal.consolidate().matrix,n=[h.a,h.b,h.c,h.d,h.e,h.f],n.join(",")==="1,0,0,1,0,0"?co:n):(n===co&&!t.offsetParent&&t!==sn&&!i.svg&&(h=s.display,s.display="block",o=t.parentNode,(!o||!t.offsetParent)&&(l=1,a=t.nextElementSibling,sn.appendChild(t)),n=z0(t),h?s.display=h:uo(t,"display"),l&&(a?o.insertBefore(t,a):o?o.appendChild(t):sn.removeChild(t))),e&&n.length>6?[n[0],n[1],n[4],n[5],n[12],n[13]]:n)},Bc=function(t,e,i,s,n,o){var a=t._gsap,h=n||Wc(t,!0),l=a.xOrigin||0,u=a.yOrigin||0,c=a.xOffset||0,d=a.yOffset||0,p=h[0],m=h[1],f=h[2],g=h[3],y=h[4],_=h[5],b=e.split(" "),v=parseFloat(b[0])||0,S=parseFloat(b[1])||0,E,A,I,P;i?h!==co&&(A=p*g-m*f)&&(I=v*(g/A)+S*(-f/A)+(f*_-g*y)/A,P=v*(-m/A)+S*(p/A)-(p*_-m*y)/A,v=I,S=P):(E=X0(t),v=E.x+(~b[0].indexOf("%")?v/100*E.width:v),S=E.y+(~(b[1]||b[0]).indexOf("%")?S/100*E.height:S)),s||s!==!1&&a.smooth?(y=v-l,_=S-u,a.xOffset=c+(y*p+_*f)-y,a.yOffset=d+(y*m+_*g)-_):a.xOffset=a.yOffset=0,a.xOrigin=v,a.yOrigin=S,a.smooth=!!s,a.origin=e,a.originIsAbsolute=!!i,t.style[hi]="0px 0px",o&&(Gr(o,a,"xOrigin",l,v),Gr(o,a,"yOrigin",u,S),Gr(o,a,"xOffset",c,a.xOffset),Gr(o,a,"yOffset",d,a.yOffset)),t.setAttribute("data-svg-origin",v+" "+S)},po=function(t,e){var i=t._gsap||new T0(t);if("x"in i&&!e&&!i.uncache)return i;var s=t.style,n=i.scaleX<0,o="px",a="deg",h=getComputedStyle(t),l=Mi(t,hi)||"0",u,c,d,p,m,f,g,y,_,b,v,S,E,A,I,P,B,G,N,C,F,X,V,L,k,K,D,U,j,q,pt,nt;return u=c=d=f=g=y=_=b=v=0,p=m=1,i.svg=!!(t.getCTM&&Z0(t)),h.translate&&((h.translate!=="none"||h.scale!=="none"||h.rotate!=="none")&&(s[Bt]=(h.translate!=="none"?"translate3d("+(h.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(h.rotate!=="none"?"rotate("+h.rotate+") ":"")+(h.scale!=="none"?"scale("+h.scale.split(" ").join(",")+") ":"")+(h[Bt]!=="none"?h[Bt]:"")),s.scale=s.rotate=s.translate="none"),A=Wc(t,i.svg),i.svg&&(i.uncache?(k=t.getBBox(),l=i.xOrigin-k.x+"px "+(i.yOrigin-k.y)+"px",L=""):L=!e&&t.getAttribute("data-svg-origin"),Bc(t,L||l,!!L||i.originIsAbsolute,i.smooth!==!1,A)),S=i.xOrigin||0,E=i.yOrigin||0,A!==co&&(G=A[0],N=A[1],C=A[2],F=A[3],u=X=A[4],c=V=A[5],A.length===6?(p=Math.sqrt(G*G+N*N),m=Math.sqrt(F*F+C*C),f=G||N?on(N,G)*ps:0,_=C||F?on(C,F)*ps+f:0,_&&(m*=Math.abs(Math.cos(_*nn))),i.svg&&(u-=S-(S*G+E*C),c-=E-(S*N+E*F))):(nt=A[6],q=A[7],D=A[8],U=A[9],j=A[10],pt=A[11],u=A[12],c=A[13],d=A[14],I=on(nt,j),g=I*ps,I&&(P=Math.cos(-I),B=Math.sin(-I),L=X*P+D*B,k=V*P+U*B,K=nt*P+j*B,D=X*-B+D*P,U=V*-B+U*P,j=nt*-B+j*P,pt=q*-B+pt*P,X=L,V=k,nt=K),I=on(-C,j),y=I*ps,I&&(P=Math.cos(-I),B=Math.sin(-I),L=G*P-D*B,k=N*P-U*B,K=C*P-j*B,pt=F*B+pt*P,G=L,N=k,C=K),I=on(N,G),f=I*ps,I&&(P=Math.cos(I),B=Math.sin(I),L=G*P+N*B,k=X*P+V*B,N=N*P-G*B,V=V*P-X*B,G=L,X=k),g&&Math.abs(g)+Math.abs(f)>359.9&&(g=f=0,y=180-y),p=Ht(Math.sqrt(G*G+N*N+C*C)),m=Ht(Math.sqrt(V*V+nt*nt)),I=on(X,V),_=Math.abs(I)>2e-4?I*ps:0,v=pt?1/(pt<0?-pt:pt):0),i.svg&&(L=t.getAttribute("transform"),i.forceCSS=t.setAttribute("transform","")||!Y0(Mi(t,Bt)),L&&t.setAttribute("transform",L))),Math.abs(_)>90&&Math.abs(_)<270&&(n?(p*=-1,_+=f<=0?180:-180,f+=f<=0?180:-180):(m*=-1,_+=_<=0?180:-180)),e=e||i.uncache,i.x=u-((i.xPercent=u&&(!e&&i.xPercent||(Math.round(t.offsetWidth/2)===Math.round(-u)?-50:0)))?t.offsetWidth*i.xPercent/100:0)+o,i.y=c-((i.yPercent=c&&(!e&&i.yPercent||(Math.round(t.offsetHeight/2)===Math.round(-c)?-50:0)))?t.offsetHeight*i.yPercent/100:0)+o,i.z=d+o,i.scaleX=Ht(p),i.scaleY=Ht(m),i.rotation=Ht(f)+a,i.rotationX=Ht(g)+a,i.rotationY=Ht(y)+a,i.skewX=_+a,i.skewY=b+a,i.transformPerspective=v+o,(i.zOrigin=parseFloat(l.split(" ")[2])||0)&&(s[hi]=ph(l)),i.xOffset=i.yOffset=0,i.force3D=Ae.force3D,i.renderTransform=i.svg?QE:W0?j0:$E,i.uncache=0,i},ph=function(t){return(t=t.split(" "))[0]+" "+t[1]},Uc=function(t,e,i){var s=pe(e);return Ht(parseFloat(e)+parseFloat(Nr(t,"x",i+"px",s)))+s},$E=function(t,e){e.z="0px",e.rotationY=e.rotationX="0deg",e.force3D=0,j0(t,e)},fs="0deg",fo="0px",ms=") ",j0=function(t,e){var i=e||this,s=i.xPercent,n=i.yPercent,o=i.x,a=i.y,h=i.z,l=i.rotation,u=i.rotationY,c=i.rotationX,d=i.skewX,p=i.skewY,m=i.scaleX,f=i.scaleY,g=i.transformPerspective,y=i.force3D,_=i.target,b=i.zOrigin,v="",S=y==="auto"&&t&&t!==1||y===!0;if(b&&(c!==fs||u!==fs)){var E=parseFloat(u)*nn,A=Math.sin(E),I=Math.cos(E),P;E=parseFloat(c)*nn,P=Math.cos(E),o=Uc(_,o,A*P*-b),a=Uc(_,a,-Math.sin(E)*-b),h=Uc(_,h,I*P*-b+b)}g!==fo&&(v+="perspective("+g+ms),(s||n)&&(v+="translate("+s+"%, "+n+"%) "),(S||o!==fo||a!==fo||h!==fo)&&(v+=h!==fo||S?"translate3d("+o+", "+a+", "+h+") ":"translate("+o+", "+a+ms),l!==fs&&(v+="rotate("+l+ms),u!==fs&&(v+="rotateY("+u+ms),c!==fs&&(v+="rotateX("+c+ms),(d!==fs||p!==fs)&&(v+="skew("+d+", "+p+ms),(m!==1||f!==1)&&(v+="scale("+m+", "+f+ms),_.style[Bt]=v||"translate(0, 0)"},QE=function(t,e){var i=e||this,s=i.xPercent,n=i.yPercent,o=i.x,a=i.y,h=i.rotation,l=i.skewX,u=i.skewY,c=i.scaleX,d=i.scaleY,p=i.target,m=i.xOrigin,f=i.yOrigin,g=i.xOffset,y=i.yOffset,_=i.forceCSS,b=parseFloat(o),v=parseFloat(a),S,E,A,I,P;h=parseFloat(h),l=parseFloat(l),u=parseFloat(u),u&&(u=parseFloat(u),l+=u,h+=u),h||l?(h*=nn,l*=nn,S=Math.cos(h)*c,E=Math.sin(h)*c,A=Math.sin(h-l)*-d,I=Math.cos(h-l)*d,l&&(u*=nn,P=Math.tan(l-u),P=Math.sqrt(1+P*P),A*=P,I*=P,u&&(P=Math.tan(u),P=Math.sqrt(1+P*P),S*=P,E*=P)),S=Ht(S),E=Ht(E),A=Ht(A),I=Ht(I)):(S=c,I=d,E=A=0),(b&&!~(o+"").indexOf("px")||v&&!~(a+"").indexOf("px"))&&(b=Nr(p,"x",o,"px"),v=Nr(p,"y",a,"px")),(m||f||g||y)&&(b=Ht(b+m-(m*S+f*A)+g),v=Ht(v+f-(m*E+f*I)+y)),(s||n)&&(P=p.getBBox(),b=Ht(b+s/100*P.width),v=Ht(v+n/100*P.height)),P="matrix("+S+","+E+","+A+","+I+","+b+","+v+")",p.setAttribute("transform",P),_&&(p.style[Bt]=P)},qE=function(t,e,i,s,n){var o=360,a=re(n),h=parseFloat(n)*(a&&~n.indexOf("rad")?ps:1),l=h-s,u=s+l+"deg",c,d;return a&&(c=n.split("_")[1],c==="short"&&(l%=o,l!==l%(o/2)&&(l+=l<0?o:-o)),c==="cw"&&l<0?l=(l+o*N0)%o-~~(l/o)*o:c==="ccw"&&l>0&&(l=(l-o*N0)%o-~~(l/o)*o)),t._pt=d=new we(t._pt,e,i,s,l,DE),d.e=u,d.u="deg",t._props.push(i),d},J0=function(t,e){for(var i in e)t[i]=e[i];return t},tC=function(t,e,i){var s=J0({},i._gsap),n="perspective,force3D,transformOrigin,svgOrigin",o=i.style,a,h,l,u,c,d,p,m;s.svg?(l=i.getAttribute("transform"),i.setAttribute("transform",""),o[Bt]=e,a=po(i,1),uo(i,Bt),i.setAttribute("transform",l)):(l=getComputedStyle(i)[Bt],o[Bt]=e,a=po(i,1),o[Bt]=l);for(h in sr)l=s[h],u=a[h],l!==u&&n.indexOf(h)<0&&(p=pe(l),m=pe(u),c=p!==m?Nr(i,h,l,m):parseFloat(l),d=parseFloat(u),t._pt=new we(t._pt,a,h,c,d-c,Fc),t._pt.u=m||0,t._props.push(h));J0(a,s)};ve("padding,margin,Width,Radius",function(r,t){var e="Top",i="Right",s="Bottom",n="Left",o=(t<3?[e,i,s,n]:[e+n,e+i,s+i,s+n]).map(function(a){return t<2?r+a:"border"+a+r});dh[t>1?"border"+r:r]=function(a,h,l,u,c){var d,p;if(arguments.length<4)return d=o.map(function(m){return nr(a,m,l)}),p=d.join(" "),p.split(d[0]).length===5?d[0]:p;d=(u+"").split(" "),p={},o.forEach(function(m,f){return p[m]=d[f]=d[f]||d[(f-1)/2|0]}),a.init(h,p,c)}});var $0={name:"css",register:kc,targetTest:function(t){return t.style&&t.nodeType},init:function(t,e,i,s,n){var o=this._props,a=t.style,h=i.vars.startAt,l,u,c,d,p,m,f,g,y,_,b,v,S,E,A,I;Lc||kc(),this.styles=this.styles||O0(t),I=this.styles.props,this.tween=i;for(f in e)if(f!=="autoRound"&&(u=e[f],!(Me[f]&&w0(f,e,i,s,t,n)))){if(p=typeof u,m=dh[f],p==="function"&&(u=u.call(i,s,t,n),p=typeof u),p==="string"&&~u.indexOf("random(")&&(u=so(u)),m)m(this,t,f,u,i)&&(A=1);else if(f.substr(0,2)==="--")l=(getComputedStyle(t).getPropertyValue(f)+"").trim(),u+="",Mr.lastIndex=0,Mr.test(l)||(g=pe(l),y=pe(u)),y?g!==y&&(l=Nr(t,f,l,y)+y):g&&(u+=g),this.add(a,"setProperty",l,u,s,n,0,0,f),o.push(f),I.push(f,0,a[f]);else if(p!=="undefined"){if(h&&f in h?(l=typeof h[f]=="function"?h[f].call(i,s,t,n):h[f],re(l)&&~l.indexOf("random(")&&(l=so(l)),pe(l+"")||(l+=Ae.units[f]||pe(nr(t,f))||""),(l+"").charAt(1)==="="&&(l=nr(t,f))):l=nr(t,f),d=parseFloat(l),_=p==="string"&&u.charAt(1)==="="&&u.substr(0,2),_&&(u=u.substr(2)),c=parseFloat(u),f in Ri&&(f==="autoAlpha"&&(d===1&&nr(t,"visibility")==="hidden"&&c&&(d=0),I.push("visibility",0,a.visibility),Gr(this,a,"visibility",d?"inherit":"hidden",c?"inherit":"hidden",!c)),f!=="scale"&&f!=="transform"&&(f=Ri[f],~f.indexOf(",")&&(f=f.split(",")[0]))),b=f in sr,b){if(this.styles.save(f),v||(S=t._gsap,S.renderTransform&&!e.parseTransform||po(t,e.parseTransform),E=e.smoothOrigin!==!1&&S.smooth,v=this._pt=new we(this._pt,a,Bt,0,1,S.renderTransform,S,0,-1),v.dep=1),f==="scale")this._pt=new we(this._pt,S,"scaleY",S.scaleY,(_?Qs(S.scaleY,_+c):c)-S.scaleY||0,Fc),this._pt.u=0,o.push("scaleY",f),f+="X";else if(f==="transformOrigin"){I.push(hi,0,a[hi]),u=jE(u),S.svg?Bc(t,u,0,E,0,this):(y=parseFloat(u.split(" ")[2])||0,y!==S.zOrigin&&Gr(this,S,"zOrigin",S.zOrigin,y),Gr(this,a,f,ph(l),ph(u)));continue}else if(f==="svgOrigin"){Bc(t,u,1,E,0,this);continue}else if(f in H0){qE(this,S,f,d,_?Qs(d,_+u):u);continue}else if(f==="smoothOrigin"){Gr(this,S,"smooth",S.smooth,u);continue}else if(f==="force3D"){S[f]=u;continue}else if(f==="transform"){tC(this,u,t);continue}}else f in a||(f=an(f)||f);if(b||(c||c===0)&&(d||d===0)&&!FE.test(u)&&f in a)g=(l+"").substr((d+"").length),c||(c=0),y=pe(u)||(f in Ae.units?Ae.units[f]:g),g!==y&&(d=Nr(t,f,l,y)),this._pt=new we(this._pt,b?S:a,f,d,(_?Qs(d,_+c):c)-d,!b&&(y==="px"||f==="zIndex")&&e.autoRound!==!1?OE:Fc),this._pt.u=y||0,g!==y&&y!=="%"&&(this._pt.b=l,this._pt.r=kE);else if(f in a)zE.call(this,t,f,l,_?_+u:u);else if(f in t)this.add(t,f,l||t[f],_?_+u:u,s,n);else if(f!=="parseTransform"){lc(f,u);continue}b||(f in a?I.push(f,0,a[f]):I.push(f,1,l||t[f])),o.push(f)}}A&&R0(this)},render:function(t,e){if(e.tween._time||!Gc())for(var i=e._pt;i;)i.r(t,i.d),i=i._next;else e.styles.revert()},get:nr,aliases:Ri,getSetter:function(t,e,i){var s=Ri[e];return s&&s.indexOf(",")<0&&(e=s),e in sr&&e!==hi&&(t._gsap.x||nr(t,"x"))?i&&G0===i?e==="scale"?XE:UE:(G0=i||{})&&(e==="scale"?ZE:VE):t.style&&!rc(t.style[e])?WE:~e.indexOf("-")?BE:Ic(t,e)},core:{_removeProperty:uo,_getMatrix:Wc}};Se.utils.checkPrefix=an,Se.core.getStyleSaver=O0,function(r,t,e,i){var s=ve(r+","+t+","+e,function(n){sr[n]=1});ve(t,function(n){Ae.units[n]="deg",H0[n]=1}),Ri[s[13]]=r+","+t,ve(i,function(n){var o=n.split(":");Ri[o[1]]=s[o[0]]})}("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY"),ve("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(r){Ae.units[r]="px"}),Se.registerPlugin($0);var Q0=Se.registerPlugin($0)||Se;Q0.core.Tween;const gs=new ct;class eC{constructor(t={}){this._recursive=typeof t.recursive=="boolean"?t.recursive:!0,this._toggle=t.toggle||"visible",this._targetList=new Set}add(t){return this._targetList.add(t),this}addAll(t){for(let e=0,i=t.length;e<i;e++)this._targetList.add(t[e]);return this}remove(t){return this._targetList.delete(t),this}removeAll(t){for(let e=0,i=t.length;e<i;e++)this._targetList.delete(t[e]);return this}clear(){return this._targetList.clear(),this}cull(t,e=!1){return e||this.uncull(),this._targetList.forEach(i=>{e||i.getBounds(!1,gs),this._recursive?this.cullRecursive(t,i,e):(e&&i._bounds.getRectangle(t),i[this._toggle]=gs.right>t.left&&gs.left<t.right&&gs.bottom>t.top&&gs.top<t.bottom)}),this}uncull(){return this._targetList.forEach(t=>{this._recursive?this.uncullRecursive(t):t[this._toggle]=!1}),this}cullRecursive(t,e,i){const s=i?e._bounds.getRectangle(gs):e.getBounds(!0,gs);if(e[this._toggle]=s.right>t.left&&s.left<t.right&&s.bottom>t.top&&s.top<t.bottom,!(s.left>=t.left&&s.top>=t.top&&s.right<=t.right&&s.bottom<=t.bottom)&&e[this._toggle]&&e.children&&e.children.length){const o=e.children;for(let a=0,h=o.length;a<h;a++)this.cullRecursive(t,o[a])}}uncullRecursive(t){if(t[this._toggle]=!0,t.children&&t.children.length){const e=t.children;for(let i=0,s=e.length;i<s;i++)this.uncullRecursive(e[i])}}}let Pi=null;const q0=new ResizeObserver(()=>{Pi&&xt.emit("stageUpdated",Pi)});function iC(r){Pi=r,q0.observe(Pi),xt.emit("stageCreated",Pi)}function rC(){Pi&&q0.unobserve(Pi),Pi=null}async function Xc(){return Pi||await Oe("stageCreated")}let Le=null;async function sC(){const r=await Xc();oC(r),xt.on("stageUpdated",aC)}function nC(){Le&&(Le.destroy(!0,{children:!0}),Le=null)}function oC(r){Le=new jm({backgroundAlpha:0,resizeTo:r,antialias:!0,resolution:window.devicePixelRatio}),Le.stage.sortableChildren=!0,r.appendChild(Le.view),xt.emit("applicationCreated",Le),process.env.NODE_ENV==="development"&&(globalThis.__PIXI_APP__=Le)}async function li(){return Le||await Oe("applicationCreated")}function aC(r){Le&&(Le.resizeTo=r,xt.emit("applicationResized",Le))}var fh={exports:{}};fh.exports,function(r,t){var e=200,i="__lodash_hash_undefined__",s=1,n=2,o=9007199254740991,a="[object Arguments]",h="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",c="[object Date]",d="[object Error]",p="[object Function]",m="[object GeneratorFunction]",f="[object Map]",g="[object Number]",y="[object Null]",_="[object Object]",b="[object Promise]",v="[object Proxy]",S="[object RegExp]",E="[object Set]",A="[object String]",I="[object Symbol]",P="[object Undefined]",B="[object WeakMap]",G="[object ArrayBuffer]",N="[object DataView]",C="[object Float32Array]",F="[object Float64Array]",X="[object Int8Array]",V="[object Int16Array]",L="[object Int32Array]",k="[object Uint8Array]",K="[object Uint8ClampedArray]",D="[object Uint16Array]",U="[object Uint32Array]",j=/[\\^$.*+?()[\]{}|]/g,q=/^\[object .+?Constructor\]$/,pt=/^(?:0|[1-9]\d*)$/,nt={};nt[C]=nt[F]=nt[X]=nt[V]=nt[L]=nt[k]=nt[K]=nt[D]=nt[U]=!0,nt[a]=nt[h]=nt[G]=nt[u]=nt[N]=nt[c]=nt[d]=nt[p]=nt[f]=nt[g]=nt[_]=nt[S]=nt[E]=nt[A]=nt[B]=!1;var Et=typeof qe=="object"&&qe&&qe.Object===Object&&qe,Rt=typeof self=="object"&&self&&self.Object===Object&&self,wt=Et||Rt||Function("return this")(),Y=t&&!t.nodeType&&t,it=Y&&!0&&r&&!r.nodeType&&r,tt=it&&it.exports===Y,O=tt&&Et.process,bt=function(){try{return O&&O.binding&&O.binding("util")}catch{}}(),gt=bt&&bt.isTypedArray;function Mt(T,R){for(var x=-1,w=T==null?0:T.length,M=0,Z=[];++x<w;){var ht=T[x];R(ht,x,T)&&(Z[M++]=ht)}return Z}function Ut(T,R){for(var x=-1,w=R.length,M=T.length;++x<w;)T[M+x]=R[x];return T}function Ne(T,R){for(var x=-1,w=T==null?0:T.length;++x<w;)if(R(T[x],x,T))return!0;return!1}function ci(T,R){for(var x=-1,w=Array(T);++x<T;)w[x]=R(x);return w}function Id(T){return function(R){return T(R)}}function yn(T,R){return T.has(R)}function Ao(T,R){return T==null?void 0:T[R]}function bn(T){var R=-1,x=Array(T.size);return T.forEach(function(w,M){x[++R]=[M,w]}),x}function di(T,R){return function(x){return T(R(x))}}function kh(T){var R=-1,x=Array(T.size);return T.forEach(function(w){x[++R]=w}),x}var Oh=Array.prototype,Ad=Function.prototype,xn=Object.prototype,kr=wt["__core-js_shared__"],Ro=Ad.toString,Fe=xn.hasOwnProperty,Mo=function(){var T=/[^.]+$/.exec(kr&&kr.keys&&kr.keys.IE_PROTO||"");return T?"Symbol(src)_1."+T:""}(),Po=xn.toString,Wh=RegExp("^"+Ro.call(Fe).replace(j,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Bh=tt?wt.Buffer:void 0,_n=wt.Symbol,ki=wt.Uint8Array,ws=xn.propertyIsEnumerable,Rd=Oh.splice,Oi=_n?_n.toStringTag:void 0,Uh=Object.getOwnPropertySymbols,Xh=Bh?Bh.isBuffer:void 0,Ss=di(Object.keys,Object),Lo=dr(wt,"DataView"),De=dr(wt,"Map"),Go=dr(wt,"Promise"),No=dr(wt,"Set"),Fo=dr(wt,"WeakMap"),Es=dr(Object,"create"),Md=fi(Lo),pi=fi(De),Pd=fi(Go),Ld=fi(No),Gd=fi(Fo),Zh=_n?_n.prototype:void 0,Do=Zh?Zh.valueOf:void 0;function Ce(T){var R=-1,x=T==null?0:T.length;for(this.clear();++R<x;){var w=T[R];this.set(w[0],w[1])}}function Nd(){this.__data__=Es?Es(null):{},this.size=0}function Fd(T){var R=this.has(T)&&delete this.__data__[T];return this.size-=R?1:0,R}function Dd(T){var R=this.__data__;if(Es){var x=R[T];return x===i?void 0:x}return Fe.call(R,T)?R[T]:void 0}function kd(T){var R=this.__data__;return Es?R[T]!==void 0:Fe.call(R,T)}function Od(T,R){var x=this.__data__;return this.size+=this.has(T)?0:1,x[T]=Es&&R===void 0?i:R,this}Ce.prototype.clear=Nd,Ce.prototype.delete=Fd,Ce.prototype.get=Dd,Ce.prototype.has=kd,Ce.prototype.set=Od;function fe(T){var R=-1,x=T==null?0:T.length;for(this.clear();++R<x;){var w=T[R];this.set(w[0],w[1])}}function Wd(){this.__data__=[],this.size=0}function Bd(T){var R=this.__data__,x=Tn(R,T);if(x<0)return!1;var w=R.length-1;return x==w?R.pop():Rd.call(R,x,1),--this.size,!0}function Ud(T){var R=this.__data__,x=Tn(R,T);return x<0?void 0:R[x][1]}function Xd(T){return Tn(this.__data__,T)>-1}function Zd(T,R){var x=this.__data__,w=Tn(x,T);return w<0?(++this.size,x.push([T,R])):x[w][1]=R,this}fe.prototype.clear=Wd,fe.prototype.delete=Bd,fe.prototype.get=Ud,fe.prototype.has=Xd,fe.prototype.set=Zd;function ur(T){var R=-1,x=T==null?0:T.length;for(this.clear();++R<x;){var w=T[R];this.set(w[0],w[1])}}function ko(){this.size=0,this.__data__={hash:new Ce,map:new(De||fe),string:new Ce}}function Vd(T){var R=Sn(this,T).delete(T);return this.size-=R?1:0,R}function vn(T){return Sn(this,T).get(T)}function Oo(T){return Sn(this,T).has(T)}function Kd(T,R){var x=Sn(this,T),w=x.size;return x.set(T,R),this.size+=x.size==w?0:1,this}ur.prototype.clear=ko,ur.prototype.delete=Vd,ur.prototype.get=vn,ur.prototype.has=Oo,ur.prototype.set=Kd;function cr(T){var R=-1,x=T==null?0:T.length;for(this.__data__=new ur;++R<x;)this.add(T[R])}function Vh(T){return this.__data__.set(T,i),this}function Hd(T){return this.__data__.has(T)}cr.prototype.add=cr.prototype.push=Vh,cr.prototype.has=Hd;function Wi(T){var R=this.__data__=new fe(T);this.size=R.size}function Yd(){this.__data__=new fe,this.size=0}function Kh(T){var R=this.__data__,x=R.delete(T);return this.size=R.size,x}function zd(T){return this.__data__.get(T)}function jd(T){return this.__data__.has(T)}function Jd(T,R){var x=this.__data__;if(x instanceof fe){var w=x.__data__;if(!De||w.length<e-1)return w.push([T,R]),this.size=++x.size,this;x=this.__data__=new ur(w)}return x.set(T,R),this.size=x.size,this}Wi.prototype.clear=Yd,Wi.prototype.delete=Kh,Wi.prototype.get=zd,Wi.prototype.has=jd,Wi.prototype.set=Jd;function $d(T,R){var x=In(T),w=!x&&Uo(T),M=!x&&!w&&Is(T),Z=!x&&!w&&!M&&tl(T),ht=x||w||M||Z,ft=ht?ci(T.length,String):[],yt=ft.length;for(var ot in T)(R||Fe.call(T,ot))&&!(ht&&(ot=="length"||M&&(ot=="offset"||ot=="parent")||Z&&(ot=="buffer"||ot=="byteLength"||ot=="byteOffset")||Bo(ot,yt)))&&ft.push(ot);return ft}function Tn(T,R){for(var x=T.length;x--;)if(Cn(T[x][0],R))return x;return-1}function Qd(T,R,x){var w=R(T);return In(T)?w:Ut(w,x(T))}function Cs(T){return T==null?T===void 0?P:y:Oi&&Oi in Object(T)?ip(T):En(T)}function Hh(T){return Wr(T)&&Cs(T)==a}function Yh(T,R,x,w,M){return T===R?!0:T==null||R==null||!Wr(T)&&!Wr(R)?T!==T&&R!==R:qd(T,R,x,w,Yh,M)}function qd(T,R,x,w,M,Z){var ht=In(T),ft=In(R),yt=ht?h:Bi(T),ot=ft?h:Bi(R);yt=yt==a?_:yt,ot=ot==a?_:ot;var _t=yt==_,Ft=ot==_,At=yt==ot;if(At&&Is(T)){if(!Is(R))return!1;ht=!0,_t=!1}if(At&&!_t)return Z||(Z=new Wi),ht||tl(T)?zh(T,R,x,w,M,Z):jh(T,R,yt,x,w,M,Z);if(!(x&s)){var ne=_t&&Fe.call(T,"__wrapped__"),me=Ft&&Fe.call(R,"__wrapped__");if(ne||me){var $e=ne?T.value():T,Qe=me?R.value():R;return Z||(Z=new Wi),M($e,Qe,x,w,Z)}}return At?(Z||(Z=new Wi),ep(T,R,x,w,M,Z)):!1}function wn(T){if(!qh(T)||np(T))return!1;var R=Ui(T)?Wh:q;return R.test(fi(T))}function Wo(T){return Wr(T)&&Or(T.length)&&!!nt[Cs(T)]}function tp(T){if(!op(T))return Ss(T);var R=[];for(var x in Object(T))Fe.call(T,x)&&x!="constructor"&&R.push(x);return R}function zh(T,R,x,w,M,Z){var ht=x&s,ft=T.length,yt=R.length;if(ft!=yt&&!(ht&&yt>ft))return!1;var ot=Z.get(T);if(ot&&Z.get(R))return ot==R;var _t=-1,Ft=!0,At=x&n?new cr:void 0;for(Z.set(T,R),Z.set(R,T);++_t<ft;){var ne=T[_t],me=R[_t];if(w)var $e=ht?w(me,ne,_t,R,T,Z):w(ne,me,_t,T,R,Z);if($e!==void 0){if($e)continue;Ft=!1;break}if(At){if(!Ne(R,function(Qe,As){if(!yn(At,As)&&(ne===Qe||M(ne,Qe,x,w,Z)))return At.push(As)})){Ft=!1;break}}else if(!(ne===me||M(ne,me,x,w,Z))){Ft=!1;break}}return Z.delete(T),Z.delete(R),Ft}function jh(T,R,x,w,M,Z,ht){switch(x){case N:if(T.byteLength!=R.byteLength||T.byteOffset!=R.byteOffset)return!1;T=T.buffer,R=R.buffer;case G:return!(T.byteLength!=R.byteLength||!Z(new ki(T),new ki(R)));case u:case c:case g:return Cn(+T,+R);case d:return T.name==R.name&&T.message==R.message;case S:case A:return T==R+"";case f:var ft=bn;case E:var yt=w&s;if(ft||(ft=kh),T.size!=R.size&&!yt)return!1;var ot=ht.get(T);if(ot)return ot==R;w|=n,ht.set(T,R);var _t=zh(ft(T),ft(R),w,M,Z,ht);return ht.delete(T),_t;case I:if(Do)return Do.call(T)==Do.call(R)}return!1}function ep(T,R,x,w,M,Z){var ht=x&s,ft=Jh(T),yt=ft.length,ot=Jh(R),_t=ot.length;if(yt!=_t&&!ht)return!1;for(var Ft=yt;Ft--;){var At=ft[Ft];if(!(ht?At in R:Fe.call(R,At)))return!1}var ne=Z.get(T);if(ne&&Z.get(R))return ne==R;var me=!0;Z.set(T,R),Z.set(R,T);for(var $e=ht;++Ft<yt;){At=ft[Ft];var Qe=T[At],As=R[At];if(w)var vb=ht?w(As,Qe,At,R,T,Z):w(Qe,As,At,T,R,Z);if(!(vb===void 0?Qe===As||M(Qe,As,x,w,Z):vb)){me=!1;break}$e||($e=At=="constructor")}if(me&&!$e){var il=T.constructor,rl=R.constructor;il!=rl&&"constructor"in T&&"constructor"in R&&!(typeof il=="function"&&il instanceof il&&typeof rl=="function"&&rl instanceof rl)&&(me=!1)}return Z.delete(T),Z.delete(R),me}function Jh(T){return Qd(T,el,rp)}function Sn(T,R){var x=T.__data__;return sp(R)?x[typeof R=="string"?"string":"hash"]:x.map}function dr(T,R){var x=Ao(T,R);return wn(x)?x:void 0}function ip(T){var R=Fe.call(T,Oi),x=T[Oi];try{T[Oi]=void 0;var w=!0}catch{}var M=Po.call(T);return w&&(R?T[Oi]=x:delete T[Oi]),M}var rp=Uh?function(T){return T==null?[]:(T=Object(T),Mt(Uh(T),function(R){return ws.call(T,R)}))}:ap,Bi=Cs;(Lo&&Bi(new Lo(new ArrayBuffer(1)))!=N||De&&Bi(new De)!=f||Go&&Bi(Go.resolve())!=b||No&&Bi(new No)!=E||Fo&&Bi(new Fo)!=B)&&(Bi=function(T){var R=Cs(T),x=R==_?T.constructor:void 0,w=x?fi(x):"";if(w)switch(w){case Md:return N;case pi:return f;case Pd:return b;case Ld:return E;case Gd:return B}return R});function Bo(T,R){return R=R??o,!!R&&(typeof T=="number"||pt.test(T))&&T>-1&&T%1==0&&T<R}function sp(T){var R=typeof T;return R=="string"||R=="number"||R=="symbol"||R=="boolean"?T!=="__proto__":T===null}function np(T){return!!Mo&&Mo in T}function op(T){var R=T&&T.constructor,x=typeof R=="function"&&R.prototype||xn;return T===x}function En(T){return Po.call(T)}function fi(T){if(T!=null){try{return Ro.call(T)}catch{}try{return T+""}catch{}}return""}function Cn(T,R){return T===R||T!==T&&R!==R}var Uo=Hh(function(){return arguments}())?Hh:function(T){return Wr(T)&&Fe.call(T,"callee")&&!ws.call(T,"callee")},In=Array.isArray;function $h(T){return T!=null&&Or(T.length)&&!Ui(T)}var Is=Xh||hp;function Qh(T,R){return Yh(T,R)}function Ui(T){if(!qh(T))return!1;var R=Cs(T);return R==p||R==m||R==l||R==v}function Or(T){return typeof T=="number"&&T>-1&&T%1==0&&T<=o}function qh(T){var R=typeof T;return T!=null&&(R=="object"||R=="function")}function Wr(T){return T!=null&&typeof T=="object"}var tl=gt?Id(gt):Wo;function el(T){return $h(T)?$d(T):tp(T)}function ap(){return[]}function hp(){return!1}r.exports=Qh}(fh,fh.exports);var hC=fh.exports;const ty=Gn(hC);var lC=Object.defineProperty,uC=(r,t,e)=>t in r?lC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W=(r,t,e)=>(uC(r,typeof t!="symbol"?t+"":t,e),e);class ze{constructor(t){W(this,"parent"),W(this,"paused"),this.parent=t,this.paused=!1}destroy(){}down(t){return!1}move(t){return!1}up(t){return!1}wheel(t){return!1}update(t){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var cC=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ey={exports:{}};(function(r,t){(function(){var e,i;i=function(s){return r.exports=s},e={linear:function(s,n,o,a){return o*s/a+n},easeInQuad:function(s,n,o,a){return o*(s/=a)*s+n},easeOutQuad:function(s,n,o,a){return-o*(s/=a)*(s-2)+n},easeInOutQuad:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s+n:-o/2*(--s*(s-2)-1)+n},easeInCubic:function(s,n,o,a){return o*(s/=a)*s*s+n},easeOutCubic:function(s,n,o,a){return o*((s=s/a-1)*s*s+1)+n},easeInOutCubic:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s*s+n:o/2*((s-=2)*s*s+2)+n},easeInQuart:function(s,n,o,a){return o*(s/=a)*s*s*s+n},easeOutQuart:function(s,n,o,a){return-o*((s=s/a-1)*s*s*s-1)+n},easeInOutQuart:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s*s*s+n:-o/2*((s-=2)*s*s*s-2)+n},easeInQuint:function(s,n,o,a){return o*(s/=a)*s*s*s*s+n},easeOutQuint:function(s,n,o,a){return o*((s=s/a-1)*s*s*s*s+1)+n},easeInOutQuint:function(s,n,o,a){return(s/=a/2)<1?o/2*s*s*s*s*s+n:o/2*((s-=2)*s*s*s*s+2)+n},easeInSine:function(s,n,o,a){return-o*Math.cos(s/a*(Math.PI/2))+o+n},easeOutSine:function(s,n,o,a){return o*Math.sin(s/a*(Math.PI/2))+n},easeInOutSine:function(s,n,o,a){return-o/2*(Math.cos(Math.PI*s/a)-1)+n},easeInExpo:function(s,n,o,a){return s===0?n:o*Math.pow(2,10*(s/a-1))+n},easeOutExpo:function(s,n,o,a){return s===a?n+o:o*(-Math.pow(2,-10*s/a)+1)+n},easeInOutExpo:function(s,n,o,a){return(s/=a/2)<1?o/2*Math.pow(2,10*(s-1))+n:o/2*(-Math.pow(2,-10*--s)+2)+n},easeInCirc:function(s,n,o,a){return-o*(Math.sqrt(1-(s/=a)*s)-1)+n},easeOutCirc:function(s,n,o,a){return o*Math.sqrt(1-(s=s/a-1)*s)+n},easeInOutCirc:function(s,n,o,a){return(s/=a/2)<1?-o/2*(Math.sqrt(1-s*s)-1)+n:o/2*(Math.sqrt(1-(s-=2)*s)+1)+n},easeInElastic:function(s,n,o,a){var h,l,u;return u=1.70158,l=0,h=o,s===0||(s/=a),l||(l=a*.3),h<Math.abs(o)?(h=o,u=l/4):u=l/(2*Math.PI)*Math.asin(o/h),-(h*Math.pow(2,10*(s-=1))*Math.sin((s*a-u)*(2*Math.PI)/l))+n},easeOutElastic:function(s,n,o,a){var h,l,u;return u=1.70158,l=0,h=o,s===0||(s/=a),l||(l=a*.3),h<Math.abs(o)?(h=o,u=l/4):u=l/(2*Math.PI)*Math.asin(o/h),h*Math.pow(2,-10*s)*Math.sin((s*a-u)*(2*Math.PI)/l)+o+n},easeInOutElastic:function(s,n,o,a){var h,l,u;return u=1.70158,l=0,h=o,s===0||(s/=a/2),l||(l=a*(.3*1.5)),h<Math.abs(o)?(h=o,u=l/4):u=l/(2*Math.PI)*Math.asin(o/h),s<1?-.5*(h*Math.pow(2,10*(s-=1))*Math.sin((s*a-u)*(2*Math.PI)/l))+n:h*Math.pow(2,-10*(s-=1))*Math.sin((s*a-u)*(2*Math.PI)/l)*.5+o+n},easeInBack:function(s,n,o,a,h){return h===void 0&&(h=1.70158),o*(s/=a)*s*((h+1)*s-h)+n},easeOutBack:function(s,n,o,a,h){return h===void 0&&(h=1.70158),o*((s=s/a-1)*s*((h+1)*s+h)+1)+n},easeInOutBack:function(s,n,o,a,h){return h===void 0&&(h=1.70158),(s/=a/2)<1?o/2*(s*s*(((h*=1.525)+1)*s-h))+n:o/2*((s-=2)*s*(((h*=1.525)+1)*s+h)+2)+n},easeInBounce:function(s,n,o,a){var h;return h=e.easeOutBounce(a-s,0,o,a),o-h+n},easeOutBounce:function(s,n,o,a){return(s/=a)<1/2.75?o*(7.5625*s*s)+n:s<2/2.75?o*(7.5625*(s-=1.5/2.75)*s+.75)+n:s<2.5/2.75?o*(7.5625*(s-=2.25/2.75)*s+.9375)+n:o*(7.5625*(s-=2.625/2.75)*s+.984375)+n},easeInOutBounce:function(s,n,o,a){var h;return s<a/2?(h=e.easeInBounce(s*2,0,o,a),h*.5+n):(h=e.easeOutBounce(s*2-a,0,o,a),h*.5+o*.5+n)}},i(e)}).call(cC)})(ey);const iy=ey.exports;function mh(r,t){if(r){if(typeof r=="function")return r;if(typeof r=="string")return iy[r]}else return iy[t]}const dC={removeOnInterrupt:!1,ease:"linear",time:1e3};class pC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"startX"),W(this,"startY"),W(this,"deltaX"),W(this,"deltaY"),W(this,"keepCenter"),W(this,"startWidth",null),W(this,"startHeight",null),W(this,"deltaWidth",null),W(this,"deltaHeight",null),W(this,"width",null),W(this,"height",null),W(this,"time",0),this.options=Object.assign({},dC,e),this.options.ease=mh(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),!this.keepCenter&&this.options.position&&this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(t){if(this.paused)return;this.time+=t;const e=new lt(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const i=this.parent.width,s=this.parent.height;this.complete(),(i!==this.parent.width||s!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const i=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const s=this.startWidth,n=this.deltaWidth;this.parent.fitWidth(s+n*i,this.keepCenter,this.height===null)}if(this.height!==null){const s=this.startHeight,n=this.deltaHeight;this.parent.fitHeight(s+n*i,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const s=this.startX,n=this.startY,o=this.deltaX,a=this.deltaY,h=new lt(this.parent.x,this.parent.y);this.parent.moveCenter(s+o*i,n+a*i),this.parent.emit("moved",{viewport:this.parent,original:h,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}}const fC={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class mC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"left"),W(this,"top"),W(this,"right"),W(this,"bottom"),W(this,"underflowX"),W(this,"underflowY"),W(this,"ease"),W(this,"toX"),W(this,"toY"),this.options=Object.assign({},fC,e),this.ease=mh(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const i=this.options.underflow.toLowerCase();i==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=i.indexOf("left")!==-1?-1:i.indexOf("right")!==-1?1:0,this.underflowY=i.indexOf("top")!==-1?-1:i.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}oob(){const t=this.options.bounceBox;if(t){const e=typeof t.x>"u"?0:t.x,i=typeof t.y>"u"?0:t.y,s=typeof t.width>"u"?this.parent.worldWidth:t.width,n=typeof t.height>"u"?this.parent.worldHeight:t.height;return{left:this.parent.left<e,right:this.parent.right>s,top:this.parent.top<i,bottom:this.parent.bottom>n,topLeft:new lt(e*this.parent.scale.x,i*this.parent.scale.y),bottomRight:new lt(s*this.parent.scale.x-this.parent.screenWidth,n*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new lt(0,0),bottomRight:new lt(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var t,e;if(this.paused)return;let i,s=this.parent.plugins.get("decelerate",!0);s&&(s.x||s.y)&&(s.x&&s.percentChangeX===((t=s.options)==null?void 0:t.friction)||s.y&&s.percentChangeY===((e=s.options)==null?void 0:e.friction))&&(i=this.oob(),(i.left&&this.left||i.right&&this.right)&&(s.percentChangeX=this.options.friction),(i.top&&this.top||i.bottom&&this.bottom)&&(s.percentChangeY=this.options.friction));const n=this.parent.plugins.get("drag",!0)||{},o=this.parent.plugins.get("pinch",!0)||{};if(s=s||{},!(n!=null&&n.active)&&!(o!=null&&o.active)&&(!this.toX||!this.toY)&&(!s.x||!s.y)){i=i||this.oob();const a=i.topLeft,h=i.bottomRight;if(!this.toX&&!s.x){let l=null;i.left&&this.left?l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-a.x:i.right&&this.right&&(l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-h.x),l!==null&&this.parent.x!==l&&(this.toX={time:0,start:this.parent.x,delta:l-this.parent.x,end:l},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!s.y){let l=null;i.top&&this.top?l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-a.y:i.bottom&&this.bottom&&(l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-h.y),l!==null&&this.parent.y!==l&&(this.toY={time:0,start:this.parent.y,delta:l-this.parent.y,end:l},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const gC={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class yC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"last"),W(this,"noUnderflow"),W(this,"underflowX"),W(this,"underflowY"),this.options=Object.assign({},gC,e),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="none"?this.noUnderflow=!0:t==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const t=new lt(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,i=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,i=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,i=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,e.x=0,i=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,i=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,i=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,i=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,e.y=0,i=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const bC={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class xC extends ze{constructor(t,e={}){super(t),W(this,"options"),this.options=Object.assign({},bC,e),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&t<this.options.minWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&t>this.options.maxWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&e<this.options.minHeight){const i=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&e>this.options.maxHeight){const i=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/i,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},e={x:null,y:null};if(typeof this.options.minScale=="number")t.x=this.options.minScale,t.y=this.options.minScale;else if(this.options.minScale!==null){const n=this.options.minScale;t.x=typeof n.x>"u"?null:n.x,t.y=typeof n.y>"u"?null:n.y}if(typeof this.options.maxScale=="number")e.x=this.options.maxScale,e.y=this.options.maxScale;else if(this.options.maxScale!==null){const n=this.options.maxScale;e.x=typeof n.x>"u"?null:n.x,e.y=typeof n.y>"u"?null:n.y}let i=this.parent.scale.x,s=this.parent.scale.y;t.x!==null&&i<t.x&&(i=t.x),e.x!==null&&i>e.x&&(i=e.x),t.y!==null&&s<t.y&&(s=t.y),e.y!==null&&s>e.y&&(s=e.y),(i!==this.parent.scale.x||s!==this.parent.scale.y)&&(this.parent.scale.set(i,s),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const _C={friction:.98,bounce:.8,minSpeed:.01},Fr=16;class vC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"x"),W(this,"y"),W(this,"percentChangeX"),W(this,"percentChangeY"),W(this,"saved"),W(this,"timeSinceRelease"),this.options=Object.assign({},_C,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",i=>this.handleMoved(i))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const t=this.parent.input.count();return(t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}handleMoved(t){if(this.saved.length){const e=this.saved[this.saved.length-1];t.type==="clamp-x"&&t.original?e.x===t.original.x&&(e.x=this.parent.x):t.type==="clamp-y"&&t.original&&e.y===t.original.y&&(e.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const t=performance.now();for(const e of this.saved)if(e.time>=t-100){const i=t-e.time;this.x=(this.parent.x-e.x)/i,this.y=(this.parent.y-e.y)/i,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){t=t||{},typeof t.x<"u"&&(this.x=t.x,this.percentChangeX=this.options.friction),typeof t.y<"u"&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;const e=this.x||this.y,i=this.timeSinceRelease,s=this.timeSinceRelease+t;if(this.x){const n=this.percentChangeX,o=Math.log(n);this.parent.x+=this.x*Fr/o*(Math.pow(n,s/Fr)-Math.pow(n,i/Fr)),this.x*=Math.pow(this.percentChangeX,t/Fr)}if(this.y){const n=this.percentChangeY,o=Math.log(n);this.parent.y+=this.y*Fr/o*(Math.pow(n,s/Fr)-Math.pow(n,i/Fr)),this.y*=Math.pow(this.percentChangeY,t/Fr)}this.timeSinceRelease+=t,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const TC={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class wC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"moved"),W(this,"reverse"),W(this,"xDirection"),W(this,"yDirection"),W(this,"keyIsPressed"),W(this,"mouse"),W(this,"underflowX"),W(this,"underflowY"),W(this,"last"),W(this,"current"),W(this,"windowEventHandlers",[]),this.options=Object.assign({},TC,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){const e=s=>{t.includes(s.code)&&(this.keyIsPressed=!0)},i=s=>{t.includes(s.code)&&(this.keyIsPressed=!1)};this.addWindowEventHandler("keyup",i),this.addWindowEventHandler("keydown",e)}addWindowEventHandler(t,e){window.addEventListener(t,e),this.windowEventHandlers.push({event:t,handler:e})}destroy(){this.windowEventHandlers.forEach(({event:t,handler:e})=>{window.removeEventListener(t,e)})}mouseButtons(t){!t||t==="all"?this.mouse=[!0,!0,!0]:this.mouse=[t.indexOf("left")!==-1,t.indexOf("middle")!==-1,t.indexOf("right")!==-1]}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(t.includes("left")?this.underflowX=-1:t.includes("right")?this.underflowX=1:this.underflowX=0,t.includes("top")?this.underflowY=-1:t.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(t){const e=t.pointerType==="mouse",i=this.parent.input.count();return!!((i===1||i>1&&!this.parent.plugins.get("pinch",!0))&&(!e||this.mouse[t.button]))}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&t.data.pointerType==="touch"}down(t){return this.paused||!this.options.pressDrag?!1:this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.global.x,y:t.global.y},this.current=t.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(t){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===t.data.pointerId){const e=t.global.x,i=t.global.y,s=this.parent.input.count();if(s===1||s>1&&!this.parent.plugins.get("pinch",!0)){const n=e-this.last.x,o=i-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(n)||this.yDirection&&this.parent.input.checkThreshold(o)){const a={x:e,y:i};return this.xDirection&&(this.parent.x+=(a.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(a.y-this.last.y)*this.options.factor),this.last=a,this.moved||this.parent.emit("drag-start",{event:t,screen:new lt(this.last.x,this.last.y),world:this.parent.toWorld(new lt(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(t){if(this.paused)return!1;const e=this.parent.input.touches;if(e.length===1){const i=e[0];return i.last&&(this.last={x:i.last.x,y:i.last.y},this.current=i.id),this.moved=!1,!0}else if(this.last&&this.moved){const i=new lt(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:i,world:this.parent.toWorld(i),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!t.ctrlKey){const i=t.deltaMode?this.options.lineHeight:1,s=[t.deltaX,t.deltaY],[n,o]=this.options.wheelSwapAxes?s.reverse():s;return this.xDirection&&(this.parent.x+=n*i*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=o*i*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||t.preventDefault(),this.parent.options.stopPropagation&&t.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,t.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,t.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const SC={speed:0,acceleration:null,radius:null};class EC extends ze{constructor(t,e,i={}){super(t),W(this,"options"),W(this,"target"),W(this,"velocity"),this.target=e,this.options=Object.assign({},SC,i),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const e=this.parent.center;let i=this.target.x,s=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius){const a=Math.atan2(this.target.y-e.y,this.target.x-e.x);i=this.target.x-Math.cos(a)*this.options.radius,s=this.target.y-Math.sin(a)*this.options.radius}else return;const n=i-e.x,o=s-e.y;if(n||o)if(this.options.speed)if(this.options.acceleration){const a=Math.atan2(s-e.y,i-e.x),h=Math.sqrt(Math.pow(n,2)+Math.pow(o,2));if(h){const l=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);h>l?this.velocity={x:Math.min(this.velocity.x+(this.options.acceleration*t,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration*t,this.options.speed))}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(a)*this.velocity.x,c=Math.sin(a)*this.velocity.y,d=Math.abs(u)>Math.abs(n)?i:e.x+u,p=Math.abs(c)>Math.abs(o)?s:e.y+c;this.parent.moveCenter(d,p),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const a=Math.atan2(s-e.y,i-e.x),h=Math.cos(a)*this.options.speed,l=Math.sin(a)*this.options.speed,u=Math.abs(h)>Math.abs(n)?i:e.x+h,c=Math.abs(l)>Math.abs(o)?s:e.y+l;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(i,s),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const CC={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class IC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"reverse"),W(this,"radiusSquared"),W(this,"left"),W(this,"top"),W(this,"right"),W(this,"bottom"),W(this,"horizontal"),W(this,"vertical"),this.options=Object.assign({},CC,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;t!==null?(this.left=t,this.top=t,this.right=this.parent.screenWidth-t,this.bottom=this.parent.screenHeight-t):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(t){if(this.paused||t.pointerType!=="mouse"&&t.pointerId!==1||!this.options.allowButtons&&t.buttons!==0)return!1;const e=t.global.x,i=t.global.y;if(this.radiusSquared){const s=this.parent.toScreen(this.parent.center);if(Math.pow(s.x-e,2)+Math.pow(s.y-i,2)>=this.radiusSquared){const n=Math.atan2(s.y-i,s.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(n))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(n))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(n)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(n)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&i<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&i>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate",!0);this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate",!0);this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const AC={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class RC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"active",!1),W(this,"pinching",!1),W(this,"moved",!1),W(this,"lastCenter"),this.options=Object.assign({},AC,e)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(t){if(this.paused||!this.active)return!1;const e=t.global.x,i=t.global.y,s=this.parent.input.touches;if(s.length>=2){const n=s[0],o=s[1],a=n.last&&o.last?Math.sqrt(Math.pow(o.last.x-n.last.x,2)+Math.pow(o.last.y-n.last.y,2)):null;if(n.id===t.pointerId?n.last={x:e,y:i,data:t}:o.id===t.pointerId&&(o.last={x:e,y:i,data:t}),a){let h;const l=new lt(n.last.x+(o.last.x-n.last.x)/2,n.last.y+(o.last.y-n.last.y)/2);this.options.center||(h=this.parent.toLocal(l));let u=Math.sqrt(Math.pow(o.last.x-n.last.x,2)+Math.pow(o.last.y-n.last.y,2));u=u===0?u=1e-10:u;const c=(1-a/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=c),this.isAxisY()&&(this.parent.scale.y+=c),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:l});const d=this.parent.plugins.get("clamp-zoom",!0);if(d&&d.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const p=this.parent.toGlobal(h);this.parent.x+=(l.x-p.x)*this.options.factor,this.parent.y+=(l.y-p.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(l.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(l.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=l,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const MC={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class PC extends ze{constructor(t,e,i,s={}){super(t),W(this,"options"),W(this,"ease"),W(this,"x"),W(this,"y"),W(this,"percent"),W(this,"snapping"),W(this,"deltaX"),W(this,"deltaY"),W(this,"startX"),W(this,"startY"),this.options=Object.assign({},MC,s),this.ease=mh(s.ease,"easeInOutSine"),this.x=e,this.y=i,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const t=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-t.x,this.deltaY=this.y-t.y,this.startX=t.x,this.startY=t.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const t=this.parent.plugins.get("decelerate",!0);t&&(t.x||t.y)&&(t.percentChangeX=t.percentChangeY=this.options.friction)}return!1}update(t){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const e=this.snapping;e.time+=t;let i,s,n;const o=this.startX,a=this.startY,h=this.deltaX,l=this.deltaY;if(e.time>this.options.time)i=!0,s=o+h,n=a+l;else{const u=this.ease(e.time,0,1,this.options.time);s=o+h*u,n=a+l*u}this.options.topLeft?this.parent.moveCorner(s,n):this.parent.moveCenter(s,n),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),i&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const e=this.options.topLeft?this.parent.corner:this.parent.center;(e.x!==this.x||e.y!==this.y)&&this.snapStart()}}}const LC={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class GC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"ease"),W(this,"xScale"),W(this,"yScale"),W(this,"xIndependent"),W(this,"yIndependent"),W(this,"snapping"),this.options=Object.assign({},LC,e),this.ease=mh(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=t.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,i=this.parent.screenWidth/this.xScale,s=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:e,deltaX:i-t,deltaY:s-e},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(t){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const i=this.snapping;if(i.time+=t,i.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const n=this.snapping,o=this.ease(n.time,n.startX,n.deltaX,this.options.time),a=this.ease(n.time,n.startY,n.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/o,this.parent.scale.y=this.parent.screenHeight/a}const s=this.parent.plugins.get("clamp-zoom",!0);s&&s.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}resume(){this.snapping=null,super.resume()}}const NC={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class FC extends ze{constructor(t,e={}){super(t),W(this,"options"),W(this,"smoothing"),W(this,"smoothingCenter"),W(this,"smoothingCount"),W(this,"keyIsPressed"),this.options=Object.assign({},NC,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",e=>{t.includes(e.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",e=>{t.includes(e.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const t=this.smoothingCenter,e=this.smoothing;let i;this.options.center||(i=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const n=this.parent.toGlobal(i);this.parent.x+=t.x-n.x,this.parent.y+=t.y-n.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(t){if(this.paused)return;const e=this.parent.input.getPointerPosition(t),i=-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/200,s=Math.pow(2,(1+this.options.percent)*i);let n;this.options.center||(n=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.toGlobal(n);this.parent.x+=e.x-a.x,this.parent.y+=e.y-a.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}wheel(t){if(this.paused||!this.checkKeyPress())return!1;if(t.ctrlKey&&this.options.trackpadPinch)this.pinch(t);else if(this.options.wheelZoom){const e=this.parent.input.getPointerPosition(t),i=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,s=Math.pow(2,(1+this.options.percent)*i);if(this.options.smooth){const n={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+n.x)*s-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+n.y)*s-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let n;this.options.center||(n=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.toGlobal(n);this.parent.x+=e.x-a.x,this.parent.y+=e.y-a.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}return!this.parent.options.passiveWheel}}class DC{constructor(t){W(this,"viewport"),W(this,"clickedAvailable"),W(this,"isMouseDown"),W(this,"last"),W(this,"wheelFunction"),W(this,"touches"),this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new ct(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,this):this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(t){if(!(this.viewport.pause||!this.viewport.worldVisible)){if(t.pointerType==="mouse"?this.isMouseDown=!0:this.get(t.pointerId)||this.touches.push({id:t.pointerId,last:null}),this.count()===1){this.last=t.global.clone();const e=this.viewport.plugins.get("decelerate",!0),i=this.viewport.plugins.get("bounce",!0);(!e||!e.isActive())&&(!i||!i.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const i=t.global.x-this.last.x,s=t.global.y-this.last.y;(this.checkThreshold(i)||this.checkThreshold(s))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;t.pointerType==="mouse"&&(this.isMouseDown=!1),t.pointerType!=="mouse"&&this.remove(t.pointerId);const e=this.viewport.plugins.up(t);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const e=new lt;return this.viewport.options.events.mapPositionToPoint(e,t.clientX,t.clientY),e}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(t));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom&&this.viewport.plugins.wheel(t)&&!this.viewport.options.passiveWheel&&t.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(const e of this.touches)if(e.id===t)return e;return null}remove(t){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===t){this.touches.splice(e,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}const mo=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class kC{constructor(t){W(this,"plugins"),W(this,"list"),W(this,"viewport"),this.viewport=t,this.list=[],this.plugins={}}add(t,e,i=mo.length){const s=this.plugins[t];s&&s.destroy(),this.plugins[t]=e;const n=mo.indexOf(t);n!==-1&&mo.splice(n,1),mo.splice(i,0,t),this.sort()}get(t,e){var i;return e&&(i=this.plugins[t])!=null&&i.paused?null:this.plugins[t]}update(t){for(const e of this.list)e.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.list.forEach(t=>{t.destroy()}),this.plugins={},this.sort()}remove(t){var e;this.plugins[t]&&((e=this.plugins[t])==null||e.destroy(),delete this.plugins[t],this.viewport.emit("plugin-remove",t),this.sort())}pause(t){var e;(e=this.plugins[t])==null||e.pause()}resume(t){var e;(e=this.plugins[t])==null||e.resume()}sort(){this.list=[];for(const t of mo)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let e=!1;for(const i of this.list)i.down(t)&&(e=!0);return e}move(t){let e=!1;for(const i of this.viewport.plugins.list)i.move(t)&&(e=!0);return e}up(t){let e=!1;for(const i of this.list)i.up(t)&&(e=!0);return e}wheel(t){let e=!1;for(const i of this.list)i.wheel(t)&&(e=!0);return e}}const OC={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:be.shared,allowPreserveDragOutside:!1};class WC extends Xt{constructor(t){super(),W(this,"moving"),W(this,"screenWidth"),W(this,"screenHeight"),W(this,"threshold"),W(this,"input"),W(this,"plugins"),W(this,"zooming"),W(this,"lastViewport"),W(this,"options"),W(this,"_dirty"),W(this,"_forceHitArea"),W(this,"_hitAreaDefault"),W(this,"_pause"),W(this,"tickerFunction"),W(this,"_worldWidth"),W(this,"_worldHeight"),W(this,"_disableOnContextMenu",e=>e.preventDefault()),this.options={...OC,...t},this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new DC(this),this.plugins=new kC(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new ct(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=window.innerWidth,e=window.innerHeight,i,s){this.screenWidth=t,this.screenHeight=e,typeof i<"u"&&(this._worldWidth=i),typeof s<"u"&&(this._worldHeight=s),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new ct(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,e){return arguments.length===2?this.toLocal(new lt(t,e)):this.toLocal(t)}toScreen(t,e){return arguments.length===2?this.toGlobal(new lt(t,e)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new lt(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(...t){let e,i;typeof t[0]=="number"?(e=t[0],i=t[1]):(e=t[0].x,i=t[0].y);const s=(this.worldScreenWidth/2-e)*this.scale.x,n=(this.worldScreenHeight/2-i)*this.scale.y;return(this.x!==s||this.y!==n)&&(this.position.set(s,n),this.plugins.reset(),this.dirty=!0),this}get corner(){return new lt(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let e,i;return t.length===1?(e=-t[0].x*this.scale.x,i=-t[0].y*this.scale.y):(e=-t[0]*this.scale.x,i=-t[1]*this.scale.y),(e!==this.x||i!==this.y)&&(this.position.set(e,i),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(t){return this.screenWidth/t}findFitHeight(t){return this.screenHeight/t}findFit(t,e){const i=this.screenWidth/t,s=this.screenHeight/e;return Math.min(i,s)}findCover(t,e){const i=this.screenWidth/t,s=this.screenHeight/e;return Math.max(i,s)}fitWidth(t=this.worldWidth,e,i=!0,s){let n;e&&(n=this.center),this.scale.x=this.screenWidth/t,i&&(this.scale.y=this.scale.x);const o=this.plugins.get("clamp-zoom",!0);return!s&&o&&o.clamp(),e&&n&&this.moveCenter(n),this}fitHeight(t=this.worldHeight,e,i=!0,s){let n;e&&(n=this.center),this.scale.y=this.screenHeight/t,i&&(this.scale.x=this.scale.y);const o=this.plugins.get("clamp-zoom",!0);return!s&&o&&o.clamp(),e&&n&&this.moveCenter(n),this}fitWorld(t){let e;t&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),t&&e&&this.moveCenter(e),this}fit(t,e=this.worldWidth,i=this.worldHeight){let s;t&&(s=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/i,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const n=this.plugins.get("clamp-zoom",!0);return n&&n.clamp(),t&&s&&this.moveCenter(s),this}setZoom(t,e){let i;e&&(i=this.center),this.scale.set(t);const s=this.plugins.get("clamp-zoom",!0);return s&&s.clamp(),e&&i&&this.moveCenter(i),this}zoomPercent(t,e){return this.setZoom(this.scale.x+this.scale.x*t,e)}zoom(t,e){return this.fitWidth(t+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new GC(this,t)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new lt(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new ct(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new wC(this,t)),this}clamp(t){return this.plugins.add("clamp",new yC(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new vC(this,t)),this}bounce(t){return this.plugins.add("bounce",new mC(this,t)),this}pinch(t){return this.plugins.add("pinch",new RC(this,t)),this}snap(t,e,i){return this.plugins.add("snap",new PC(this,t,e,i)),this}follow(t,e){return this.plugins.add("follow",new EC(this,t,e)),this}wheel(t){return this.plugins.add("wheel",new FC(this,t)),this}animate(t){return this.plugins.add("animate",new pC(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new xC(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new IC(this,t)),this}get pause(){return!!this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,e,i,s,n){n&&(i>this.worldScreenWidth||s>this.worldScreenHeight)&&(this.fit(!0,i,s),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let o=!1;t<this.left?(this.left=t,o=!0):t+i>this.right&&(this.right=t+i,o=!0),e<this.top?(this.top=e,o=!0):e+s>this.bottom&&(this.bottom=e+s,o=!0),o&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}function gh(r,t){return r==null||t==null?NaN:r<t?-1:r>t?1:r>=t?0:NaN}function BC(r,t){return r==null||t==null?NaN:t<r?-1:t>r?1:t>=r?0:NaN}function Zc(r){let t,e,i;r.length!==2?(t=gh,e=(a,h)=>gh(r(a),h),i=(a,h)=>r(a)-h):(t=r===gh||r===BC?r:UC,e=r,i=r);function s(a,h,l=0,u=a.length){if(l<u){if(t(h,h)!==0)return u;do{const c=l+u>>>1;e(a[c],h)<0?l=c+1:u=c}while(l<u)}return l}function n(a,h,l=0,u=a.length){if(l<u){if(t(h,h)!==0)return u;do{const c=l+u>>>1;e(a[c],h)<=0?l=c+1:u=c}while(l<u)}return l}function o(a,h,l=0,u=a.length){const c=s(a,h,l,u-1);return c>l&&i(a[c-1],h)>-i(a[c],h)?c-1:c}return{left:s,center:o,right:n}}function UC(){return 0}function XC(r){return r===null?NaN:+r}const ZC=Zc(gh).right;Zc(XC).center;const VC=ZC,KC=Math.sqrt(50),HC=Math.sqrt(10),YC=Math.sqrt(2);function yh(r,t,e){const i=(t-r)/Math.max(0,e),s=Math.floor(Math.log10(i)),n=i/Math.pow(10,s),o=n>=KC?10:n>=HC?5:n>=YC?2:1;let a,h,l;return s<0?(l=Math.pow(10,-s)/o,a=Math.round(r*l),h=Math.round(t*l),a/l<r&&++a,h/l>t&&--h,l=-l):(l=Math.pow(10,s)*o,a=Math.round(r/l),h=Math.round(t/l),a*l<r&&++a,h*l>t&&--h),h<a&&.5<=e&&e<2?yh(r,t,e*2):[a,h,l]}function zC(r,t,e){if(t=+t,r=+r,e=+e,!(e>0))return[];if(r===t)return[r];const i=t<r,[s,n,o]=i?yh(t,r,e):yh(r,t,e);if(!(n>=s))return[];const a=n-s+1,h=new Array(a);if(i)if(o<0)for(let l=0;l<a;++l)h[l]=(n-l)/-o;else for(let l=0;l<a;++l)h[l]=(n-l)*o;else if(o<0)for(let l=0;l<a;++l)h[l]=(s+l)/-o;else for(let l=0;l<a;++l)h[l]=(s+l)*o;return h}function Vc(r,t,e){return t=+t,r=+r,e=+e,yh(r,t,e)[2]}function Kc(r,t,e){t=+t,r=+r,e=+e;const i=t<r,s=i?Vc(t,r,e):Vc(r,t,e);return(i?-1:1)*(s<0?1/-s:s)}function Hc(r,t,e){r.prototype=t.prototype=e,e.constructor=r}function ry(r,t){var e=Object.create(r.prototype);for(var i in t)e[i]=t[i];return e}function go(){}var yo=.7,bh=1/yo,hn="\\s*([+-]?\\d+)\\s*",bo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Li="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",jC=/^#([0-9a-f]{3,8})$/,JC=new RegExp(`^rgb\\(${hn},${hn},${hn}\\)$`),$C=new RegExp(`^rgb\\(${Li},${Li},${Li}\\)$`),QC=new RegExp(`^rgba\\(${hn},${hn},${hn},${bo}\\)$`),qC=new RegExp(`^rgba\\(${Li},${Li},${Li},${bo}\\)$`),tI=new RegExp(`^hsl\\(${bo},${Li},${Li}\\)$`),eI=new RegExp(`^hsla\\(${bo},${Li},${Li},${bo}\\)$`),sy={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Hc(go,xo,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ny,formatHex:ny,formatHex8:iI,formatHsl:rI,formatRgb:oy,toString:oy});function ny(){return this.rgb().formatHex()}function iI(){return this.rgb().formatHex8()}function rI(){return cy(this).formatHsl()}function oy(){return this.rgb().formatRgb()}function xo(r){var t,e;return r=(r+"").trim().toLowerCase(),(t=jC.exec(r))?(e=t[1].length,t=parseInt(t[1],16),e===6?ay(t):e===3?new Ee(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):e===8?xh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):e===4?xh(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=JC.exec(r))?new Ee(t[1],t[2],t[3],1):(t=$C.exec(r))?new Ee(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=QC.exec(r))?xh(t[1],t[2],t[3],t[4]):(t=qC.exec(r))?xh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=tI.exec(r))?uy(t[1],t[2]/100,t[3]/100,1):(t=eI.exec(r))?uy(t[1],t[2]/100,t[3]/100,t[4]):sy.hasOwnProperty(r)?ay(sy[r]):r==="transparent"?new Ee(NaN,NaN,NaN,0):null}function ay(r){return new Ee(r>>16&255,r>>8&255,r&255,1)}function xh(r,t,e,i){return i<=0&&(r=t=e=NaN),new Ee(r,t,e,i)}function sI(r){return r instanceof go||(r=xo(r)),r?(r=r.rgb(),new Ee(r.r,r.g,r.b,r.opacity)):new Ee}function Yc(r,t,e,i){return arguments.length===1?sI(r):new Ee(r,t,e,i??1)}function Ee(r,t,e,i){this.r=+r,this.g=+t,this.b=+e,this.opacity=+i}Hc(Ee,Yc,ry(go,{brighter(r){return r=r==null?bh:Math.pow(bh,r),new Ee(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?yo:Math.pow(yo,r),new Ee(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new Ee(ys(this.r),ys(this.g),ys(this.b),_h(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:hy,formatHex:hy,formatHex8:nI,formatRgb:ly,toString:ly}));function hy(){return`#${bs(this.r)}${bs(this.g)}${bs(this.b)}`}function nI(){return`#${bs(this.r)}${bs(this.g)}${bs(this.b)}${bs((isNaN(this.opacity)?1:this.opacity)*255)}`}function ly(){const r=_h(this.opacity);return`${r===1?"rgb(":"rgba("}${ys(this.r)}, ${ys(this.g)}, ${ys(this.b)}${r===1?")":`, ${r})`}`}function _h(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function ys(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function bs(r){return r=ys(r),(r<16?"0":"")+r.toString(16)}function uy(r,t,e,i){return i<=0?r=t=e=NaN:e<=0||e>=1?r=t=NaN:t<=0&&(r=NaN),new ui(r,t,e,i)}function cy(r){if(r instanceof ui)return new ui(r.h,r.s,r.l,r.opacity);if(r instanceof go||(r=xo(r)),!r)return new ui;if(r instanceof ui)return r;r=r.rgb();var t=r.r/255,e=r.g/255,i=r.b/255,s=Math.min(t,e,i),n=Math.max(t,e,i),o=NaN,a=n-s,h=(n+s)/2;return a?(t===n?o=(e-i)/a+(e<i)*6:e===n?o=(i-t)/a+2:o=(t-e)/a+4,a/=h<.5?n+s:2-n-s,o*=60):a=h>0&&h<1?0:o,new ui(o,a,h,r.opacity)}function oI(r,t,e,i){return arguments.length===1?cy(r):new ui(r,t,e,i??1)}function ui(r,t,e,i){this.h=+r,this.s=+t,this.l=+e,this.opacity=+i}Hc(ui,oI,ry(go,{brighter(r){return r=r==null?bh:Math.pow(bh,r),new ui(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?yo:Math.pow(yo,r),new ui(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,t=isNaN(r)||isNaN(this.s)?0:this.s,e=this.l,i=e+(e<.5?e:1-e)*t,s=2*e-i;return new Ee(zc(r>=240?r-240:r+120,s,i),zc(r,s,i),zc(r<120?r+240:r-120,s,i),this.opacity)},clamp(){return new ui(dy(this.h),vh(this.s),vh(this.l),_h(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=_h(this.opacity);return`${r===1?"hsl(":"hsla("}${dy(this.h)}, ${vh(this.s)*100}%, ${vh(this.l)*100}%${r===1?")":`, ${r})`}`}}));function dy(r){return r=(r||0)%360,r<0?r+360:r}function vh(r){return Math.max(0,Math.min(1,r||0))}function zc(r,t,e){return(r<60?t+(e-t)*r/60:r<180?e:r<240?t+(e-t)*(240-r)/60:t)*255}const jc=r=>()=>r;function aI(r,t){return function(e){return r+e*t}}function hI(r,t,e){return r=Math.pow(r,e),t=Math.pow(t,e)-r,e=1/e,function(i){return Math.pow(r+i*t,e)}}function lI(r){return(r=+r)==1?py:function(t,e){return e-t?hI(t,e,r):jc(isNaN(t)?e:t)}}function py(r,t){var e=t-r;return e?aI(r,e):jc(isNaN(r)?t:r)}const fy=function r(t){var e=lI(t);function i(s,n){var o=e((s=Yc(s)).r,(n=Yc(n)).r),a=e(s.g,n.g),h=e(s.b,n.b),l=py(s.opacity,n.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=h(u),s.opacity=l(u),s+""}}return i.gamma=r,i}(1);function uI(r,t){t||(t=[]);var e=r?Math.min(t.length,r.length):0,i=t.slice(),s;return function(n){for(s=0;s<e;++s)i[s]=r[s]*(1-n)+t[s]*n;return i}}function cI(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function dI(r,t){var e=t?t.length:0,i=r?Math.min(e,r.length):0,s=new Array(i),n=new Array(e),o;for(o=0;o<i;++o)s[o]=Qc(r[o],t[o]);for(;o<e;++o)n[o]=t[o];return function(a){for(o=0;o<i;++o)n[o]=s[o](a);return n}}function pI(r,t){var e=new Date;return r=+r,t=+t,function(i){return e.setTime(r*(1-i)+t*i),e}}function Th(r,t){return r=+r,t=+t,function(e){return r*(1-e)+t*e}}function fI(r,t){var e={},i={},s;(r===null||typeof r!="object")&&(r={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in r?e[s]=Qc(r[s],t[s]):i[s]=t[s];return function(n){for(s in e)i[s]=e[s](n);return i}}var Jc=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$c=new RegExp(Jc.source,"g");function mI(r){return function(){return r}}function gI(r){return function(t){return r(t)+""}}function yI(r,t){var e=Jc.lastIndex=$c.lastIndex=0,i,s,n,o=-1,a=[],h=[];for(r=r+"",t=t+"";(i=Jc.exec(r))&&(s=$c.exec(t));)(n=s.index)>e&&(n=t.slice(e,n),a[o]?a[o]+=n:a[++o]=n),(i=i[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,h.push({i:o,x:Th(i,s)})),e=$c.lastIndex;return e<t.length&&(n=t.slice(e),a[o]?a[o]+=n:a[++o]=n),a.length<2?h[0]?gI(h[0].x):mI(t):(t=h.length,function(l){for(var u=0,c;u<t;++u)a[(c=h[u]).i]=c.x(l);return a.join("")})}function Qc(r,t){var e=typeof t,i;return t==null||e==="boolean"?jc(t):(e==="number"?Th:e==="string"?(i=xo(t))?(t=i,fy):yI:t instanceof xo?fy:t instanceof Date?pI:cI(t)?uI:Array.isArray(t)?dI:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?fI:Th)(r,t)}function bI(r,t){return r=+r,t=+t,function(e){return Math.round(r*(1-e)+t*e)}}function xI(r){return Math.abs(r=Math.round(r))>=1e21?r.toLocaleString("en").replace(/,/g,""):r.toString(10)}function wh(r,t){if((e=(r=t?r.toExponential(t-1):r.toExponential()).indexOf("e"))<0)return null;var e,i=r.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+r.slice(e+1)]}function ln(r){return r=wh(Math.abs(r)),r?r[1]:NaN}function _I(r,t){return function(e,i){for(var s=e.length,n=[],o=0,a=r[0],h=0;s>0&&a>0&&(h+a+1>i&&(a=Math.max(1,i-h)),n.push(e.substring(s-=a,s+a)),!((h+=a+1)>i));)a=r[o=(o+1)%r.length];return n.reverse().join(t)}}function vI(r){return function(t){return t.replace(/[0-9]/g,function(e){return r[+e]})}}var TI=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Sh(r){if(!(t=TI.exec(r)))throw new Error("invalid format: "+r);var t;return new qc({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Sh.prototype=qc.prototype;function qc(r){this.fill=r.fill===void 0?" ":r.fill+"",this.align=r.align===void 0?">":r.align+"",this.sign=r.sign===void 0?"-":r.sign+"",this.symbol=r.symbol===void 0?"":r.symbol+"",this.zero=!!r.zero,this.width=r.width===void 0?void 0:+r.width,this.comma=!!r.comma,this.precision=r.precision===void 0?void 0:+r.precision,this.trim=!!r.trim,this.type=r.type===void 0?"":r.type+""}qc.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function wI(r){t:for(var t=r.length,e=1,i=-1,s;e<t;++e)switch(r[e]){case".":i=s=e;break;case"0":i===0&&(i=e),s=e;break;default:if(!+r[e])break t;i>0&&(i=0);break}return i>0?r.slice(0,i)+r.slice(s+1):r}var my;function SI(r,t){var e=wh(r,t);if(!e)return r+"";var i=e[0],s=e[1],n=s-(my=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,o=i.length;return n===o?i:n>o?i+new Array(n-o+1).join("0"):n>0?i.slice(0,n)+"."+i.slice(n):"0."+new Array(1-n).join("0")+wh(r,Math.max(0,t+n-1))[0]}function gy(r,t){var e=wh(r,t);if(!e)return r+"";var i=e[0],s=e[1];return s<0?"0."+new Array(-s).join("0")+i:i.length>s+1?i.slice(0,s+1)+"."+i.slice(s+1):i+new Array(s-i.length+2).join("0")}const yy={"%":(r,t)=>(r*100).toFixed(t),b:r=>Math.round(r).toString(2),c:r=>r+"",d:xI,e:(r,t)=>r.toExponential(t),f:(r,t)=>r.toFixed(t),g:(r,t)=>r.toPrecision(t),o:r=>Math.round(r).toString(8),p:(r,t)=>gy(r*100,t),r:gy,s:SI,X:r=>Math.round(r).toString(16).toUpperCase(),x:r=>Math.round(r).toString(16)};function by(r){return r}var xy=Array.prototype.map,_y=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function EI(r){var t=r.grouping===void 0||r.thousands===void 0?by:_I(xy.call(r.grouping,Number),r.thousands+""),e=r.currency===void 0?"":r.currency[0]+"",i=r.currency===void 0?"":r.currency[1]+"",s=r.decimal===void 0?".":r.decimal+"",n=r.numerals===void 0?by:vI(xy.call(r.numerals,String)),o=r.percent===void 0?"%":r.percent+"",a=r.minus===void 0?"−":r.minus+"",h=r.nan===void 0?"NaN":r.nan+"";function l(c){c=Sh(c);var d=c.fill,p=c.align,m=c.sign,f=c.symbol,g=c.zero,y=c.width,_=c.comma,b=c.precision,v=c.trim,S=c.type;S==="n"?(_=!0,S="g"):yy[S]||(b===void 0&&(b=12),v=!0,S="g"),(g||d==="0"&&p==="=")&&(g=!0,d="0",p="=");var E=f==="$"?e:f==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",A=f==="$"?i:/[%p]/.test(S)?o:"",I=yy[S],P=/[defgprs%]/.test(S);b=b===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,b)):Math.max(0,Math.min(20,b));function B(G){var N=E,C=A,F,X,V;if(S==="c")C=I(G)+C,G="";else{G=+G;var L=G<0||1/G<0;if(G=isNaN(G)?h:I(Math.abs(G),b),v&&(G=wI(G)),L&&+G==0&&m!=="+"&&(L=!1),N=(L?m==="("?m:a:m==="-"||m==="("?"":m)+N,C=(S==="s"?_y[8+my/3]:"")+C+(L&&m==="("?")":""),P){for(F=-1,X=G.length;++F<X;)if(V=G.charCodeAt(F),48>V||V>57){C=(V===46?s+G.slice(F+1):G.slice(F))+C,G=G.slice(0,F);break}}}_&&!g&&(G=t(G,1/0));var k=N.length+G.length+C.length,K=k<y?new Array(y-k+1).join(d):"";switch(_&&g&&(G=t(K+G,K.length?y-C.length:1/0),K=""),p){case"<":G=N+G+C+K;break;case"=":G=N+K+G+C;break;case"^":G=K.slice(0,k=K.length>>1)+N+G+C+K.slice(k);break;default:G=K+N+G+C;break}return n(G)}return B.toString=function(){return c+""},B}function u(c,d){var p=l((c=Sh(c),c.type="f",c)),m=Math.max(-8,Math.min(8,Math.floor(ln(d)/3)))*3,f=Math.pow(10,-m),g=_y[8+m/3];return function(y){return p(f*y)+g}}return{format:l,formatPrefix:u}}var Eh,vy,Ty;CI({thousands:",",grouping:[3],currency:["$",""]});function CI(r){return Eh=EI(r),vy=Eh.format,Ty=Eh.formatPrefix,Eh}function II(r){return Math.max(0,-ln(Math.abs(r)))}function AI(r,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ln(t)/3)))*3-ln(Math.abs(r)))}function RI(r,t){return r=Math.abs(r),t=Math.abs(t)-r,Math.max(0,ln(t)-ln(r))+1}function wy(r,t){switch(arguments.length){case 0:break;case 1:this.range(r);break;default:this.range(t).domain(r);break}return this}function MI(r){return function(){return r}}function PI(r){return+r}var Sy=[0,1];function un(r){return r}function td(r,t){return(t-=r=+r)?function(e){return(e-r)/t}:MI(isNaN(t)?NaN:.5)}function LI(r,t){var e;return r>t&&(e=r,r=t,t=e),function(i){return Math.max(r,Math.min(t,i))}}function GI(r,t,e){var i=r[0],s=r[1],n=t[0],o=t[1];return s<i?(i=td(s,i),n=e(o,n)):(i=td(i,s),n=e(n,o)),function(a){return n(i(a))}}function NI(r,t,e){var i=Math.min(r.length,t.length)-1,s=new Array(i),n=new Array(i),o=-1;for(r[i]<r[0]&&(r=r.slice().reverse(),t=t.slice().reverse());++o<i;)s[o]=td(r[o],r[o+1]),n[o]=e(t[o],t[o+1]);return function(a){var h=VC(r,a,1,i)-1;return n[h](s[h](a))}}function Ey(r,t){return t.domain(r.domain()).range(r.range()).interpolate(r.interpolate()).clamp(r.clamp()).unknown(r.unknown())}function FI(){var r=Sy,t=Sy,e=Qc,i,s,n,o=un,a,h,l;function u(){var d=Math.min(r.length,t.length);return o!==un&&(o=LI(r[0],r[d-1])),a=d>2?NI:GI,h=l=null,c}function c(d){return d==null||isNaN(d=+d)?n:(h||(h=a(r.map(i),t,e)))(i(o(d)))}return c.invert=function(d){return o(s((l||(l=a(t,r.map(i),Th)))(d)))},c.domain=function(d){return arguments.length?(r=Array.from(d,PI),u()):r.slice()},c.range=function(d){return arguments.length?(t=Array.from(d),u()):t.slice()},c.rangeRound=function(d){return t=Array.from(d),e=bI,u()},c.clamp=function(d){return arguments.length?(o=d?!0:un,u()):o!==un},c.interpolate=function(d){return arguments.length?(e=d,u()):e},c.unknown=function(d){return arguments.length?(n=d,c):n},function(d,p){return i=d,s=p,u()}}function Cy(){return FI()(un,un)}function DI(r,t,e,i){var s=Kc(r,t,e),n;switch(i=Sh(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(r),Math.abs(t));return i.precision==null&&!isNaN(n=AI(s,o))&&(i.precision=n),Ty(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(n=RI(s,Math.max(Math.abs(r),Math.abs(t))))&&(i.precision=n-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(n=II(s))&&(i.precision=n-(i.type==="%")*2);break}}return vy(i)}function kI(r){var t=r.domain;return r.ticks=function(e){var i=t();return zC(i[0],i[i.length-1],e??10)},r.tickFormat=function(e,i){var s=t();return DI(s[0],s[s.length-1],e??10,i)},r.nice=function(e){e==null&&(e=10);var i=t(),s=0,n=i.length-1,o=i[s],a=i[n],h,l,u=10;for(a<o&&(l=o,o=a,a=l,l=s,s=n,n=l);u-- >0;){if(l=Vc(o,a,e),l===h)return i[s]=o,i[n]=a,t(i);if(l>0)o=Math.floor(o/l)*l,a=Math.ceil(a/l)*l;else if(l<0)o=Math.ceil(o*l)/l,a=Math.floor(a*l)/l;else break;h=l}return r},r}function Iy(){var r=Cy();return r.copy=function(){return Ey(r,Iy())},wy.apply(r,arguments),kI(r)}function OI(r,t){r=r.slice();var e=0,i=r.length-1,s=r[e],n=r[i],o;return n<s&&(o=e,e=i,i=o,o=s,s=n,n=o),r[e]=t.floor(s),r[i]=t.ceil(n),r}const ed=new Date,id=new Date;function $t(r,t,e,i){function s(n){return r(n=arguments.length===0?new Date:new Date(+n)),n}return s.floor=n=>(r(n=new Date(+n)),n),s.ceil=n=>(r(n=new Date(n-1)),t(n,1),r(n),n),s.round=n=>{const o=s(n),a=s.ceil(n);return n-o<a-n?o:a},s.offset=(n,o)=>(t(n=new Date(+n),o==null?1:Math.floor(o)),n),s.range=(n,o,a)=>{const h=[];if(n=s.ceil(n),a=a==null?1:Math.floor(a),!(n<o)||!(a>0))return h;let l;do h.push(l=new Date(+n)),t(n,a),r(n);while(l<n&&n<o);return h},s.filter=n=>$t(o=>{if(o>=o)for(;r(o),!n(o);)o.setTime(o-1)},(o,a)=>{if(o>=o)if(a<0)for(;++a<=0;)for(;t(o,-1),!n(o););else for(;--a>=0;)for(;t(o,1),!n(o););}),e&&(s.count=(n,o)=>(ed.setTime(+n),id.setTime(+o),r(ed),r(id),Math.floor(e(ed,id))),s.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?s.filter(i?o=>i(o)%n===0:o=>s.count(0,o)%n===0):s)),s}const Ch=$t(()=>{},(r,t)=>{r.setTime(+r+t)},(r,t)=>t-r);Ch.every=r=>(r=Math.floor(r),!isFinite(r)||!(r>0)?null:r>1?$t(t=>{t.setTime(Math.floor(t/r)*r)},(t,e)=>{t.setTime(+t+e*r)},(t,e)=>(e-t)/r):Ch),Ch.range;const or=1e3,je=or*60,ar=je*60,hr=ar*24,rd=hr*7,Ay=hr*30,sd=hr*365,cn=$t(r=>{r.setTime(r-r.getMilliseconds())},(r,t)=>{r.setTime(+r+t*or)},(r,t)=>(t-r)/or,r=>r.getUTCSeconds());cn.range;const nd=$t(r=>{r.setTime(r-r.getMilliseconds()-r.getSeconds()*or)},(r,t)=>{r.setTime(+r+t*je)},(r,t)=>(t-r)/je,r=>r.getMinutes());nd.range,$t(r=>{r.setUTCSeconds(0,0)},(r,t)=>{r.setTime(+r+t*je)},(r,t)=>(t-r)/je,r=>r.getUTCMinutes()).range;const od=$t(r=>{r.setTime(r-r.getMilliseconds()-r.getSeconds()*or-r.getMinutes()*je)},(r,t)=>{r.setTime(+r+t*ar)},(r,t)=>(t-r)/ar,r=>r.getHours());od.range,$t(r=>{r.setUTCMinutes(0,0,0)},(r,t)=>{r.setTime(+r+t*ar)},(r,t)=>(t-r)/ar,r=>r.getUTCHours()).range;const _o=$t(r=>r.setHours(0,0,0,0),(r,t)=>r.setDate(r.getDate()+t),(r,t)=>(t-r-(t.getTimezoneOffset()-r.getTimezoneOffset())*je)/hr,r=>r.getDate()-1);_o.range;const ad=$t(r=>{r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCDate(r.getUTCDate()+t)},(r,t)=>(t-r)/hr,r=>r.getUTCDate()-1);ad.range,$t(r=>{r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCDate(r.getUTCDate()+t)},(r,t)=>(t-r)/hr,r=>Math.floor(r/hr)).range;function xs(r){return $t(t=>{t.setDate(t.getDate()-(t.getDay()+7-r)%7),t.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+e*7)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*je)/rd)}const Ih=xs(0),Ah=xs(1),WI=xs(2),BI=xs(3),dn=xs(4),UI=xs(5),XI=xs(6);Ih.range,Ah.range,WI.range,BI.range,dn.range,UI.range,XI.range;function _s(r){return $t(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-r)%7),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e*7)},(t,e)=>(e-t)/rd)}const Ry=_s(0),Rh=_s(1),ZI=_s(2),VI=_s(3),pn=_s(4),KI=_s(5),HI=_s(6);Ry.range,Rh.range,ZI.range,VI.range,pn.range,KI.range,HI.range;const hd=$t(r=>{r.setDate(1),r.setHours(0,0,0,0)},(r,t)=>{r.setMonth(r.getMonth()+t)},(r,t)=>t.getMonth()-r.getMonth()+(t.getFullYear()-r.getFullYear())*12,r=>r.getMonth());hd.range,$t(r=>{r.setUTCDate(1),r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCMonth(r.getUTCMonth()+t)},(r,t)=>t.getUTCMonth()-r.getUTCMonth()+(t.getUTCFullYear()-r.getUTCFullYear())*12,r=>r.getUTCMonth()).range;const lr=$t(r=>{r.setMonth(0,1),r.setHours(0,0,0,0)},(r,t)=>{r.setFullYear(r.getFullYear()+t)},(r,t)=>t.getFullYear()-r.getFullYear(),r=>r.getFullYear());lr.every=r=>!isFinite(r=Math.floor(r))||!(r>0)?null:$t(t=>{t.setFullYear(Math.floor(t.getFullYear()/r)*r),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e*r)}),lr.range;const vs=$t(r=>{r.setUTCMonth(0,1),r.setUTCHours(0,0,0,0)},(r,t)=>{r.setUTCFullYear(r.getUTCFullYear()+t)},(r,t)=>t.getUTCFullYear()-r.getUTCFullYear(),r=>r.getUTCFullYear());vs.every=r=>!isFinite(r=Math.floor(r))||!(r>0)?null:$t(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/r)*r),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e*r)}),vs.range;function YI(r,t,e,i,s,n){const o=[[cn,1,or],[cn,5,5*or],[cn,15,15*or],[cn,30,30*or],[n,1,je],[n,5,5*je],[n,15,15*je],[n,30,30*je],[s,1,ar],[s,3,3*ar],[s,6,6*ar],[s,12,12*ar],[i,1,hr],[i,2,2*hr],[e,1,rd],[t,1,Ay],[t,3,3*Ay],[r,1,sd]];function a(l,u,c){const d=u<l;d&&([l,u]=[u,l]);const p=c&&typeof c.range=="function"?c:h(l,u,c),m=p?p.range(l,+u+1):[];return d?m.reverse():m}function h(l,u,c){const d=Math.abs(u-l)/c,p=Zc(([,,g])=>g).right(o,d);if(p===o.length)return r.every(Kc(l/sd,u/sd,c));if(p===0)return Ch.every(Math.max(Kc(l,u,c),1));const[m,f]=o[d/o[p-1][2]<o[p][2]/d?p-1:p];return m.every(f)}return[a,h]}const[zI,jI]=YI(lr,hd,Ih,_o,od,nd);function ld(r){if(0<=r.y&&r.y<100){var t=new Date(-1,r.m,r.d,r.H,r.M,r.S,r.L);return t.setFullYear(r.y),t}return new Date(r.y,r.m,r.d,r.H,r.M,r.S,r.L)}function ud(r){if(0<=r.y&&r.y<100){var t=new Date(Date.UTC(-1,r.m,r.d,r.H,r.M,r.S,r.L));return t.setUTCFullYear(r.y),t}return new Date(Date.UTC(r.y,r.m,r.d,r.H,r.M,r.S,r.L))}function vo(r,t,e){return{y:r,m:t,d:e,H:0,M:0,S:0,L:0}}function JI(r){var t=r.dateTime,e=r.date,i=r.time,s=r.periods,n=r.days,o=r.shortDays,a=r.months,h=r.shortMonths,l=To(s),u=wo(s),c=To(n),d=wo(n),p=To(o),m=wo(o),f=To(a),g=wo(a),y=To(h),_=wo(h),b={a:L,A:k,b:K,B:D,c:null,d:Fy,e:Fy,f:xA,g:RA,G:PA,H:gA,I:yA,j:bA,L:Dy,m:_A,M:vA,p:U,q:j,Q:Xy,s:Zy,S:TA,u:wA,U:SA,V:EA,w:CA,W:IA,x:null,X:null,y:AA,Y:MA,Z:LA,"%":Uy},v={a:q,A:pt,b:nt,B:Et,c:null,d:Oy,e:Oy,f:DA,g:HA,G:zA,H:GA,I:NA,j:FA,L:Wy,m:kA,M:OA,p:Rt,q:wt,Q:Xy,s:Zy,S:WA,u:BA,U:UA,V:XA,w:ZA,W:VA,x:null,X:null,y:KA,Y:YA,Z:jA,"%":Uy},S={a:B,A:G,b:N,B:C,c:F,d:Gy,e:Gy,f:dA,g:Ly,G:Py,H:Ny,I:Ny,j:hA,L:cA,m:aA,M:lA,p:P,q:oA,Q:fA,s:mA,S:uA,u:eA,U:iA,V:rA,w:tA,W:sA,x:X,X:V,y:Ly,Y:Py,Z:nA,"%":pA};b.x=E(e,b),b.X=E(i,b),b.c=E(t,b),v.x=E(e,v),v.X=E(i,v),v.c=E(t,v);function E(Y,it){return function(tt){var O=[],bt=-1,gt=0,Mt=Y.length,Ut,Ne,ci;for(tt instanceof Date||(tt=new Date(+tt));++bt<Mt;)Y.charCodeAt(bt)===37&&(O.push(Y.slice(gt,bt)),(Ne=My[Ut=Y.charAt(++bt)])!=null?Ut=Y.charAt(++bt):Ne=Ut==="e"?" ":"0",(ci=it[Ut])&&(Ut=ci(tt,Ne)),O.push(Ut),gt=bt+1);return O.push(Y.slice(gt,bt)),O.join("")}}function A(Y,it){return function(tt){var O=vo(1900,void 0,1),bt=I(O,Y,tt+="",0),gt,Mt;if(bt!=tt.length)return null;if("Q"in O)return new Date(O.Q);if("s"in O)return new Date(O.s*1e3+("L"in O?O.L:0));if(it&&!("Z"in O)&&(O.Z=0),"p"in O&&(O.H=O.H%12+O.p*12),O.m===void 0&&(O.m="q"in O?O.q:0),"V"in O){if(O.V<1||O.V>53)return null;"w"in O||(O.w=1),"Z"in O?(gt=ud(vo(O.y,0,1)),Mt=gt.getUTCDay(),gt=Mt>4||Mt===0?Rh.ceil(gt):Rh(gt),gt=ad.offset(gt,(O.V-1)*7),O.y=gt.getUTCFullYear(),O.m=gt.getUTCMonth(),O.d=gt.getUTCDate()+(O.w+6)%7):(gt=ld(vo(O.y,0,1)),Mt=gt.getDay(),gt=Mt>4||Mt===0?Ah.ceil(gt):Ah(gt),gt=_o.offset(gt,(O.V-1)*7),O.y=gt.getFullYear(),O.m=gt.getMonth(),O.d=gt.getDate()+(O.w+6)%7)}else("W"in O||"U"in O)&&("w"in O||(O.w="u"in O?O.u%7:"W"in O?1:0),Mt="Z"in O?ud(vo(O.y,0,1)).getUTCDay():ld(vo(O.y,0,1)).getDay(),O.m=0,O.d="W"in O?(O.w+6)%7+O.W*7-(Mt+5)%7:O.w+O.U*7-(Mt+6)%7);return"Z"in O?(O.H+=O.Z/100|0,O.M+=O.Z%100,ud(O)):ld(O)}}function I(Y,it,tt,O){for(var bt=0,gt=it.length,Mt=tt.length,Ut,Ne;bt<gt;){if(O>=Mt)return-1;if(Ut=it.charCodeAt(bt++),Ut===37){if(Ut=it.charAt(bt++),Ne=S[Ut in My?it.charAt(bt++):Ut],!Ne||(O=Ne(Y,tt,O))<0)return-1}else if(Ut!=tt.charCodeAt(O++))return-1}return O}function P(Y,it,tt){var O=l.exec(it.slice(tt));return O?(Y.p=u.get(O[0].toLowerCase()),tt+O[0].length):-1}function B(Y,it,tt){var O=p.exec(it.slice(tt));return O?(Y.w=m.get(O[0].toLowerCase()),tt+O[0].length):-1}function G(Y,it,tt){var O=c.exec(it.slice(tt));return O?(Y.w=d.get(O[0].toLowerCase()),tt+O[0].length):-1}function N(Y,it,tt){var O=y.exec(it.slice(tt));return O?(Y.m=_.get(O[0].toLowerCase()),tt+O[0].length):-1}function C(Y,it,tt){var O=f.exec(it.slice(tt));return O?(Y.m=g.get(O[0].toLowerCase()),tt+O[0].length):-1}function F(Y,it,tt){return I(Y,t,it,tt)}function X(Y,it,tt){return I(Y,e,it,tt)}function V(Y,it,tt){return I(Y,i,it,tt)}function L(Y){return o[Y.getDay()]}function k(Y){return n[Y.getDay()]}function K(Y){return h[Y.getMonth()]}function D(Y){return a[Y.getMonth()]}function U(Y){return s[+(Y.getHours()>=12)]}function j(Y){return 1+~~(Y.getMonth()/3)}function q(Y){return o[Y.getUTCDay()]}function pt(Y){return n[Y.getUTCDay()]}function nt(Y){return h[Y.getUTCMonth()]}function Et(Y){return a[Y.getUTCMonth()]}function Rt(Y){return s[+(Y.getUTCHours()>=12)]}function wt(Y){return 1+~~(Y.getUTCMonth()/3)}return{format:function(Y){var it=E(Y+="",b);return it.toString=function(){return Y},it},parse:function(Y){var it=A(Y+="",!1);return it.toString=function(){return Y},it},utcFormat:function(Y){var it=E(Y+="",v);return it.toString=function(){return Y},it},utcParse:function(Y){var it=A(Y+="",!0);return it.toString=function(){return Y},it}}}var My={"-":"",_:" ",0:"0"},se=/^\s*\d+/,$I=/^%/,QI=/[\\^$*+?|[\]().{}]/g;function It(r,t,e){var i=r<0?"-":"",s=(i?-r:r)+"",n=s.length;return i+(n<e?new Array(e-n+1).join(t)+s:s)}function qI(r){return r.replace(QI,"\\$&")}function To(r){return new RegExp("^(?:"+r.map(qI).join("|")+")","i")}function wo(r){return new Map(r.map((t,e)=>[t.toLowerCase(),e]))}function tA(r,t,e){var i=se.exec(t.slice(e,e+1));return i?(r.w=+i[0],e+i[0].length):-1}function eA(r,t,e){var i=se.exec(t.slice(e,e+1));return i?(r.u=+i[0],e+i[0].length):-1}function iA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.U=+i[0],e+i[0].length):-1}function rA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.V=+i[0],e+i[0].length):-1}function sA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.W=+i[0],e+i[0].length):-1}function Py(r,t,e){var i=se.exec(t.slice(e,e+4));return i?(r.y=+i[0],e+i[0].length):-1}function Ly(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.y=+i[0]+(+i[0]>68?1900:2e3),e+i[0].length):-1}function nA(r,t,e){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(e,e+6));return i?(r.Z=i[1]?0:-(i[2]+(i[3]||"00")),e+i[0].length):-1}function oA(r,t,e){var i=se.exec(t.slice(e,e+1));return i?(r.q=i[0]*3-3,e+i[0].length):-1}function aA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.m=i[0]-1,e+i[0].length):-1}function Gy(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.d=+i[0],e+i[0].length):-1}function hA(r,t,e){var i=se.exec(t.slice(e,e+3));return i?(r.m=0,r.d=+i[0],e+i[0].length):-1}function Ny(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.H=+i[0],e+i[0].length):-1}function lA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.M=+i[0],e+i[0].length):-1}function uA(r,t,e){var i=se.exec(t.slice(e,e+2));return i?(r.S=+i[0],e+i[0].length):-1}function cA(r,t,e){var i=se.exec(t.slice(e,e+3));return i?(r.L=+i[0],e+i[0].length):-1}function dA(r,t,e){var i=se.exec(t.slice(e,e+6));return i?(r.L=Math.floor(i[0]/1e3),e+i[0].length):-1}function pA(r,t,e){var i=$I.exec(t.slice(e,e+1));return i?e+i[0].length:-1}function fA(r,t,e){var i=se.exec(t.slice(e));return i?(r.Q=+i[0],e+i[0].length):-1}function mA(r,t,e){var i=se.exec(t.slice(e));return i?(r.s=+i[0],e+i[0].length):-1}function Fy(r,t){return It(r.getDate(),t,2)}function gA(r,t){return It(r.getHours(),t,2)}function yA(r,t){return It(r.getHours()%12||12,t,2)}function bA(r,t){return It(1+_o.count(lr(r),r),t,3)}function Dy(r,t){return It(r.getMilliseconds(),t,3)}function xA(r,t){return Dy(r,t)+"000"}function _A(r,t){return It(r.getMonth()+1,t,2)}function vA(r,t){return It(r.getMinutes(),t,2)}function TA(r,t){return It(r.getSeconds(),t,2)}function wA(r){var t=r.getDay();return t===0?7:t}function SA(r,t){return It(Ih.count(lr(r)-1,r),t,2)}function ky(r){var t=r.getDay();return t>=4||t===0?dn(r):dn.ceil(r)}function EA(r,t){return r=ky(r),It(dn.count(lr(r),r)+(lr(r).getDay()===4),t,2)}function CA(r){return r.getDay()}function IA(r,t){return It(Ah.count(lr(r)-1,r),t,2)}function AA(r,t){return It(r.getFullYear()%100,t,2)}function RA(r,t){return r=ky(r),It(r.getFullYear()%100,t,2)}function MA(r,t){return It(r.getFullYear()%1e4,t,4)}function PA(r,t){var e=r.getDay();return r=e>=4||e===0?dn(r):dn.ceil(r),It(r.getFullYear()%1e4,t,4)}function LA(r){var t=r.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+It(t/60|0,"0",2)+It(t%60,"0",2)}function Oy(r,t){return It(r.getUTCDate(),t,2)}function GA(r,t){return It(r.getUTCHours(),t,2)}function NA(r,t){return It(r.getUTCHours()%12||12,t,2)}function FA(r,t){return It(1+ad.count(vs(r),r),t,3)}function Wy(r,t){return It(r.getUTCMilliseconds(),t,3)}function DA(r,t){return Wy(r,t)+"000"}function kA(r,t){return It(r.getUTCMonth()+1,t,2)}function OA(r,t){return It(r.getUTCMinutes(),t,2)}function WA(r,t){return It(r.getUTCSeconds(),t,2)}function BA(r){var t=r.getUTCDay();return t===0?7:t}function UA(r,t){return It(Ry.count(vs(r)-1,r),t,2)}function By(r){var t=r.getUTCDay();return t>=4||t===0?pn(r):pn.ceil(r)}function XA(r,t){return r=By(r),It(pn.count(vs(r),r)+(vs(r).getUTCDay()===4),t,2)}function ZA(r){return r.getUTCDay()}function VA(r,t){return It(Rh.count(vs(r)-1,r),t,2)}function KA(r,t){return It(r.getUTCFullYear()%100,t,2)}function HA(r,t){return r=By(r),It(r.getUTCFullYear()%100,t,2)}function YA(r,t){return It(r.getUTCFullYear()%1e4,t,4)}function zA(r,t){var e=r.getUTCDay();return r=e>=4||e===0?pn(r):pn.ceil(r),It(r.getUTCFullYear()%1e4,t,4)}function jA(){return"+0000"}function Uy(){return"%"}function Xy(r){return+r}function Zy(r){return Math.floor(+r/1e3)}var fn,Vy;JA({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function JA(r){return fn=JI(r),Vy=fn.format,fn.parse,fn.utcFormat,fn.utcParse,fn}function $A(r){return new Date(r)}function QA(r){return r instanceof Date?+r:+new Date(+r)}function Ky(r,t,e,i,s,n,o,a,h,l){var u=Cy(),c=u.invert,d=u.domain,p=l(".%L"),m=l(":%S"),f=l("%I:%M"),g=l("%I %p"),y=l("%a %d"),_=l("%b %d"),b=l("%B"),v=l("%Y");function S(E){return(h(E)<E?p:a(E)<E?m:o(E)<E?f:n(E)<E?g:i(E)<E?s(E)<E?y:_:e(E)<E?b:v)(E)}return u.invert=function(E){return new Date(c(E))},u.domain=function(E){return arguments.length?d(Array.from(E,QA)):d().map($A)},u.ticks=function(E){var A=d();return r(A[0],A[A.length-1],E??10)},u.tickFormat=function(E,A){return A==null?S:l(A)},u.nice=function(E){var A=d();return(!E||typeof E.range!="function")&&(E=t(A[0],A[A.length-1],E??10)),E?d(OI(A,E)):u},u.copy=function(){return Ey(u,Ky(r,t,e,i,s,n,o,a,h,l))},u}function qA(){return wy.apply(Ky(zI,jI,lr,hd,Ih,_o,od,nd,cn,Vy).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function So(r,t,e){this.k=r,this.x=t,this.y=e}So.prototype={constructor:So,scale:function(r){return r===1?this:new So(this.k*r,this.x,this.y)},translate:function(r,t){return r===0&t===0?this:new So(this.k,this.x+this.k*r,this.y+this.k*t)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},So.prototype;function Hy(r){return r.mode==="temporal"||r.mode==="left-aligned"?tR(r):eR(r)}function tR({domain:r,range:t}){return qA().domain(r).range(t)}function eR({domain:r,range:t}){return Iy().domain(r).range(t)}function cd(r){return{mode:dt.horizontal,range:lM(),domain:uM(r)}}function iR(){return{mode:dt.vertical}}let mn=null;async function rR(){const r=await Sd();Yy(r.start_time),xt.on("layoutSettingsUpdated",()=>Yy(r.start_time))}function sR(){mn=null}async function Eo(){return mn||await Oe("scaleCreated")}async function Yy(r){await Di();const t=mn?"scaleUpdated":"scaleCreated",e=cd(r);mn=Hy(e),xt.emit(t,mn)}let Ge=null,dd=null;async function nR(){const r=await li(),t=await Xc();Ge=new WC({screenHeight:t.clientHeight,screenWidth:t.clientWidth,events:r.renderer.events,passiveWheel:!1}),Ge.zIndex=1,Ge.drag().pinch().wheel({trackpadPinch:!0}).decelerate({friction:.9}).clampZoom({minWidth:t.clientWidth/2}),r.stage.addChild(Ge),xt.emit("viewportCreated",Ge),xt.on("applicationResized",uR),xt.on("scaleUpdated",()=>Mh()),hR()}function oR(){Ge=null,dd=null}async function pd({animate:r}={}){const t=await Je(),e=await ge(),i=t.getChildByName(yp);if(!i)throw new Error("Nodes container not found");const s=e.styles.guideTextSize+e.styles.guideTextTopPadding;pR();const{x:n,y:o,width:a,height:h}=i.getLocalBounds(),l=a+e.styles.columnGap*2,u=h+e.styles.rowGap*2+s*2,c=t.findFit(l,u);!a||!h||t.animate({position:{x:n+a/2,y:o+h/2-s},scale:Math.min(c,1),time:r?e.animationDuration:0,ease:"easeInOutQuad",removeOnInterrupt:!0,callbackOnComplete:()=>{fd(),Mh()}})}async function Je(){return Ge||await Oe("viewportCreated")}function zy(r){ty(dd,r)||(dd=r,xt.emit("viewportDateRangeUpdated",r))}function aR({xOffset:r,yOffset:t}){if(!Ge)return;const{x:e,y:i}=Ge.transform.position;Ge.setTransform(e+r,i+t,Ge.transform.scale.x,Ge.transform.scale.y)}async function hR(){const r=await Je();Mh(),r.on("moved",()=>Mh())}async function Mh(){const r=await jy();r&&zy(r)}async function jy(){const r=await Je(),t=await Eo(),e=t.invert(r.left),i=t.invert(r.right);return e instanceof Date&&i instanceof Date?[e,i]:null}async function lR(r){const t=await jy(),e=await Di();if(r===void 0||e.isDependency()||ty(r,t))return;const i=await Je(),s=await Eo(),[n,o]=r,a=s(n),h=s(o),l=a+(h-a)/2;zy(r),i.fitWidth(h-a,!0),i.moveCenter(l,i.center.y)}async function uR(){const r=await li(),t=await Je(),e=await Xc(),i=t.screenWidth,s=t.screenHeight,n=e.clientWidth,o=e.clientHeight,a=(n-i)/2,h=(o-s)/2;t.resize(r.screen.width,r.screen.height),aR({xOffset:a,yOffset:h})}class Jy{constructor(){lp(this,"status","visible");lp(this,"labels",new Set)}get visible(){return this.status==="visible"}get hidden(){return this.status==="hidden"}show(){if(this.status!=="visible"){for(const t of this.labels)t.visible=!0;this.status="visible"}}hide(){if(this.status!=="hidden"){for(const t of this.labels)t.visible=!1;this.status="hidden"}}toggle(t){t?this.show():this.hide()}add(t){this.labels.add(t),t.visible=this.visible}clear(){this.labels.clear()}}let Gi=null,Ni=null,Fi=null;async function cR(){const r=await Je(),t=await li();Gi=new eC({toggle:"renderable"}),Ni=new Jy,Fi=new Jy,t.ticker.add(()=>{if(r.dirty){const e=r.scale.x>.1,i=r.scale.x>.2;Fi==null||Fi.toggle(e),Ni==null||Ni.toggle(i),Gi==null||Gi.cull(t.renderer.screen),r.dirty=!1}}),xt.emit("cullCreated",Gi)}function dR(){Gi=null,Ni==null||Ni.clear(),Ni=null,Fi==null||Fi.clear(),Fi=null}async function fd(){const r=await Je();r.dirty=!0}function pR(){Gi&&Gi.uncull()}async function $y(){return Gi||await Oe("cullCreated")}async function fR(){return Fi||await Oe("edgeCullCreated")}async function mR(){return Ni||await Oe("labelCullCreated")}async function Qy(){const r=await Di(),t=await ge();function e(i,s,n){const a=r.disableAnimations||n?0:t.animationDuration/1e3;return Q0.to(i,{...s,duration:a,ease:"power1.out",onUpdate:()=>{fd()}})}return{animate:e}}let md=[];function gR(){md.forEach(r=>r.unsubscribe()),md=[]}async function gd(r,t){const e=Zi.useSubscription(r,t);return md.push(e),await e.promise(),e.response}async function yR({size:r,stroke:t=1,radius:e=0}){const i=await li(),s=new qn;return s.lineStyle(t,"#fff",1,0),s.drawRoundedRect(0,0,r*2,r*2,e),i.renderer.generateTexture(s,{region:new ct(0,0,r,r),resolution:10})}async function qy(r){return await gd(yR,[r])}var Ph=(r=>(r[r.Up=0]="Up",r[r.Down=180]="Down",r[r.Left=270]="Left",r[r.Right=90]="Right",r))(Ph||{});function tb(){const r=new ie;async function t(e){const{rotate:i=0}=e,s={size:e.size,radius:e.radius,stroke:e.stroke},n=await qy(s);return r.texture=n,r.anchor.set(.5,.5),r.angle=45+i,r}return{element:r,render:t}}async function bR(){const r=await li(),t=new qn;return t.beginFill("#fff"),t.drawRect(0,0,1,1),t.endFill(),r.renderer.generateTexture(t)}async function yd(){return await gd(bR,[])}function bd(r,t){return Array.from({length:r},(e,i)=>t(i))}const xR=8,_R=2;async function vR(){const r=await ge(),t=await $y(),e=await fR(),{animate:i}=await Qy(),s=new Xt,{element:n,render:o}=await tb(),a=await yd(),h=bd(20,()=>new lt),l=new uS(a,h);let u=!1;s.name=Ib,s.addChild(n),s.addChild(l),t.addAll([n,l]),e.add(s);async function c(){return await o({size:10,rotate:Ph.Right}),n.tint=r.styles.edgeColor,l.tint=r.styles.edgeColor,s}async function d(m,f){const g=p(f);u||await c();for(const[y,_]of h.entries()){const{x:b,y:v}=g[y];i(_,{x:b,y:v},!u)}i(s,{x:m.x,y:m.y},!u),i(n,{x:f.x-xR,y:f.y},!u),u=!0}function p({x:m,y:f}){const g=[],y={x:0,y:0},_={x:m-_R,y:f},b={x:eb(y.x,{source:y,target:_}),y:y.y},v={x:eb(_.x,{source:y,target:_},!0),y:_.y};for(const[S]of h.entries()){if(S===h.length-1){g[S]=_;continue}const E=TR(S,{source:y,target:_,sourceBezier:b,targetBezier:v});g[S]=E}return g}return{element:s,render:c,setPosition:d}}function eb(r,{source:t,target:e},i){const s=(e.x-t.x)/2;return r+(s>64?s:64)*(i?-1:1)}function TR(r,t){const e=r/20,{source:i,target:s,sourceBezier:n,targetBezier:o}=t,a=i.x+(n.x-i.x)*e,h=i.y+(n.y-i.y)*e,l=n.x+(o.x-n.x)*e,u=n.y+(o.y-n.y)*e,c=o.x+(s.x-o.x)*e,d=o.y+(s.y-o.y)*e,p=a+(l-a)*e,m=h+(u-h)*e,f=l+(c-l)*e,g=u+(d-u)*e,y=p+(f-p)*e,_=m+(g-m)*e;return{x:y,y:_}}function xd(){const r=new Xt,t=new ie,e=new ie,i=new ie,s=new ie,n=new ie,o=new ie,a=new ie,h=new ie;t.name="border-corner-top-left",e.name="border-corner-top-right",i.name="border-corner-bottom-left",s.name="border-corner-bottom-right",n.name="border-corner-left",o.name="border-corner-right",a.name="border-corner-top",h.name="border-corner-bottom",e.anchor.x=1,e.scale.x=-1,i.anchor.y=1,i.scale.y=-1,s.anchor.x=1,s.scale.x=-1,s.anchor.y=1,s.scale.y=-1,r.addChild(t),r.addChild(e),r.addChild(i),r.addChild(s),r.addChild(n),r.addChild(o),r.addChild(a),r.addChild(h);async function l(p){const{radius:m=0,color:f="#fff",stroke:g,width:y,height:_}=p,b=Math.min(y,_),v=m*2>b?b/2:m,E=await qy({size:v,radius:m,stroke:g}),A=await yd();return u({texture:E,width:y,height:_,size:v}),c({texture:A,width:y,height:_,size:v,stroke:g}),d(f),r}function u({texture:p,width:m,height:f,size:g}){t.texture=p,e.texture=p,i.texture=p,s.texture=p,t.position.set(0,0),e.position.set(m-g,0),i.position.set(0,f-g),s.position.set(m-g,f-g)}function c({texture:p,size:m,width:f,height:g,stroke:y}){const _=Math.max(g-m*2,0),b=Math.max(f-m*2,0);a.texture=p,n.texture=p,o.texture=p,h.texture=p,n.position.set(0,m),n.height=_,n.width=y,o.position.set(f-y,m),o.height=_,o.width=y,a.position.set(m,0),a.width=b,a.height=y,h.position.set(m,g-y),h.width=b,h.height=y}function d(p){t.tint=p,e.tint=p,i.tint=p,s.tint=p,a.tint=p,n.tint=p,o.tint=p,h.tint=p}return{element:r,render:l}}var ib={exports:{}};(function(r){(function(){function t(f,g){document.addEventListener?f.addEventListener("scroll",g,!1):f.attachEvent("scroll",g)}function e(f){document.body?f():document.addEventListener?document.addEventListener("DOMContentLoaded",function g(){document.removeEventListener("DOMContentLoaded",g),f()}):document.attachEvent("onreadystatechange",function g(){(document.readyState=="interactive"||document.readyState=="complete")&&(document.detachEvent("onreadystatechange",g),f())})}function i(f){this.g=document.createElement("div"),this.g.setAttribute("aria-hidden","true"),this.g.appendChild(document.createTextNode(f)),this.h=document.createElement("span"),this.i=document.createElement("span"),this.m=document.createElement("span"),this.j=document.createElement("span"),this.l=-1,this.h.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.i.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.j.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.m.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.h.appendChild(this.m),this.i.appendChild(this.j),this.g.appendChild(this.h),this.g.appendChild(this.i)}function s(f,g){f.g.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:"+g+";"}function n(f){var g=f.g.offsetWidth,y=g+100;return f.j.style.width=y+"px",f.i.scrollLeft=y,f.h.scrollLeft=f.h.scrollWidth+100,f.l!==g?(f.l=g,!0):!1}function o(f,g){function y(){var b=_;n(b)&&b.g.parentNode!==null&&g(b.l)}var _=f;t(f.h,y),t(f.i,y),n(f)}function a(f,g,y){g=g||{},y=y||window,this.family=f,this.style=g.style||"normal",this.weight=g.weight||"normal",this.stretch=g.stretch||"normal",this.context=y}var h=null,l=null,u=null,c=null;function d(f){return l===null&&(p(f)&&/Apple/.test(window.navigator.vendor)?(f=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent),l=!!f&&603>parseInt(f[1],10)):l=!1),l}function p(f){return c===null&&(c=!!f.document.fonts),c}function m(f,g){var y=f.style,_=f.weight;if(u===null){var b=document.createElement("div");try{b.style.font="condensed 100px sans-serif"}catch{}u=b.style.font!==""}return[y,_,u?f.stretch:"","100px",g].join(" ")}a.prototype.load=function(f,g){var y=this,_=f||"BESbswy",b=0,v=g||3e3,S=new Date().getTime();return new Promise(function(E,A){if(p(y.context)&&!d(y.context)){var I=new Promise(function(B,G){function N(){new Date().getTime()-S>=v?G(Error(""+v+"ms timeout exceeded")):y.context.document.fonts.load(m(y,'"'+y.family+'"'),_).then(function(C){1<=C.length?B():setTimeout(N,25)},G)}N()}),P=new Promise(function(B,G){b=setTimeout(function(){G(Error(""+v+"ms timeout exceeded"))},v)});Promise.race([P,I]).then(function(){clearTimeout(b),E(y)},A)}else e(function(){function B(){var j;(j=X!=-1&&V!=-1||X!=-1&&L!=-1||V!=-1&&L!=-1)&&((j=X!=V&&X!=L&&V!=L)||(h===null&&(j=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),h=!!j&&(536>parseInt(j[1],10)||parseInt(j[1],10)===536&&11>=parseInt(j[2],10))),j=h&&(X==k&&V==k&&L==k||X==K&&V==K&&L==K||X==D&&V==D&&L==D)),j=!j),j&&(U.parentNode!==null&&U.parentNode.removeChild(U),clearTimeout(b),E(y))}function G(){if(new Date().getTime()-S>=v)U.parentNode!==null&&U.parentNode.removeChild(U),A(Error(""+v+"ms timeout exceeded"));else{var j=y.context.document.hidden;(j===!0||j===void 0)&&(X=N.g.offsetWidth,V=C.g.offsetWidth,L=F.g.offsetWidth,B()),b=setTimeout(G,50)}}var N=new i(_),C=new i(_),F=new i(_),X=-1,V=-1,L=-1,k=-1,K=-1,D=-1,U=document.createElement("div");U.dir="ltr",s(N,m(y,"sans-serif")),s(C,m(y,"serif")),s(F,m(y,"monospace")),U.appendChild(N.g),U.appendChild(C.g),U.appendChild(F.g),y.context.document.body.appendChild(U),k=N.g.offsetWidth,K=C.g.offsetWidth,D=F.g.offsetWidth,G(),o(N,function(j){X=j,B()}),s(N,m(y,'"'+y.family+'",sans-serif')),o(C,function(j){V=j,B()}),s(C,m(y,'"'+y.family+'",serif')),o(F,function(j){L=j,B()}),s(F,m(y,'"'+y.family+'",monospace'))})})},r.exports=a})()})(ib);var wR=ib.exports;const SR=Gn(wR),rb={inter:{fontFamily:"InterVariable",fontSize:16,lineHeight:20,fill:16777215}},sb={resolution:4,chars:ai.ASCII},nb="sans-serif",ob={inter:AR(rb.inter)};let _d=!1;async function ER(){const r=Object.values(rb);await Promise.all(r.map(t=>CR(t))),_d=!0,xt.emit("fontsLoaded",ob)}async function CR(r){const{fontFamily:t,...e}=r,i=new SR(t);try{await i.load()}catch(s){console.error(s),console.warn(`fonts: font ${t} failed to load, falling back to ${nb}`),ai.from(t,{fontFamily:nb,...e},sb);return}ai.from(t,r,sb)}function IR(){_d=!1}async function ab(){return _d?ob:await Oe("fontsLoaded")}function AR(r){const{fontFamily:t,...e}=r,i={fontName:t,...e};return s=>new OS(s,i)}async function hb(){const{inter:r}=await ab(),t=await mR(),e=r("");t.add(e);async function i(s){return e.text=s,await e}return{element:e,render:i}}async function RR({height:r,radius:t}){const e=await li(),i=new qn;return i.beginFill("#fff"),i.drawRoundedRect(0,0,t*2,r,t),i.endFill(),e.renderer.generateTexture(i,{region:new ct(0,0,t,r),resolution:10})}async function MR(r){return await gd(RR,[r])}function PR(){const r=new ie,t=new ie;async function e(i){const s=await MR(i);return r.texture=s,t.texture=s,t.anchor.x=1,t.scale.x=-1,{left:r,right:t}}return{left:r,right:t,render:e}}async function vd(){const r=await yd();return new ie(r)}async function lb(){const r=new Xt,t=await vd(),{left:e,right:i,render:s}=await PR();r.addChild(t),r.addChild(e),r.addChild(i);async function n(h){const{width:l,x:u,visible:c}=a(h);return await s({height:h.height,radius:h.radius}),t.visible=c,t.width=l,t.height=h.height,t.x=u,e.visible=o(h.capLeft,h.radius),i.visible=o(h.capRight,h.radius),i.x=h.radius+l,t.tint=h.background,e.tint=h.background,i.tint=h.background,r}function o(h,l){return l===0?!1:h??!0}function a(h){const l=o(h.capLeft,h.radius),u=o(h.capRight,h.radius);let c=0;l&&(c+=h.radius),u&&(c+=h.radius);const d=Math.max(h.width-c,0),p=d>0,m=l?h.radius:0;return{width:d,visible:p,x:m}}return{element:r,render:n}}async function LR(){const r=await ge(),t=new Xt,{element:e,render:i}=await tb(),{element:s,render:n}=await lb(),{element:o,render:a}=await xd(),h=new Pa;t.eventMode="static",t.cursor="pointer",t.addChild(s),t.addChild(e),t.addChild(o),t.on("mouseover",u),t.on("mouseout",c),s.filters=[h],o.visible=!1;async function l({inside:d,isOpen:p,background:m}){const f={size:10,stroke:2,rotate:p?Ph.Up:Ph.Down},g=await i(f),y={width:r.styles.nodeToggleSize,height:r.styles.nodeToggleSize,background:d?m:"#333",radius:r.styles.nodeToggleBorderRadius},_=await n(y),b=await a({width:y.width,height:y.height,radius:y.radius,stroke:1,color:r.styles.nodeToggleBorderColor});b.alpha=d?0:1;const v={y:_.height/2,x:_.width/2},S=f.size/4;return g.x=v.x,g.y=p?v.y+S:v.y-S,t}function u(){h.brightness(.5,!1),o.visible=!0}function c(){h.brightness(1,!1),o.visible=!1}return{element:t,render:l}}let gn=null,Lh=!1;async function GR(){const r=await Je();r.on("click",()=>Td(null)),r.on("drag-start",()=>{Lh=!0}),r.on("drag-end",()=>{setTimeout(()=>{Lh=!1})})}function NR(){gn=null,Lh=!1}function Td(r){if(Lh||wd(r))return;if(gn=r,r===null){xt.emit("nodeSelected",null);return}const{id:t,kind:e}=r;xt.emit("nodeSelected",{id:t,kind:e})}function wd(r){return(r==null?void 0:r.id)===(gn==null?void 0:gn.id)}function FR(){return gn}const Gh=4,DR=2;async function ub(){const r=await ge(),t=await Di(),e=new Xt,{element:i,render:s}=await lb(),{element:n,render:o}=await xd();e.addChild(i),n.position.set(-Gh,-Gh);async function a(u){const{background:c="#fff"}=r.styles.node(u),{nodeHeight:d,nodeRadius:p}=r.styles,m=l(u,p),f=u.state_type!=="RUNNING"||t.isDependency();return await s({width:m,height:d,radius:p,background:c,capRight:f}),await h(u,m,d),i}async function h(u,c,d){if(!wd(u)){e.removeChild(n);return}e.addChild(n),await o({stroke:DR,radius:r.styles.nodeBorderRadius,width:c+Gh*2,height:d+Gh*2,color:r.styles.nodeSelectedBorderColor})}function l(u,c){const d=Ed();if(dt.isTemporal()||dt.isLeftAligned()){const p=u.start_time,m=u.end_time??new Date,g=_p(m,p)/Mb*d;return Math.max(g,c*2)}return d}return{element:e,render:a}}class cb extends Xt{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)this.children[t].updateTransform()}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(const t of this.children)if(t.calculateBounds(),t._mask){const e=t._mask.isMaskData?t._mask.maskObject:t._mask;e?(e.calculateBounds(),this._bounds.addBoundsMask(t._bounds,e._bounds)):this._bounds.addBounds(t._bounds)}else t.filterArea?this._bounds.addBoundsArea(t._bounds,t.filterArea):this._bounds.addBounds(t._bounds);this._bounds.updateID=this._boundsID}}async function kR(r){const t=new cb,e=await ge(),{element:i,render:s}=await ub(),{element:n,render:o}=await hb(),{element:a,render:h,getSize:l}=await bb(),{element:u,render:c}=await LR(),{element:d,render:p}=await xd(),{start:m,stop:f}=await Dg(r.id,G=>{h(G)});let g=r,y=!1;t.addChild(d),t.addChild(i),t.addChild(n),t.addChild(u),u.on("click",G=>{G.stopPropagation(),b()}),a.position={x:0,y:e.styles.nodeHeight+e.styles.nodesPadding},a.on("rendered",()=>{fd(),P()});async function _(G){return g=G,await s(G),await A(G),await I(G),await v(G),t}async function b(){y?await E():await S()}async function v(G){const{background:N="#fff"}=e.styles.node(G),C=4,{width:F,height:X}=l(),V=X+e.styles.nodeHeight+e.styles.nodesPadding*2+C*2,L=e.styles.nodeHeight,k=y?-C:C,K=Math.max(i.width,F),D=y?K+C*2:i.width-C*2;(await p({width:D,height:y?V:L,stroke:y?2:1,radius:e.styles.nodeBorderRadius,color:N})).position.set(k,k)}async function S(){y=!0,t.addChild(a),await Promise.all([m(),_(g)]),P()}async function E(){y=!1,t.removeChild(a),await Promise.all([f(),_(g)]),P()}async function A(G){const N=e.styles.nodeToggleSize,C=e.styles.nodeHeight-N,F=i.width>N,{background:X="#fff"}=e.styles.node(G),V=await c({background:X,inside:F,isOpen:y});return V.x=F?C/2:i.width+e.styles.nodePadding,V.y=C/2,V}async function I(G){const N=await o(G.label),C=e.styles.colorMode==="dark"?e.styles.textDefault:e.styles.textInverse,F=e.styles.nodePadding,X=u.x+u.width+F,V=i.width+F,L=i.width>X+N.width+F,k=e.styles.nodeHeight/2-N.height/2,K=L?X:Math.max(V,X);return N.position={x:K,y:k},N.tint=L?C:e.styles.textDefault,N}function P(){v(g);const G=B();t.emit("resized",G)}function B(){const G=l(),N=y?G.height+e.styles.nodesPadding*2:0,C=y?G.width:0;return{height:e.styles.nodeHeight+N,width:Math.max(C,t.width)}}return{kind:"flow-run",element:t,bar:i,render:_}}async function OR(){const r=await ge(),t=new cb,{element:e,render:i}=await hb(),{element:s,render:n}=await ub();t.addChild(s),t.addChild(e);async function o(h){return await Promise.all([n(h),i(h.label)]),a(),t}function a(){const h=r.styles.colorMode==="dark"?r.styles.textDefault:r.styles.textInverse,l=r.styles.nodePadding,u=s.width>l+e.width+l,c=u?l:s.width+l,d=r.styles.nodeHeight/2-e.height/2;e.position={x:c,y:d},e.tint=u?h:r.styles.textDefault}return{kind:"task-run",element:t,render:o,bar:s}}async function WR(){const r=await li(),t=await Je(),e=await Di(),i=await ge(),{inter:s}=await ab(),n=new Xt,o=await vd();n.addChild(o);const a=s("");n.addChild(a);let h=await Eo(),l,u;xt.on("scaleUpdated",f=>h=f),r.ticker.add(()=>{e.disableGuides||(m(),n.height!==r.screen.height&&d())});function c(f,g){l=f,u=g,d(),p(f)}function d(){o.width=i.styles.guideLineWidth,o.height=r.screen.height,o.tint=i.styles.guideLineColor}function p(f){a.text=u(f),a.fontSize=i.styles.guideTextSize,a.tint=i.styles.guideTextColor,a.position.set(i.styles.guideTextLeftPadding,i.styles.guideTextTopPadding)}function m(){l!==void 0&&(n.position.x=h(l)*t.scale._x+t.worldTransform.tx)}return{element:n,render:c}}class db extends Error{constructor(){super("Layout is not temporal")}}function BR(r){return r.toLocaleTimeString()}function pb(r){const t=navigator.language;return new Intl.DateTimeFormat(t,{timeStyle:"short"}).format(r)}function UR(r){const t=navigator.language;return new Intl.DateTimeFormat(t,{dateStyle:"short"}).format(r)}function XR(r){return r.getHours()===0&&r.getMinutes()===0?`${Nh.date(r)}
1176
+ ${pb(r)}`:pb(r)}const Nh={timeBySeconds:BR,timeByMinutesWithDates:XR,date:UR},Qt={seconds:"seconds",minutes:"minutes",date:"date"},Co={day:r=>{const t=new Date(r.getTime());return t.setHours(0,0,0,0),t.getTime()},week:r=>{const t=new Date(r.getTime());return t.setHours(0,0,0,0),t.setDate(r.getDate()-r.getDay()+1),t.getTime()}},Ct={second:1e3,minute:1e3*60,hour:1e3*60*60,day:1e3*60*60*24,week:1e3*60*60*24*7},fb=[{ceiling:Ct.second*4,increment:Ct.second,labelFormat:Qt.seconds},{ceiling:Ct.second*8,increment:Ct.second*5,labelFormat:Qt.seconds},{ceiling:Ct.second*13,increment:Ct.second*10,labelFormat:Qt.seconds},{ceiling:Ct.second*20,increment:Ct.second*15,labelFormat:Qt.seconds},{ceiling:Ct.second*45,increment:Ct.second*30,labelFormat:Qt.seconds},{ceiling:Ct.minute*4,increment:Ct.minute,labelFormat:Qt.minutes},{ceiling:Ct.minute*8,increment:Ct.minute*5,labelFormat:Qt.minutes},{ceiling:Ct.minute*13,increment:Ct.minute*10,labelFormat:Qt.minutes},{ceiling:Ct.minute*28,increment:Ct.minute*15,labelFormat:Qt.minutes},{ceiling:Ct.hour*1.24,increment:Ct.minute*30,labelFormat:Qt.minutes},{ceiling:Ct.hour*3,increment:Ct.hour,labelFormat:Qt.minutes},{ceiling:Ct.hour*8,increment:Ct.hour*2,getAnchor:Co.day,labelFormat:Qt.minutes},{ceiling:Ct.hour*13,increment:Ct.hour*6,getAnchor:Co.day,labelFormat:Qt.minutes},{ceiling:Ct.hour*22,increment:Ct.hour*12,getAnchor:Co.day,labelFormat:Qt.minutes},{ceiling:Ct.day*4,increment:Ct.day,getAnchor:Co.day,labelFormat:Qt.date},{ceiling:Ct.week*2,increment:Ct.week,getAnchor:Co.week,labelFormat:Qt.date},{ceiling:1/0,increment:Ct.week*4,labelFormat:Qt.date}],ZR=300;async function VR(){const r=await Je(),t=await Di(),e=new Xt,i=new Map;let s=await Eo();xt.on("scaleUpdated",d=>s=d),await o();function n(){if(e.visible=!t.disableGuides,!t.disableGuides)try{const{anchor:d,increment:p,labelFormat:m}=a(),f=c(d,p);u(f,m)}catch(d){if(d instanceof db)return;console.error(d)}}async function o(){const d=[];bd(30,async p=>{const m=WR();d.push(m);const f=await m;e.addChild(f.element),i.set(p,f)}),await Promise.all(d)}function a(){const d=r.left-ZR,p=s.invert(d),m=s.invert(d+260/r.scale.x);if(!(p instanceof Date)||!(m instanceof Date))throw new db;const f=m.getTime()-p.getTime(),{increment:g,getAnchor:y,labelFormat:_}=h(f);return{anchor:y(p),increment:g,labelFormat:l(_)}}function h(d){const p=fb.find(m=>m.ceiling>d)??fb[0];return p.getAnchor||(p.getAnchor=m=>Math.floor(m.getTime()/p.increment)*p.increment),p}function l(d){switch(d){case Qt.minutes:return Nh.timeByMinutesWithDates;case Qt.date:return Nh.date;default:return Nh.timeBySeconds}}function u(d,p){const m=new Map(i.entries()),f=Array.from(m.keys()).filter(g=>!d.includes(g));i.clear();for(const g of d){if(m.has(g)){const _=m.get(g);i.set(g,_),_.render(new Date(g),p);continue}const y=m.get(f.pop()??-1);if(y===void 0){console.warn("Guides: No unused guides available to render.");continue}y.render(new Date(g),p),i.set(g,y)}}function c(d,p){return bd(30,m=>d+p*m)}return{element:e,render:n}}async function KR(){const r=await li(),{element:t,render:e}=await VR();r.stage.addChild(t),e(),xt.on("viewportDateRangeUpdated",()=>e()),xt.on("layoutSettingsUpdated",()=>e()),xt.on("configUpdated",()=>e())}function XM(){}const HR=80;async function YR(){const r=await li(),t=await Je(),e=await Di(),i=await ge(),s=await vd();let n=await Eo();xt.on("scaleUpdated",h=>n=h);function o(){if(!e.isTemporal()){s.visible=!1;return}s.width=i.styles.playheadWidth,s.height=r.stage.height,s.tint=i.styles.playheadColor,s.position.x=n(new Date)*t.scale.x+t.worldTransform.tx,a()}function a(){if(t.moving||!(s.position.x>0&&s.position.x<r.screen.width)||!(s.position.x>r.screen.width-HR))return;const u=t.left;t.zoomPercent(-.1,!0),t.left=u}return{element:s,render:o}}async function zR(){const r=await li(),t=await Sd(),{element:e,render:i}=await YR();t.end_time||(r.stage.addChild(e),r.ticker.add(i)),xt.on("runDataUpdated",({end_time:s})=>{s&&(r.ticker.remove(i),r.stage.removeChild(e))})}function ZM(){}function jR({stage:r,props:t}){sC(),nR(),rR(),KR(),eM(),zR(),Ob(),ER(),iC(r),Xb(t),cR(),aM(),GR()}function JR(){xt.clear();try{nC(),oR(),sR(),rC(),iM(),Zb(),Wb(),IR(),dR(),hM(),NR(),gR()}catch(r){console.error(r)}}async function $R(r){const t=await ge(),e=await li(),i=await $y(),{animate:s}=await Qy(),{element:n,render:o,bar:a}=await g(r);let h=r,l=null,u=!1,c=!1;i.add(n),n.eventMode="static",n.cursor="pointer",n.name=Cb,n.on("click",b=>{b.stopPropagation(),Td(h)}),r.end_time||p(),xt.on("nodeSelected",()=>{const b=wd(r);b!==u&&(u=b,o(h))});async function d(b){h=b;const v=y(b);return v===l||(l=v,await o(b),b.end_time&&m()),n}function p(){e.ticker.add(f)}function m(){e.ticker.remove(f)}function f(){d(r)}async function g(b){const{kind:v}=b;switch(v){case"task-run":return await OR();case"flow-run":return await kR(b);default:const S=v;throw new Error(`switch does not have case for value: ${S}`)}}function y(b){const v=b.end_time??new Date;return[b.state_type,v.getTime(),dt.horizontal,dt.horizontalScaleMultiplier,t.styles.colorMode].join("-")}function _({x:b,y:v}){s(n,{x:b,y:v},!c),c=!0}return{element:n,render:d,bar:a,setPosition:_}}function mb({gap:r=0,minimum:t=0}={}){const e=new Map;function i(u){const c=e.get(u)??[];return Math.max(...c.values(),z.toValue(t))+z.toValue(r)}function s(u){let c=0;for(let d=0;d<u;d++)c+=i(d);return c}function n(u){return s(u+1)-z.toValue(r)}function o({axis:u,nodeId:c,offset:d}){const p=e.get(u)??new Map;p.set(c,d),e.set(u,p)}function a({axis:u,nodeId:c}){let d,p;for(const[m,f]of e.entries())if(f.has(c)){d=m,p=f.get(c);break}d===u||d===void 0||p===void 0||(h({axis:d,nodeId:c}),o({axis:u,nodeId:c,offset:p}))}function h({axis:u,nodeId:c}){var d;(d=e.get(u))==null||d.delete(c)}function l(){e.clear()}return{getOffset:i,getTotalOffset:s,getTotalValue:n,setOffset:o,updateNodeAxis:a,removeOffset:h,clear:l}}function QR(r){throw new Error(`switch does not have case for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twb3N0TWVzc2FnZShuKX1hc3luYyBmdW5jdGlvbiBTbyhuKXtjb25zdHtkYXRhOmV9PW4sdD13byhuKSxyPWF3YWl0IENvKG4sdCksbz1uZXcgTWFwO2xldCBpPTAsYT0wO2Zvcihjb25zdFt1LGxdb2YgZS5ub2Rlcyl7Y29uc3QgZj10LmdldCh1KSxnPXIuZ2V0KHUpO2lmKGY9PT12b2lkIDApe2NvbnNvbGUud2FybihgTm9kZUlkIG5vdCBmb3VuZCBpbiBob3Jpem9udGFsIGxheW91dDogU2tpcHBpbmcgJHtsLmxhYmVsfWApO2NvbnRpbnVlfWlmKGc9PT12b2lkIDApe2NvbnNvbGUud2FybihgTm9kZUlkIG5vdCBmb3VuZCBpbiB2ZXJ0aWNhbCBsYXlvdXQ6IFNraXBwaW5nICR7bC5sYWJlbH1gKTtjb250aW51ZX1pPU1hdGgubWF4KGksZyksYT1NYXRoLm1heChhLGYuY29sdW1uKSxvLnNldCh1LHsuLi5mLHk6Zyxyb3c6Z30pfWtvKHt0eXBlOiJsYXlvdXQiLGxheW91dDp7bWF4Um93OmksbWF4Q29sdW1uOmEscG9zaXRpb25zOm99fSl9fSkoKTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cnVuR3JhcGgud29ya2VyLTdjMzNlM2VlLmpzLm1hcAo=",yb=typeof window<"u"&&window.Blob&&new Blob([atob(gb)],{type:"text/javascript;charset=utf-8"});function qR(){let r;try{if(r=yb&&(window.URL||window.webkitURL).createObjectURL(yb),!r)throw"";return new Worker(r)}catch{return new Worker("data:application/javascript;base64,"+gb)}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}function tM(r){const t=new qR;return t.onmessage=r,t}async function bb(){const r=tM(P),t=new Map,e=new Map,i=new Xt,s=new Xt,n=await ge(),o=mb({gap:()=>n.styles.rowGap,minimum:()=>n.styles.nodeHeight}),a=mb({gap:()=>n.styles.columnGap,minimum:()=>Ed()});let h=null,l=null;i.name=yp,xt.on("layoutUpdated",()=>{o.clear(),a.clear()}),xt.on("layoutSettingsUpdated",()=>{l&&i.parent&&u(l),G()}),xt.on("nodeSelected",()=>{G()});async function u(L){l=L,h=null,await Promise.all([c(L),p(L)]),f(L)}async function c(L){const k=[];for(const K of L.nodes.values())k.push(d(K));await Promise.all(k)}async function d(L){const{render:k}=await _(L);return await k(L)}async function p(L){if((await Di()).disableEdges){i.removeChild(s);return}i.addChildAt(s,0);const K=[];for(const[D,{children:U}]of L.nodes)for(const{id:j}of U)K.push(m(D,j));await Promise.all(K)}async function m(L,k){const K=`${L}_${k}`;if(e.has(K))return;const D=await vR();e.has(K)||(e.set(K,D),s.addChild(D.element))}function f(L){const k=new Map;for(const[K,{element:D}]of t)k.set(K,D.width);r.postMessage({type:"layout",data:L,widths:k,horizontalSettings:cd(L.start_time),verticalSettings:iR()})}function g(){if(h)for(const[L,k]of e){const[K,D]=L.split("_"),U=h.positions.get(K),j=h.positions.get(D),q=t.get(K);if(!U||!j){console.warn(`Could not find edge in layout: Skipping ${L}`);continue}if(!q){console.warn(`Could not find parent node in nodes: Skipping ${K}`);continue}const pt=q.bar.width,nt=v(U),Et={x:nt.x+pt,y:nt.y+n.styles.nodeHeight/2},Rt=v(j),wt={x:Rt.x-Et.x,y:Rt.y-Et.y+n.styles.nodeHeight/2};k.setPosition(Et,wt)}}function y(){if(h){for(const[L,k]of t){const K=h.positions.get(L);if(!K){console.warn(`Could not find node in layout: Skipping ${L}`);continue}const D=v(K);k.setPosition(D),o.updateNodeAxis({nodeId:L,axis:K.y}),a.updateNodeAxis({nodeId:L,axis:K.column})}g(),i.emit("rendered"),i.emit("resized",I())}}async function _(L){const k=t.get(L.id);if(k)return k;const K=await $R(L);return K.element.on("resized",D=>b(L.id,D)),t.set(L.id,K),i.addChild(K.element),K}function b(L,k){if(!h)return;const K=t.get(L),D=h.positions.get(L);!K||!D||(o.setOffset({nodeId:L,axis:D.y,offset:k.height}),a.setOffset({nodeId:L,axis:D.column,offset:k.width}),y())}function v(L){const k=o.getTotalOffset(L.y);return{x:S(L),y:k}}function S(L){return dt.isDependency()?a.getTotalOffset(L.column):L.x}function E(){return h?o.getTotalValue(h.maxRow):0}function A(){if(!h||!l)return 0;if(dt.isDependency())return a.getTotalValue(h.maxColumn);const L=cd(l.start_time),k=Hy(L),K=k(l.end_time??new Date),D=k(l.start_time);return K-D}function I(){return{width:A(),height:E()}}function P({data:L}){const{type:k}=L;switch(k){case"layout":B(L);return;default:QR(k)}}function B(L){h=L.layout,y()}async function G(){const L=await Di(),k=FR();if(!k||L.disableEdges){N([]);return}const K=X(k.id);N(K)}function N(L){C(L),F(L)}function C(L){for(const[k,{element:K}]of t){if(L.length===0||L.includes(k)){K.alpha=1;continue}K.alpha=n.styles.nodeUnselectedAlpha}}function F(L){for(const[k,{element:K}]of e){const[D,U]=k.split("_");if(L.length===0||L.includes(D)&&L.includes(U)){K.alpha=1;continue}K.alpha=n.styles.nodeUnselectedAlpha}}function X(L){const k=V(L,"parents"),K=V(L,"children");return[L,...k,...K]}function V(L,k){const K=l==null?void 0:l.nodes.get(L);if(!K)return[];const D=[];for(const{id:U}of K[k])D.push(U),D.push(...V(U,k));return D}return{element:i,getSize:I,render:u}}let Io=null,Dr=null,Ts=null;async function eM(){const r=await Je(),t=await ge(),{element:e,render:i}=await bb();r.addChild(e),e.alpha=0;const s=await Dg(t.runId,async n=>{const o=Dr?"runDataUpdated":"runDataCreated";Dr=n,xt.emit(o,Dr),await Di(),i(n)});xt.on("configUpdated",()=>{Dr&&i(Dr)}),Ts=e,Io=s.stop,Ts.once("rendered",()=>rM()),xt.on("layoutUpdated",()=>sM()),s.start()}function iM(){Io==null||Io(),Io=null,Ts=null,Dr=null}async function Sd(){return Dr||await Oe("runDataCreated")}function rM(){pd(),be.shared.addOnce(()=>{Ts&&(Ts.alpha=1)})}async function sM(){if(!Ts)return;const r=await ge();Ts.once("rendered",()=>{setTimeout(()=>{pd({animate:!0})},r.animationDuration)})}function nM(r){let t=0;for(const[,{children:e}]of r)t+=e.length;return t}function oM({start_time:r,end_time:t}){const e=Gb(t??new Date,r);return e<xp?2:e<xp*6?1:.1}async function aM(){const r=await Sd(),t=await ge(),e=oM(r);Fh(e,!0),r.nodes.size>t.disableAnimationsThreshold&&(dt.disableAnimations=!0),nM(r.nodes)>t.disableEdgesThreshold&&(dt.disableEdges=!0)}function hM(){dt.horizontal="temporal",dt.vertical="nearest-parent",dt.horizontalScaleMultiplierDefault=0,dt.horizontalScaleMultiplier=0,dt.disableAnimations=!1,dt.disableEdges=!1,dt.disableGuides=!1}const dt=z.reactive({horizontal:"temporal",vertical:"nearest-parent",horizontalScaleMultiplierDefault:0,horizontalScaleMultiplier:0,disableAnimations:!1,disableEdges:!1,disableGuides:!1,isTemporal(){return this.horizontal==="temporal"},isDependency(){return this.horizontal==="dependency"},isWaterfall(){return this.vertical==="waterfall"},isNearestParent(){return this.vertical==="nearest-parent"},isLeftAligned(){return this.horizontal==="left-aligned"}});async function Di(){return Cd()?dt:await Oe("layoutSettingsCreated")}function Ed(){return dt.isDependency()?200:20*dt.horizontalScaleMultiplier}function lM(){return[0,Ed()]}function uM(r){if(dt.isDependency())return[0,1];const t=r,e=Rb(t,1);return[t,e]}function Fh(r,t=!1){if(dt.horizontalScaleMultiplier===r)return;const e=Dh();dt.horizontalScaleMultiplier=r,t&&(dt.horizontalScaleMultiplierDefault=r),e()}function cM(){Fh(dt.horizontalScaleMultiplierDefault)}function dM(r){if(dt.horizontal===r)return;const t=Dh();dt.horizontal=r,dt.disableGuides=dt.isDependency()||dt.isLeftAligned(),t()}function pM(r){if(dt.vertical===r)return;const t=Dh();dt.vertical=r,t()}function fM(r){if(dt.disableEdges===r)return;const t=Dh();dt.disableEdges=r,t()}function Dh(){const r=Cd()?"layoutSettingsUpdated":"layoutSettingsCreated",{horizontal:t,vertical:e}=dt;return()=>{Cd()&&xt.emit(r,dt),(t!==dt.horizontal||e!==dt.vertical)&&xt.emit("layoutUpdated")}}function Cd(){return dt.horizontalScaleMultiplier!==0}function xb(r){if(!(r instanceof HTMLElement))return!1;const t=r.tagName.toLowerCase();return["input","textarea"].includes(t)}const mM={class:"flex items-center gap-2"},gM=z.defineComponent({__name:"RunGraphSettings",setup(r){const t=[Vi.positions.topRight,Vi.positions.bottomRight,Vi.positions.topLeft,Vi.positions.bottomLeft],e=[{label:"Temporal dependency",value:"temporal_nearest-parent"},{label:"Temporal sequence",value:"temporal_waterfall"},{label:"Dependency grid",value:"dependency_nearest-parent"},{label:"Sequential grid",value:"dependency_waterfall"},{label:"Comparative duration",value:"left-aligned_duration-sorted"}],i=z.computed({get(){return`${dt.horizontal}_${dt.vertical}`},set(l){const[u,c]=l.split("_");dM(u),pM(c)}}),s=z.computed({get(){return dt.disableEdges},set(l){fM(l)}});function n(){const u=dt.horizontalScaleMultiplier*1.25;Fh(u)}function o(){const l=Math.abs(-.75),u=dt.horizontalScaleMultiplier*l;Fh(u)}Zi.useKeyDown(["-","="],a);function a(l){if(!(xb(l.target)||l.metaKey||l.ctrlKey))switch(l.key){case"-":o();break;case"=":n();break}}function h(){cM()}return(l,u)=>{const c=z.resolveComponent("p-radio-group"),d=z.resolveComponent("p-label"),p=z.resolveComponent("p-divider"),m=z.resolveComponent("p-checkbox"),f=z.resolveComponent("p-overflow-menu");return z.openBlock(),z.createBlock(z.unref(Vi.PPopOver),{class:"run-graph-settings","auto-close":"",placement:t},{target:z.withCtx(({toggle:g})=>[z.createVNode(z.unref(Vi.PButton),{"aria-label":"Run Graph Options",icon:"CogIcon",flat:"",onClick:g},null,8,["onClick"])]),default:z.withCtx(()=>[z.createVNode(f,{class:"run-graph-settings__menu"},{default:z.withCtx(()=>[z.createVNode(d,{label:"Layout"},{default:z.withCtx(()=>[z.createVNode(c,{modelValue:i.value,"onUpdate:modelValue":u[0]||(u[0]=g=>i.value=g),options:e},{label:z.withCtx(({option:g})=>[z.createTextVNode(z.toDisplayString(g.label),1)]),_:1},8,["modelValue"])]),_:1}),z.unref(dt).isTemporal()||z.unref(dt).isLeftAligned()?(z.openBlock(),z.createElementBlock(z.Fragment,{key:0},[z.createVNode(p),z.createVNode(d,{label:"Scaling"},{default:z.withCtx(()=>[z.createElementVNode("div",mM,[z.createVNode(z.unref(Vi.PButton),{title:"Decrease scale (-)",small:"",icon:"MinusIcon",onClick:o}),z.createVNode(z.unref(Vi.PButton),{title:"Increase scale (+)",small:"",icon:"PlusIcon",onClick:n}),z.createVNode(z.unref(Vi.PButton),{small:"",onClick:h},{default:z.withCtx(()=>[z.createTextVNode(" Reset ")]),_:1})])]),_:1})],64)):z.createCommentVNode("",!0),z.createVNode(p),z.createVNode(m,{modelValue:s.value,"onUpdate:modelValue":u[1]||(u[1]=g=>s.value=g),label:"Hide dependency arrows"},null,8,["modelValue"])]),_:1})]),_:1})}}}),VM="",yM={class:"run-graph__actions"},bM=z.defineComponent({__name:"RunGraph",props:{config:{},viewport:{},fullscreen:{type:[Boolean,null],default:null},selected:{default:null}},emits:["update:viewport","update:fullscreen","update:selected"],setup(r,{emit:t}){const e=r,i=z.ref(),s=z.ref(!1),n=z.computed({get(){return e.fullscreen??s.value},set(u){s.value=u,t("update:fullscreen",u)}});z.watch(()=>e.selected,u=>Td(u)),xt.on("nodeSelected",u=>t("update:selected",u)),z.watch(()=>e.viewport,u=>lR(u));const o=z.computed(()=>({root:{"run-graph--fullscreen":n.value}}));xt.on("viewportDateRangeUpdated",u=>t("update:viewport",u));function a(){pd({animate:!0})}function h(){n.value=!n.value}z.onMounted(()=>{if(!i.value)throw new Error("Stage does not exist");jR({stage:i.value,props:e})}),z.onBeforeUnmount(()=>{JR()}),Zi.useKeyDown(["c","f","Escape"],l);function l(u){if(!(xb(u.target)||u.metaKey||u.ctrlKey))switch(u.key){case"c":a();break;case"f":h();break;case"Escape":n.value&&h();break}}return(u,c)=>{const d=z.resolveComponent("p-button");return z.openBlock(),z.createElementBlock("div",{class:z.normalizeClass(["run-graph",o.value.root])},[z.createElementVNode("div",{ref_key:"stage",ref:i,class:"run-graph__stage"},null,512),z.createElementVNode("div",yM,[z.createVNode(d,{title:"Recenter graph (c)",icon:"Target",flat:"",onClick:a}),z.createVNode(d,{title:"Toggle fullscreen (f)",icon:"ArrowsPointingOutIcon",flat:"",onClick:h}),z.createVNode(gM)])],2)}}}),KM="",_b=["flow-run","task-run"];function xM(r){return _b.includes(r)}oe.RunGraph=bM,oe.isRunGraphNodeType=xM,oe.runGraphNodeKinds=_b,Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"})});
1177
1177
  //# sourceMappingURL=graphs.umd.js.map