@vimp-games/tanks 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client-DI5HnMSd.js
DELETED
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
class Ii{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Rn.unregister(this),t}free(){const t=this.__destroy_into_raw();B.__wbg_clientcore_free(t,0)}apply_input(t,e,s){const n=me(t,B.__wbindgen_malloc,B.__wbindgen_realloc),r=It,o=me(e,B.__wbindgen_malloc,B.__wbindgen_realloc),a=It;B.clientcore_apply_input(this.__wbg_ptr,n,r,o,a,s)}cycle_weapon(t){B.clientcore_cycle_weapon(this.__wbg_ptr,t)}decode_frame(t){let e,s;try{const n=Bn(t,B.__wbindgen_malloc),r=It,o=B.clientcore_decode_frame(this.__wbg_ptr,n,r);return e=o[0],s=o[1],je(o[0],o[1])}finally{B.__wbindgen_free(e,s,1)}}hot_ptr(){return B.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const t=B.clientcore_hot_values(this.__wbg_ptr);var e=uh(t[0],t[1]).slice();return B.__wbindgen_free(t[0],t[1]*4,4),e}my_game_id(){return B.clientcore_my_game_id(this.__wbg_ptr)}constructor(t){const e=me(t,B.__wbindgen_malloc,B.__wbindgen_realloc),s=It,n=B.clientcore_new(e,s);if(n[2])throw Ln(n[1]);return this.__wbg_ptr=n[0],Rn.register(this,this.__wbg_ptr,this),this}offset(){return B.clientcore_offset(this.__wbg_ptr)}push_frame(t,e){const s=Bn(t,B.__wbindgen_malloc),n=It;return B.clientcore_push_frame(this.__wbg_ptr,s,n,e)!==0}reset(){B.clientcore_reset(this.__wbg_ptr)}sample(t){return B.clientcore_sample(this.__wbg_ptr,t)>>>0}set_active(t){B.clientcore_set_active(this.__wbg_ptr,t)}set_map(t){const e=me(t,B.__wbindgen_malloc,B.__wbindgen_realloc),s=It,n=B.clientcore_set_map(this.__wbg_ptr,e,s);if(n[1])throw Ln(n[0])}set_model(t){const e=me(t,B.__wbindgen_malloc,B.__wbindgen_realloc),s=It;B.clientcore_set_model(this.__wbg_ptr,e,s)}sync_panel(t){const e=me(t,B.__wbindgen_malloc,B.__wbindgen_realloc),s=It;B.clientcore_sync_panel(this.__wbg_ptr,e,s)}take_frames(){let t,e;try{const s=B.clientcore_take_frames(this.__wbg_ptr);return t=s[0],e=s[1],je(s[0],s[1])}finally{B.__wbindgen_free(t,e,1)}}try_fire(t){const e=B.clientcore_try_fire(this.__wbg_ptr,t);let s;return e[0]!==0&&(s=je(e[0],e[1]).slice(),B.__wbindgen_free(e[0],e[1]*1,1)),s}}Symbol.dispose&&(Ii.prototype[Symbol.dispose]=Ii.prototype.free);function ch(){return{__proto__:null,"./vimp_tanks_core_bg.js":{__proto__:null,__wbg_Error_92b29b0548f8b746:function(t,e){return Error(je(t,e))},__wbg___wbindgen_throw_344f42d3211c4765:function(t,e){throw new Error(je(t,e))},__wbindgen_init_externref_table:function(){const t=B.__wbindgen_externrefs,e=t.grow(4);t.set(0,void 0),t.set(e+0,void 0),t.set(e+1,null),t.set(e+2,!0),t.set(e+3,!1)}}}}const Rn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>B.__wbg_clientcore_free(i,1));typeof FinalizationRegistry>"u"||new FinalizationRegistry(i=>B.__wbg_gamecore_free(i,1));function uh(i,t){return i=i>>>0,dh().subarray(i/4,i/4+t)}let He=null;function dh(){return(He===null||He.byteLength===0)&&(He=new Float32Array(B.memory.buffer)),He}function je(i,t){return ph(i>>>0,t)}let Ne=null;function qe(){return(Ne===null||Ne.byteLength===0)&&(Ne=new Uint8Array(B.memory.buffer)),Ne}function Bn(i,t){const e=t(i.length*1,1)>>>0;return qe().set(i,e/1),It=i.length,e}function me(i,t,e){if(e===void 0){const a=Ke.encode(i),h=t(a.length,1)>>>0;return qe().subarray(h,h+a.length).set(a),It=a.length,h}let s=i.length,n=t(s,1)>>>0;const r=qe();let o=0;for(;o<s;o++){const a=i.charCodeAt(o);if(a>127)break;r[n+o]=a}if(o!==s){o!==0&&(i=i.slice(o)),n=e(n,s,s=o+i.length*3,1)>>>0;const a=qe().subarray(n+o,n+s),h=Ke.encodeInto(i,a);o+=h.written,n=e(n,s,o,1)>>>0}return It=o,n}function Ln(i){const t=B.__wbindgen_externrefs.get(i);return B.__externref_table_dealloc(i),t}let Fs=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Fs.decode();const fh=2146435072;let qs=0;function ph(i,t){return qs+=t,qs>=fh&&(Fs=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Fs.decode(),qs=t),Fs.decode(qe().subarray(i,i+t))}const Ke=new TextEncoder;"encodeInto"in Ke||(Ke.encodeInto=function(i,t){const e=Ke.encode(i);return t.set(e),{read:i.length,written:e.length}});let It=0,B;function gh(i,t){return B=i.exports,He=null,Ne=null,B.__wbindgen_start(),B}async function mh(i,t){if(typeof Response=="function"&&i instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(i,t)}catch(n){if(i.ok&&e(i.type)&&i.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}const s=await i.arrayBuffer();return await WebAssembly.instantiate(s,t)}else{const s=await WebAssembly.instantiate(i,t);return s instanceof WebAssembly.Instance?{instance:s,module:i}:s}function e(s){switch(s){case"basic":case"cors":case"default":return!0}return!1}}async function _h(i){if(B!==void 0)return B;i!==void 0&&(Object.getPrototypeOf(i)===Object.prototype?{module_or_path:i}=i:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),i===void 0&&(i=new URL("/assets/vimp_tanks_core_bg-6JRQcDoQ.wasm",import.meta.url));const t=ch();(typeof i=="string"||typeof Request=="function"&&i instanceof Request||typeof URL=="function"&&i instanceof URL)&&(i=fetch(i));const{instance:e,module:s}=await mh(await i,t);return gh(e)}const yh='@charset "UTF-8";#panel table td#panel-bullet:before{content:"bullet: "}#panel table td#panel-bomb:before{content:"bomb: "}#panel table td#panel-time:before{content:"time: "}#vimp{background:#222;position:absolute;inset:0;margin:auto;z-index:1}#radar{position:absolute;right:1%;top:35px;z-index:2;border-radius:50%;background-color:#00be5acc;box-shadow:inset 0 0 47px #ee6,0 0 0 3px #054}#team1{color:#f56}#team2{color:#7ed}#spectators{color:#fe5}#team1 tHead tr,#team2 tHead tr,#spectators tHead tr{border-bottom:1px solid #888;text-transform:capitalize;font-weight:700}#team1 tBody tr,#team2 tBody tr{border-bottom:1px solid #444}#team1 tHead td:first-child:before{content:"team1 ("}#team1 tHead td:first-child:after{content:")"}#team2 tHead td:first-child:before{content:"team2 ("}#team2 tHead td:first-child:after{content:")"}#spectators tHead td:first-child:before{content:"spectators"}#spectators tBody td:nth-child(1){padding:0 1%;line-height:1.4em}#spectators tBody td:nth-child(2),#spectators tBody td:nth-child(3),#spectators tBody td:nth-child(4),#spectators tBody td:nth-child(5){display:none}',xh="modulepreload",bh=function(i){return"/"+i},On={},rn=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){let h=function(l){return Promise.all(l.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");n=h(e.map(l=>{if(l=bh(l),l in On)return;On[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":xh,c||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),c)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})};var k=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.TextureUploaderWebGL="texture-uploader-webgl",i.TextureUploaderWebGPU="texture-uploader-webgpu",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(k||{});const Fi=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},ys=(i,t)=>Fi(i).priority??t,$={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Fi).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...i){return i.map(Fi).forEach(t=>{t.type.forEach(e=>{const s=this._addHandlers,n=this._queue;s[e]?s[e]?.(t):(n[e]=n[e]||[],n[e]?.push(t))})}),this},handle(i,t,e){const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const r=this._queue;return r[i]&&(r[i]?.forEach(o=>t(o)),delete r[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,o)=>ys(o.value,e)-ys(r.value,e)))},s=>{const n=t.findIndex(r=>r.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,r)=>ys(r,e)-ys(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})},mixin(i,...t){for(const e of t)Object.defineProperties(i.prototype,Object.getOwnPropertyDescriptors(e))}},vh={extension:{type:k.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await rn(()=>Promise.resolve().then(()=>rg),void 0)}},wh={extension:{type:k.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await rn(()=>Promise.resolve().then(()=>og),void 0)}};class ht{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new ht(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function Sh(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ks={exports:{}},Dn;function Th(){return Dn||(Dn=1,(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(c,u||h,d),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,d,f,p){var g=e?e+l:l;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,x,b;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,u),!0;case 4:return m.fn.call(m.context,c,u,d),!0;case 5:return m.fn.call(m.context,c,u,d,f),!0;case 6:return m.fn.call(m.context,c,u,d,f,p),!0}for(b=1,x=new Array(_-1);b<_;b++)x[b-1]=arguments[b];m.fn.apply(m.context,x)}else{var y=m.length,v;for(b=0;b<y;b++)switch(m[b].once&&this.removeListener(l,m[b].fn,void 0,!0),_){case 1:m[b].fn.call(m[b].context);break;case 2:m[b].fn.call(m[b].context,c);break;case 3:m[b].fn.call(m[b].context,c,u);break;case 4:m[b].fn.call(m[b].context,c,u,d);break;default:if(!x)for(v=1,x=new Array(_-1);v<_;v++)x[v-1]=arguments[v];m[b].fn.apply(m[b].context,x)}}return!0},a.prototype.on=function(l,c,u){return r(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return r(this,l,c,u,!0)},a.prototype.removeListener=function(l,c,u,d){var f=e?e+l:l;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var g=0,m=[],_=p.length;g<_;g++)(p[g].fn!==c||d&&!p[g].once||u&&p[g].context!==u)&&m.push(p[g]);m.length?this._events[f]=m.length===1?m[0]:m:o(this,f)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,i.exports=a})(Ks)),Ks.exports}var Ah=Th();const Rt=Sh(Ah),Ch=Math.PI*2,Ph=180/Math.PI,Mh=Math.PI/180;class Z{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new Z(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}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Zs.x=0,Zs.y=0,Zs}}const Zs=new Z;class z{constructor(t=1,e=0,s=0,n=1,r=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=n,this.tx=r,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,s,n,r,o){return this.a=t,this.b=e,this.c=s,this.d=n,this.tx=r,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new Z;const s=t.x,n=t.y;return e.x=this.a*s+this.c*n+this.tx,e.y=this.b*s+this.d*n+this.ty,e}applyInverse(t,e){e=e||new Z;const s=this.a,n=this.b,r=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(s*o+r*-n),c=t.x,u=t.y;return e.x=o*l*c+-r*l*u+(h*r-a*o)*l,e.y=s*l*u+-n*l*c+(-h*s+a*n)*l,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),s=Math.sin(t),n=this.a,r=this.c,o=this.tx;return this.a=n*e-this.b*s,this.b=n*s+this.b*e,this.c=r*e-this.d*s,this.d=r*s+this.d*e,this.tx=o*e-this.ty*s,this.ty=o*s+this.ty*e,this}append(t){const e=this.a,s=this.b,n=this.c,r=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*s+t.b*r,this.c=t.c*e+t.d*n,this.d=t.c*s+t.d*r,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*s+t.ty*r+this.ty,this}appendFrom(t,e){const s=t.a,n=t.b,r=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,c=e.b,u=e.c,d=e.d;return this.a=s*l+n*u,this.b=s*c+n*d,this.c=r*l+o*u,this.d=r*c+o*d,this.tx=a*l+h*u+e.tx,this.ty=a*c+h*d+e.ty,this}setTransform(t,e,s,n,r,o,a,h,l){return this.a=Math.cos(a+l)*r,this.b=Math.sin(a+l)*r,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(s*this.a+n*this.c),this.ty=e-(s*this.b+n*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,n=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*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,s=this.b,n=this.c,r=this.d,o=t.pivot,a=-Math.atan2(-n,r),h=Math.atan2(s,e),l=Math.abs(a+h);return l<1e-5||Math.abs(Ch-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+s*s),t.scale.y=Math.sqrt(n*n+r*r),t.position.x=this.tx+(o.x*e+o.y*n),t.position.y=this.ty+(o.x*s+o.y*r),t}invert(){const t=this.a,e=this.b,s=this.c,n=this.d,r=this.tx,o=t*n-e*s;return this.a=n/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-n*r)/o,this.ty=-(t*this.ty-e*r)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}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 z;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}equals(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}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Eh.identity()}static get shared(){return kh.identity()}}const kh=new z,Eh=new z,ne=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],re=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],oe=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ae=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ri=[],To=[],xs=Math.sign;function Ih(){for(let i=0;i<16;i++){const t=[];Ri.push(t);for(let e=0;e<16;e++){const s=xs(ne[i]*ne[e]+oe[i]*re[e]),n=xs(re[i]*ne[e]+ae[i]*re[e]),r=xs(ne[i]*oe[e]+oe[i]*ae[e]),o=xs(re[i]*oe[e]+ae[i]*ae[e]);for(let a=0;a<16;a++)if(ne[a]===s&&re[a]===n&&oe[a]===r&&ae[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new z;t.set(ne[i],re[i],oe[i],ae[i],0,0),To.push(t)}}Ih();const U={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:i=>ne[i],uY:i=>re[i],vX:i=>oe[i],vY:i=>ae[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Ri[i][t],sub:(i,t)=>Ri[i][U.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?U.S:U.N:Math.abs(t)*2<=Math.abs(i)?i>0?U.E:U.W:t>0?i>0?U.SE:U.SW:i>0?U.NE:U.NW,matrixAppendRotationInv:(i,t,e=0,s=0,n=0,r=0)=>{const o=To[U.inv(t)],a=o.a,h=o.b,l=o.c,c=o.d,u=e-Math.min(0,a*n,l*r,a*n+l*r),d=s-Math.min(0,h*n,c*r,h*n+c*r),f=i.a,p=i.b,g=i.c,m=i.d;i.a=a*f+h*g,i.b=a*p+h*m,i.c=l*f+c*g,i.d=l*p+c*m,i.tx=u*f+d*g+i.tx,i.ty=u*p+d*m+i.ty},transformRectCoords:(i,t,e,s)=>{const{x:n,y:r,width:o,height:a}=i,{x:h,y:l,width:c,height:u}=t;return e===U.E?(s.set(n+h,r+l,o,a),s):e===U.S?s.set(c-r-a+h,n+l,a,o):e===U.W?s.set(c-n-o+h,u-r-a+l,o,a):e===U.N?s.set(r+h,u-n-o+l,a,o):s.set(n+h,r+l,o,a)}},bs=[new Z,new Z,new Z,new Z];class W{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new W(0,0,0,0)}clone(){return new W(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),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}strokeContains(t,e,s,n=.5){const{width:r,height:o}=this;if(r<=0||o<=0)return!1;const a=this.x,h=this.y,l=s*(1-n),c=s-l,u=a-l,d=a+r+l,f=h-l,p=h+o+l,g=a+c,m=a+r-c,_=h+c,x=h+o-c;return t>=u&&t<=d&&e>=f&&e<=p&&!(t>g&&t<m&&e>_&&e<x)}intersects(t,e){if(!e){const C=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=C)return!1;const T=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>T}const s=this.left,n=this.right,r=this.top,o=this.bottom;if(n<=s||o<=r)return!1;const a=bs[0].set(t.left,t.top),h=bs[1].set(t.left,t.bottom),l=bs[2].set(t.right,t.top),c=bs[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=s||Math.min(a.x,h.x,l.x,c.x)>=n||Math.max(a.y,h.y,l.y,c.y)<=r||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const d=u*(h.y-a.y),f=u*(a.x-h.x),p=d*s+f*r,g=d*n+f*r,m=d*s+f*o,_=d*n+f*o;if(Math.max(p,g,m,_)<=d*a.x+f*a.y||Math.min(p,g,m,_)>=d*c.x+f*c.y)return!1;const x=u*(a.y-l.y),b=u*(l.x-a.x),y=x*s+b*r,v=x*n+b*r,w=x*s+b*o,S=x*n+b*o;return!(Math.max(y,v,w,S)<=x*a.x+b*a.y||Math.min(y,v,w,S)>=x*c.x+b*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=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=s-this.x,this.height=n-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=r-n,this}getBounds(t){return t||(t=new W),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,n=t.x+t.width,r=t.y+t.height;return e>=this.x&&e<this.x+this.width&&s>=this.y&&s<this.y+this.height&&n>=this.x&&n<this.x+this.width&&r>=this.y&&r<this.y+this.height}set(t,e,s,n){return this.x=t,this.y=e,this.width=s,this.height=n,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Qs={default:-1};function et(i="default"){return Qs[i]===void 0&&(Qs[i]=-1),++Qs[i]}const Gn=new Set,j="8.0.0",Fh="8.3.4",we={quiet:!1,noColor:!1},D=((i,t,e=3)=>{if(we.quiet||Gn.has(t))return;let s=new Error().stack;const n=`${t}
|
|
2
|
-
Deprecated since v${i}`,r=typeof console.groupCollapsed=="function"&&!we.noColor;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",n):(s=s.split(`
|
|
3
|
-
`).splice(e).join(`
|
|
4
|
-
`),r?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(s))),Gn.add(t)});Object.defineProperties(D,{quiet:{get:()=>we.quiet,set:i=>{we.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>we.noColor,set:i=>{we.noColor=i},enumerable:!0,configurable:!1}});const Ao=()=>{};function Me(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function zn(i){return!(i&i-1)&&!!i}function Co(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const Un=Object.create(null);function Rh(i){const t=Un[i];return t===void 0&&(Un[i]=et("resource")),t}const Po=class Mo extends Rt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Mo.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){D(j,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Rh(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Po.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let jt=Po;const ko=class Eo extends Rt{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=et("textureSource"),this._resourceType="textureSource",this._resourceId=et("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...Eo.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=t.transient??!1,this.alphaMode=t.alphaMode,this.style=new jt(Co(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=et("resource"),this.emit("change",this),this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*s),r=Math.round(e*s);return this.width=n/s,this.height=r/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=et("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=zn(this.pixelWidth)&&zn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};ko.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Mt=ko;class on extends Mt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}on.extension=k.TextureSource;const Wn=new z;class Bh{constructor(t,e){this.mapCoord=new z,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this)),this.update()}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let n=0;n<t.length;n+=2){const r=t[n],o=t[n+1];e[n]=r*s.a+o*s.c+s.tx,e[n+1]=r*s.b+o*s.d+s.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const s=t.orig,n=t.trim;n&&(Wn.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Wn));const r=t.source,o=this.uClampFrame,a=this.clampMargin/r._resolution,h=this.clampOffset/r._resolution;return o[0]=(t.frame.x+a+h)/r.width,o[1]=(t.frame.y+a+h)/r.height,o[2]=(t.frame.x+t.frame.width-a+h)/r.width,o[3]=(t.frame.y+t.frame.height-a+h)/r.height,this.uClampOffset[0]=this.clampOffset/r.pixelWidth,this.uClampOffset[1]=this.clampOffset/r.pixelHeight,this.isSimple=t.frame.width===r.width&&t.frame.height===r.height&&t.rotate===0,!0}}class G extends Rt{constructor({source:t,label:e,frame:s,orig:n,trim:r,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=et("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new W,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=t?.source??new Mt,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:c,height:u}=this._source;this.frame.width=c,this.frame.height=u}this.orig=n||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Bh(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:s,height:n}=this._source,r=e.x/s,o=e.y/n,a=e.width/s,h=e.height/n;let l=this.rotate;if(l){const c=a/2,u=h/2,d=r+c,f=o+u;l=U.add(l,U.NW),t.x0=d+c*U.uX(l),t.y0=f+u*U.uY(l),l=U.add(l,2),t.x1=d+c*U.uX(l),t.y1=f+u*U.uY(l),l=U.add(l,2),t.x2=d+c*U.uX(l),t.y2=f+u*U.uY(l),l=U.add(l,2),t.x3=d+c*U.uX(l),t.y3=f+u*U.uY(l)}else t.x0=r,t.y0=o,t.x1=r+a,t.y1=o,t.x2=r+a,t.y2=o+h,t.x3=r,t.y3=o+h}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return D(j,"Texture.baseTexture is now Texture.source"),this._source}}G.EMPTY=new G({label:"EMPTY",source:new Mt({label:"EMPTY"})});G.EMPTY.destroy=Ao;G.WHITE=new G({source:new on({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});G.WHITE.destroy=Ao;function Io(i,t,e){const{width:s,height:n}=e.orig,r=e.trim;if(r){const o=r.width,a=r.height;i.minX=r.x-t._x*s,i.maxX=i.minX+o,i.minY=r.y-t._y*n,i.maxY=i.minY+a}else i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}const Xn=new z;class _t{constructor(t=1/0,e=1/0,s=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Xn,this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new W);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Xn,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,r){r||(r=this.matrix);const o=r.a,a=r.b,h=r.c,l=r.d,c=r.tx,u=r.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=o*t+h*e+c,_=a*t+l*e+u;m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*s+h*e+c,_=a*s+l*e+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*t+h*n+c,_=a*t+l*n+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*s+h*n+c,_=a*s+l*n+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,s=this.minY,n=this.maxX,r=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:u}=t;let d=o*e+h*s+c,f=a*e+l*s+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=o*n+h*s+c,f=a*n+l*s+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=o*e+h*r+c,f=a*e+l*r+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=o*n+h*r+c,f=a*n+l*r+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>n&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new _t(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,n){let r=this.minX,o=this.minY,a=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,u=n.c,d=n.d,f=n.tx,p=n.ty;for(let g=e;g<s;g+=2){const m=t[g],_=t[g+1],x=l*m+u*_+f,b=c*m+d*_+p;r=x<r?x:r,o=b<o?b:o,a=x>a?x:a,h=b>h?b:h}this.minX=r,this.minY=o,this.maxX=a,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var Lh={grad:.9,turn:360,rad:360/(2*Math.PI)},Dt=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},at=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},Pt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},Fo=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Yn=function(i){return{r:Pt(i.r,0,255),g:Pt(i.g,0,255),b:Pt(i.b,0,255),a:Pt(i.a)}},Js=function(i){return{r:at(i.r),g:at(i.g),b:at(i.b),a:at(i.a,3)}},Oh=/^#([0-9a-f]{3,8})$/i,vs=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},Ro=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=Math.max(t,e,s),o=r-Math.min(t,e,s),a=o?r===t?(e-s)/o:r===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:n}},Bo=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var r=Math.floor(t),o=s*(1-e),a=s*(1-(t-r)*e),h=s*(1-(1-t+r)*e),l=r%6;return{r:255*[s,a,o,o,h,s][l],g:255*[h,s,s,a,o,o][l],b:255*[o,o,h,s,s,a][l],a:n}},Hn=function(i){return{h:Fo(i.h),s:Pt(i.s,0,100),l:Pt(i.l,0,100),a:Pt(i.a)}},Nn=function(i){return{h:at(i.h),s:at(i.s),l:at(i.l),a:at(i.a,3)}},$n=function(i){return Bo((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Ze=function(i){return{h:(t=Ro(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},Dh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,zh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Uh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bi={string:[[function(i){var t=Oh.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?at(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?at(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=zh.exec(i)||Uh.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:Yn({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(i){var t=Dh.exec(i)||Gh.exec(i);if(!t)return null;var e,s,n=Hn({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(Lh[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return $n(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=n===void 0?1:n;return Dt(t)&&Dt(e)&&Dt(s)?Yn({r:Number(t),g:Number(e),b:Number(s),a:Number(r)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,r=n===void 0?1:n;if(!Dt(t)||!Dt(e)||!Dt(s))return null;var o=Hn({h:Number(t),s:Number(e),l:Number(s),a:Number(r)});return $n(o)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,r=n===void 0?1:n;if(!Dt(t)||!Dt(e)||!Dt(s))return null;var o=(function(a){return{h:Fo(a.h),s:Pt(a.s,0,100),v:Pt(a.v,0,100),a:Pt(a.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(r)});return Bo(o)},"hsv"]]},Vn=function(i,t){for(var e=0;e<t.length;e++){var s=t[e][0](i);if(s)return[s,t[e][1]]}return[null,void 0]},Wh=function(i){return typeof i=="string"?Vn(i.trim(),Bi.string):typeof i=="object"&&i!==null?Vn(i,Bi.object):[null,void 0]},ti=function(i,t){var e=Ze(i);return{h:e.h,s:Pt(e.s+100*t,0,100),l:e.l,a:e.a}},ei=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},jn=function(i,t){var e=Ze(i);return{h:e.h,s:e.s,l:Pt(e.l+100*t,0,100),a:e.a}},Li=(function(){function i(t){this.parsed=Wh(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return at(ei(this.rgba),2)},i.prototype.isDark=function(){return ei(this.rgba)<.5},i.prototype.isLight=function(){return ei(this.rgba)>=.5},i.prototype.toHex=function(){return t=Js(this.rgba),e=t.r,s=t.g,n=t.b,o=(r=t.a)<1?vs(at(255*r)):"","#"+vs(e)+vs(s)+vs(n)+o;var t,e,s,n,r,o},i.prototype.toRgb=function(){return Js(this.rgba)},i.prototype.toRgbString=function(){return t=Js(this.rgba),e=t.r,s=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+n+", "+r+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,r},i.prototype.toHsl=function(){return Nn(Ze(this.rgba))},i.prototype.toHslString=function(){return t=Nn(Ze(this.rgba)),e=t.h,s=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+r+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,r},i.prototype.toHsv=function(){return t=Ro(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},i.prototype.invert=function(){return Bt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),Bt(ti(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Bt(ti(this.rgba,-t))},i.prototype.grayscale=function(){return Bt(ti(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Bt(jn(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Bt(jn(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?Bt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Ze(this.rgba);return typeof t=="number"?Bt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Bt(t).toHex()},i})(),Bt=function(i){return i instanceof Li?i:new Li(i)},qn=[],Xh=function(i){i.forEach(function(t){qn.indexOf(t)<0&&(t(Li,Bi),qn.push(t))})};function Yh(i,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"},s={};for(var n in e)s[e[n]]=n;var r={};i.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=s[this.toHex()];if(l)return l;if(o?.closest){var c=this.toRgb(),u=1/0,d="black";if(!r.length)for(var f in e)r[f]=new i(e[f]).toRgb();for(var p in e){var g=(a=c,h=r[p],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));g<u&&(u=g,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new i(h).toRgb():null},"name"])}Xh([Yh]);const ke=class $e{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 $e)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}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 s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="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((r,o)=>r===e[o]);if(t!==null&&e!==null){const r=Object.keys(t),o=Object.keys(e);return r.length!==o.length?!1:r.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,n,r]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,n,r]=$e._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,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 s=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,s,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,n=(o&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,r=255]=t,e/=255,s/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=$e.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Bt(t);o.isValid()&&({r:e,g:s,b:n,a:r}=o.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof $e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};ke.shared=new ke;ke._temp=new ke;ke.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let st=ke;const Hh={cullArea:null,cullable:!1,cullableChildren:!0};let si=0;const Kn=500;function Y(...i){si!==Kn&&(si++,si===Kn?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const Xs={_registeredResources:new Set,register(i){this._registeredResources.add(i)},unregister(i){this._registeredResources.delete(i)},release(){this._registeredResources.forEach(i=>i.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(i){return this._registeredResources.has(i)},reset(){this._registeredResources.clear()}};class Nh{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class $h{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Nh(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const yt=new $h;Xs.register(yt);const Vh={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(i){typeof i=="boolean"&&i===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(i===!0?{}:i))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(i){D("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function Lo(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const r=s-e;for(n=t;n<r;++n)i[n]=i[n+e];i.length=r}const jh={allowChildren:!0,removeChildren(i=0,t){const e=t??this.children.length,s=e-i,n=[];if(s>0&&s<=e){for(let o=e-1;o>=i;o--){const a=this.children[o];a&&(n.push(a),a.parent=null)}Lo(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let o=0;o<n.length;++o){const a=n[o];a.parentRenderLayer?.detach(a),this.emit("childRemoved",a,this,o),n[o].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(s===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const t=this.getChildAt(i);return this.removeChild(t)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||D(j,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const s=i.parent===this;if(i.parent){const r=i.parent.children.indexOf(i);if(s){if(r===t)return i;i.parent.children.splice(r,1)}else i.removeFromParent()}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(i),this.sortableChildren&&(this.sortDirty=!0),s||(this.emit("childAdded",i,this,t),i.emit("added",this)),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i},replaceChild(i,t){i.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(i)),t.setFromMatrix(i.localTransform),t.updateLocalTransform(),this.removeChild(i)}},qh={collectRenderables(i,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(i,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,i):this.collectRenderablesWithEffects(i,t,e))},collectRenderablesSimple(i,t,e){const s=this.children,n=s.length;for(let r=0;r<n;r++)s[r].collectRenderables(i,t,e)},collectRenderablesWithEffects(i,t,e){const{renderPipes:s}=t;for(let n=0;n<this.effects.length;n++){const r=this.effects[n];s[r.pipe].push(r,this,i)}this.collectRenderablesSimple(i,t,e);for(let n=this.effects.length-1;n>=0;n--){const r=this.effects[n];s[r.pipe].pop(r,this,i)}}};class Zn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class Kh{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const s=this._tests[e];if(s.test(t))return yt.get(s.maskClass,t)}return t}returnMaskEffect(t){yt.return(t)}}const Oi=new Kh;$.handleByList(k.MaskEffect,Oi._effectClasses);const Zh={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0)},addEffect(i){this.effects.indexOf(i)===-1&&(this.effects.push(i),this.effects.sort((e,s)=>e.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(i){const t=this._maskEffect;t?.mask!==i&&(t&&(this.removeEffect(t),Oi.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=Oi.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(i){this._maskOptions={...this._maskOptions,...i},i.mask&&(this.mask=i.mask),this._markStructureAsChanged()},set filters(i){!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new Zn);i=i;const e=i?.length>0,s=t.filters?.length>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){return this._filterEffect?.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new Zn),this._filterEffect.filterArea=i},get filterArea(){return this._filterEffect?.filterArea}},Qh={label:null,get name(){return D(j,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){D(j,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const n=e[s];if(n.label===i||i instanceof RegExp&&i.test(n.label))return n}if(t)for(let s=0;s<e.length;s++){const r=e[s].getChildByLabel(i,!0);if(r)return r}return null},getChildrenByLabel(i,t=!1,e=[]){const s=this.children;for(let n=0;n<s.length;n++){const r=s[n];(r.label===i||i instanceof RegExp&&i.test(r.label))&&e.push(r)}if(t)for(let n=0;n<s.length;n++)s[n].getChildrenByLabel(i,!0,e);return e}},pt=yt.getPool(z),Xt=yt.getPool(_t),Jh=new z,tl={getFastGlobalBounds(i,t){t||(t=new _t),t.clear(),this._getGlobalBoundsRecursive(!!i,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(i,t,e){let s=t;if(i&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(s=Xt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const r=this.children;for(let o=0;o<r.length;o++)r[o]._getGlobalBoundsRecursive(i,s,e)}if(n){let r=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(r||(r=!0,s.applyMatrix(o.worldTransform)),this.effects[a].addBounds(s,!0));r&&s.applyMatrix(o.worldTransform.copyTo(Jh).invert()),t.addBounds(s),Xt.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),Xt.return(s))}};function Oo(i,t,e){e.clear();let s,n;return i.parent?t?s=i.parent.worldTransform:(n=pt.get().identity(),s=an(i,n)):s=z.IDENTITY,Do(i,e,s,t),n&&pt.return(n),e.isValid||e.set(0,0,0,0),e}function Do(i,t,e,s){if(!i.visible||!i.measurable)return;let n;s?n=i.worldTransform:(i.updateLocalTransform(),n=pt.get(),n.appendFrom(i.localTransform,e));const r=t,o=!!i.effects.length;if(o&&(t=Xt.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{const a=i.bounds;a&&!a.isEmpty()&&(t.matrix=n,t.addBounds(a));for(let h=0;h<i.children.length;h++)Do(i.children[h],t,n,s)}if(o){for(let a=0;a<i.effects.length;a++)i.effects[a].addBounds?.(t);r.addBounds(t,z.IDENTITY),Xt.return(t)}s||pt.return(n)}function an(i,t){const e=i.parent;return e&&(an(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Go(i,t){if(i===16777215||!t)return t;if(t===16777215||!i)return i;const e=i>>16&255,s=i>>8&255,n=i&255,r=t>>16&255,o=t>>8&255,a=t&255,h=e*r/255|0,l=s*o/255|0,c=n*a/255|0;return(h<<16)+(l<<8)+c}const Qn=16777215;function Jn(i,t){return i===Qn?t:t===Qn?i:Go(i,t)}function Rs(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const el={getGlobalAlpha(i){if(i)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(i=new z,t){if(t)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const e=an(this,pt.get().identity());return i.appendFrom(this.localTransform,e),pt.return(e),i},getGlobalTint(i){if(i)return this.renderGroup?Rs(this.renderGroup.worldColor):this.parentRenderGroup?Rs(Jn(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Jn(t,e.localColor),e=e.parent;return Rs(t)}};function zo(i,t,e){return t.clear(),e||(e=z.IDENTITY),Uo(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function Uo(i,t,e,s,n){let r;if(n)r=pt.get(),r=e.copyTo(r);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const h=i.localTransform;r=pt.get(),r.appendFrom(h,e)}const o=t,a=!!i.effects.length;if(a&&(t=Xt.get().clear()),i.boundsArea)t.addRect(i.boundsArea,r);else{i.renderPipeId&&(t.matrix=r,t.addBounds(i.bounds));const h=i.children;for(let l=0;l<h.length;l++)Uo(h[l],t,r,s,!1)}if(a){for(let h=0;h<i.effects.length;h++)i.effects[h].addLocalBounds?.(t,s);o.addBounds(t,z.IDENTITY),Xt.return(t)}pt.return(r)}function Wo(i,t){const e=i.children;for(let s=0;s<e.length;s++){const n=e[s],r=n.uid,o=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,a=t.index;(t.data[a]!==r||t.data[a+1]!==o)&&(t.data[t.index]=r,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,n.children.length&&Wo(n,t)}return t.didChange}const sl=new z,il={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=i/t*e:this.scale.x=e},_setHeight(i,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=i/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new _t});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),Wo(this,i),i.didChange&&zo(this,i.localBounds,sl),i.localBounds},getBounds(i,t){return Oo(this,i,t||new _t)}},nl={_onRender:null,set onRender(i){const t=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},rl={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(ol))}};function ol(i,t){return i._zIndex-t._zIndex}const al={getGlobalPosition(i=new Z,t=!1){return this.parent?this.parent.toGlobal(this._position,i,t):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,t,e=!1){const s=this.getGlobalTransform(pt.get(),e);return t=s.apply(i,t),pt.return(s),t},toLocal(i,t,e,s){t&&(i=t.toGlobal(i,e,s));const n=this.getGlobalTransform(pt.get(),s);return e=n.applyInverse(i,e),pt.return(n),e}};class hn{constructor(){this.uid=et("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let hl=0;class ll{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new jt(this.textureOptions)}createTexture(t,e,s,n){const r=new Mt({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:n});return new G({source:r,label:`texturePool_${hl++}`})}getOptimalTexture(t,e,s=1,n,r=!1){let o=Math.ceil(t*s-1e-6),a=Math.ceil(e*s-1e-6);o=Me(o),a=Me(a);const h=n?1:0,l=r?1:0,c=(o<<17)+(a<<2)+(l<<1)+h;this._texturePool[c]||(this._texturePool[c]=[]);let u=this._texturePool[c].pop();return u||(u=this.createTexture(o,a,n,r)),u.source._resolution=s,u.source.width=o/s,u.source.height=a/s,u.source.pixelWidth=o,u.source.pixelHeight=a,u.frame.x=0,u.frame.y=0,u.frame.width=t,u.frame.height=e,u.updateUvs(),this._poolKeyHash[u.uid]=c,u}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t,e=!1){const s=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[s].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let n=0;n<s.length;n++)s[n].destroy(!0)}this._texturePool={}}}const lt=new ll;Xs.register(lt);class cl{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new z,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new hn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s<e.length;s++){const n=e[s];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(lt.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let s=0;s<e.length;s++)this.removeChild(e[s])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let s=0;s<e.length;s++)this._getChildren(e[s],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const s=t.children;for(let n=0;n<s.length;n++)this._getChildren(s[n],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new z),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new z),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new z),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function ul(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const ii=new ht(null),ws=new ht(null),ni=new ht(null,1,1),Ss=new ht(null),tr=1,dl=2,ri=4;class it extends Rt{constructor(t={}){super(),this.uid=et("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new z,this.relativeGroupTransform=new z,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ht(this,0,0),this._scale=ni,this._pivot=ws,this._origin=Ss,this._skew=ii,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],ul(this,t,{children:!0,parent:!0,effects:!0}),t.children?.forEach(e=>this.addChild(e)),t.parent?.addChild(this)}static mixin(t){D("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),$.mixin(it,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||D(j,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n<t.length;n++)this.addChild(t[n]);return t[0]}const e=t[0],s=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),s&&(s.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,s&&s.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let n=0;n<t.length;n++)this.removeChild(t[n]);return t[0]}const e=t[0],s=this.children.indexOf(e);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=yt.get(cl,this),this.groupTransform=z.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),yt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new z),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Ph}set angle(t){this.rotation=t*Mh}get pivot(){return this._pivot===ws&&(this._pivot=new ht(this,0,0)),this._pivot}set pivot(t){this._pivot===ws&&(this._pivot=new ht(this,0,0),this._origin!==Ss&&Y("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ii&&(this._skew=new ht(this,0,0)),this._skew}set skew(t){this._skew===ii&&(this._skew=new ht(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===ni&&(this._scale=new ht(this,1,1)),this._scale}set scale(t){this._scale===ni&&(this._scale=new ht(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Ss&&(this._origin=new ht(this,0,0)),this._origin}set origin(t){this._origin===Ss&&(this._origin=new ht(this,0,0),this._pivot!==ws&&Y("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX:this.scale.x,typeof t.scaleY=="number"?t.scaleY:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,r=this._origin,o=this._position,a=s._x,h=s._y,l=n._x,c=n._y,u=-r._x,d=-r._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(u*e.a+d*e.c)-u,e.ty=o._y-(l*e.b+c*e.d)+(u*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=tr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=st.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=tr,this._onUpdate())}get tint(){return Rs(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=dl,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ri,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ri,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=ri,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;this.destroyed=!0;let e;if(this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t?.children)&&e)for(let n=0;n<e.length;++n)e[n].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}$.mixin(it,jh,tl,al,nl,il,Zh,Qh,rl,Hh,Vh,el,qh);class ln extends it{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new _t(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=t.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:s,y:n}=t;return s>=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,s){const{renderPipes:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const o=n[this.renderPipeId];o?.addRenderable&&o.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,h=a.length;for(let l=0;l<h;l++)a[l].collectRenderables(t,e,s);n.blendMode.popBlendMode(t)}}class ot extends ln{constructor(t=G.EMPTY){t instanceof G&&(t={texture:t});const{texture:e=G.EMPTY,anchor:s,roundPixels:n,width:r,height:o,...a}=t;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new ht({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof G?new ot(t):new ot(G.from(t,e))}set texture(t){t||(t=G.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return Io(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return D("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:n,height:r}=e.orig;s.minX=-t._x*n,s.maxX=s.minX+n,s.minY=-t._y*r,s.maxY=s.minY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t?.texture){const s=typeof t=="boolean"?t:t?.textureSource;this._texture.destroy(s)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const fl=new _t;function Xo(i,t,e){const s=fl;i.measurable=!0,Oo(i,e,s),t.addBoundsMask(s),i.measurable=!1}function Yo(i,t,e){const s=Xt.get();i.measurable=!0;const n=pt.get().identity(),r=Ho(i,e,n);zo(i,s,r),i.measurable=!1,t.addBoundsMask(s),pt.return(n),Xt.return(s)}function Ho(i,t,e){return i?(i!==t&&(Ho(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(Y("Mask bounds, renderable is not inside the root container"),e)}class No{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof ot),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||Xo(this.mask,t,e)}addLocalBounds(t,e){Yo(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof ot}}No.extension=k.MaskEffect;class $o{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}$o.extension=k.MaskEffect;class Vo{constructor(t){this.priority=0,this.pipe="stencilMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){Xo(this.mask,t,e)}addLocalBounds(t,e){Yo(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof it}}Vo.extension=k.MaskEffect;const pl={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let er=pl;const N={get(){return er},set(i){er=i}};class jo extends Mt{constructor(t){t.resource||(t.resource=N.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}jo.extension=k.TextureSource;class ue extends Mt{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ue.extension=k.TextureSource;var is=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(is||{});class oi{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}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 qo=class xt{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 oi(null,null,1/0),this.deltaMS=1/xt.targetFPMS,this.elapsedMS=1/xt.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,s=is.NORMAL){return this._addListener(new oi(t,e,s))}addOnce(t,e,s=is.NORMAL){return this._addListener(new oi(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.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 r=t-this._lastFrame|0;if(r<this._minElapsedMS)return;this._lastFrame=t-r%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*xt.targetFPMS;const s=this._head;let n=s.next;for(;n;)n=n.emit(this);s.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(Math.max(0,t)/1e3,xt.targetFPMS);this._maxElapsedMS=1/e,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t<this.minFPS&&(this.minFPS=t),this._minElapsedMS=1/(t/1e3))}static get shared(){if(!xt._shared){const t=xt._shared=new xt;t.autoStart=!0,t._protected=!0}return xt._shared}static get system(){if(!xt._system){const t=xt._system=new xt;t.autoStart=!0,t._protected=!0}return xt._system}};qo.targetFPMS=.06;let ct=qo,ai;async function Ko(){return ai??(ai=(async()=>{const t=N.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=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(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(s),t.getExtension("WEBGL_lose_context")?.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ai}const Ys=class Zo extends Mt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Zo.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",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._onCanPlayThrough=this._onCanPlayThrough.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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ct.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;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._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await Ko(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;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._onCanPlayThrough),t.removeEventListener("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}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.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ct.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ct.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ct.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ys.extension=k.TextureSource;Ys.defaultOptions={...Mt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ys.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Qe=Ys;const Ft=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class gl{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||Y(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=Ft(t);let n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){n=l.getCacheableAssets(s,e);break}}const r=new Map(Object.entries(n||{}));n||s.forEach(h=>{r.set(h,e)});const o=[...r.keys()],a={cacheKeys:o,keys:s};s.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&Y("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){Y(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const q=new gl,Di=[];$.handleByList(k.TextureSource,Di);function Qo(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n<Di.length;n++){const r=Di[n];if(r.test(e))return new r(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function ml(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,n=e?i:{resource:i};if(!t&&q.has(s))return q.get(s);const r=new G({source:Qo(n)});return r.on("destroy",()=>{q.has(s)&&q.remove(s)}),t||q.set(s,r),r}function _l(i,t=!1){return typeof i=="string"?q.get(i):i instanceof Mt?new G({source:i}):ml(i,t)}G.from=_l;Mt.from=Qo;$.add(No,$o,Vo,Qe,ue,jo,on);var qt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(qt||{});function kt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Le(i){return i.split("?")[0].split("#")[0]}function yl(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xl(i,t,e){return i.replace(new RegExp(yl(t),"g"),e)}function bl(i,t){let e="",s=0,n=-1,r=0,o=-1;for(let a=0;a<=i.length;++a){if(a<i.length)o=i.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(n===a-1||r===1))if(n!==a-1&&r===2){if(e.length<2||s!==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="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),n=a,r=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=a,r=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,a)}`:e=i.slice(n+1,a),s=a-n-1;n=a,r=0}else o===46&&r!==-1?++r:r=-1}return e}const St={toPosix(i){return xl(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){kt(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(kt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Le(this.toPosix(t??N.get().getBaseUrl())),n=Le(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?St.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(kt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=bl(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return kt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e<i.length;++e){const s=i[e];if(kt(s),s.length>0)if(t===void 0)t=s;else{const n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(kt(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const r=this.getProtocol(i),o=i;i=i.slice(r.length);for(let a=i.length-1;a>=1;--a)if(t=i.charCodeAt(a),t===47){if(!n){s=a;break}}else n=!1;return s===-1?e?"/":this.isUrl(o)?r+i:r:e&&s===1?"//":r+i.slice(0,s)},rootname(i){kt(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){kt(i),t&&kt(t),i=Le(this.toPosix(i));let e=0,s=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let o=t.length-1,a=-1;for(r=i.length-1;r>=0;--r){const h=i.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else a===-1&&(n=!1,a=r+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(s=r):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=i.length),i.slice(e,s)}for(r=i.length-1;r>=0;--r)if(i.charCodeAt(r)===47){if(!n){e=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":i.slice(e,s)},extname(i){kt(i),i=Le(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,r=0;for(let o=i.length-1;o>=0;--o){const a=i.charCodeAt(o);if(a===47){if(!n){e=o+1;break}continue}s===-1&&(n=!1,s=o+1),a===46?t===-1?t=o:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){kt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Le(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let r=-1,o=0,a=-1,h=!0,l=i.length-1,c=0;for(;l>=n;--l){if(e=i.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||a===-1||c===0||c===1&&r===a-1&&r===o+1?a!==-1&&(o===0&&s?t.base=t.name=i.slice(1,a):t.base=t.name=i.slice(o,a)):(o===0&&s?(t.name=i.slice(1,r),t.base=i.slice(1,a)):(t.name=i.slice(o,r),t.base=i.slice(o,a)),t.ext=i.slice(r,a)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Jo(i,t,e,s,n){const r=t[e];for(let o=0;o<r.length;o++){const a=r[o];e<t.length-1?Jo(i.replace(s[e],a),t,e+1,s,n):n.push(i.replace(s[e],a))}}function vl(i){const t=/\{(.*?)\}/g,e=i.match(t),s=[];if(e){const n=[];e.forEach(r=>{const o=r.substring(1,r.length-1).split(",");n.push(o)}),Jo(i,n,0,e,s)}else s.push(i);return s}const Ls=i=>!Array.isArray(i);class Fe{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(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return Ft(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(o=>o?.src??o):r?.src?r.src:r,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&Y("[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 s=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,o])=>typeof o=="string"||Array.isArray(o)?{alias:r,src:o}:{alias:r,...o})),n.forEach(r=>{const o=r.src,a=r.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);s.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));s.push(...l),h=[...a,...l]}this.add({...r,alias:h,src:o})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&Y(`[Resolver] already has key: ${r} overwriting`)},Ft(e).forEach(r=>{const{src:o}=r;let{data:a,format:h,loadParser:l,parser:c}=r;const u=Ft(o).map(g=>typeof g=="string"?vl(g):Array.isArray(g)?g:[g]),d=this.getAlias(r);Array.isArray(d)?d.forEach(s):s(d);const f=[],p=g=>{const m=this._parsers.find(_=>_.test(g));return{src:g,...m?.parse(g)}};u.forEach(g=>{g.forEach(m=>{let _={};if(typeof m!="object"?_=p(m):(a=m.data??a,h=m.format??h,(m.loadParser||m.parser)&&(l=m.loadParser??l,c=m.parser??c),_={...p(m.src),...m}),!d)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this._buildResolvedAsset(_,{aliases:d,data:a,format:h,loadParser:l,parser:c,progressSize:r.progressSize}),f.push(_)})}),d.forEach(g=>{this._assetMap[g]=f})})}resolveBundle(t){const e=Ls(t);t=Ft(t);const s={};return t.forEach(n=>{const r=this._bundles[n];if(r){const o=this.resolve(r),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(n,h)]=l}s[n]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=Ls(t);t=Ft(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const o=this._getPreferredOrder(r);o?.priority.forEach(a=>{o.params[a].forEach(h=>{const l=r.filter(c=>c[a]?c[a]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[e],n=this._preferredOrder.find(r=>r.params.format.includes(s.format));if(n)return n}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:s,data:n,loadParser:r,parser:o,format:a,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=St.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??wl(t.src),h!==void 0&&(t.progressSize=h),t}}Fe.RETINA_PREFIX=/@([0-9\.]+)x/;function wl(i){return i.split(".").pop().split("?").shift().split("#").shift()}const Gi=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},ta=class Ve{constructor(t,e){this.linkedSheets=[];let s=t;t?.source instanceof Mt&&(s={texture:t,data:e});const{texture:n,data:r,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=n instanceof G?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=r;const a=parseFloat(r.meta.scale);a?(this.resolution=a,n.source.resolution=this.resolution):this.resolution=n.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Ve.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let s=t;const n=e?1/0:Ve.BATCH_SIZE;for(;s-t<n&&s<this._frameKeys.length;){const r=this._frameKeys[s],o=this._frames[r],a=o.frame;if(a){let h=null,l=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,u=new W(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?h=new W(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):h=new W(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(l=new W(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[r]=new G({source:this.textureSource,frame:h,orig:u,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:r.toString()})}s++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const n=t[e][s];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Ve.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ve.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ta.BATCH_SIZE=1e3;let zi=ta;const Sl=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function ea(i,t,e){const s={};if(i.forEach(n=>{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=St.dirname(i[0]);t.linkedSheets.forEach((r,o)=>{const a=ea([`${n}/${t.data.meta.related_multi_packs[o]}`],r,!0);Object.assign(s,a)})}return s}const Tl={extension:k.Asset,cache:{test:i=>i instanceof zi,getCacheableAssets:(i,t)=>ea(i,t,!1)},resolver:{extension:{type:k.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&Sl.includes(n)},parse:i=>{const t=i.split(".");return{resolution:parseFloat(Fe.RETINA_PREFIX.exec(i)?.[1]??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:k.LoadParser,priority:qt.Normal,name:"spritesheetLoader"},async testParse(i,t){return St.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){const{texture:s,imageFilename:n,textureOptions:r,cachePrefix:o}=t?.data??{};let a=St.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(s instanceof G)h=s;else{const u=Gi(a+(n??i.meta.image),t.src);h=(await e.load([{src:u,data:r}]))[u]}const l=new zi({texture:h.source,data:i,cachePrefix:o});await l.parse();const c=i?.meta?.related_multi_packs;if(Array.isArray(c)){const u=[];for(const f of c){if(typeof f!="string")continue;let p=a+f;t.data?.ignoreMultiPack||(p=Gi(p,t.src),u.push(e.load({src:p,data:{textureOptions:r,ignoreMultiPack:!0}})))}const d=await Promise.all(u);l.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[l].concat(l.linkedSheets.filter(p=>p!==f))})}return l},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};$.add(Tl);class sa{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),s=this._canvas.width,n=this._canvas.height,r=e.width/s*this._renderer.resolution,o=e.height/n*this._renderer.resolution,a=e.left,h=e.top,l=`translate(${a}px, ${h}px) scale(${r}, ${o})`;l!==this._lastTransform&&(this._domElement.style.transform=l,this._lastTransform=l)},this._domElement=t.domElement,this._renderer=t.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const s=this.canvas.width,n=this.canvas.height,r=e.contentRect.width/s*this._renderer.resolution,o=e.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==r||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||ct.shared.add(this.updateTranslation,this,is.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&ct.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class us{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=us.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Z,this.page=new Z,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,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,s,n,r){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}}var hi=/iPhone/i,sr=/iPod/i,ir=/iPad/i,nr=/\biOS-universal(?:.+)Mac\b/i,li=/\bAndroid(?:.+)Mobile\b/i,rr=/Android/i,_e=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ts=/Silk/i,Gt=/Windows Phone/i,or=/\bWindows(?:.+)ARM\b/i,ar=/BlackBerry/i,hr=/BB10/i,lr=/Opera Mini/i,cr=/\b(CriOS|Chrome)(?:.+)Mobile/i,ur=/Mobile(?:.+)Firefox\b/i,dr=function(i){return typeof i<"u"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream>"u"};function Al(i){return function(t){return t.test(i)}}function fr(i){var t={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?t.userAgent=i:i&&i.userAgent&&(t={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]<"u"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]<"u"&&(e=s[0]);var n=Al(e),r={apple:{phone:n(hi)&&!n(Gt),ipod:n(sr),tablet:!n(hi)&&(n(ir)||dr(t))&&!n(Gt),universal:n(nr),device:(n(hi)||n(sr)||n(ir)||n(nr)||dr(t))&&!n(Gt)},amazon:{phone:n(_e),tablet:!n(_e)&&n(Ts),device:n(_e)||n(Ts)},android:{phone:!n(Gt)&&n(_e)||!n(Gt)&&n(li),tablet:!n(Gt)&&!n(_e)&&!n(li)&&(n(Ts)||n(rr)),device:!n(Gt)&&(n(_e)||n(Ts)||n(li)||n(rr))||n(/\bokhttp\b/i)},windows:{phone:n(Gt),tablet:n(or),device:n(Gt)||n(or)},other:{blackberry:n(ar),blackberry10:n(hr),opera:n(lr),firefox:n(ur),chrome:n(cr),device:n(ar)||n(hr)||n(lr)||n(ur)||n(cr)},any:!1,phone:!1,tablet:!1};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}const Cl=fr.default??fr,Pl=Cl(globalThis.navigator),Ml=9,pr=100,kl=0,El=0,gr=2,mr=1,Il=-1e3,Fl=-1e3,Rl=2,cn=class ia{constructor(t,e=Pl){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const t=document.createElement("button");t.style.width=`${mr}px`,t.style.height=`${mr}px`,t.style.position="absolute",t.style.top=`${Il}px`,t.style.left=`${Fl}px`,t.style.zIndex=Rl.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(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${kl}px`,this._div.style.left=`${El}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=gr.toString(),this._canvasObserver=new sa({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const t of this._children)t._accessibleDiv?.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;for(const t in this._pools)this._pools[t].forEach(s=>{s.parentNode&&s.parentNode.removeChild(s)}),delete this._pools[t];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let s=0;s<e.length;s++)this._updateAccessibleObjects(e[s])}init(t){const s={accessibilityOptions:{...ia.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=s.accessibilityOptions.debug,this._activateOnTab=s.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=s.accessibilityOptions.deactivateOnMouseMove,s.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const s of this._children)s._renderId===this._renderId&&e.add(this._children.indexOf(s))}for(let s=this._children.length-1;s>=0;s--){const n=this._children[s];e.has(s)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,Lo(this._children,s,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let s=0;s<this._children.length;s++){const n=this._children[s];if(!n._accessibleActive||!n._accessibleDiv)continue;const r=n._accessibleDiv,o=n.hitArea||n.getBounds().rectangle;if(n.hitArea){const a=n.worldTransform;r.style.left=`${a.tx+o.x*a.a}px`,r.style.top=`${a.ty+o.y*a.d}px`,r.style.width=`${o.width*a.a}px`,r.style.height=`${o.height*a.d}px`}else this._capHitArea(o),r.style.left=`${o.x}px`,r.style.top=`${o.y}px`,r.style.width=`${o.width}px`,r.style.height=`${o.height}px`}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:s}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}_addChild(t){let s=this._getPool(t.accessibleType).pop();s?(s.innerHTML="",s.removeAttribute("title"),s.removeAttribute("aria-label"),s.tabIndex=0):(t.accessibleType==="button"?s=document.createElement("button"):(s=document.createElement(t.accessibleType),s.style.cssText=`
|
|
5
|
-
color: transparent;
|
|
6
|
-
pointer-events: none;
|
|
7
|
-
padding: 0;
|
|
8
|
-
margin: 0;
|
|
9
|
-
border: 0;
|
|
10
|
-
outline: 0;
|
|
11
|
-
background: transparent;
|
|
12
|
-
box-sizing: border-box;
|
|
13
|
-
user-select: none;
|
|
14
|
-
-webkit-user-select: none;
|
|
15
|
-
-moz-user-select: none;
|
|
16
|
-
-ms-user-select: none;
|
|
17
|
-
`,t.accessibleText&&(s.innerText=t.accessibleText)),s.style.width=`${pr}px`,s.style.height=`${pr}px`,s.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",s.style.position="absolute",s.style.zIndex=gr.toString(),s.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?s.setAttribute("aria-live","off"):s.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?s.setAttribute("aria-relevant","additions"):s.setAttribute("aria-relevant","text"),s.addEventListener("click",this._onClick.bind(this)),s.addEventListener("focus",this._onFocus.bind(this)),s.addEventListener("focusout",this._onFocusOut.bind(this))),s.style.pointerEvents=t.accessiblePointerEvents,s.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?s.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(s.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&s.setAttribute("aria-label",t.accessibleHint),t.interactive?s.tabIndex=t.tabIndex:s.tabIndex=0,this.debug&&this._updateDebugHTML(s),t._accessibleActive=!0,t._accessibleDiv=s,s.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:s}=t.target,n=this._renderer.events.rootBoundary,r=Object.assign(new us(n),{target:s});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>n.dispatchEvent(r,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!==Ml||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}_getPool(t){return this._pools[t]||(this._pools[t]=[]),this._pools[t]}};cn.extension={type:[k.WebGLSystem,k.WebGPUSystem],name:"accessibility"};cn.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Bl=cn;const Ll={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1},ci=Object.create(null),_r=Object.create(null);function un(i,t){let e=_r[i];return e===void 0&&(ci[t]===void 0&&(ci[t]=1),_r[i]=e=ci[t]++),e}let As;function na(){return(!As||As?.isContextLost())&&(As=N.get().createCanvas().getContext("webgl",{})),As}let Cs;function Ol(){if(!Cs){Cs="mediump";const i=na();i&&i.getShaderPrecisionFormat&&(Cs=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return Cs}function Dl(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),`
|
|
18
|
-
|
|
19
|
-
#ifdef GL_ES // This checks if it is WebGL1
|
|
20
|
-
#define in varying
|
|
21
|
-
#define finalColor gl_FragColor
|
|
22
|
-
#define texture texture2D
|
|
23
|
-
#endif
|
|
24
|
-
${i}
|
|
25
|
-
`):`
|
|
26
|
-
|
|
27
|
-
#ifdef GL_ES // This checks if it is WebGL1
|
|
28
|
-
#define in attribute
|
|
29
|
-
#define out varying
|
|
30
|
-
#endif
|
|
31
|
-
${i}
|
|
32
|
-
`}function Gl(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&s!=="highp"&&(n="mediump"),`precision ${n} float;
|
|
33
|
-
${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function zl(i,t){return t?`#version 300 es
|
|
34
|
-
${i}`:i}const Ul={},Wl={};function Xl(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Ul:Wl;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`}
|
|
35
|
-
${i}`}function Yl(i,t){return t?i.replace("#version 300 es",""):i}const ui={stripVersion:Yl,ensurePrecision:Gl,addProgramDefines:Dl,setProgramName:Xl,insertVersion:zl},Oe=Object.create(null),ra=class Ui{constructor(t){t={...Ui.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ol()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(ui).forEach(o=>{const a=s[o];n=ui[o](n,a,!0),r=ui[o](r,a,!1)}),this.fragment=n,this.vertex=r,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=un(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,Oe[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Oe[e]||(Oe[e]=new Ui(t),Oe[e]._cacheKey=e),Oe[e]}};ra.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let ds=ra;const yr={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Hl(i){return yr[i]??yr.float32}const Nl={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},xr=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function br(i,t){let e;for(;(e=xr.exec(i))!==null;){const s=Nl[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:s,stride:Hl(s).stride,offset:0,instance:!1,start:0}}xr.lastIndex=0}function $l(i){return i.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Vl({source:i,entryPoint:t}){const e={},s=$l(i),n=s.indexOf(`fn ${t}(`);if(n===-1)return e;const r=s.indexOf("->",n);if(r===-1)return e;const o=s.substring(n,r);if(br(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const h=a[1],l=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=s.match(l);c&&br(c[1],e)}}return e}function di(i){const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=i.match(t)?.map(u=>({group:parseInt(u.match(e)[1],10),binding:parseInt(u.match(s)[1],10),name:u.match(n)[2],isUniform:u.match(n)[1]==="<uniform>",type:u.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=i.match(o)?.map(u=>{const d=u.match(h)[1],f=u.match(a).reduce((p,g)=>{const[m,_]=g.split(":");return p[m.trim()]=_.trim(),p},{});return f?{name:d,members:f}:null}).filter(({name:u})=>l.some(d=>d.type===u||d.type.includes(`<${u}>`)))??[];return{groups:l,structs:c}}var he=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(he||{});function jl({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:he.VERTEX|he.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:he.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:he.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):s.type==="texture_2d_array"||s.type.startsWith("texture_2d_array<")?t[s.group].push({binding:s.binding,visibility:he.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(s.type==="texture_cube"||s.type.startsWith("texture_cube<"))&&t[s.group].push({binding:s.binding,visibility:he.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function ql({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function Kl(i,t){const e=new Set,s=new Set,n=[...i.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),r=[...i.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:n,groups:r}}const De=Object.create(null);class ge{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:r,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=s,e.source===s.source){const a=di(e.source);this.structsAndGroups=a}else{const a=di(s.source),h=di(e.source);this.structsAndGroups=Kl(a,h)}this.layout=n??ql(this.structsAndGroups),this.gpuLayout=r??jl(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=un(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Vl(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,De[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return De[e]||(De[e]=new ge(t),De[e]._cacheKey=e),De[e]}}const oa=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],Zl=oa.reduce((i,t)=>(i[t]=!0,i),{});function Ql(i,t){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const aa=class ha{constructor(t,e){this._touched=0,this.uid=et("uniform"),this._resourceType="uniformGroup",this._resourceId=et("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...ha.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!Zl[r.type]){const o=r.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${r.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${oa.join(", ")}`)}r.value??(r.value=Ql(r.type,r.size)),s[n]=r.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=un(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};aa.defaultOptions={ubo:!1,isStatic:!1};let dn=aa;class Je{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){const s=this.resources[e];t!==s&&(s?.off?.("change",this.onResourceChange,this),t.on?.("change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const s=this.resources;for(const n in s)s[n]._gcLastUsed=t,s[n]._touched=e}destroy(){const t=this.resources;for(const e in t)t[e]?.off?.("change",this.onResourceChange,this);this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var de=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.CANVAS=4]="CANVAS",i[i.BOTH=3]="BOTH",i))(de||{});class Hs extends Rt{constructor(t){super(),this.uid=et("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:n,resources:r,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=de.WEBGPU),s&&(o|=de.WEBGL)),this.compatibleRenderers=o;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&a)for(const l in a)for(const c in a[l]){const u=a[l][c];h[u]={group:l,binding:c,name:u}}else if(e&&n&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(r){n={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let l=0;for(const c in r)h[c]||(n[99]||(n[99]=new Je,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in r){const u=c;let d=r[c];!d.source&&!d._resourceType&&(d=new dn(d));const f=h[u];f&&(n[f.group]||(n[f.group]=new Je,this._ownedBindGroups.push(n[f.group])),n[f.group].setResource(d,f.binding))}}this.groups=n,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[s]||(r[s]=t),this.groups[e]||(this.groups[e]=new Je,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const r=e[n];Object.defineProperty(s,r.name,{get(){return t[r.group].getResource(r.binding)},set(o){t[r.group].setResource(o,r.binding)}})}return s}destroy(t=!1){this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(e=>{e.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:s,...n}=t;let r,o;return e&&(r=ge.from(e)),s&&(o=ds.from(s)),new Hs({gpuProgram:r,glProgram:o,...n})}}const Jl={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},fi=0,pi=1,gi=2,mi=3,_i=4,yi=5,Wi=class la{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<fi)}set blend(t){!!(this.data&1<<fi)!==t&&(this.data^=1<<fi)}get offsets(){return!!(this.data&1<<pi)}set offsets(t){!!(this.data&1<<pi)!==t&&(this.data^=1<<pi)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<gi)}set culling(t){!!(this.data&1<<gi)!==t&&(this.data^=1<<gi)}get depthTest(){return!!(this.data&1<<mi)}set depthTest(t){!!(this.data&1<<mi)!==t&&(this.data^=1<<mi)}get depthMask(){return!!(this.data&1<<yi)}set depthMask(t){!!(this.data&1<<yi)!==t&&(this.data^=1<<yi)}get clockwiseFrontFace(){return!!(this.data&1<<_i)}set clockwiseFrontFace(t){!!(this.data&1<<_i)!==t&&(this.data^=1<<_i)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=Jl[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new la;return t.depthTest=!1,t.blend=!0,t}};Wi.default2d=Wi.for2d();let fn=Wi;const ca=class Xi extends Hs{constructor(t){t={...Xi.defaultOptions,...t},super(t),this.enabled=!0,this._state=fn.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,s,n){t.applyFilter(this,e,s,n)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:s,...n}=t;let r,o;return e&&(r=ge.from(e)),s&&(o=ds.from(s)),new Xi({gpuProgram:r,glProgram:o,...n})}};ca.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let pn=ca;const ns=new Set;let Yi=!1;function vr(i,t,e=2){const s=t&&t.length,n=s?t[0]*e:i.length;ns.size&&ns.clear();let r=ua(i,0,n,e,!0);const o=[];if(!r||r.next===r.prev)return o;let a=0,h=0,l=0;if(s&&(r=nc(i,t,r,e)),i.length>80*e){a=i[0],h=i[1];let c=a,u=h;for(let d=e;d<n;d+=e){const f=i[d],p=i[d+1];f<a&&(a=f),p<h&&(h=p),f>c&&(c=f),p>u&&(u=p)}l=Math.max(c-a,u-h),l=l!==0?32767/l:0}return Hi(r,o,a,h,l),o}function ua(i,t,e,s,n){let r=null;if(n===_c(i,t,e,s)>0)for(let o=t;o<e;o+=s)r=Tr(o/s|0,i[o],i[o+1],r);else for(let o=e-s;o>=t;o-=s)r=Tr(o/s|0,i[o],i[o+1],r);return r&&rs(r,r.next)&&(as(r),r=r.next),r}function fe(i,t=i){const e=t===i;let s=i,n;do n=!1,s!==s.next&&(ns.size===0||!ns.has(s))&&(rs(s,s.next)||rt(s.prev,s,s.next)===0)?((e||s===t)&&(t=s.prev),Yi=!0,as(s),s=s.prev,n=!0):(e||s!==t)&&(s=s.next,n=!e);while(n||s!==t);return t}function Hi(i,t,e,s,n){n&&uc(i,e,s,n);let r=i,o=!1;for(;i.prev!==i.next;){const a=i.prev,h=i.next;if(rt(a,i,h)<0&&(n?ec(i,e,s,n):tc(i))){t.push(a.i,i.i,h.i),as(i),i=h,r=h;continue}if(i=h,i===r){if(Yi=!1,i=fe(i),Yi){r=i;continue}if(!o){i=sc(i,t),r=i,o=!0;continue}ic(i,t,e,s,n);break}}}function tc(i){const t=i.prev,e=i,s=i.next,n=t.x,r=e.x,o=s.x,a=t.y,h=e.y,l=s.y,c=Math.min(n,r,o),u=Math.min(a,h,l),d=Math.max(n,r,o),f=Math.max(a,h,l);let p=s.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&!(n===p.x&&a===p.y)&&Ds(n,a,r,h,o,l,p.x,p.y)&&rt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function ec(i,t,e,s){const n=i.prev,r=i,o=i.next,a=n.x,h=r.x,l=o.x,c=n.y,u=r.y,d=o.y,f=Math.min(a,h,l),p=Math.min(c,u,d),g=Math.max(a,h,l),m=Math.max(c,u,d),_=ji(f,p,t,e,s),x=ji(g,m,t,e,s);let b=i.prevZ;for(;b&&b.z>=_;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=m&&b!==o&&!(a===b.x&&c===b.y)&&Ds(a,c,h,u,l,d,b.x,b.y)&&rt(b.prev,b,b.next)>=0)return!1;b=b.prevZ}let y=i.nextZ;for(;y&&y.z<=x;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==o&&!(a===y.x&&c===y.y)&&Ds(a,c,h,u,l,d,y.x,y.y)&&rt(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function sc(i,t){let e=i,s=!1;do{const n=e.prev,r=e.next.next;pa(n,e,e.next,r,!1)&&os(n,r)&&os(r,n)&&(t.push(n.i,e.i,r.i),as(e),as(e.next),e=i=r,s=!0),e=e.next}while(e!==i);return s?fe(e):e}function ic(i,t,e,s,n){let r=i;do{let o=r.next.next;for(;o!==r.prev;){if(r.i!==o.i&&pc(r,o)){let a=ga(r,o);r=fe(r,r.next),a=fe(a,a.next),Hi(r,t,e,s,n),Hi(a,t,e,s,n);return}o=o.next}r=r.next}while(r!==i)}let Ni=!1;function nc(i,t,e,s){const n=[];for(let r=0,o=t.length;r<o;r++){const a=t[r]*s,h=r<o-1?t[r+1]*s:i.length,l=ua(i,a,h,s,!1);l===l.next&&ns.add(l),n.push(fc(l))}n.sort(rc),ac(i.length/s,t.length),fa(e,e),Ni=!0;for(let r=0;r<n.length;r++)e=oc(n[r],e);return Ni=!1,fe(e)}function rc(i,t){return i.x-t.x||i.y-t.y||(i.next.y-i.y)/(i.next.x-i.x)-(t.next.y-t.y)/(t.next.x-t.x)}function oc(i,t){const e=lc(i,t);if(!e)return t;const s=ga(e,i),n=s.next;return fa(e,n.next),fe(s,s.next),fe(e,e.next)}const da=16;let J=new Float64Array(0),Os=0;const $i=[],Vi=[];function ac(i,t){const e=Math.ceil((i+2*t)/da)+t+2;J.length<e*4&&(J=new Float64Array(e*4)),Os=0}function fa(i,t){let e=i;do{const s=Os++;$i[s]=e;let n=1/0,r=1/0,o=-1/0,a=-1/0,h=0;do{const c=e.next;e.z=s,e.x<n&&(n=e.x),e.x>o&&(o=e.x),e.y<r&&(r=e.y),e.y>a&&(a=e.y),c.x<n&&(n=c.x),c.x>o&&(o=c.x),c.y<r&&(r=c.y),c.y>a&&(a=c.y),e=c}while(++h<da&&e!==t);Vi[s]=e;const l=s*4;J[l]=n,J[l+1]=r,J[l+2]=o,J[l+3]=a}while(e!==t)}function hc(i,t){const e=i.z*4;t.x<J[e]&&(J[e]=t.x),t.y<J[e+1]&&(J[e+1]=t.y),t.x>J[e+2]&&(J[e+2]=t.x),t.y>J[e+3]&&(J[e+3]=t.y)}function wr(i){let t=Vi[i];for(;t.prev.next!==t;)t=t.next;return Vi[i]=t,t}function Sr(i){let t=$i[i];for(;t.prev.next!==t;)t=t.next;return $i[i]=t,t}function lc(i,t){let e=t;const s=i.x,n=i.y;let r=-1/0,o;if(rs(i,e))return e;for(let d=0,f=0;d<Os;d++,f+=4){if(n<J[f+1]||n>J[f+3]||J[f]>s||J[f+2]<=r)continue;const p=wr(d);e=Sr(d);do{if(e.prev.next===e){if(rs(i,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const g=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(g<=s&&g>r&&(r=g,o=e.x<e.next.x?e:e.next,g===s))return o}}e=e.next}while(e!==p)}if(!o)return null;const a=o.x,h=o.y,l=Math.min(n,h),c=Math.max(n,h);let u=1/0;for(let d=0,f=0;d<Os;d++,f+=4){if(J[f+2]<a||J[f]>s||J[f+3]<l||J[f+1]>c)continue;const p=wr(d);e=Sr(d);do{if(e.prev.next===e&&s>=e.x&&e.x>=a&&s!==e.x&&Ds(n<h?s:r,n,a,h,n<h?r:s,n,e.x,e.y)){const g=Math.abs(n-e.y)/(s-e.x);(os(e,i)||e.y===n&&e.next.y===n&&e.next.x>s)&&(g<u||g===u&&(e.x>o.x||e.x===o.x&&cc(o,e)))&&(o=e,u=g)}e=e.next}while(e!==p)}return o}function cc(i,t){return rt(i.prev,i,t.prev)<0&&rt(t.next,i,i.next)<0}const Tt=[];let Ge=[],ee=new Uint32Array(0),ze=new Uint32Array(0);const Ue=new Uint32Array(256);function uc(i,t,e,s){let n=i,r=0;do n.z=ji(n.x,n.y,t,e,s),Tt[r++]=n,n=n.next;while(n!==i);dc(r);let o=null;for(let a=0;a<r;a++){const h=Tt[a];h.prevZ=o,o&&(o.nextZ=h),o=h}o.nextZ=null}function dc(i){if(i<=32){for(let t=1;t<i;t++){const e=Tt[t],s=e.z;let n=t-1;for(;n>=0&&Tt[n].z>s;)Tt[n+1]=Tt[n],n--;Tt[n+1]=e}return}ee.length<i&&(ee=new Uint32Array(i),ze=new Uint32Array(i),Ge=new Array(i));for(let t=0;t<i;t++)ee[t]=Tt[t].z;Ps(i,Tt,ee,Ge,ze,0),Ps(i,Ge,ze,Tt,ee,8),Ps(i,Tt,ee,Ge,ze,16),Ps(i,Ge,ze,Tt,ee,24)}function Ps(i,t,e,s,n,r){Ue.fill(0);for(let a=0;a<i;a++)Ue[e[a]>>>r&255]++;let o=0;for(let a=0;a<256;a++){const h=Ue[a];Ue[a]=o,o+=h}for(let a=0;a<i;a++){const h=e[a],l=Ue[h>>>r&255]++;s[l]=t[a],n[l]=h}}function ji(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function fc(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Ds(i,t,e,s,n,r,o,a){return(n-o)*(t-a)>=(i-o)*(r-a)&&(i-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(r-a)>=(n-o)*(s-a)}function pc(i,t){const e=rs(i,t)&&rt(i.prev,i,i.next)>0&&rt(t.prev,t,t.next)>0;return i.next.i!==t.i&&(e||os(i,t)&&os(t,i)&&(rt(i.prev,i,t.prev)!==0||rt(i,t.prev,t)!==0))&&!gc(i,t)&&(e||mc(i,t))}function rt(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function rs(i,t){return i.x===t.x&&i.y===t.y}function pa(i,t,e,s,n=!0){const r=rt(i,t,e),o=rt(i,t,s),a=rt(e,s,i),h=rt(e,s,t);return(r>0&&o<0||r<0&&o>0)&&(a>0&&h<0||a<0&&h>0)?!0:n?!!(r===0&&Ms(i,e,t)||o===0&&Ms(i,s,t)||a===0&&Ms(e,i,s)||h===0&&Ms(e,t,s)):!1}function Ms(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function gc(i,t){const e=Math.min(i.x,t.x),s=Math.max(i.x,t.x),n=Math.min(i.y,t.y),r=Math.max(i.y,t.y);let o=i;do{const a=o.next;if(o.x>s&&a.x>s||o.x<e&&a.x<e||o.y>r&&a.y>r||o.y<n&&a.y<n){o=a;continue}if(o.i!==i.i&&a.i!==i.i&&o.i!==t.i&&a.i!==t.i&&pa(o,a,i,t))return!0;o=a}while(o!==i);return!1}function os(i,t){return rt(i.prev,i,i.next)<0?rt(i,t,i.next)>=0&&rt(i,i.prev,t)>=0:rt(i,t,i.prev)<0||rt(i,i.next,t)<0}function mc(i,t){let e=i,s=!1;const n=(i.x+t.x)/2,r=(i.y+t.y)/2;do{const o=e.next;e.y>r!=o.y>r&&n<(o.x-e.x)*(r-e.y)/(o.y-e.y)+e.x&&(s=!s),e=o}while(e!==i);return s}function ga(i,t){const e=qi(i.i,i.x,i.y),s=qi(t.i,t.x,t.y),n=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function Tr(i,t,e,s){const n=qi(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function as(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ),Ni&&hc(i.prev,i.next)}function qi(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function _c(i,t,e,s){let n=0;for(let r=t,o=e-s;r<e;r+=s)n+=(i[o]-i[r])*(i[r+1]+i[o+1]),o=r;return n}const yc=vr.default||vr,xi={test(i){return typeof i=="string"&&i.startsWith("info face=")},parse(i){const t=i.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in t){const d=t[u].match(/^[a-z]+/gm)[0],f=t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const g in f){const m=f[g].split("="),_=m[0],x=m[1].replace(/"/gm,""),b=parseFloat(x),y=isNaN(b)?x:b;p[_]=y}e[d].push(p)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[n]=e.info,[r]=e.common,[o]=e.distanceField??[];o&&(s.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),s.fontSize=parseInt(n.size,10),s.fontFamily=n.face,s.lineHeight=parseInt(r.lineHeight,10);const a=e.page;for(let u=0;u<a.length;u++)s.pages.push({id:parseInt(a[u].id,10)||0,file:a[u].file});const h={};s.baseLineOffset=s.lineHeight-parseInt(r.base,10);const l=e.char;for(let u=0;u<l.length;u++){const d=l[u],f=parseInt(d.id,10);let p=d.letter??d.char??String.fromCharCode(f);p==="space"&&(p=" "),h[f]=p,s.chars[p]={id:f,page:parseInt(d.page,10)||0,x:parseInt(d.x,10),y:parseInt(d.y,10),width:parseInt(d.width,10),height:parseInt(d.height,10),xOffset:parseInt(d.xoffset,10),yOffset:parseInt(d.yoffset,10),xAdvance:parseInt(d.xadvance,10),kerning:{}}}const c=e.kerning||[];for(let u=0;u<c.length;u++){const d=parseInt(c[u].first,10),f=parseInt(c[u].second,10),p=parseInt(c[u].amount,10);s.chars[h[f]]&&(s.chars[h[f]].kerning[h[d]]=p)}return s}},Ar={test(i){const t=i;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(i){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=i.getElementsByTagName("info")[0],s=i.getElementsByTagName("common")[0],n=i.getElementsByTagName("distanceField")[0];n&&(t.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const r=i.getElementsByTagName("page"),o=i.getElementsByTagName("char"),a=i.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let l=0;l<r.length;l++)t.pages.push({id:parseInt(r[l].getAttribute("id"),10)||0,file:r[l].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(s.getAttribute("base"),10);for(let l=0;l<o.length;l++){const c=o[l],u=parseInt(c.getAttribute("id"),10);let d=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(u);d==="space"&&(d=" "),h[u]=d,t.chars[d]={id:u,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let l=0;l<a.length;l++){const c=parseInt(a[l].getAttribute("first"),10),u=parseInt(a[l].getAttribute("second"),10),d=parseInt(a[l].getAttribute("amount"),10);t.chars[h[u]]&&(t.chars[h[u]].kerning[h[c]]=d)}return t}},Cr={test(i){return typeof i=="string"&&i.match(/<font(\s|>)/)?Ar.test(N.get().parseXML(i)):!1},parse(i){return Ar.parse(N.get().parseXML(i))}},xc=[".xml",".fnt"],bc={extension:{type:k.CacheParser,name:"cacheBitmapFont"},test:i=>!!i?.pages&&!!i?.chars&&typeof i?.fontFamily=="string"&&i.fontFamily!=="",getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},vc={extension:{type:k.LoadParser,priority:qt.Normal},name:"loadBitmapFont",id:"bitmap-font",test(i){return xc.includes(St.extname(i).toLowerCase())},async testParse(i){return xi.test(i)||Cr.test(i)},async parse(i,t,e){const s=xi.test(i)?xi.parse(i):Cr.parse(i),{src:n}=t,{pages:r}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;d<r.length;++d){const f=r[d].file;let p=St.join(St.dirname(n),f);p=Gi(p,n),o.push({src:p,data:a})}const[h,{BitmapFont:l}]=await Promise.all([e.load(o),rn(()=>Promise.resolve().then(()=>xp),void 0)]),c=o.map(d=>h[d.src]);return new l({data:s,textures:c},n)},async load(i,t){return await(await N.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class wc{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 s=0;s<e;s++)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())}}const Sc={extension:{type:k.CacheParser,name:"cacheTextureArray"},test:i=>Array.isArray(i)&&i.every(t=>t instanceof G),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((n,r)=>{e[s+(r===0?"":r+1)]=n})}),e}};async function ma(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Tc={extension:{type:k.DetectionParser,priority:1},test:async()=>ma("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},Pr=["png","jpg","jpeg"],Ac={extension:{type:k.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...Pr],remove:async i=>i.filter(t=>!Pr.includes(t))},Cc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ns(i){return Cc?!1:document.createElement("video").canPlayType(i)!==""}const Pc={extension:{type:k.DetectionParser,priority:0},test:async()=>Ns("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},Mc={extension:{type:k.DetectionParser,priority:0},test:async()=>Ns("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},kc={extension:{type:k.DetectionParser,priority:0},test:async()=>Ns("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Ec={extension:{type:k.DetectionParser,priority:0},test:async()=>ma("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")},_a=class Bs{constructor(){this.loadOptions={...Bs.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{let n=null,r=null;if((e.parser||e.loadParser)&&(r=this._parserHash[e.parser||e.loadParser],e.loadParser&&Y(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),r||Y(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!r){for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];if(a.load&&a.test?.(t,e,this)){r=a;break}}if(!r)return Y(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}n=await r.load(t,e,this),s.parser=r;for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];a.parse&&a.parse&&await a.testParse?.(n,e,this)&&(n=await a.parse(n,e,this)||n,s.parser=a)}return n})(),s}async load(t,e){this._parsersValidated||this._validateParsers();const s=typeof e=="function"?{...Bs.defaultOptions,...this.loadOptions,onProgress:e}:{...Bs.defaultOptions,...this.loadOptions,...e||{}},{onProgress:n,onError:r,strategy:o,retryCount:a,retryDelay:h}=s;let l=0;const c={},u=Ls(t),d=Ft(t,g=>({alias:[g],src:g,data:{}})),f=d.reduce((g,m)=>g+(m.progressSize||1),0),p=d.map(async g=>{const m=St.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(m,g,{onProgress:n,onError:r,strategy:o,retryCount:a,retryDelay:h},c),l+=g.progressSize||1,n&&n(l/f))});return await Promise.all(p),u?c[d[0].src]:c}async unload(t){const s=Ft(t,n=>({alias:[n],src:n})).map(async n=>{const r=St.toAbsolute(n.src),o=this.promiseCache[r];if(o){const a=await o.promise;delete this.promiseCache[r],await o.parser?.unload?.(a,n,this)}});await Promise.all(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id?Y("[Assets] parser should have an id"):(t[e.name]||t[e.id])&&Y(`[Assets] parser id conflict "${e.id}"`),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,s,n){let r=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=s,c=u=>new Promise(d=>setTimeout(d,u));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),n[e.src]=await this.promiseCache[t].promise;return}catch(u){delete this.promiseCache[t],delete n[e.src],r++;const d=a!=="retry"||r>h;if(a==="retry"&&!d){o&&o(u,e),await c(l);continue}if(a==="skip"){o&&o(u,e);return}o&&o(u,e);const f=new Error(`[Loader.load] Failed to load ${t}.
|
|
36
|
-
${u}`);throw u instanceof Error&&u.stack&&(f.stack=u.stack),f}}};_a.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let Ic=_a;function Re(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function Be(i,t){const e=i.split("?")[0],s=St.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const Fc=".json",Rc="application/json",Bc={extension:{type:k.LoadParser,priority:qt.Low},name:"loadJson",id:"json",test(i){return Re(i,Rc)||Be(i,Fc)},async load(i){return await(await N.get().fetch(i)).json()}},Lc=".txt",Oc="text/plain",Dc={name:"loadTxt",id:"text",extension:{type:k.LoadParser,priority:qt.Low,name:"loadTxt"},test(i){return Re(i,Oc)||Be(i,Lc)},async load(i){return await(await N.get().fetch(i)).text()}},Gc=["normal","bold","100","200","300","400","500","600","700","800","900"],zc=[".ttf",".otf",".woff",".woff2"],Uc=["font/ttf","font/otf","font/woff","font/woff2"],Wc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Xc(i){const t=St.extname(i),n=St.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let r=n.length>0;for(const a of n)if(!a.match(Wc)){r=!1;break}let o=n.join(" ");return r||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const Yc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Hc(i){return Yc.test(i)?i:encodeURI(i)}const Nc={extension:{type:k.LoadParser,priority:qt.Low},name:"loadWebFont",id:"web-font",test(i){return Re(i,Uc)||Be(i,zc)},async load(i,t){const e=N.get().getFontFaceSet();if(e){const s=[],n=t.data?.family??Xc(i),r=t.data?.weights?.filter(a=>Gc.includes(a))??["normal"],o=t.data??{};for(let a=0;a<r.length;a++){const h=r[a],l=new FontFace(n,`url('${Hc(i)}')`,{...o,weight:h});await l.load(),e.add(l),s.push(l)}return q.has(`${n}-and-url`)?q.get(`${n}-and-url`).entries.push({url:i,faces:s}):q.set(`${n}-and-url`,{entries:[{url:i,faces:s}]}),s.length===1?s[0]:s}return Y("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(i){const t=Array.isArray(i)?i:[i],e=t[0].family,s=q.get(`${e}-and-url`),n=s.entries.find(r=>r.faces.some(o=>t.indexOf(o)!==-1));n.faces=n.faces.filter(r=>t.indexOf(r)===-1),n.faces.length===0&&(s.entries=s.entries.filter(r=>r!==n)),t.forEach(r=>{N.get().getFontFaceSet().delete(r)}),s.entries.length===0&&q.remove(`${e}-and-url`)}},bi={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},$c=/([astvzqmhlc])([^astvzqmhlc]*)/gi,Vc=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function jc(i){const t=[];return i.replace($c,(e,s,n)=>{let r=s.toLowerCase(),o=s;const a=qc(n);for(r==="m"&&a.length>2&&(t.push([o,...a.splice(0,2)]),r="l",o=o==="m"?"l":"L");;){if(a.length===bi[r])return t.push([o,...a]),"";if(a.length<bi[r])throw new Error("malformed path data");t.push([o,...a.splice(0,bi[r])])}}),t}function qc(i){const t=i.match(Vc);return t?t.map(Number):[]}function Kc(i,t){const e=jc(i),s=[];let n=null,r=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case"M":r=c[1],o=c[2],t.moveTo(r,o);break;case"m":r+=c[1],o+=c[2],t.moveTo(r,o);break;case"H":r=c[1],t.lineTo(r,o);break;case"h":r+=c[1],t.lineTo(r,o);break;case"V":o=c[1],t.lineTo(r,o);break;case"v":o+=c[1],t.lineTo(r,o);break;case"L":r=c[1],o=c[2],t.lineTo(r,o);break;case"l":r+=c[1],o+=c[2],t.lineTo(r,o);break;case"C":r=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],r,o);break;case"c":t.bezierCurveTo(r+c[1],o+c[2],r+c[3],o+c[4],r+c[5],o+c[6]),r+=c[5],o+=c[6];break;case"S":r=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],r,o);break;case"s":t.bezierCurveToShort(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"Q":r=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],r,o);break;case"q":t.quadraticCurveTo(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"T":r=c[1],o=c[2],t.quadraticCurveToShort(r,o);break;case"t":r+=c[1],o+=c[2],t.quadraticCurveToShort(r,o);break;case"A":r=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"a":r+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"Z":case"z":t.closePath(),s.length>0&&(n=s.pop(),n?(r=n.startX,o=n.startY):(r=0,o=0)),n=null;break;default:Y(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:o},s.push(n))}return t}class gn{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new gn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=s}strokeContains(t,e,s,n=.5){if(this.radius===0)return!1;const r=this.x-t,o=this.y-e,a=this.radius,h=(1-n)*s,l=Math.sqrt(r*r+o*o);return l<=a+h&&l>a-(s-h)}getBounds(t){return t||(t=new W),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class mn{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new mn(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s,n=.5){const{halfWidth:r,halfHeight:o}=this;if(r<=0||o<=0)return!1;const a=s*(1-n),h=s-a,l=r-h,c=o-h,u=r+a,d=o+a,f=t-this.x,p=e-this.y,g=f*f/(l*l)+p*p/(c*c),m=f*f/(u*u)+p*p/(d*d);return g>1&&m<=1}getBounds(t){return t||(t=new W),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Zc(i,t,e,s,n,r){const o=i-e,a=t-s,h=n-e,l=r-s,c=o*h+a*l,u=h*h+l*l;let d=-1;u!==0&&(d=c/u);let f,p;d<0?(f=e,p=s):d>1?(f=n,p=r):(f=e+d*h,p=s+d*l);const g=i-f,m=t-p;return g*g+m*m}let Qc,Jc;class ts{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,r=e.length;n<r;n++)s.push(e[n].x,e[n].y);e=s}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,s=e.length;for(let n=0;n<s;n+=2){const r=e[n],o=e[n+1],a=e[(n+2)%s],h=e[(n+3)%s];t+=(a-r)*(h+o)}return t<0}containsPolygon(t){const e=this.getBounds(Qc),s=t.getBounds(Jc);if(!e.containsRect(s))return!1;const n=t.points;for(let r=0;r<n.length;r+=2){const o=n[r],a=n[r+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new ts(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const n=this.points.length/2;for(let r=0,o=n-1;r<n;o=r++){const a=this.points[r*2],h=this.points[r*2+1],l=this.points[o*2],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(s=!s)}return s}strokeContains(t,e,s,n=.5){const r=s*s,o=r*(1-n),a=r-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const u=h[c],d=h[c+1],f=h[(c+2)%h.length],p=h[(c+3)%h.length],g=Zc(t,e,u,d,f,p),m=Math.sign((f-u)*(e-d)-(p-d)*(t-u));if(g<=(m<0?a:o))return!0}return!1}getBounds(t){t||(t=new W);const e=this.points;let s=1/0,n=-1/0,r=1/0,o=-1/0;for(let a=0,h=e.length;a<h;a+=2){const l=e[a],c=e[a+1];s=l<s?l:s,n=l>n?l:n,r=c<r?c:r,o=c>o?c:o}return t.x=s,t.width=n-s,t.y=r,t.height=o-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return D("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return D("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const ks=(i,t,e,s,n,r,o)=>{const a=i-e,h=t-s,l=Math.sqrt(a*a+h*h);return l>=n-r&&l<=n+o};class _n{constructor(t=0,e=0,s=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=r}getBounds(t){return t||(t=new W),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new _n(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}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 s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let n=t-(this.x+s),r=e-(this.y+s);const o=s*s;if(n*n+r*r<=o||(n=t-(this.x+this.width-s),n*n+r*r<=o)||(r=e-(this.y+this.height-s),n*n+r*r<=o)||(n=t-(this.x+s),n*n+r*r<=o))return!0}return!1}strokeContains(t,e,s,n=.5){const{x:r,y:o,width:a,height:h,radius:l}=this,c=s*(1-n),u=s-c,d=r+l,f=o+l,p=a-l*2,g=h-l*2,m=r+a,_=o+h;return(t>=r-c&&t<=r+u||t>=m-u&&t<=m+c)&&e>=f&&e<=f+g||(e>=o-c&&e<=o+u||e>=_-u&&e<=_+c)&&t>=d&&t<=d+p?!0:t<d&&e<f&&ks(t,e,d,f,l,u,c)||t>m-l&&e<f&&ks(t,e,m-l,f,l,u,c)||t>m-l&&e>_-l&&ks(t,e,m-l,_-l,l,u,c)||t<d&&e>_-l&&ks(t,e,d,_-l,l,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const ya={};function tu(i,t,e){let s=2166136261;for(let n=0;n<t;n++)s^=i[n].uid,s=Math.imul(s,16777619),s>>>=0;return ya[s]||eu(i,t,s,e)}function eu(i,t,e,s){const n={};let r=0;for(let a=0;a<s;a++){const h=a<t?i[a]:G.EMPTY.source;n[r++]=h.source,n[r++]=h.style}const o=new Je(n);return ya[e]=o,o}class Mr{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),this.size=this.rawBinaryData.byteLength}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 int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=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`)}}}function kr(i,t,e,s){if(e??(e=0),s??(s=Math.min(i.byteLength-e,t.byteLength)),!(e&7)&&!(s&7)){const n=s/8;new Float64Array(t,0,n).set(new Float64Array(i,e,n))}else if(!(e&3)&&!(s&3)){const n=s/4;new Float32Array(t,0,n).set(new Float32Array(i,e,n))}else new Uint8Array(t).set(new Uint8Array(i,e,s))}const su={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};function Er(i,t){return t.alphaMode==="no-premultiply-alpha"&&su[i]||i}const iu=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
37
|
-
`);function nu(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
|
|
38
|
-
else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function ru(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=iu.replace(/%forloop%/gi,nu(i));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}}finally{t.deleteShader(e)}return i}let ye=null;function ou(){if(ye)return ye;const i=na();return ye=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),ye=ru(ye,i),i.getExtension("WEBGL_lose_context")?.loseContext(),ye}class au{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class hu{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new au,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const es=[];let Gs=0;Xs.register({clear:()=>{if(es.length>0)for(const i of es)i&&i.destroy();es.length=0,Gs=0}});function Ir(){return Gs>0?es[--Gs]:new hu}function Fr(i){i.elements=null,es[Gs++]=i}let We=0;const xa=class ba{constructor(t){this.uid=et("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...ba.defaultOptions,...t},t.maxTextures||(D("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=ou());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new Mr(s*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Fr(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const s=t._batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t._textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let s=Ir(),n=s.textures;n.clear();const r=e[this.elementStart];let o=Er(r.blendMode,r.texture._source),a=r.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,d=this._batchIndexStart,f="startBatch",p=[];const g=this.maxTextures;for(let m=this.elementStart;m<this.elementSize;++m){const _=e[m];e[m]=null;const b=_.texture._source,y=Er(_.blendMode,b),v=o!==y||a!==_.topology;if(b._batchTick===We&&!v){_._textureId=b._textureBindLocation,u+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,h,l,_._attributeStart,_._textureId),this.packQuadIndex(c,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,h,l,_._attributeStart,_._textureId),this.packIndex(_,c,_._indexStart,_._attributeStart/this.vertexSize)),_._batch=s,p.push(_);continue}b._batchTick=We,(n.count>=g||v)&&(this._finishBatch(s,d,u-d,n,o,a,t,f,p),f="renderBatch",d=u,o=y,a=_.topology,s=Ir(),n=s.textures,n.clear(),p=[],++We),_._textureId=b._textureBindLocation=n.count,n.ids[b.uid]=n.count,n.textures[n.count++]=b,_._batch=s,p.push(_),u+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,h,l,_._attributeStart,_._textureId),this.packQuadIndex(c,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,h,l,_._attributeStart,_._textureId),this.packIndex(_,c,_._indexStart,_._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,d,u-d,n,o,a,t,f,p),d=u,++We),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(t,e,s,n,r,o,a,h,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=n,t.blendMode=r,t.topology=o,t.start=e,t.size=s,t.elements=l,++We,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new Mr(e);kr(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r<e.length;r++)n[r]=e[r];else kr(e.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}packIndex(t,e,s,n){const r=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[s++]=n+r[l+a]-h}destroy(t={}){if(this.batches!==null){for(let e=0;e<this.batchIndex;e++)Fr(this.batches[e]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&(this.shader?.destroy(),this.shader=null);for(let e=0;e<this._elements.length;e++)this._elements[e]&&(this._elements[e]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};xa.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let lu=xa;var mt=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(mt||{});class hs extends Rt{constructor(t){let{data:e,size:s}=t;const{usage:n,label:r,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=et("buffer"),this._resourceType="buffer",this._resourceId=et("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s??(s=e?.byteLength);const a=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:a,label:r},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&mt.STATIC)}set static(t){t?this.descriptor.usage|=mt.STATIC:this.descriptor.usage&=~mt.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const n=this._data;if(this._data=t,this._dataInt32=null,!n||n.length!==t.length){!this.shrinkToFit&&n&&t.byteLength<n.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=et("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function va(i,t){if(!(i instanceof hs)){let e=t?mt.INDEX:mt.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=mt.INDEX|mt.COPY_DST):(i=new Float32Array(i),e=mt.VERTEX|mt.COPY_DST)),i=new hs({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function cu(i,t,e){const s=i.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const n=s.buffer.data;let r=1/0,o=1/0,a=-1/0,h=-1/0;const l=n.BYTES_PER_ELEMENT,c=(s.offset||0)/l,u=(s.stride||8)/l;for(let d=c;d<n.length;d+=u){const f=n[d],p=n[d+1];f>a&&(a=f),p>h&&(h=p),f<r&&(r=f),p<o&&(o=p)}return e.minX=r,e.minY=o,e.maxX=a,e.maxY=h,e}function uu(i){return(i instanceof hs||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=va(i.buffer,!1),i}class wa extends Rt{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=et("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new _t,this._boundsDirty=!0;const{attributes:e,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},e)for(const r in e)this.addAttribute(r,e[r]);this.instanceCount=t.instanceCount??1,s&&this.addIndex(s),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const s=uu(e);this.buffers.indexOf(s.buffer)===-1&&(this.buffers.push(s.buffer),s.buffer.on("update",this.onBufferUpdate,this),s.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=s}addIndex(t){this.indexBuffer=va(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,cu(this,"aPosition",this._bounds)):this._bounds}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.unload(),this.indexBuffer?.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const du=new Float32Array(1),fu=new Uint32Array(1);class pu extends wa{constructor(){const e=new hs({data:du,label:"attribute-batch-buffer",usage:mt.VERTEX|mt.COPY_DST,shrinkToFit:!1}),s=new hs({data:fu,label:"index-batch-buffer",usage:mt.INDEX|mt.COPY_DST,shrinkToFit:!1}),n=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:20}},indexBuffer:s})}}function Rr(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),r=t[n];if(r){let o=i[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(o)}else Y(`${s} placement hook does not exist in shader`)}}const gu=/\{\{(.*?)\}\}/g;function Br(i){const t={};return(i.match(gu)?.map(s=>s.replace(/[{()}]/g,""))??[]).forEach(s=>{t[s]=[]}),t}function Lr(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Or(i,t,e=!1){const s=[];Lr(t,s),i.forEach(a=>{a.header&&Lr(a.header,s)});const n=s;e&&n.sort();const r=n.map((a,h)=>` @location(${h}) ${a},`).join(`
|
|
39
|
-
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
|
|
40
|
-
${r}
|
|
41
|
-
`),o}function Dr(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function mu(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function _u(i){const t=/@.*?\s+/g;return i.replace(t,"")}function yu(i,t){const e=[];Dr(t,e),i.forEach(h=>{h.header&&Dr(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
|
|
42
|
-
`),r=e.sort().map(h=>` var ${_u(h)};`).join(`
|
|
43
|
-
`),o=`return VSOutput(
|
|
44
|
-
${e.sort().map(h=>` ${mu(h)}`).join(`,
|
|
45
|
-
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
|
|
46
|
-
${n}
|
|
47
|
-
`),a=a.replace("{{start}}",`
|
|
48
|
-
${r}
|
|
49
|
-
`),a=a.replace("{{return}}",`
|
|
50
|
-
${o}
|
|
51
|
-
`),a}function Gr(i,t){let e=i;for(const s in t){const n=t[s];n.join(`
|
|
52
|
-
`).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
|
|
53
|
-
${n.join(`
|
|
54
|
-
`)}
|
|
55
|
-
//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const $t=Object.create(null),vi=new Map;let xu=0;function bu({template:i,bits:t}){const e=Sa(i,t);if($t[e])return $t[e];const{vertex:s,fragment:n}=wu(i,t);return $t[e]=Ta(s,n,t),$t[e]}function vu({template:i,bits:t}){const e=Sa(i,t);return $t[e]||($t[e]=Ta(i.vertex,i.fragment,t)),$t[e]}function wu(i,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let n=Or(e,i.vertex,!0);n=yu(e,n);const r=Or(s,i.fragment,!0);return{vertex:n,fragment:r}}function Sa(i,t){return t.map(e=>(vi.has(e)||vi.set(e,xu++),vi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function Ta(i,t,e){const s=Br(i),n=Br(t);return e.forEach(r=>{Rr(r.vertex,s,r.name),Rr(r.fragment,n,r.name)}),{vertex:Gr(i,s),fragment:Gr(t,n)}}const Su=`
|
|
56
|
-
@in aPosition: vec2<f32>;
|
|
57
|
-
@in aUV: vec2<f32>;
|
|
58
|
-
|
|
59
|
-
@out @builtin(position) vPosition: vec4<f32>;
|
|
60
|
-
@out vUV : vec2<f32>;
|
|
61
|
-
@out vColor : vec4<f32>;
|
|
62
|
-
|
|
63
|
-
{{header}}
|
|
64
|
-
|
|
65
|
-
struct VSOutput {
|
|
66
|
-
{{struct}}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
@vertex
|
|
70
|
-
fn main( {{in}} ) -> VSOutput {
|
|
71
|
-
|
|
72
|
-
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
|
73
|
-
var modelMatrix = mat3x3<f32>(
|
|
74
|
-
1.0, 0.0, 0.0,
|
|
75
|
-
0.0, 1.0, 0.0,
|
|
76
|
-
0.0, 0.0, 1.0
|
|
77
|
-
);
|
|
78
|
-
var position = aPosition;
|
|
79
|
-
var uv = aUV;
|
|
80
|
-
|
|
81
|
-
{{start}}
|
|
82
|
-
|
|
83
|
-
vColor = vec4<f32>(1., 1., 1., 1.);
|
|
84
|
-
|
|
85
|
-
{{main}}
|
|
86
|
-
|
|
87
|
-
vUV = uv;
|
|
88
|
-
|
|
89
|
-
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
90
|
-
|
|
91
|
-
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
|
92
|
-
|
|
93
|
-
vColor *= globalUniforms.uWorldColorAlpha;
|
|
94
|
-
|
|
95
|
-
{{end}}
|
|
96
|
-
|
|
97
|
-
{{return}}
|
|
98
|
-
};
|
|
99
|
-
`,Tu=`
|
|
100
|
-
@in vUV : vec2<f32>;
|
|
101
|
-
@in vColor : vec4<f32>;
|
|
102
|
-
|
|
103
|
-
{{header}}
|
|
104
|
-
|
|
105
|
-
@fragment
|
|
106
|
-
fn main(
|
|
107
|
-
{{in}}
|
|
108
|
-
) -> @location(0) vec4<f32> {
|
|
109
|
-
|
|
110
|
-
{{start}}
|
|
111
|
-
|
|
112
|
-
var outColor:vec4<f32>;
|
|
113
|
-
|
|
114
|
-
{{main}}
|
|
115
|
-
|
|
116
|
-
var finalColor:vec4<f32> = outColor * vColor;
|
|
117
|
-
|
|
118
|
-
{{end}}
|
|
119
|
-
|
|
120
|
-
return finalColor;
|
|
121
|
-
};
|
|
122
|
-
`,Au=`
|
|
123
|
-
in vec2 aPosition;
|
|
124
|
-
in vec2 aUV;
|
|
125
|
-
|
|
126
|
-
out vec4 vColor;
|
|
127
|
-
out vec2 vUV;
|
|
128
|
-
|
|
129
|
-
{{header}}
|
|
130
|
-
|
|
131
|
-
void main(void){
|
|
132
|
-
|
|
133
|
-
mat3 worldTransformMatrix = uWorldTransformMatrix;
|
|
134
|
-
mat3 modelMatrix = mat3(
|
|
135
|
-
1.0, 0.0, 0.0,
|
|
136
|
-
0.0, 1.0, 0.0,
|
|
137
|
-
0.0, 0.0, 1.0
|
|
138
|
-
);
|
|
139
|
-
vec2 position = aPosition;
|
|
140
|
-
vec2 uv = aUV;
|
|
141
|
-
|
|
142
|
-
{{start}}
|
|
143
|
-
|
|
144
|
-
vColor = vec4(1.);
|
|
145
|
-
|
|
146
|
-
{{main}}
|
|
147
|
-
|
|
148
|
-
vUV = uv;
|
|
149
|
-
|
|
150
|
-
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
151
|
-
|
|
152
|
-
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
153
|
-
|
|
154
|
-
vColor *= uWorldColorAlpha;
|
|
155
|
-
|
|
156
|
-
{{end}}
|
|
157
|
-
}
|
|
158
|
-
`,Cu=`
|
|
159
|
-
|
|
160
|
-
in vec4 vColor;
|
|
161
|
-
in vec2 vUV;
|
|
162
|
-
|
|
163
|
-
out vec4 finalColor;
|
|
164
|
-
|
|
165
|
-
{{header}}
|
|
166
|
-
|
|
167
|
-
void main(void) {
|
|
168
|
-
|
|
169
|
-
{{start}}
|
|
170
|
-
|
|
171
|
-
vec4 outColor;
|
|
172
|
-
|
|
173
|
-
{{main}}
|
|
174
|
-
|
|
175
|
-
finalColor = outColor * vColor;
|
|
176
|
-
|
|
177
|
-
{{end}}
|
|
178
|
-
}
|
|
179
|
-
`,Pu={name:"global-uniforms-bit",vertex:{header:`
|
|
180
|
-
struct GlobalUniforms {
|
|
181
|
-
uProjectionMatrix:mat3x3<f32>,
|
|
182
|
-
uWorldTransformMatrix:mat3x3<f32>,
|
|
183
|
-
uWorldColorAlpha: vec4<f32>,
|
|
184
|
-
uResolution: vec2<f32>,
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
188
|
-
`}},Mu={name:"global-uniforms-bit",vertex:{header:`
|
|
189
|
-
uniform mat3 uProjectionMatrix;
|
|
190
|
-
uniform mat3 uWorldTransformMatrix;
|
|
191
|
-
uniform vec4 uWorldColorAlpha;
|
|
192
|
-
uniform vec2 uResolution;
|
|
193
|
-
`}};function ku({bits:i,name:t}){const e=bu({template:{fragment:Tu,vertex:Su},bits:[Pu,...i]});return ge.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Eu({bits:i,name:t}){return new ds({name:t,...vu({template:{vertex:Au,fragment:Cu},bits:[Mu,...i]})})}const Iu={name:"color-bit",vertex:{header:`
|
|
194
|
-
@in aColor: vec4<f32>;
|
|
195
|
-
`,main:`
|
|
196
|
-
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
197
|
-
`}},Fu={name:"color-bit",vertex:{header:`
|
|
198
|
-
in vec4 aColor;
|
|
199
|
-
`,main:`
|
|
200
|
-
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
201
|
-
`}},wi={};function Ru(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s<i;s++)t.push(`@group(1) @binding(${e++}) var textureSource${s+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
|
|
202
|
-
`)}function Bu(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<i;e++)e===i-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
|
|
203
|
-
`)}function Lu(i){return wi[i]||(wi[i]={name:"texture-batch-bit",vertex:{header:`
|
|
204
|
-
@in aTextureIdAndRound: vec2<u32>;
|
|
205
|
-
@out @interpolate(flat) vTextureId : u32;
|
|
206
|
-
`,main:`
|
|
207
|
-
vTextureId = aTextureIdAndRound.y;
|
|
208
|
-
`,end:`
|
|
209
|
-
if(aTextureIdAndRound.x == 1)
|
|
210
|
-
{
|
|
211
|
-
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
212
|
-
}
|
|
213
|
-
`},fragment:{header:`
|
|
214
|
-
@in @interpolate(flat) vTextureId: u32;
|
|
215
|
-
|
|
216
|
-
${Ru(i)}
|
|
217
|
-
`,main:`
|
|
218
|
-
var uvDx = dpdx(vUV);
|
|
219
|
-
var uvDy = dpdy(vUV);
|
|
220
|
-
|
|
221
|
-
${Bu(i)}
|
|
222
|
-
`}}),wi[i]}const Si={};function Ou(i){const t=[];for(let e=0;e<i;e++)e>0&&t.push("else"),e<i-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
|
|
223
|
-
`)}function Du(i){return Si[i]||(Si[i]={name:"texture-batch-bit",vertex:{header:`
|
|
224
|
-
in vec2 aTextureIdAndRound;
|
|
225
|
-
out float vTextureId;
|
|
226
|
-
|
|
227
|
-
`,main:`
|
|
228
|
-
vTextureId = aTextureIdAndRound.y;
|
|
229
|
-
`,end:`
|
|
230
|
-
if(aTextureIdAndRound.x == 1.)
|
|
231
|
-
{
|
|
232
|
-
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
233
|
-
}
|
|
234
|
-
`},fragment:{header:`
|
|
235
|
-
in float vTextureId;
|
|
236
|
-
|
|
237
|
-
uniform sampler2D uTextures[${i}];
|
|
238
|
-
|
|
239
|
-
`,main:`
|
|
240
|
-
|
|
241
|
-
${Ou(i)}
|
|
242
|
-
`}}),Si[i]}const Gu={name:"round-pixels-bit",vertex:{header:`
|
|
243
|
-
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
244
|
-
{
|
|
245
|
-
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
246
|
-
}
|
|
247
|
-
`}},zu={name:"round-pixels-bit",vertex:{header:`
|
|
248
|
-
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
249
|
-
{
|
|
250
|
-
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
251
|
-
}
|
|
252
|
-
`}},zr={};function Uu(i){let t=zr[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=zr[i]=new dn({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class Ur extends Hs{constructor(t){const e=Eu({name:"batch",bits:[Fu,Du(t),zu]}),s=ku({name:"batch",bits:[Iu,Lu(t),Gu]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Uu(t)}}),this.maxTextures=t}}let Xe=null;const Aa=class Ca extends lu{constructor(t){super(t),this.geometry=new pu,this.name=Ca.extension.name,this.vertexSize=6,Xe??(Xe=new Ur(t.maxTextures)),this.shader=Xe}packAttributes(t,e,s,n,r){const o=r<<16|t.roundPixels&65535,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,{positions:p,uvs:g}=t,m=t.color,_=t.attributeOffset,x=_+t.attributeSize;for(let b=_;b<x;b++){const y=b*2,v=p[y],w=p[y+1];e[n++]=h*v+c*w+d,e[n++]=u*w+l*v+f,e[n++]=g[y],e[n++]=g[y+1],s[n++]=m,s[n++]=o}}packQuadAttributes(t,e,s,n,r){const o=t.texture,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,p=t.bounds,g=p.maxX,m=p.minX,_=p.maxY,x=p.minY,b=o.uvs,y=t.color,v=r<<16|t.roundPixels&65535;e[n+0]=h*m+c*x+d,e[n+1]=u*x+l*m+f,e[n+2]=b.x0,e[n+3]=b.y0,s[n+4]=y,s[n+5]=v,e[n+6]=h*g+c*x+d,e[n+7]=u*x+l*g+f,e[n+8]=b.x1,e[n+9]=b.y1,s[n+10]=y,s[n+11]=v,e[n+12]=h*g+c*_+d,e[n+13]=u*_+l*g+f,e[n+14]=b.x2,e[n+15]=b.y2,s[n+16]=y,s[n+17]=v,e[n+18]=h*m+c*_+d,e[n+19]=u*_+l*m+f,e[n+20]=b.x3,e[n+21]=b.y3,s[n+22]=y,s[n+23]=v}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Xe=new Ur(t),this.shader=Xe)}destroy(){this.shader=null,super.destroy()}};Aa.extension={type:[k.Batcher],name:"default"};let Wu=Aa;class fs{constructor(t){this.items=Object.create(null);const{renderer:e,type:s,onUnload:n,priority:r,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",s,r??0),this._onUnload=n,this.name=o}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){if(!this.items[t.uid])return;const s=t._gpuData[this._renderer.uid];s&&(this._onUnload?.(t,...e),s.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function Xu(i,t,e,s,n,r,o,a=null){let h=0;e*=t,n*=r;const l=a.a,c=a.b,u=a.c,d=a.d,f=a.tx,p=a.ty;for(;h<o;){const g=i[e],m=i[e+1];s[n]=l*g+u*m+f,s[n+1]=c*g+d*m+p,n+=r,e+=t,h++}}function Yu(i,t,e,s){let n=0;for(t*=e;n<s;)i[t]=0,i[t+1]=0,t+=e,n++}function Pa(i,t,e,s,n){const r=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,c=t.ty;e||(e=0),s||(s=2),n||(n=i.length/s-e);let u=e*s;for(let d=0;d<n;d++){const f=i[u],p=i[u+1];i[u]=r*f+a*p+l,i[u+1]=o*f+h*p+c,u+=s}}const Hu=new z;class yn{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?Go(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||Hu}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const ls={extension:{type:k.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,r,o,a;if(i.type==="circle"){const y=i;if(o=a=y.radius,o<=0)return!1;e=y.x,s=y.y,n=r=0}else if(i.type==="ellipse"){const y=i;if(o=y.halfWidth,a=y.halfHeight,o<=0||a<=0)return!1;e=y.x,s=y.y,n=r=0}else{const y=i,v=y.width/2,w=y.height/2;e=y.x+v,s=y.y+w,o=a=Math.max(0,Math.min(y.radius,Math.min(v,w))),n=v-o,r=w-a}if(n<0||r<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return!1;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+r,t[2]=t[4]=e-n,t[5]=t[7]=s-r,!0;let c=0,u=h*4+(n?2:0)+2,d=u,f=l,p=n+o,g=r,m=e+p,_=e-p,x=s+g;if(t[c++]=m,t[c++]=x,t[--u]=x,t[--u]=_,r){const y=s-g;t[d++]=_,t[d++]=y,t[--f]=y,t[--f]=m}for(let y=1;y<h;y++){const v=Math.PI/2*(y/h),w=n+Math.cos(v)*o,S=r+Math.sin(v)*a,C=e+w,P=e-w,T=s+S,A=s-S;t[c++]=C,t[c++]=T,t[--u]=T,t[--u]=P,t[d++]=P,t[d++]=A,t[--f]=A,t[--f]=C}p=n,g=r+a,m=e+p,_=e-p,x=s+g;const b=s-g;return t[c++]=m,t[c++]=x,t[--f]=b,t[--f]=m,n&&(t[c++]=_,t[c++]=x,t[--f]=b,t[--f]=_),!0},triangulate(i,t,e,s,n,r){if(i.length===0)return;let o=0,a=0;for(let c=0;c<i.length;c+=2)o+=i[c],a+=i[c+1];o/=i.length/2,a/=i.length/2;let h=s;t[h*e]=o,t[h*e+1]=a;const l=h++;for(let c=0;c<i.length;c+=2)t[h*e]=i[c],t[h*e+1]=i[c+1],c>0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},Nu={...ls,extension:{...ls.extension,name:"ellipse"}},$u={...ls,extension:{...ls.extension,name:"roundedRectangle"}},Ma=1e-4,Wr=1e-4;function Vu(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],r=i[t-1];s<t;s+=2){const o=i[s],a=i[s+1];e+=(o-n)*(a+r),n=o,r=a}return e<0?-1:1}function Xr(i,t,e,s,n,r,o,a){const h=i-e*n,l=t-s*n,c=i+e*r,u=t+s*r;let d,f;o?(d=s,f=-e):(d=-s,f=e);const p=h+d,g=l+f,m=c+d,_=u+f;return a.push(p,g),a.push(m,_),2}function se(i,t,e,s,n,r,o,a){const h=e-i,l=s-t;let c=Math.atan2(h,l),u=Math.atan2(n-i,r-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),g=Math.sqrt(h*h+l*l),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/m;if(d+=_,a){o.push(i,t),o.push(e,s);for(let x=1,b=d;x<m;x++,b+=_)o.push(i,t),o.push(i+Math.sin(b)*g,t+Math.cos(b)*g);o.push(i,t),o.push(n,r)}else{o.push(e,s),o.push(i,t);for(let x=1,b=d;x<m;x++,b+=_)o.push(i+Math.sin(b)*g,t+Math.cos(b)*g),o.push(i,t);o.push(n,r),o.push(i,t)}return m*2}function ju(i,t,e,s,n,r){const o=Ma;if(i.length===0)return;const a=t;let h=a.alignment;if(t.alignment!==.5){let I=Vu(i);h=(h-.5)*I+.5}const l=new Z(i[0],i[1]),c=new Z(i[i.length-2],i[i.length-1]),u=s,d=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(u){i=i.slice(),d&&(i.pop(),i.pop(),c.set(i[i.length-2],i[i.length-1]));const I=(l.x+c.x)*.5,V=(c.y+l.y)*.5;i.unshift(I,V),i.push(I,V)}const f=n,p=i.length/2;let g=i.length;const m=f.length/2,_=a.width/2,x=_*_,b=a.miterLimit*a.miterLimit;let y=i[0],v=i[1],w=i[2],S=i[3],C=0,P=0,T=-(v-S),A=y-w,F=0,O=0,L=Math.sqrt(T*T+A*A);T/=L,A/=L,T*=_,A*=_;const H=h,M=(1-H)*2,E=H*2;u||(a.cap==="round"?g+=se(y-T*(M-E)*.5,v-A*(M-E)*.5,y-T*M,v-A*M,y+T*E,v+A*E,f,!0)+2:a.cap==="square"&&(g+=Xr(y,v,T,A,M,E,!0,f))),f.push(y-T*M,v-A*M),f.push(y+T*E,v+A*E);for(let I=1;I<p-1;++I){y=i[(I-1)*2],v=i[(I-1)*2+1],w=i[I*2],S=i[I*2+1],C=i[(I+1)*2],P=i[(I+1)*2+1],T=-(v-S),A=y-w,L=Math.sqrt(T*T+A*A),T/=L,A/=L,T*=_,A*=_,F=-(S-P),O=w-C,L=Math.sqrt(F*F+O*O),F/=L,O/=L,F*=_,O*=_;const V=w-y,nt=v-S,gt=w-C,tt=P-S,ft=V*gt+nt*tt,Ot=nt*gt-tt*V,Kt=Ot<0;if(Math.abs(Ot)<.001*Math.abs(ft)){f.push(w-T*M,S-A*M),f.push(w+T*E,S+A*E),ft>=0&&(a.join==="round"?g+=se(w,S,w-T*M,S-A*M,w-F*M,S-O*M,f,!1)+4:g+=2,f.push(w-F*E,S-O*E),f.push(w+F*M,S+O*M));continue}const En=(-T+y)*(-A+S)-(-T+w)*(-A+v),In=(-F+C)*(-O+S)-(-F+w)*(-O+P),ms=(V*In-gt*En)/Ot,_s=(tt*En-nt*In)/Ot,js=(ms-w)*(ms-w)+(_s-S)*(_s-S),Zt=w+(ms-w)*M,Qt=S+(_s-S)*M,Jt=w-(ms-w)*E,te=S-(_s-S)*E,hh=Math.min(V*V+nt*nt,gt*gt+tt*tt),Fn=Kt?M:E,lh=hh+Fn*Fn*x;js<=lh?a.join==="bevel"||js/x>b?(Kt?(f.push(Zt,Qt),f.push(w+T*E,S+A*E),f.push(Zt,Qt),f.push(w+F*E,S+O*E)):(f.push(w-T*M,S-A*M),f.push(Jt,te),f.push(w-F*M,S-O*M),f.push(Jt,te)),g+=2):a.join==="round"?Kt?(f.push(Zt,Qt),f.push(w+T*E,S+A*E),g+=se(w,S,w+T*E,S+A*E,w+F*E,S+O*E,f,!0)+4,f.push(Zt,Qt),f.push(w+F*E,S+O*E)):(f.push(w-T*M,S-A*M),f.push(Jt,te),g+=se(w,S,w-T*M,S-A*M,w-F*M,S-O*M,f,!1)+4,f.push(w-F*M,S-O*M),f.push(Jt,te)):(f.push(Zt,Qt),f.push(Jt,te)):(f.push(w-T*M,S-A*M),f.push(w+T*E,S+A*E),a.join==="round"?Kt?g+=se(w,S,w+T*E,S+A*E,w+F*E,S+O*E,f,!0)+2:g+=se(w,S,w-T*M,S-A*M,w-F*M,S-O*M,f,!1)+2:a.join==="miter"&&js/x<=b&&(Kt?(f.push(Jt,te),f.push(Jt,te)):(f.push(Zt,Qt),f.push(Zt,Qt)),g+=2),f.push(w-F*M,S-O*M),f.push(w+F*E,S+O*E),g+=2)}y=i[(p-2)*2],v=i[(p-2)*2+1],w=i[(p-1)*2],S=i[(p-1)*2+1],T=-(v-S),A=y-w,L=Math.sqrt(T*T+A*A),T/=L,A/=L,T*=_,A*=_,f.push(w-T*M,S-A*M),f.push(w+T*E,S+A*E),u||(a.cap==="round"?g+=se(w-T*(M-E)*.5,S-A*(M-E)*.5,w-T*M,S-A*M,w+T*E,S+A*E,f,!1)+2:a.cap==="square"&&(g+=Xr(w,S,T,A,M,E,!1,f)));const X=Wr*Wr;for(let I=m;I<g+m-2;++I)y=f[I*2],v=f[I*2+1],w=f[(I+1)*2],S=f[(I+1)*2+1],C=f[(I+2)*2],P=f[(I+2)*2+1],!(Math.abs(y*(S-P)+w*(P-v)+C*(v-S))<X)&&r.push(I,I+1,I+2)}function qu(i,t,e,s){const n=Ma;if(i.length===0)return;const r=i[0],o=i[1],a=i[i.length-2],h=i[i.length-1],l=t||Math.abs(r-a)<n&&Math.abs(o-h)<n,c=e,u=i.length/2,d=c.length/2;for(let f=0;f<u;f++)c.push(i[f*2]),c.push(i[f*2+1]);for(let f=0;f<u-1;f++)s.push(d+f,d+f+1);l&&s.push(d+u-1,d)}function ka(i,t,e,s,n,r,o){const a=yc(i,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)r[o++]=a[l]+n,r[o++]=a[l+1]+n,r[o++]=a[l+2]+n;let h=n*s;for(let l=0;l<i.length;l+=2)e[h]=i[l],e[h+1]=i[l+1],h+=s}const Ku=[],Zu={extension:{type:k.ShapeBuilder,name:"polygon"},build(i,t){for(let e=0;e<i.points.length;e++)t[e]=i.points[e];return!0},triangulate(i,t,e,s,n,r){ka(i,Ku,t,e,s,n,r)}},Qu={extension:{type:k.ShapeBuilder,name:"rectangle"},build(i,t){const e=i,s=e.x,n=e.y,r=e.width,o=e.height;return r>0&&o>0?(t[0]=s,t[1]=n,t[2]=s+r,t[3]=n,t[4]=s+r,t[5]=n+o,t[6]=s,t[7]=n+o,!0):!1},triangulate(i,t,e,s,n,r){let o=0;s*=e,t[s+o]=i[0],t[s+o+1]=i[1],o+=e,t[s+o]=i[2],t[s+o+1]=i[3],o+=e,t[s+o]=i[6],t[s+o+1]=i[7],o+=e,t[s+o]=i[4],t[s+o+1]=i[5],o+=e;const a=s/e;n[r++]=a,n[r++]=a+1,n[r++]=a+2,n[r++]=a+1,n[r++]=a+3,n[r++]=a+2}},Ju={extension:{type:k.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,!0},triangulate(i,t,e,s,n,r){let o=0;s*=e,t[s+o]=i[0],t[s+o+1]=i[1],o+=e,t[s+o]=i[2],t[s+o+1]=i[3],o+=e,t[s+o]=i[4],t[s+o+1]=i[5];const a=s/e;n[r++]=a,n[r++]=a+1,n[r++]=a+2}},Yr=[{offset:0,color:"white"},{offset:1,color:"black"}],xn=class Ki{constructor(...t){this.uid=et("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=td(t);e={...e.type==="radial"?Ki.defaultRadialOptions:Ki.defaultLinearOptions,...Co(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:st.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:n}=this.end,r=s-t,o=n-e;const a=r<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(r<0){const m=t;t=s,s=m,r*=-1}if(o<0){const m=e;e=n,n=m,o*=-1}}const h=this.colorStops.length?this.colorStops:Yr,l=this._textureSize,{canvas:c,context:u}=Nr(l,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Hr(d,h),u.fillStyle=d,u.fillRect(0,0,l,1),this.texture=new G({source:new ue({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(r*r+o*o),p=Math.atan2(o,r),g=new z;g.scale(f/l,1),g.rotate(p),g.translate(t,e),this.textureSpace==="local"&&g.scale(l,l),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Yr,e=this._textureSize,{canvas:s,context:n}=Nr(e,e),{x:r,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,u=a-c,d=h-c,f=e/(c*2),p=(r-u)*f,g=(o-d)*f,m=n.createRadialGradient(p,g,l*f,(a-u)*f,(h-d)*f,c*f);Hr(m,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=m,n.translate(p,g),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-p,-g),n.fillRect(0,0,e,e),this.texture=new G({source:new ue({resource:s,addressMode:this._wrapMode})});const _=new z;this.textureSpace==="local"?_.scale(2*c,2*c):_.scale(1/f,1/f),_.translate(u,d),this.transform=_}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};xn.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};xn.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Ht=xn;function Hr(i,t){for(let e=0;e<t.length;e++){const s=t[e];i.addColorStop(s.offset,s.color)}}function Nr(i,t){const e=N.get().createCanvas(i,t),s=e.getContext("2d");return{canvas:e,context:s}}function td(i){let t=i[0]??{};return(typeof t=="number"||i[1])&&(D("8.5.2","use options object instead"),t={type:"linear",start:{x:i[0],y:i[1]},end:{x:i[2],y:i[3]},textureSpace:i[4],textureSize:i[5]??Ht.defaultLinearOptions.textureSize}),t}const ed=new z,sd=new W;function id(i,t,e,s){const n=t.matrix?i.copyFrom(t.matrix).invert():i.identity();if(t.textureSpace==="local"){const o=e.getBounds(sd);t.width&&o.pad(t.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,u=-a*l,d=-h*c,f=n.a,p=n.b,g=n.c,m=n.d;n.a*=l,n.b*=l,n.c*=c,n.d*=c,n.tx=u*f+d*g+n.tx,n.ty=u*p+d*m+n.ty}else n.translate(t.texture.frame.x,t.texture.frame.y),n.scale(1/t.texture.source.width,1/t.texture.source.height);const r=t.texture.source.style;return!(t.fill instanceof Ht)&&r.addressMode==="clamp-to-edge"&&(r.addressMode="repeat",r.update()),s&&n.append(ed.copyFrom(s).invert()),n}const $s={};$.handleByMap(k.ShapeBuilder,$s);$.add(Qu,Zu,Ju,ls,Nu,$u);const nd=new W,rd=new z;function od(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n<i.instructions.length;n++){const r=i.instructions[n];if(r.action==="texture")ad(r.data,s,e);else if(r.action==="fill"||r.action==="stroke"){const o=r.action==="stroke",a=r.data.path.shapePath,h=r.data.style,l=r.data.hole;o&&l&&$r(l.shapePath,h,!0,s,e),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),$r(a,h,o,s,e)}}}function ad(i,t,e){const s=[],n=$s.rectangle,r=nd;r.x=i.dx,r.y=i.dy,r.width=i.dw,r.height=i.dh;const o=i.transform;if(!n.build(r,s))return;const{vertices:a,uvs:h,indices:l}=e,c=l.length,u=a.length/2;o&&Pa(s,o),n.triangulate(s,a,2,u,l,c);const d=i.image,f=d.uvs;h.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=yt.get(yn);p.indexOffset=c,p.indexSize=l.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=i.style,p.alpha=i.alpha,p.texture=d,p.geometryData=e,t.push(p)}function $r(i,t,e,s,n){const{vertices:r,uvs:o,indices:a}=n;i.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const u=[],d=$s[h.type];if(!d.build(h,u))return;const f=a.length,p=r.length/2;let g="triangle-list";if(l&&Pa(u,l),e){const b=h.closePath??!0,y=t;y.pixelLine?(qu(u,b,r,a),g="line-list"):ju(u,y,!1,b,r,a)}else if(c){const b=[],y=u.slice();hd(c).forEach(w=>{b.push(y.length/2),y.push(...w)}),ka(y,b,r,2,p,a,f)}else d.triangulate(u,r,2,p,a,f);const m=o.length/2,_=t.texture;if(_!==G.WHITE){const b=id(rd,t,h,l);Xu(r,2,p,o,m,2,r.length/2-p,b)}else Yu(o,m,2,r.length/2-p);const x=yt.get(yn);x.indexOffset=f,x.indexSize=a.length-f,x.attributeOffset=p,x.attributeSize=r.length/2-p,x.baseColor=t.color,x.alpha=t.alpha,x.texture=_,x.geometryData=n,x.topology=g,s.push(x)})}function hd(i){const t=[];for(let e=0;e<i.length;e++){const s=i[e].shape,n=[];$s[s.type].build(s,n)&&t.push(n)}return t}class ld{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{yt.return(t)}),this.graphicsData&&yt.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class cd{constructor(){this.instructions=new hn}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Wu({maxTextures:e}),this.instructions.reset()}get geometry(){return D(Fh,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const bn=class Zi{constructor(t){this._renderer=t,this._managedContexts=new fs({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Zi.defaultOptions.bezierSmoothness=t?.bezierSmoothness??Zi.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],s=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&s.reset(),od(t,s);const n=t.batchMode;t.customShader||n==="no-batch"?s.isBatchable=!1:n==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,t.dirty=!1}return s}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=yt.get(cd,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:n,geometryData:r}=s;s.graphicsData=e;const o=r.vertices.length,a=r.indices.length;for(let u=0;u<n.length;u++)n[u].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let u=0;u<n.length;u++){const d=n[u];h.add(d)}h.finish(e.instructions);const l=h.geometry;l.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,!0),l.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,!0);const c=h.batches;for(let u=0;u<c.length;u++){const d=c[u];d.bindGroup=tu(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new ld;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};bn.extension={type:[k.WebGLSystem,k.WebGPUSystem],name:"graphicsContext"};bn.defaultOptions={bezierSmoothness:.5};let vn=bn;const ud=8,Es=11920929e-14,dd=1;function Ea(i,t,e,s,n,r,o,a,h,l){const u=Math.min(.99,Math.max(0,l??vn.defaultOptions.bezierSmoothness));let d=(dd-u)/1;return d*=d,fd(t,e,s,n,r,o,a,h,i,d),i}function fd(i,t,e,s,n,r,o,a,h,l){Qi(i,t,e,s,n,r,o,a,h,l,0),h.push(o,a)}function Qi(i,t,e,s,n,r,o,a,h,l,c){if(c>ud)return;const u=(i+e)/2,d=(t+s)/2,f=(e+n)/2,p=(s+r)/2,g=(n+o)/2,m=(r+a)/2,_=(u+f)/2,x=(d+p)/2,b=(f+g)/2,y=(p+m)/2,v=(_+b)/2,w=(x+y)/2;if(c>0){let S=o-i,C=a-t;const P=Math.abs((e-o)*C-(s-a)*S),T=Math.abs((n-o)*C-(r-a)*S);if(P>Es&&T>Es){if((P+T)*(P+T)<=l*(S*S+C*C)){h.push(v,w);return}}else if(P>Es){if(P*P<=l*(S*S+C*C)){h.push(v,w);return}}else if(T>Es){if(T*T<=l*(S*S+C*C)){h.push(v,w);return}}else if(S=v-(i+o)/2,C=w-(t+a)/2,S*S+C*C<=l){h.push(v,w);return}}Qi(i,t,u,d,_,x,v,w,h,l,c+1),Qi(v,w,b,y,g,m,o,a,h,l,c+1)}const pd=8,gd=11920929e-14,md=1;function _d(i,t,e,s,n,r,o,a){const l=Math.min(.99,Math.max(0,a??vn.defaultOptions.bezierSmoothness));let c=(md-l)/1;return c*=c,yd(t,e,s,n,r,o,i,c),i}function yd(i,t,e,s,n,r,o,a){Ji(o,i,t,e,s,n,r,a,0),o.push(n,r)}function Ji(i,t,e,s,n,r,o,a,h){if(h>pd)return;const l=(t+s)/2,c=(e+n)/2,u=(s+r)/2,d=(n+o)/2,f=(l+u)/2,p=(c+d)/2;let g=r-t,m=o-e;const _=Math.abs((s-r)*m-(n-o)*g);if(_>gd){if(_*_<=a*(g*g+m*m)){i.push(f,p);return}}else if(g=f-(t+r)/2,m=p-(e+o)/2,g*g+m*m<=a){i.push(f,p);return}Ji(i,t,e,l,c,f,p,a,h+1),Ji(i,f,p,u,d,r,o,a,h+1)}function Ia(i,t,e,s,n,r,o,a){let h=Math.abs(n-r);(!o&&n>r||o&&r>n)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI)))),a=Math.max(a,3);let l=h/a,c=n;l*=o?-1:1;for(let u=0;u<a+1;u++){const d=Math.cos(c),f=Math.sin(c),p=t+d*s,g=e+f*s;i.push(p,g),c+=l}}function xd(i,t,e,s,n,r){const o=i[i.length-2],h=i[i.length-1]-e,l=o-t,c=n-e,u=s-t,d=Math.abs(h*u-l*c);if(d<1e-8||r===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const f=h*h+l*l,p=c*c+u*u,g=h*c+l*u,m=r*Math.sqrt(f)/d,_=r*Math.sqrt(p)/d,x=m*g/f,b=_*g/p,y=m*u+_*l,v=m*c+_*h,w=l*(_+x),S=h*(_+x),C=u*(m+b),P=c*(m+b),T=Math.atan2(S-v,w-y),A=Math.atan2(P-v,C-y);Ia(i,y+t,v+e,r,T,A,l*c>u*h)}const ss=Math.PI*2,Ti={centerX:0,centerY:0,ang1:0,ang2:0},Ai=({x:i,y:t},e,s,n,r,o,a,h)=>{i*=e,t*=s;const l=n*i-r*t,c=r*i+n*t;return h.x=l+o,h.y=c+a,h};function bd(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),r=Math.sin(i),o=Math.cos(i+t),a=Math.sin(i+t);return[{x:n-r*s,y:r+n*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Vr=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let r=i*e+t*s;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},vd=(i,t,e,s,n,r,o,a,h,l,c,u,d)=>{const f=Math.pow(n,2),p=Math.pow(r,2),g=Math.pow(c,2),m=Math.pow(u,2);let _=f*p-f*m-p*g;_<0&&(_=0),_/=f*m+p*g,_=Math.sqrt(_)*(o===a?-1:1);const x=_*n/r*u,b=_*-r/n*c,y=l*x-h*b+(i+e)/2,v=h*x+l*b+(t+s)/2,w=(c-x)/n,S=(u-b)/r,C=(-c-x)/n,P=(-u-b)/r,T=Vr(1,0,w,S);let A=Vr(w,S,C,P);a===0&&A>0&&(A-=ss),a===1&&A<0&&(A+=ss),d.centerX=y,d.centerY=v,d.ang1=T,d.ang2=A};function wd(i,t,e,s,n,r,o,a=0,h=0,l=0){if(r===0||o===0)return;const c=Math.sin(a*ss/360),u=Math.cos(a*ss/360),d=u*(t-s)/2+c*(e-n)/2,f=-c*(t-s)/2+u*(e-n)/2;if(d===0&&f===0)return;r=Math.abs(r),o=Math.abs(o);const p=Math.pow(d,2)/Math.pow(r,2)+Math.pow(f,2)/Math.pow(o,2);p>1&&(r*=Math.sqrt(p),o*=Math.sqrt(p)),vd(t,e,s,n,r,o,h,l,c,u,d,f,Ti);let{ang1:g,ang2:m}=Ti;const{centerX:_,centerY:x}=Ti;let b=Math.abs(m)/(ss/4);Math.abs(1-b)<1e-7&&(b=1);const y=Math.max(Math.ceil(b),1);m/=y;let v=i[i.length-2],w=i[i.length-1];const S={x:0,y:0};for(let C=0;C<y;C++){const P=bd(g,m),{x:T,y:A}=Ai(P[0],r,o,u,c,_,x,S),{x:F,y:O}=Ai(P[1],r,o,u,c,_,x,S),{x:L,y:H}=Ai(P[2],r,o,u,c,_,x,S);Ea(i,v,w,T,A,F,O,L,H),v=L,w=H,g+=m}}function Sd(i,t,e){const s=(o,a)=>{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),u=h/c,d=l/c;return{len:c,nx:u,ny:d}},n=(o,a)=>{o===0?i.moveTo(a.x,a.y):i.lineTo(a.x,a.y)};let r=t[t.length-1];for(let o=0;o<t.length;o++){const a=t[o%t.length],h=a.radius??e;if(h<=0){n(o,a),r=a;continue}const l=t[(o+1)%t.length],c=s(a,r),u=s(a,l);if(c.len<1e-4||u.len<1e-4){n(o,a),r=a;continue}let d=Math.asin(c.nx*u.ny-c.ny*u.nx),f=1,p=!1;c.nx*u.nx-c.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,f=-1,p=!0):d>0&&(f=-1,p=!0);const g=d/2;let m,_=Math.abs(Math.cos(g)*h/Math.sin(g));_>Math.min(c.len/2,u.len/2)?(_=Math.min(c.len/2,u.len/2),m=Math.abs(_*Math.sin(g)/Math.cos(g))):m=h;const x=a.x+u.nx*_+-u.ny*m*f,b=a.y+u.ny*_+u.nx*m*f,y=Math.atan2(c.ny,c.nx)+Math.PI/2*f,v=Math.atan2(u.ny,u.nx)-Math.PI/2*f;o===0&&i.moveTo(x+Math.cos(y)*m,b+Math.sin(y)*m),i.arc(x,b,m,y,v,p),r=a}}function Td(i,t,e,s){const n=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),r=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=t.length;for(let a=0;a<o;a++){const h=t[(a+1)%o],l=h.radius??e;if(l<=0){a===0?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y);continue}const c=t[a],u=t[(a+2)%o],d=n(c,h);let f;if(d<1e-4)f=h;else{const m=Math.min(d/2,l);f=r(h,c,m/d)}const p=n(u,h);let g;if(p<1e-4)g=h;else{const m=Math.min(p/2,l);g=r(h,u,m/p)}a===0?i.moveTo(f.x,f.y):i.lineTo(f.x,f.y),i.quadraticCurveTo(h.x,h.y,g.x,g.y,s)}}const Ad=new W;class Cd{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new _t,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const s=this._currentPoly.points,n=s[s.length-2],r=s[s.length-1];return(n!==t||r!==e)&&s.push(t,e),this}arc(t,e,s,n,r,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Ia(a,t,e,s,n,r,o),this}arcTo(t,e,s,n,r){this._ensurePoly();const o=this._currentPoly.points;return xd(o,t,e,s,n,r),this}arcToSvg(t,e,s,n,r,o,a){const h=this._currentPoly.points;return wd(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,s,n,r),this}bezierCurveTo(t,e,s,n,r,o,a){this._ensurePoly();const h=this._currentPoly;return Ea(this._currentPoly.points,h.lastX,h.lastY,t,e,s,n,r,o,a),this}quadraticCurveTo(t,e,s,n,r){this._ensurePoly();const o=this._currentPoly;return _d(this._currentPoly.points,o.lastX,o.lastY,t,e,s,n,r),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const s=this.shapePrimitives,n=s.length;for(let r=0;r<t.instructions.length;r++){const o=t.instructions[r];this[o.action](...o.data)}if(t.checkForHoles&&s.length-n>1){let r=null;for(let o=n;o<s.length;o++){const a=s[o];if(a.shape.type==="polygon"){const h=a.shape,l=r?.shape;l&&l.containsPolygon(h)?(r.holes||(r.holes=[]),r.holes.push(a),s.copyWithin(o,o+1),s.length--,o--):r=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,n,r){return this.drawShape(new W(t,e,s,n),r),this}circle(t,e,s,n){return this.drawShape(new gn(t,e,s),n),this}poly(t,e,s){const n=new ts(t);return n.closePath=e,this.drawShape(n,s),this}regularPoly(t,e,s,n,r=0,o){n=Math.max(n|0,3);const a=-1*Math.PI/2+r,h=Math.PI*2/n,l=[];for(let c=0;c<n;c++){const u=a-c*h;l.push(t+s*Math.cos(u),e+s*Math.sin(u))}return this.poly(l,!0,o),this}roundPoly(t,e,s,n,r,o=0,a){if(n=Math.max(n|0,3),r<=0)return this.regularPoly(t,e,s,n,o);const h=s*Math.sin(Math.PI/n)-.001;r=Math.min(r,h);const l=-1*Math.PI/2+o,c=Math.PI*2/n,u=(n-2)*Math.PI/n/2;for(let d=0;d<n;d++){const f=d*c+l,p=t+s*Math.cos(f),g=e+s*Math.sin(f),m=f+Math.PI+u,_=f-Math.PI-u,x=p+r*Math.cos(m),b=g+r*Math.sin(m),y=p+r*Math.cos(_),v=g+r*Math.sin(_);d===0?this.moveTo(x,b):this.lineTo(x,b),this.quadraticCurveTo(p,g,y,v,a)}return this.closePath()}roundShape(t,e,s=!1,n){return t.length<3?this:(s?Td(this,t,e,n):Sd(this,t,e),this.closePath())}filletRect(t,e,s,n,r){if(r===0)return this.rect(t,e,s,n);const o=Math.min(s,n)/2,a=Math.min(o,Math.max(-o,r)),h=t+s,l=e+n,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(t,e+u).arcTo(t+c,e+c,t+u,e,u).lineTo(h-u,e).arcTo(h-c,e+c,h,e+u,u).lineTo(h,l-u).arcTo(h-c,l-c,t+s-u,l,u).lineTo(t+u,l).arcTo(t+c,l-c,t,l-u,u).closePath()}chamferRect(t,e,s,n,r,o){if(r<=0)return this.rect(t,e,s,n);const a=Math.min(r,Math.min(s,n)/2),h=t+s,l=e+n,c=[t+a,e,h-a,e,h,e+a,h,l-a,h-a,l,t+a,l,t,l-a,t,e+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(t,e,s,n,r){return this.drawShape(new mn(t,e,s,n),r),this}roundRect(t,e,s,n,r,o){return this.drawShape(new _n(t,e,s,n,r),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new ts,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new ts,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,o=s;s=r.a*s+r.c*n+r.tx,n=r.b*o+r.d*n+r.ty}this._currentPoly.points.push(s,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const s=t.instructions[e];this[s.action](...s.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let s=0;s<e.length;s++){const n=e[s],r=n.shape.getBounds(Ad);n.transform?t.addRect(r,n.transform):t.addRect(r)}return t}}class Yt{constructor(t,e=!1){this.instructions=[],this.uid=et("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?Kc(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new Cd(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,s,n,r){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(Z.shared);let h=0,l=0;if(!o||o.action!=="bezierCurveTo")h=a.x,l=a.y;else{h=o.data[2],l=o.data[3];const c=a.x,u=a.y;h=c+(c-h),l=u+(u-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,t,e,s,n,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,s){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(Z.shared);let o=0,a=0;if(!n||n.action!=="quadraticCurveTo")o=r.x,a=r.y;else{o=n.data[0],a=n.data[1];const h=r.x,l=r.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,s]}),this._dirty=!0,this}rect(t,e,s,n,r){return this.instructions.push({action:"rect",data:[t,e,s,n,r]}),this._dirty=!0,this}circle(t,e,s,n){return this.instructions.push({action:"circle",data:[t,e,s,n]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,s,n,r,o,a){r||(r=n/2);const h=-1*Math.PI/2+o,l=s*2,c=Math.PI*2/l,u=[];for(let d=0;d<l;d++){const f=d%2?r:n,p=d*c+h;u.push(t+f*Math.cos(p),e+f*Math.sin(p))}return this.poly(u,!0,a),this}clone(t=!1){const e=new Yt;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const n=this.instructions[s];e.instructions.push({action:n.action,data:n.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,s=t.b,n=t.c,r=t.d,o=t.tx,a=t.ty;let h=0,l=0,c=0,u=0,d=0,f=0,p=0,g=0;for(let m=0;m<this.instructions.length;m++){const _=this.instructions[m],x=_.data;switch(_.action){case"moveTo":case"lineTo":h=x[0],l=x[1],x[0]=e*h+n*l+o,x[1]=s*h+r*l+a;break;case"bezierCurveTo":c=x[0],u=x[1],d=x[2],f=x[3],h=x[4],l=x[5],x[0]=e*c+n*u+o,x[1]=s*c+r*u+a,x[2]=e*d+n*f+o,x[3]=s*d+r*f+a,x[4]=e*h+n*l+o,x[5]=s*h+r*l+a;break;case"quadraticCurveTo":c=x[0],u=x[1],h=x[2],l=x[3],x[0]=e*c+n*u+o,x[1]=s*c+r*u+a,x[2]=e*h+n*l+o,x[3]=s*h+r*l+a;break;case"arcToSvg":h=x[5],l=x[6],p=x[0],g=x[1],x[0]=e*p+n*g,x[1]=s*p+r*g,x[5]=e*h+n*l+o,x[6]=s*h+r*l+a;break;case"circle":x[4]=xe(x[3],t);break;case"rect":x[4]=xe(x[4],t);break;case"ellipse":x[8]=xe(x[8],t);break;case"roundRect":x[5]=xe(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=xe(x[2],t);break;case"regularPoly":case"chamferRect":x[5]=xe(x[5],t);break;case"closePath":break;default:Y("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,s=this.instructions[e];if(!s)return t.x=0,t.y=0,t;for(;s.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;s=this.instructions[e]}switch(s.action){case"moveTo":case"lineTo":t.x=s.data[0],t.y=s.data[1];break;case"quadraticCurveTo":t.x=s.data[2],t.y=s.data[3];break;case"bezierCurveTo":t.x=s.data[4],t.y=s.data[5];break;case"arc":case"arcToSvg":t.x=s.data[5],t.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(t);break}return t}}function xe(i,t){return i?i.prepend(t):t.clone()}function Q(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function Pd(i,t){const e=i.querySelectorAll("defs");for(let s=0;s<e.length;s++){const n=e[s];for(let r=0;r<n.children.length;r++){const o=n.children[r];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=Md(o);break;case"radialgradient":t.defs[o.id]=kd();break}}}}function Md(i){const t=Q(i,"x1",0),e=Q(i,"y1",0),s=Q(i,"x2",1),n=Q(i,"y2",0),r=i.getAttribute("gradientUnits")||"objectBoundingBox",o=new Ht(t,e,s,n,r==="objectBoundingBox"?"local":"global");for(let a=0;a<i.children.length;a++){const h=i.children[a],l=Q(h,"offset",0),c=st.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function kd(i){return Y("[SVG Parser] Radial gradients are not yet supported"),new Ht(0,0,1,0)}function jr(i){const t=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const qr={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function Fa(i,t){const e=i.getAttribute("style"),s={},n={},r={strokeStyle:s,fillStyle:n,useFill:!1,useStroke:!1};for(const o in qr){const a=i.getAttribute(o);a&&Kr(t,r,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const h=o[a].trim(),[l,c]=h.split(":");qr[l]&&Kr(t,r,l,c.trim())}}return{strokeStyle:r.useStroke?s:null,fillStyle:r.useFill?n:null,useFill:r.useFill,useStroke:r.useStroke}}function Kr(i,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const n=jr(s);t.strokeStyle.fill=i.defs[n]}else t.strokeStyle.color=st.shared.setValue(s).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(s);break;case"fill":if(s!=="none"){if(s.startsWith("url(")){const n=jr(s);t.fillStyle.fill=i.defs[n]}else t.fillStyle.color=st.shared.setValue(s).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(s);break;case"stroke-opacity":t.strokeStyle.alpha=Number(s);break;case"opacity":t.fillStyle.alpha=Number(s),t.strokeStyle.alpha=Number(s);break}}function Ed(i){if(i.length<=2)return!0;const t=i.map(a=>a.area).sort((a,h)=>h-a),[e,s]=t,n=t[t.length-1],r=e/s,o=s/n;return!(r>3&&o<2)}function Id(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function Fd(i){const t=i.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],n=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(s.push(e[c]),n.push(e[c+1]));if(s.length===0||n.length===0)return 0;const r=Math.min(...s),o=Math.max(...s),a=Math.min(...n),h=Math.max(...n);return(o-r)*(h-a)}function Zr(i,t){const e=new Yt(i,!1);for(const s of e.instructions)t.instructions.push(s)}function Rd(i,t){if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=i.trim(),i=o.querySelector("svg")}const e={context:t,defs:{},path:new Yt};Pd(i,e);const s=i.children,{fillStyle:n,strokeStyle:r}=Fa(i,e);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&Ra(a,e,n,r)}return t}function Ra(i,t,e,s){const n=i.children,{fillStyle:r,strokeStyle:o}=Fa(i,t);r&&e?e={...e,...r}:r&&(e=r),o&&s?s={...s,...o}:o&&(s=o);const a=!e&&!s;a&&(e={color:0});let h,l,c,u,d,f,p,g,m,_,x,b,y,v,w,S,C;switch(i.nodeName.toLowerCase()){case"path":{v=i.getAttribute("d");const P=i.getAttribute("fill-rule"),T=Id(v),A=P==="evenodd",F=T.length>1;if(A&&F){const L=T.map(M=>({path:M,area:Fd(M)}));if(L.sort((M,E)=>E.area-M.area),T.length>3||!Ed(L))for(let M=0;M<L.length;M++){const E=L[M],X=M===0;t.context.beginPath();const I=new Yt(void 0,!0);Zr(E.path,I),t.context.path(I),X?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let M=0;M<L.length;M++){const E=L[M],X=M%2===1;t.context.beginPath();const I=new Yt(void 0,!0);Zr(E.path,I),t.context.path(I),X?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const L=P?P==="evenodd":!0;w=new Yt(v,L),t.context.path(w),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":p=Q(i,"cx",0),g=Q(i,"cy",0),m=Q(i,"r",0),t.context.ellipse(p,g,m,m),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":h=Q(i,"x",0),l=Q(i,"y",0),S=Q(i,"width",0),C=Q(i,"height",0),_=Q(i,"rx",0),x=Q(i,"ry",0),_||x?t.context.roundRect(h,l,S,C,_||x):t.context.rect(h,l,S,C),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":p=Q(i,"cx",0),g=Q(i,"cy",0),_=Q(i,"rx",0),x=Q(i,"ry",0),t.context.beginPath(),t.context.ellipse(p,g,_,x),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"line":c=Q(i,"x1",0),u=Q(i,"y1",0),d=Q(i,"x2",0),f=Q(i,"y2",0),t.context.beginPath(),t.context.moveTo(c,u),t.context.lineTo(d,f),s&&t.context.stroke(s);break;case"polygon":y=i.getAttribute("points"),b=y.match(/-?\d+/g).map(P=>parseInt(P,10)),t.context.poly(b,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":y=i.getAttribute("points"),b=y.match(/-?\d+/g).map(P=>parseInt(P,10)),t.context.poly(b,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{Y(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}a&&(e=null);for(let P=0;P<n.length;P++)Ra(n[P],t,e,s)}function Bd(i){return i.texture!==void 0}const Qr={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Vs{constructor(t,e){this.uid=et("fillPattern"),this._tick=0,this.transform=new z;const s=Bd(t)?t:{texture:t,repetition:e};this.texture=s.texture,this.textureSpace=s.textureSpace??"global";const n=s.repetition;n&&(this.texture.source.style.addressModeU=Qr[n].addressModeU,this.texture.source.style.addressModeV=Qr[n].addressModeV)}setTransform(t){if(t){if(this.transform.equals(t))return;this.transform.copyFrom(t)}else{if(this.transform.isIdentity())return;this.transform.identity()}this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function Ld(i){return st.isColorLike(i)}function Jr(i){return i instanceof Vs}function to(i){return i instanceof Ht}function Od(i){return i instanceof G}function Dd(i,t,e){const s=st.shared.setValue(t??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=G.WHITE,{...e,...i}}function Gd(i,t,e){return i.texture=t,{...e,...i}}function eo(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,i.textureSpace=t.textureSpace,{...e,...i}}function so(i,t,e){return t.buildGradient(),i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,i.textureSpace=t.textureSpace,{...e,...i}}function zd(i,t){const e={...t,...i},s=st.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function ce(i,t){if(i==null)return null;const e={},s=i;return Ld(i)?Dd(e,i,t):Od(i)?Gd(e,i,t):Jr(i)?eo(e,i,t):to(i)?so(e,i,t):s.fill&&Jr(s.fill)?eo(s,s.fill,t):s.fill&&to(s.fill)?so(s,s.fill,t):zd(s,t)}function zs(i,t){const{width:e,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...h}=t,l=ce(i,h);return l?{width:e,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...l}:null}function Ud(i,t){let e=1;const s=i.shapePath.shapePrimitives;for(let n=0;n<s.length;n++){const r=s[n].shape;if(r.type!=="polygon")continue;const o=r.points,a=o.length;if(a<6)continue;const h=r.closePath;for(let l=0;l<a;l+=2){if(!h&&(l===0||l===a-2))continue;const c=(l-2+a)%a,u=(l+2)%a,d=o[c],f=o[c+1],p=o[l],g=o[l+1],m=o[u],_=o[u+1],x=d-p,b=f-g,y=m-p,v=_-g,w=x*x+b*b,S=y*y+v*v;if(w<1e-12||S<1e-12)continue;let T=(x*y+b*v)/Math.sqrt(w*S);T<-1?T=-1:T>1&&(T=1);const A=Math.sqrt((1-T)*.5);if(A<1e-6)continue;const F=Math.min(1/A,t);F>e&&(e=F)}}return e}const Wd=new Z,io=new z,wn=class Lt extends Rt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=et("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Yt,this._transform=new z,this._fillStyle={...Lt.defaultFillStyle},this._strokeStyle={...Lt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new _t,this._boundsDirty=!0}clone(){const t=new Lt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=ce(t,Lt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=zs(t,Lt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ce(t,Lt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ce(t,Lt.defaultStrokeStyle),this}texture(t,e,s,n,r,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:n||0,dw:r||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?st.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Yt,this}fill(t,e){let s;const n=this.instructions[this.instructions.length-1];return this._tick===0&&n?.action==="stroke"?s=n.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(D(j,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=ce(t,Lt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(Z.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s?.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=zs(t,Lt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,n,r,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,s,n,r,o),this}arcTo(t,e,s,n,r){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*n+o.tx,o.b*s+o.d*n+o.ty,r),this}arcToSvg(t,e,s,n,r,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,n,r,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,s,n,r,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*s+h.c*n+h.tx,h.b*s+h.d*n+h.ty,h.a*r+h.c*o+h.tx,h.b*r+h.d*o+h.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,s,n){return this._tick++,this._activePath.ellipse(t,e,s,n,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,n=this._activePath.instructions,r=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=r,n[0].data[1]=o,this):(this._activePath.moveTo(r,o),this)}quadraticCurveTo(t,e,s,n,r){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*n+o.tx,o.b*s+o.d*n+o.ty,r),this}rect(t,e,s,n){return this._tick++,this._activePath.rect(t,e,s,n,this._transform.clone()),this}roundRect(t,e,s,n,r){return this._tick++,this._activePath.roundRect(t,e,s,n,r,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,n,r=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,n,r,o),this}roundPoly(t,e,s,n,r,o){return this._tick++,this._activePath.roundPoly(t,e,s,n,r,o),this}roundShape(t,e,s,n){return this._tick++,this._activePath.roundShape(t,e,s,n),this}filletRect(t,e,s,n,r){return this._tick++,this._activePath.filletRect(t,e,s,n,r),this}chamferRect(t,e,s,n,r,o){return this._tick++,this._activePath.chamferRect(t,e,s,n,r,o),this}star(t,e,s,n,r=0,o=0){return this._tick++,this._activePath.star(t,e,s,n,r,o,this._transform.clone()),this}svg(t){return this._tick++,Rd(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,n,r,o){return t instanceof z?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,n,r,o),this)}transform(t,e,s,n,r,o){return t instanceof z?(this._transform.append(t),this):(io.set(t,e,s,n,r,o),this._transform.append(io),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const s=this.instructions[e],n=s.action;if(n==="fill"){const r=s.data;t.addBounds(r.path.bounds)}else if(n==="texture"){const r=s.data;t.addFrame(r.dx,r.dy,r.dx+r.dw,r.dy+r.dh,r.transform)}if(n==="stroke"){const r=s.data,o=r.style.alignment;let a=r.style.width*(1-o);r.style.join==="miter"&&(a*=Ud(r.path,r.style.miterLimit));const h=r.path.bounds;t.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let s=!1;for(let n=0;n<e.length;n++){const r=e[n],o=r.data,a=o.path;if(!r.action||!a)continue;const h=o.style,l=a.shapePath.shapePrimitives;for(let c=0;c<l.length;c++){const u=l[c].shape;if(!h||!u)continue;const d=l[c].transform,f=d?d.applyInverse(t,Wd):t;if(r.action==="fill")s=u.contains(f.x,f.y);else{const g=h;s=u.strokeContains(f.x,f.y,g.width,g.alignment)}const p=o.hole;if(p){const g=p.shapePath?.shapePrimitives;if(g)for(let m=0;m<g.length;m++)g[m].shape.contains(f.x,f.y)&&(s=!1)}if(s)return!0}}return s}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){const s=typeof t=="boolean"?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(s)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(s))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};wn.defaultFillStyle={color:16777215,alpha:1,texture:G.WHITE,matrix:null,fill:null,textureSpace:"local"};wn.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:G.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Ct=wn;function Sn(i,t=1){const e=Fe.RETINA_PREFIX?.exec(i);return e?parseFloat(e[1]):t}function Tn(i,t,e){i.label=e,i._sourceOrigin=e;const s=new G({source:i,label:e}),n=()=>{delete t.promiseCache[e],q.has(e)&&q.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(Y("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),s.once("destroy",()=>{i.destroyed||(Y("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),s}const Xd=".svg",Yd="image/svg+xml",Hd={extension:{type:k.LoadParser,priority:qt.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return Re(i,Yd)||Be(i,Xd)},async load(i,t,e){return t.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?$d(i):Nd(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function Nd(i,t,e,s){const n=await N.get().fetch(i),r=N.get().createImage();r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await n.text())}`,r.crossOrigin=s,await r.decode();const o=t.data?.width??r.width,a=t.data?.height??r.height,h=t.data?.resolution||Sn(i),l=Math.ceil(o*h),c=Math.ceil(a*h),u=N.get().createCanvas(l,c),d=u.getContext("2d");d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(r,0,0,o*h,a*h);const{parseAsGraphicsContext:f,...p}=t.data??{},g=new ue({resource:u,alphaMode:"premultiply-alpha-on-upload",resolution:h,...p});return Tn(g,e,i)}async function $d(i){const e=await(await N.get().fetch(i)).text(),s=new Ct;return s.svg(e),s}const Vd=`(function () {
|
|
253
|
-
'use strict';
|
|
254
|
-
|
|
255
|
-
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
|
|
256
|
-
async function checkImageBitmap() {
|
|
257
|
-
try {
|
|
258
|
-
if (typeof createImageBitmap !== "function") return false;
|
|
259
|
-
const response = await fetch(WHITE_PNG);
|
|
260
|
-
const imageBlob = await response.blob();
|
|
261
|
-
const imageBitmap = await createImageBitmap(imageBlob);
|
|
262
|
-
return imageBitmap.width === 1 && imageBitmap.height === 1;
|
|
263
|
-
} catch (_e) {
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
void checkImageBitmap().then((result) => {
|
|
268
|
-
self.postMessage(result);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
})();
|
|
272
|
-
`;let Ae=null,tn=class{constructor(){Ae||(Ae=URL.createObjectURL(new Blob([Vd],{type:"application/javascript"}))),this.worker=new Worker(Ae)}};tn.revokeObjectURL=function(){Ae&&(URL.revokeObjectURL(Ae),Ae=null)};const jd=`(function () {
|
|
273
|
-
'use strict';
|
|
274
|
-
|
|
275
|
-
async function loadImageBitmap(url, alphaMode) {
|
|
276
|
-
const response = await fetch(url);
|
|
277
|
-
if (!response.ok) {
|
|
278
|
-
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
|
|
279
|
-
}
|
|
280
|
-
const imageBlob = await response.blob();
|
|
281
|
-
return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
|
|
282
|
-
}
|
|
283
|
-
self.onmessage = async (event) => {
|
|
284
|
-
try {
|
|
285
|
-
const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
|
|
286
|
-
self.postMessage({
|
|
287
|
-
data: imageBitmap,
|
|
288
|
-
uuid: event.data.uuid,
|
|
289
|
-
id: event.data.id
|
|
290
|
-
}, [imageBitmap]);
|
|
291
|
-
} catch (e) {
|
|
292
|
-
self.postMessage({
|
|
293
|
-
error: e,
|
|
294
|
-
uuid: event.data.uuid,
|
|
295
|
-
id: event.data.id
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
})();
|
|
301
|
-
`;let Ce=null;class Ba{constructor(){Ce||(Ce=URL.createObjectURL(new Blob([jd],{type:"application/javascript"}))),this.worker=new Worker(Ce)}}Ba.revokeObjectURL=function(){Ce&&(URL.revokeObjectURL(Ce),Ce=null)};let no=0,Ci;class qd{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new tn;e.addEventListener("message",s=>{e.terminate(),tn.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Ci===void 0&&(Ci=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Ci&&(this._createdWorkers++,t=new Ba().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}async _run(t,e){await this._initWorkers();const s=new Promise((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[no]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:no++,id:s})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}}const ro=new qd,Kd=[".jpeg",".jpg",".png",".webp",".avif"],Zd=["image/jpeg","image/png","image/webp","image/avif"];async function Qd(i,t){const e=await N.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return t?.data?.alphaMode==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const La={name:"loadTextures",id:"texture",extension:{type:k.LoadParser,priority:qt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Re(i,Zd)||Be(i,Kd)},async load(i,t,e){let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ro.isImageBitmapSupported()?s=await ro.loadImageBitmap(i,t):s=await Qd(i,t):s=await new Promise((r,o)=>{s=N.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?r(s):(s.onload=()=>{r(s)},s.onerror=o)});const n=new ue({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:t.data?.resolution||Sn(i),...t.data});return Tn(n,e,i)},unload(i){i.destroy(!0)}},Jd=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let Pi,Mi;function tf(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=sf(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function ef(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",n),i.load();function s(){r(),t()}function n(o){r(),e(o)}function r(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",n)}})}function sf(i,t=globalThis.location){if(i.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function nf(){const i=[],t=[];for(const e of Jd){const s=Qe.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ns(s)&&(i.push(e),t.includes(s)||t.push(s))}return{validVideoExtensions:i,validVideoMime:t}}const rf={name:"loadVideo",id:"video",extension:{type:k.LoadParser,name:"loadVideo"},test(i){if(!Pi||!Mi){const{validVideoExtensions:s,validVideoMime:n}=nf();Pi=s,Mi=n}const t=Re(i,Mi),e=Be(i,Pi);return t||e},async load(i,t,e){const s={...Qe.defaultOptions,resolution:t.data?.resolution||Sn(i),alphaMode:t.data?.alphaMode||await Ko(),...t.data},n=document.createElement("video"),r={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(r).forEach(h=>{const l=r[h];l!==void 0&&n.setAttribute(h,l)}),s.muted===!0&&(n.muted=!0),tf(n,i,s.crossorigin);const o=document.createElement("source");let a;if(s.mime)a=s.mime;else if(i.startsWith("data:"))a=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const h=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();a=Qe.MIME_TYPES[h]||`video/${h}`}return o.src=i,a&&(o.type=a),new Promise((h,l)=>{s.preload&&!s.autoPlay&&n.load(),n.addEventListener("canplay",c),n.addEventListener("error",u),o.addEventListener("error",u),n.appendChild(o);async function c(){const f=new Qe({...s,resource:n});d(),t.data.preload&&await ef(n),h(Tn(f,e,i))}function u(f){d(),l(f)}function d(){n.removeEventListener("canplay",c),n.removeEventListener("error",u),o.removeEventListener("error",u)}})},unload(i){i.destroy(!0)}},Oa={extension:{type:k.ResolveParser,name:"resolveTexture"},test:La.test,parse:i=>({resolution:parseFloat(Fe.RETINA_PREFIX.exec(i)?.[1]??"1"),format:i.split(".").pop(),src:i})},of={extension:{type:k.ResolveParser,priority:-2,name:"resolveJson"},test:i=>Fe.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:Oa.parse};class af{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Fe,this.loader=new Ic,this.cache=q,this._backgroundLoader=new wc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized){Y("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let r=t.manifest;typeof r=="string"&&(r=await this.load(r)),this.resolver.addManifest(r)}const e=t.texturePreference?.resolution??1,s=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:s}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...t.loadOptions})}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=Ls(t),n=Ft(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}),r=this.resolver.resolve(n),o=await this._mapLoadToResolve(r,e);return s?o[n[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},o=Object.keys(n);let a=0;const h=[],l=()=>{e?.(h.reduce((u,d)=>u+d,0)/a)},c=o.map((u,d)=>{const f=n[u],p=Object.values(f),m=[...new Set(p.flat())].reduce((_,x)=>_+(x.progressSize||1),0);return h.push(0),a+=m,this._mapLoadToResolve(f,_=>{h[d]=_*m,l()}).then(_=>{r[u]=_})});return await Promise.all(c),s?r[t[0]]:r}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(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return q.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=q.get(t[s]);return e}async _mapLoadToResolve(t,e){const s=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=await this.loader.load(s,e);this._backgroundLoader.active=!0;const r={};return s.forEach(o=>{const a=n[o.src],h=[o.src];o.alias&&h.push(...o.alias),h.forEach(l=>{r[l]=a}),q.set(h,a)}),r}async unload(t){this._initialized||await this.init();const e=Ft(t).map(n=>typeof n!="string"?n.src:n),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=Ft(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{q.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,n)=>e.indexOf(s)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Vt=new af;$.handleByList(k.LoadParser,Vt.loader.parsers).handleByList(k.ResolveParser,Vt.resolver.parsers).handleByList(k.CacheParser,Vt.cache.parsers).handleByList(k.DetectionParser,Vt.detections);$.add(Sc,Ac,Tc,Ec,Pc,Mc,kc,Bc,Dc,Nc,Hd,La,rf,vc,bc,Oa,of);const oo={loader:k.LoadParser,resolver:k.ResolveParser,cache:k.CacheParser,detection:k.DetectionParser};$.handle(k.Asset,i=>{const t=i.ref;Object.entries(oo).filter(([e])=>!!t[e]).forEach(([e,s])=>$.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(oo).filter(e=>!!t[e]).forEach(e=>$.remove(t[e]))});class Da{constructor(t){this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new sa({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const s=t[e],n=s.element;if(!s.parent||s.globalDisplayStatus<7)n?.remove(),t.splice(e,1),e--;else{this._domElement.contains(n)||(n.style.position="absolute",n.style.pointerEvents="auto",this._domElement.appendChild(n));const r=s.worldTransform,o=s._anchor,a=s.width*o.x,h=s.height*o.y;n.style.transformOrigin=`${a}px ${h}px`,n.style.transform=`matrix(${r.a}, ${r.b}, ${r.c}, ${r.d}, ${r.tx-a}, ${r.ty-h})`,n.style.opacity=s.groupAlpha.toString()}}}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++)this._attachedDomElements[t].element?.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Da.extension={type:[k.WebGLPipes,k.WebGPUPipes,k.CanvasPipes],name:"dom"};class hf{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||(ct.system.add(this._tickerUpdate,this,is.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(ct.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(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}}const Ut=new hf;class Us extends us{constructor(){super(...arguments),this.client=new Z,this.movement=new Z,this.offset=new Z,this.global=new Z,this.screen=new Z}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,s){return t.worldTransform.applyInverse(s||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,s,n,r,o,a,h,l,c,u,d,f,p,g){throw new Error("Method not implemented.")}}class Et extends Us{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 Ee extends Us{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ee.DOM_DELTA_PIXEL=0;Ee.DOM_DELTA_LINE=1;Ee.DOM_DELTA_PAGE=2;const lf=2048,cf=new Z,Ye=new Z;class uf{constructor(t){this.dispatch=new Rt,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((s,n)=>s.priority-n.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 s=0,n=e.length;s<n;s++)e[s].fn(t);else Y(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Ut.pauseUpdate=!0;const n=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",r=this[n](this.rootTarget,this.rootTarget.eventMode,cf.set(t,e),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(t,e){if(!t.target)return;const s=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,r=s.length-1;n<r;n++)if(t.currentTarget=s[n],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 n=s.length-2;n>=0;n--)if(t.currentTarget=s[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(s.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(e)?e:[e];for(let r=s.length-1;r>=0;r--)n.forEach(o=>{t.currentTarget=s[r],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let s=0;s<lf&&t!==this.rootTarget&&t.parent;s++){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,s,n,r,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Ut.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,s,n,r,o||r(t,s));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:h&&!r(t,s)&&n(t,s)?l?[t]:[]:null}hitTestRecursive(t,e,s,n,r){if(this._interactivePrune(t)||r(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Ut.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children,l=s;for(let c=h.length-1;c>=0;c--){const u=h[c],d=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,l,n,r);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const f=t.isInteractive();return(d.length>0||f)&&d.push(t),d}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&n(t,s)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,Ye),!t.hitArea.contains(Ye.x,Ye.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s<t.effects.length;s++){const n=t.effects[s];if(n.containsPoint&&!n.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t?.containsPoint?(t.worldTransform.applyInverse(e,Ye),t.containsPoint(Ye)):!1}notifyTarget(t,e){if(!t.currentTarget.isInteractive())return;e??(e=t.type);const s=`on${e}`;t.currentTarget[s]?.(t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Et)){Y("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 n=e.button===2;this.dispatchEvent(e,n?"rightdown":"mousedown")}const s=this.trackingData(t.pointerId);s.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof Et)){Y("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 s=e.pointerType==="mouse"||e.pointerType==="pen",n=this.trackingData(t.pointerId),r=this.findMountedTarget(n.overTargets);if(n.overTargets?.length>0&&r!==e.target){const h=t.type==="mousemove"?"mouseout":"pointerout",l=this.createPointerEvent(t,h,r);if(this.dispatchEvent(l,"pointerout"),s&&this.dispatchEvent(l,"mouseout"),!e.composedPath().includes(r)){const c=this.createPointerEvent(t,"pointerleave",r);for(c.eventPhase=c.AT_TARGET;c.target&&!e.composedPath().includes(c.target);)c.currentTarget=c.target,this.notifyTarget(c),s&&this.notifyTarget(c,"mouseleave"),c.target=c.target.parent;this.freeEvent(c)}this.freeEvent(l)}if(r!==e.target){const h=t.type==="mousemove"?"mouseover":"pointerover",l=this.clonePointerEvent(e,h);this.dispatchEvent(l,"pointerover"),s&&this.dispatchEvent(l,"mouseover");let c=r?.parent;for(;c&&c!==this.rootTarget.parent&&c!==e.target;)c=c.parent;if(!c||c===this.rootTarget.parent){const d=this.clonePointerEvent(e,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==r&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(l)}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")),s&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=e.target?.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof Et)){Y("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),s=this.createPointerEvent(t),n=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),n&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=s.target?.cursor);const r=this.clonePointerEvent(s,"pointerenter");for(r.eventPhase=r.AT_TARGET;r.target&&r.target!==this.rootTarget.parent;)r.currentTarget=r.target,this.notifyTarget(r),n&&this.notifyTarget(r,"mouseenter"),r.target=r.target.parent;e.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(r)}mapPointerOut(t){if(!(t instanceof Et)){Y("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const s=t.pointerType==="mouse"||t.pointerType==="pen",n=this.findMountedTarget(e.overTargets),r=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(r),s&&this.dispatchEvent(r,"mouseout");const o=this.createPointerEvent(t,"pointerleave",n);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(r),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Et)){Y("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),r=this.findMountedTarget(n.pressTargetsByButton[t.button]);let o=r;if(r&&!s.composedPath().includes(r)){let a=r;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const h=s.button===2;this.notifyTarget(s,h?"rightupoutside":"mouseupoutside")}a=a.parent}delete n.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const h=n.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(s)}mapPointerUpOutside(t){if(!(t instanceof Et)){Y("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(s){let r=s;for(;r;)n.currentTarget=r,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),r=r.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof Ee)){Y("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 s=1;s<t.length&&t[s].parent===e;s++)e=t[s];return e}createPointerEvent(t,e,s){const n=this.allocateEvent(Et);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=s??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],typeof e=="string"&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(Ee);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 s=this.allocateEvent(Et);return s.nativeEvent=t.nativeEvent,s.originalEvent=t.originalEvent,this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.target=t.target,s.path=t.composedPath().slice(),s.type=e??s.type,s}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Et&&e instanceof Et&&(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 Us&&e instanceof Us&&(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.defaultPrevented=!1,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 s=t.currentTarget._events[e];if(s)if("fn"in s)s.once&&t.currentTarget.removeListener(e,s.fn,void 0,!0),s.fn.call(s.context,t);else for(let n=0,r=s.length;n<r&&!t.propagationImmediatelyStopped;n++)s[n].once&&t.currentTarget.removeListener(e,s[n].fn,void 0,!0),s[n].fn.call(s[n].context,t)}}const df=1,ff={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},An=class en{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new uf(null),Ut.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Et(null),this._rootWheelEvent=new Ee(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...en.defaultEventFeatures},{set:(e,s,n)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),e[s]=n,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{canvas:e,resolution:s}=this.renderer;this.setTargetElement(e),this.resolution=s,en._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){Ut.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=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 s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s);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 s=0,n=e.length;s<n;s++){const r=e[s],o=this._bootstrapEvent(this._rootPointerEvent,r);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Ut.pointerMoved();const e=this._normalizeToPointerData(t);for(let s=0,n=e.length;s<n;s++){const r=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(r)}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 s=e!==this.domElement?"outside":"",n=this._normalizeToPointerData(t);for(let r=0,o=n.length;r<o;r++){const a=this._bootstrapEvent(this._rootPointerEvent,n[r]);a.type+=s,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 s=0,n=e.length;s<n;s++){const r=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(r)}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,Ut.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Ut.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;Ut.removeTickerListener();const t=this.domElement.style;t&&(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,s){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},r=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*r,t.y=(s-n.top)*(this.domElement.height/n.height)*r}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let s=0,n=t.changedTouches.length;s<n;s++){const r=t.changedTouches[s];typeof r.button>"u"&&(r.button=0),typeof r.buttons>"u"&&(r.buttons=1),typeof r.isPrimary>"u"&&(r.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof r.width>"u"&&(r.width=r.radiusX||1),typeof r.height>"u"&&(r.height=r.radiusY||1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="touch"),typeof r.pointerId>"u"&&(r.pointerId=r.identifier||0),typeof r.pressure>"u"&&(r.pressure=r.force||.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),typeof r.layerX>"u"&&(r.layerX=r.offsetX=r.clientX),typeof r.layerY>"u"&&(r.layerY=r.offsetY=r.clientY),r.isNormalized=!0,r.type=t.type,r.altKey??(r.altKey=t.altKey),r.ctrlKey??(r.ctrlKey=t.ctrlKey),r.metaKey??(r.metaKey=t.metaKey),r.shiftKey??(r.shiftKey=t.shiftKey),e.push(r)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const s=t;typeof s.isPrimary>"u"&&(s.isPrimary=!0),typeof s.width>"u"&&(s.width=1),typeof s.height>"u"&&(s.height=1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="mouse"),typeof s.pointerId>"u"&&(s.pointerId=df),typeof s.pressure>"u"&&(s.pressure=.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),s.isNormalized=!0,e.push(s)}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=ff[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}};An.extension={name:"events",type:[k.WebGLSystem,k.CanvasSystem,k.WebGPUSystem],priority:-1};An.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ga=An;const pf={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,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(i){this.eventMode=i?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ga.defaultEventMode},set eventMode(i){this._internalEventMode=i},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(i,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,n=typeof e=="object"?e.signal:void 0,r=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;i=s?`${i}capture`:i;const a=typeof t=="function"?t:t.handleEvent,h=this;n&&n.addEventListener("abort",()=>{h.off(i,a,o)}),r?h.once(i,a,o):h.on(i,a,o)},removeEventListener(i,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,n=typeof t=="function"?void 0:t;i=s?`${i}capture`:i,t=typeof t=="function"?t:t.handleEvent,this.off(i,t,n)},dispatchEvent(i){if(!(i instanceof us))throw new Error("Container cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};let be;function ao(i){const t=N.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=i,e.fillRect(0,0,6,1),t}function gf(){if(be!==void 0)return be;try{const i=ao("#ff00ff"),t=ao("#ffff00"),s=N.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(i,0,0),s.drawImage(t,2,0);const n=s.getImageData(2,0,1,1);if(!n)be=!1;else{const r=n.data;be=r[0]===255&&r[1]===0&&r[2]===0}}catch{be=!1}return be}const K={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:gf(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:i=>{const t=i.source,e=t?.resource;if(!e)return null;const s=t.alphaMode==="premultiplied-alpha",n=t.resourceWidth??t.pixelWidth,r=t.resourceHeight??t.pixelHeight,o=n!==t.pixelWidth||r!==t.pixelHeight;if(s){if((e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)&&!o)return e;const a=K._unpremultipliedCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas}if(e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof ArrayBuffer){const a=K._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;const h=N.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d"),c=l.createImageData(t.pixelWidth,t.pixelHeight),u=c.data,d=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(t.format==="bgra8unorm")for(let f=0;f<u.length&&f+3<d.length;f+=4)u[f]=d[f+2],u[f+1]=d[f+1],u[f+2]=d[f],u[f+3]=d[f+3];else u.set(d.subarray(0,u.length));return l.putImageData(c,0,0),K._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}if(s){const a=N.get().createCanvas(t.pixelWidth,t.pixelHeight),h=a.getContext("2d",{willReadFrequently:!0});a.width=t.pixelWidth,a.height=t.pixelHeight,h.drawImage(e,0,0);const l=h.getImageData(0,0,a.width,a.height),c=l.data;for(let u=0;u<c.length;u+=4){const d=c[u+3];if(d>0){const f=255/d;c[u]=Math.min(255,c[u]*f+.5),c[u+1]=Math.min(255,c[u+1]*f+.5),c[u+2]=Math.min(255,c[u+2]*f+.5)}}return h.putImageData(l,0,0),K._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){const a=K._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;const h=N.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d");return h.width=t.pixelWidth,h.height=t.pixelHeight,l.drawImage(e,0,0),K._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}return e},getTintedCanvas:(i,t)=>{const e=i.texture,s=st.shared.setValue(t).toHex(),n=e.tintCache||(e.tintCache={}),r=n[s],o=e.source._resourceId;if(r?.tintId===o)return r;const a=r&&"getContext"in r?r:N.get().createCanvas();return K.tintMethod(e,t,a),a.tintId=o,n[s]=a,n[s]},getTintedPattern:(i,t)=>{const e=st.shared.setValue(t).toHex(),s=i.patternCache||(i.patternCache={}),n=i.source._resourceId;let r=s[e];return r?.tintId===n||(K.canvas||(K.canvas=N.get().createCanvas()),K.tintMethod(i,t,K.canvas),r=K.canvas.getContext("2d").createPattern(K.canvas,"repeat"),r.tintId=n,s[e]=r),r},applyPatternTransform:(i,t,e=!0)=>{if(!t)return;const s=i;if(!s.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const r=new n([t.a,t.b,t.c,t.d,t.tx,t.ty]);s.setTransform(e?r.inverse():r)},tintWithMultiply:(i,t,e)=>{const s=e.getContext("2d"),n=i.frame.clone(),r=i.source._resolution??i.source.resolution??1,o=i.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=U.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.fillStyle=st.shared.setValue(t).toHex(),s.fillRect(0,0,h,l),s.globalCompositeOperation="multiply";const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,n.width,n.height),s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.globalCompositeOperation="destination-atop",s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.restore()},tintWithOverlay:(i,t,e)=>{const s=e.getContext("2d"),n=i.frame.clone(),r=i.source._resolution??i.source.resolution??1,o=i.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=U.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.globalCompositeOperation="copy",s.fillStyle=st.shared.setValue(t).toHex(),s.fillRect(0,0,h,l),s.globalCompositeOperation="destination-atop";const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,n.width,n.height),s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.restore()},tintWithPerPixel:(i,t,e)=>{const s=e.getContext("2d"),n=i.frame.clone(),r=i.source._resolution??i.source.resolution??1,o=i.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=U.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.globalCompositeOperation="copy";const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,n.width,n.height),s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.restore();const u=t>>16&255,d=t>>8&255,f=t&255,p=s.getImageData(0,0,h,l),g=p.data;for(let m=0;m<g.length;m+=4)g[m]=g[m]*u/255,g[m+1]=g[m+1]*d/255,g[m+2]=g[m+2]*f/255;s.putImageData(p,0,0)},_applyInverseRotation:(i,t,e,s)=>{const n=U.inv(t),r=U.uX(n),o=U.uY(n),a=U.vX(n),h=U.vY(n),l=-Math.min(0,r*e,a*s,r*e+a*s),c=-Math.min(0,o*e,h*s,o*e+h*s);i.transform(r,o,a,h,l,c)}};K.tintMethod=K.canUseMultiply?K.tintWithMultiply:K.tintWithPerPixel;class mf{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=N.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=Me(t),e=Me(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,r=(s<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,n),this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const Ie=new mf;Xs.register(Ie);const ho=new z;function za(i,t){t.clear();const e=t.matrix;for(let s=0;s<i.length;s++){const n=i[s];if(n.globalDisplayStatus<7)continue;const r=n.renderGroup??n.parentRenderGroup;r?.isCachedAsTexture?t.matrix=ho.copyFrom(r.textureOffsetInverseTransform).append(n.worldTransform):r?._parentCacheAsTextureRenderGroup?t.matrix=ho.copyFrom(r._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(n.groupTransform):t.matrix=n.worldTransform,t.addBounds(n.bounds)}return t.matrix=e,t}const _f=new _t;function Ua(i,t,e,s,n=!1){const r=_f;r.minX=0,r.minY=0,r.maxX=i.width/s|0,r.maxY=i.height/s|0;const o=lt.getOptimalTexture(r.width,r.height,s,!1,n);return o.source.uploadMethodId="image",o.source.resource=i,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=t/s,o.frame.height=e/s,o.source.emit("update",o.source),o.updateUvs(),o}function lo(i){return typeof i.getCanvasFilterString=="function"}class yf{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new _t,this.cssFilterString=""}}class Wa{constructor(t){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=t}push(t){const e=this._pushFilterFrame(),s=t.filterEffect.filters;if(e.skip=!1,e.useClip=!1,e.filters=s,e.container=t.container,e.cssFilterString="",s.every(h=>!h.enabled)){e.skip=!0;return}const n=[],r=1;for(const h of s){if(!h.enabled)continue;if(!lo(h)){this._warnUnsupportedFilter(h);continue}const l=h.getCanvasFilterString();if(l===null){this._warnUnsupportedFilter(h);continue}l&&n.push(l)}if(n.length===0&&r===1){e.skip=!0;return}e.cssFilterString=n.join(" "),this._calculateFilterArea(t,e.bounds),e.useClip=!!t.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),e.useClip&&Number.isFinite(e.bounds.width)&&Number.isFinite(e.bounds.height)&&e.bounds.width>0&&e.bounds.height>0){const h=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(e.bounds.x*h,e.bounds.y*h,e.bounds.width*h,e.bounds.height*h),o.clip()}else e.useClip=!1;e.cssFilterString&&(o.filter=a!=="none"?`${a} ${e.cssFilterString}`:e.cssFilterString)}pop(){const t=this._popFilterFrame();if(t.skip)return;const e=this._savedStates.pop();if(!e)return;const s=this.renderer.canvasContext.activeContext;t.useClip?s.restore():s.filter=e.filter,this._alphaMultiplier=e.alphaMultiplier}generateFilteredTexture({texture:t,filters:e}){if(!e?.length||e.every(_=>!_.enabled))return t;const s=[],n=1;for(const _ of e){if(!_.enabled)continue;if(!lo(_)){this._warnUnsupportedFilter(_);continue}const x=_.getCanvasFilterString();if(x===null){this._warnUnsupportedFilter(_);continue}x&&s.push(x)}if(s.length===0&&n===1)return t;const r=K.getCanvasSource(t);if(!r)return t;const o=t.frame,a=t.source._resolution??t.source.resolution??1,h=o.width,l=o.height,c=Ie.getOptimalCanvasAndContext(h,l,a),{canvas:u,context:d}=c;d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),s.length&&(d.filter=s.join(" "));const f=o.x*a,p=o.y*a,g=h*a,m=l*a;return d.drawImage(r,f,p,g,m,0,0,g,m),d.filter="none",d.globalAlpha=1,Ua(u,h,l,a)}_calculateFilterArea(t,e){if(t.renderables?za(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const n=(t.container.renderGroup||t.container.parentRenderGroup)?.cacheToLocalTransform;n&&e.applyMatrix(n)}}_warnUnsupportedFilter(t){const e=t?.constructor?.name||"Filter";this._warnedFilterTypes.has(e)||(this._warnedFilterTypes.add(e),console.warn(`CanvasRenderer: filter "${e}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new yf),this._filterStackIndex++,t}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}Wa.extension={type:[k.CanvasSystem],name:"filter"};var xf=`in vec2 aPosition;
|
|
302
|
-
out vec2 vTextureCoord;
|
|
303
|
-
|
|
304
|
-
uniform vec4 uInputSize;
|
|
305
|
-
uniform vec4 uOutputFrame;
|
|
306
|
-
uniform vec4 uOutputTexture;
|
|
307
|
-
|
|
308
|
-
vec4 filterVertexPosition( void )
|
|
309
|
-
{
|
|
310
|
-
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
311
|
-
|
|
312
|
-
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
313
|
-
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
314
|
-
|
|
315
|
-
return vec4(position, 0.0, 1.0);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
vec2 filterTextureCoord( void )
|
|
319
|
-
{
|
|
320
|
-
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
void main(void)
|
|
324
|
-
{
|
|
325
|
-
gl_Position = filterVertexPosition();
|
|
326
|
-
vTextureCoord = filterTextureCoord();
|
|
327
|
-
}
|
|
328
|
-
`;const Xa={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},bf=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(`
|
|
329
|
-
`);function vf(i){const t=Xa[i],e=t.length;let s="";const n="finalColor = ",r=" + ",o="texture(uTexture, vBlurTexCoords[%index%]) * %value%";for(let a=0;a<i;a++){const h=a===0?n:r,l=a<e?a:i-a-1,c=o.replace("%index%",a.toString()).replace("%value%",t[l].toString());s+=`${h}${c}
|
|
330
|
-
`}return bf.replace("%blur%",`${s};`).replace("%size%",i.toString())}const wf=`
|
|
331
|
-
in vec2 aPosition;
|
|
332
|
-
|
|
333
|
-
uniform float uStrength;
|
|
334
|
-
|
|
335
|
-
out vec2 vBlurTexCoords[%size%];
|
|
336
|
-
|
|
337
|
-
uniform vec4 uInputSize;
|
|
338
|
-
uniform vec4 uOutputFrame;
|
|
339
|
-
uniform vec4 uOutputTexture;
|
|
340
|
-
|
|
341
|
-
vec4 filterVertexPosition( void )
|
|
342
|
-
{
|
|
343
|
-
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
344
|
-
|
|
345
|
-
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
346
|
-
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
347
|
-
|
|
348
|
-
return vec4(position, 0.0, 1.0);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
vec2 filterTextureCoord( void )
|
|
352
|
-
{
|
|
353
|
-
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
void main(void)
|
|
357
|
-
{
|
|
358
|
-
gl_Position = filterVertexPosition();
|
|
359
|
-
|
|
360
|
-
float pixelStrength = uInputSize.%dimension% * uStrength;
|
|
361
|
-
|
|
362
|
-
vec2 textureCoord = filterTextureCoord();
|
|
363
|
-
%blur%
|
|
364
|
-
}`;function Sf(i,t){const e=Math.ceil(i/2);let s=wf,n="",r;t?r="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":r="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o<i;o++){let a=r.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),n+=a,n+=`
|
|
365
|
-
`}return s=s.replace("%blur%",n),s=s.replace("%size%",i.toString()),s=s.replace("%dimension%",t?"z":"w"),s}function Tf(i,t){const e=Sf(t,i),s=vf(t);return ds.from({vertex:e,fragment:s,name:`blur-${i?"horizontal":"vertical"}-pass-filter`})}var Af=`
|
|
366
|
-
|
|
367
|
-
struct GlobalFilterUniforms {
|
|
368
|
-
uInputSize:vec4<f32>,
|
|
369
|
-
uInputPixel:vec4<f32>,
|
|
370
|
-
uInputClamp:vec4<f32>,
|
|
371
|
-
uOutputFrame:vec4<f32>,
|
|
372
|
-
uGlobalFrame:vec4<f32>,
|
|
373
|
-
uOutputTexture:vec4<f32>,
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
struct BlurUniforms {
|
|
377
|
-
uStrength:f32,
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
381
|
-
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
382
|
-
@group(0) @binding(2) var uSampler : sampler;
|
|
383
|
-
|
|
384
|
-
@group(1) @binding(0) var<uniform> blurUniforms : BlurUniforms;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
struct VSOutput {
|
|
388
|
-
@builtin(position) position: vec4<f32>,
|
|
389
|
-
%blur-struct%
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
393
|
-
{
|
|
394
|
-
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
395
|
-
|
|
396
|
-
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
397
|
-
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
398
|
-
|
|
399
|
-
return vec4(position, 0.0, 1.0);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
403
|
-
{
|
|
404
|
-
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
408
|
-
{
|
|
409
|
-
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
fn getSize() -> vec2<f32>
|
|
413
|
-
{
|
|
414
|
-
return gfu.uGlobalFrame.zw;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
@vertex
|
|
419
|
-
fn mainVertex(
|
|
420
|
-
@location(0) aPosition : vec2<f32>,
|
|
421
|
-
) -> VSOutput {
|
|
422
|
-
|
|
423
|
-
let filteredCord = filterTextureCoord(aPosition);
|
|
424
|
-
|
|
425
|
-
let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength;
|
|
426
|
-
|
|
427
|
-
return VSOutput(
|
|
428
|
-
filterVertexPosition(aPosition),
|
|
429
|
-
%blur-vertex-out%
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
@fragment
|
|
434
|
-
fn mainFragment(
|
|
435
|
-
@builtin(position) position: vec4<f32>,
|
|
436
|
-
%blur-fragment-in%
|
|
437
|
-
) -> @location(0) vec4<f32> {
|
|
438
|
-
|
|
439
|
-
var finalColor = vec4(0.0);
|
|
440
|
-
|
|
441
|
-
%blur-sampling%
|
|
442
|
-
|
|
443
|
-
return finalColor;
|
|
444
|
-
}
|
|
445
|
-
`;function Cf(i,t){const e=Xa[t],s=e.length,n=[],r=[],o=[];for(let u=0;u<t;u++){n[u]=`@location(${u}) offset${u}: vec2<f32>,`,i?r[u]=`filteredCord + vec2(${u-s+1} * pixelStrength, 0.0),`:r[u]=`filteredCord + vec2(0.0, ${u-s+1} * pixelStrength),`;const d=u<s?u:t-u-1,f=e[d].toString();o[u]=`finalColor += textureSample(uTexture, uSampler, offset${u}) * ${f};`}const a=n.join(`
|
|
446
|
-
`),h=r.join(`
|
|
447
|
-
`),l=o.join(`
|
|
448
|
-
`),c=Af.replace("%blur-struct%",a).replace("%blur-vertex-out%",h).replace("%blur-fragment-in%",a).replace("%blur-sampling%",l).replace("%dimension%",i?"z":"w");return ge.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}const Ya=class Ha extends pn{constructor(t){t={...Ha.defaultOptions,...t};const e=Tf(t.horizontal,t.kernelSize),s=Cf(t.horizontal,t.kernelSize);super({glProgram:e,gpuProgram:s,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}},...t}),this.horizontal=t.horizontal,this.legacy=t.legacy??!1,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._blurUniforms=this.resources.blurUniforms,this._uniforms=this._blurUniforms.uniforms}apply(t,e,s,n){this.legacy?this._applyLegacy(t,e,s,n):this._applyOptimized(t,e,s,n)}_applyLegacy(t,e,s,n){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,s,n);else{const r=lt.getSameSizeTexture(e);let o=e,a=r;this._state.blend=!1;const h=t.renderer.type===de.WEBGPU;for(let l=0;l<this.passes-1;l++){t.applyFilter(this,o,a,l===0?!0:h);const c=a;a=o,o=c}this._state.blend=!0,t.applyFilter(this,o,s,n),lt.returnTexture(r)}}_applyOptimized(t,e,s,n){if(this._uniforms.uStrength=this._calculateInitialStrength(),this.passes===1)t.applyFilter(this,e,s,n);else{const r=lt.getSameSizeTexture(e);let o=e,a=r;this._state.blend=!1;const h=t.renderer,l=h.type===de.WEBGPU,c=l?h.renderPipes.uniformBatch:null;for(let u=0;u<this.passes-1;u++){c&&this.groups[1].setResource(c.getUboResource(this._blurUniforms),0),t.applyFilter(this,o,a,l);const d=a;a=o,o=d,this._uniforms.uStrength*=.5}c&&this.groups[1].setResource(c.getUboResource(this._blurUniforms),0),this._state.blend=!0,t.applyFilter(this,o,s,n),lt.returnTexture(r)}}_calculateInitialStrength(){let t=1,e=.5;for(let s=1;s<this.passes;s++)t+=e*e,e*=.5;return this.strength/Math.sqrt(t)}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}};Ya.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};let ki=Ya;class ps extends pn{constructor(...t){let e=t[0]??{};typeof e=="number"&&(D(j,"BlurFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }"),e={strength:e},t[1]!==void 0&&(e.quality=t[1]),t[2]!==void 0&&(e.resolution=t[2]||"inherit"),t[3]!==void 0&&(e.kernelSize=t[3])),e={...ki.defaultOptions,...e};const{strength:s,strengthX:n,strengthY:r,quality:o,...a}=e;super({...a,compatibleRenderers:de.BOTH,resources:{}}),this._repeatEdgePixels=!1,this.blurXFilter=new ki({horizontal:!0,...e}),this.blurYFilter=new ki({horizontal:!1,...e}),this.quality=o,this.strengthX=n??s,this.strengthY=r??s,this.repeatEdgePixels=!1}apply(t,e,s,n){const r=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(r&&o){const a=lt.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,s,n),lt.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,s,n)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,s,n))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return D("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength}set blur(t){D("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength=t}get blurX(){return D("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX}set blurX(t){D("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX=t}get blurY(){return D("8.3.0","BlurFilter.blurY is deprecated, please use BlurFilter.strengthY instead."),this.strengthY}set blurY(t){D("8.3.0","BlurFilter.blurY is deprecated, please use BlurFilter.strengthY instead."),this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}ps.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var Pf=`in vec2 vTextureCoord;
|
|
449
|
-
out vec4 finalColor;
|
|
450
|
-
uniform sampler2D uTexture;
|
|
451
|
-
void main() {
|
|
452
|
-
finalColor = texture(uTexture, vTextureCoord);
|
|
453
|
-
}
|
|
454
|
-
`,co=`struct GlobalFilterUniforms {
|
|
455
|
-
uInputSize: vec4<f32>,
|
|
456
|
-
uInputPixel: vec4<f32>,
|
|
457
|
-
uInputClamp: vec4<f32>,
|
|
458
|
-
uOutputFrame: vec4<f32>,
|
|
459
|
-
uGlobalFrame: vec4<f32>,
|
|
460
|
-
uOutputTexture: vec4<f32>,
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
|
|
464
|
-
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
465
|
-
@group(0) @binding(2) var uSampler: sampler;
|
|
466
|
-
|
|
467
|
-
struct VSOutput {
|
|
468
|
-
@builtin(position) position: vec4<f32>,
|
|
469
|
-
@location(0) uv: vec2<f32>
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
|
|
473
|
-
{
|
|
474
|
-
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
475
|
-
|
|
476
|
-
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
477
|
-
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
478
|
-
|
|
479
|
-
return vec4(position, 0.0, 1.0);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
|
|
483
|
-
{
|
|
484
|
-
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
@vertex
|
|
488
|
-
fn mainVertex(
|
|
489
|
-
@location(0) aPosition: vec2<f32>,
|
|
490
|
-
) -> VSOutput {
|
|
491
|
-
return VSOutput(
|
|
492
|
-
filterVertexPosition(aPosition),
|
|
493
|
-
filterTextureCoord(aPosition)
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
@fragment
|
|
498
|
-
fn mainFragment(
|
|
499
|
-
@location(0) uv: vec2<f32>,
|
|
500
|
-
) -> @location(0) vec4<f32> {
|
|
501
|
-
return textureSample(uTexture, uSampler, uv);
|
|
502
|
-
}
|
|
503
|
-
`;class Mf extends pn{constructor(){const t=ge.from({vertex:{source:co,entryPoint:"mainVertex"},fragment:{source:co,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=ds.from({vertex:xf,fragment:Pf,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}class Na{constructor(t){this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Na.extension={type:[k.WebGLPipes,k.WebGPUPipes,k.CanvasPipes],name:"filter"};const kf=new wa({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class Ef{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new _t,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class $a{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new dn({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Je({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){const e=this.renderer,s=t.filterEffect.filters,n=this._pushFilterData();n.skip=!1,n.filters=s,n.container=t.container,n.outputRenderSurface=e.renderTarget.renderSurface;const r=e.renderTarget.renderTarget.colorTexture.source,o=r.resolution,a=r.antialias;if(s.every(f=>!f.enabled)){n.skip=!0;return}const h=n.bounds;if(this._calculateFilterArea(t,h),this._calculateFilterBounds(n,e.renderTarget.rootViewPort,a,o,1),n.skip)return;const l=this._getPreviousFilterData(),c=this._findFilterResolution(o);let u=0,d=0;l&&(u=l.bounds.minX,d=l.bounds.minY),this._calculateGlobalFrame(n,u,d,c,r.width,r.height),this._setupFilterTextures(n,h,e,l)}generateFilteredTexture({texture:t,filters:e}){const s=this._pushFilterData();this._activeFilterData=s,s.skip=!1,s.filters=e;const n=t.source,r=n.resolution,o=n.antialias;if(e.every(f=>!f.enabled))return s.skip=!0,t;const a=s.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(s,a.rectangle,o,r,0),s.skip)return t;const h=r;this._calculateGlobalFrame(s,0,0,h,n.width,n.height),s.outputRenderSurface=lt.getOptimalTexture(a.width,a.height,s.resolution,s.antialias),s.backTexture=G.EMPTY,s.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(s,!0);const d=s.outputRenderSurface;return d.source.alphaMode="premultiplied-alpha",d}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&<.returnTexture(e.backTexture),lt.returnTexture(e.inputTexture))}getBackTexture(t,e,s){const n=t.colorTexture.source._resolution,r=lt.getOptimalTexture(e.width,e.height,n,!1);let o=e.minX,a=e.minY;s&&(o-=s.minX,a-=s.minY),o=Math.floor(o*n),a=Math.floor(a*n);const h=Math.ceil(e.width*n),l=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,r,{x:o,y:a},{width:h,height:l},{x:0,y:0}),r}applyFilter(t,e,s,n){const r=this.renderer,o=this._activeFilterData,h=o.outputRenderSurface===s,l=r.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(l);let u=0,d=0;if(h){const p=this._findPreviousFilterOffset();u=p.x,d=p.y}this._updateFilterUniforms(e,s,o,u,d,c,h,n);const f=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,e,r)}calculateSpriteMatrix(t,e){const s=this._activeFilterData,n=t.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),r=e.worldTransform.copyTo(z.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&r.prepend(o.cacheToLocalTransform),r.invert(),n.prepend(r),n.scale(1/e.texture.orig.width,1/e.texture.orig.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Mf),this._passthroughFilter}_setupBindGroupsAndRender(t,e,s){if(s.renderPipes.uniformBatch){const n=s.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(n,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,s.encoder.draw({geometry:kf,shader:t,state:t._state,topology:"triangle-list"}),s.type===de.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,s,n){if(t.backTexture=G.EMPTY,t.inputTexture=lt.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){s.renderTarget.finishRenderPass();const r=s.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(r,e,n?.bounds)}s.renderTarget.bind(t.inputTexture,!0),s.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,s,n,r,o){const a=t.globalFrame;a.x=e*n,a.y=s*n,a.width=r*n,a.height=o*n}_updateFilterUniforms(t,e,s,n,r,o,a,h){const l=this._filterGlobalUniforms.uniforms,c=l.uOutputFrame,u=l.uInputSize,d=l.uInputPixel,f=l.uInputClamp,p=l.uGlobalFrame,g=l.uOutputTexture;a?(c[0]=s.bounds.minX-n,c[1]=s.bounds.minY-r):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],f[0]=.5*d[2],f[1]=.5*d[3],f[2]=t.frame.width*u[2]-.5*d[2],f[3]=t.frame.height*u[3]-.5*d[3];const m=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=n*o,p[1]=r*o,p[2]=m.source.width*o,p[3]=m.source.height*o,e instanceof G&&(e.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!h),e instanceof G?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=_.width,g[1]=_.height),g[2]=_.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,s=this._filterStackIndex;for(;s>0;){s--;const n=this._filterStack[s];if(!n.skip){t=n.bounds.minX,e=n.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?za(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const n=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;n&&e.applyMatrix(n)}}_applyFiltersToTexture(t,e){const s=t.inputTexture,n=t.bounds,r=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)r[o].apply(this,s,t.outputRenderSurface,e);else{let h=t.inputTexture;const l=lt.getOptimalTexture(n.width,n.height,h.source._resolution,!1);let c=l;for(let u=o;u<a;u++){const d=r[u];if(!d.enabled)continue;d.apply(this,h,c,!0);const f=h;h=c,c=f}r[a].apply(this,h,t.outputRenderSurface,e),lt.returnTexture(l)}}_calculateFilterBounds(t,e,s,n,r){const o=this.renderer,a=t.bounds,h=t.filters;let l=1/0,c=0,u=!0,d=!1,f=!1,p=!0,g=-1,m=-1;for(let _=0;_<h.length;_++){const x=h[_];if(!x.enabled)continue;if(g===-1&&(g=_),m=_,l=Math.min(l,x.resolution==="inherit"?n:x.resolution),c+=x.padding,x.antialias==="off"?u=!1:x.antialias==="inherit"&&u&&(u=s),x.clipToViewport||(p=!1),!!!(x.compatibleRenderers&o.type)){f=!1;break}if(x.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){Y("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,d||(d=x.blendRequired)}if(!f){t.skip=!0;return}if(p&&a.fitBounds(0,e.width/n,0,e.height/n),a.scale(l).ceil().scale(1/l).pad((c|0)*r),!a.isPositive){t.skip=!0;return}t.antialias=u,t.resolution=l,t.blendRequired=d,t.firstEnabledIndex=g,t.lastEnabledIndex=m}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new Ef),this._filterStackIndex++,t}}$a.extension={type:[k.WebGLSystem,k.WebGPUSystem],name:"filter"};class If{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Ff{constructor(){this.instructions=new hn}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Cn=class sn{constructor(t){this._renderer=t,this._managedContexts=new fs({renderer:t,type:"resource",name:"graphicsContext"})}init(t){sn.defaultOptions.bezierSmoothness=t?.bezierSmoothness??sn.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,s=!!e[this._renderer.uid],n=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!s)&&(s&&n.reset(),n.isBatchable=!1,t.dirty=!1),n}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new Ff,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new If;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Cn.extension={type:[k.CanvasSystem],name:"graphicsContext"};Cn.defaultOptions={bezierSmoothness:.5};let Rf=Cn;class Va{constructor(t,e){this.state=fn.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new fs({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){return!1}addRenderable(t,e){this._managedGraphics.add(t),this.renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){t.isRenderable&&this._adaptor.execute(this,t)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Va.extension={type:[k.CanvasPipes],name:"graphics"};function Bf(i,t,e){const s=(i>>24&255)/255;t[e++]=(i&255)/255*s,t[e++]=(i>>8&255)/255*s,t[e++]=(i>>16&255)/255*s,t[e++]=s}class Lf{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{yt.return(t)}),this.batches.length=0}}class ja{constructor(t,e){this.state=fn.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new fs({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,r=this.renderer.graphicsContext.updateGpuContext(e);return!!(r.isBatchable||s!==r.isBatchable)}addRenderable(t,e){const n=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),n.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const s=this._getGpuDataForRenderable(t).batches;for(let n=0;n<s.length;n++){const r=s[n];r._batcher.updateElement(r)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const r=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const o=r.resources.localUniforms.uniforms;o.uTransformMatrix=t.groupTransform,o.uRound=e._roundPixels|t._roundPixels,Bf(t.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),n=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),n.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const s=this.renderer.renderPipes.batch,n=this._getGpuDataForRenderable(t).batches;for(let r=0;r<n.length;r++){const o=n[r];s.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Lf;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const s=t.context,r=this.renderer.graphicsContext.getGpuContext(s),o=this.renderer._roundPixels|t._roundPixels;e.batches=r.batches.map(a=>{const h=yt.get(yn);return a.copyTo(h),h.renderable=t,h.roundPixels=o,h})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}ja.extension={type:[k.WebGLPipes,k.WebGPUPipes],name:"graphics"};$.add(Va);$.add(ja);$.add(Rf);$.add(vn);class ut extends ln{constructor(t){t instanceof Ct&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new Ct,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||t?.context===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new ut(this._context.clone()):(this._ownedContext=null,new ut(this._context))}lineStyle(t,e,s){D(j,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){D(j,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){D(j,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==Ct.defaultStrokeStyle.width||t.color!==Ct.defaultStrokeStyle.color||t.alpha!==Ct.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return D(j,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return D(j,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return D(j,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return D(j,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return D(j,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return D(j,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class Of extends ln{constructor(t,e){const{text:s,resolution:n,style:r,anchor:o,width:a,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new ht({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=l??!1,a!==void 0&&(this.width=a),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){t||(t={}),this._style?.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-s*this.anchor.y,t.y>=r&&t.y<=r+s)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Df(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(D(j,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}let ie=null,Wt=null;function Gf(i,t){ie||(ie=N.get().createCanvas(256,128),Wt=ie.getContext("2d",{willReadFrequently:!0}),Wt.globalCompositeOperation="copy",Wt.globalAlpha=1),(ie.width<i||ie.height<t)&&(ie.width=Me(i),ie.height=Me(t))}function uo(i,t,e){for(let s=0,n=4*e*t;s<t;++s,n+=4)if(i[n+3]!==0)return!1;return!0}function fo(i,t,e,s,n){const r=4*t;for(let o=s,a=s*r+4*e;o<=n;++o,a+=r)if(i[a+3]!==0)return!1;return!0}function zf(...i){let t=i[0];t.canvas||(t={canvas:i[0],resolution:i[1]});const{canvas:e}=t,s=Math.min(t.resolution??1,1),n=t.width??e.width,r=t.height??e.height;let o=t.output;if(Gf(n,r),!Wt)throw new TypeError("Failed to get canvas 2D context");Wt.drawImage(e,0,0,n,r,0,0,n*s,r*s);const h=Wt.getImageData(0,0,n,r).data;let l=0,c=0,u=n-1,d=r-1;for(;c<r&&uo(h,n,c);)++c;if(c===r)return W.EMPTY;for(;uo(h,n,d);)--d;for(;fo(h,n,l,c,d);)++l;for(;fo(h,n,u,c,d);)--u;return++u,++d,Wt.globalCompositeOperation="source-over",Wt.strokeRect(l,c,u-l,d-c),Wt.globalCompositeOperation="copy",o??(o=new W),o.set(l/s,c/s,(u-l)/s,(d-c)/s),o}class Uf{constructor(t=0,e=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=s,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++){const n=t[s];e[s]=[n,this.get(n)]}return e}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,s=0;for(;e!==null;)t[s++]=e.key,e=e.next;return t}setWithEvicted(t,e,s=this.resetTtl){let n=null;if(this.has(t))this.set(t,e,!0,s);else{this.max>0&&this.size===this.max&&(n={...this.first},this.evict(!0));let r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=r:this.last.next=r,this.last=r}return n}set(t,e,s=!1,n=this.resetTtl){let r=this.items[t];return s||r!==void 0?(r.value=e,s===!1&&n&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(r)):(this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=r:this.last.next=r,this.last=r),this}values(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=this.get(t[s]);return e}}function qa(i=1e3,t=0,e=!1){if(isNaN(i)||i<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new Uf(i,t,e)}function Ka(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function Za(i){return i.includes("<")}function Wf(i,t){return i.clone().assign(t)}function Xf(i,t){const e=[],s=t.tagStyles;if(!Ka(t)||!Za(i))return e.push({text:i,style:t}),e;const n=[t],r=[];let o="",a=0;for(;a<i.length;){const h=i[a];if(h==="<"){const l=i.indexOf(">",a);if(l===-1){o+=h,a++;continue}const c=i.indexOf("<",a+1);if(c!==-1&&c<l){o+=h,a++;continue}const u=i.slice(a+1,l);if(u.startsWith("/")){const d=u.slice(1).trim();if(r.length>0&&r[r.length-1]===d){o.length>0&&(e.push({text:o,style:n[n.length-1]}),o=""),n.pop(),r.pop(),a=l+1;continue}else{o+=i.slice(a,l+1),a=l+1;continue}}else{const d=u.trim();if(s[d]){o.length>0&&(e.push({text:o,style:n[n.length-1]}),o="");const f=n[n.length-1],p=Wf(f,s[d]);n.push(p),r.push(d),a=l+1;continue}else{o+=i.slice(a,l+1),a=l+1;continue}}}else o+=h,a++}return o.length>0&&e.push({text:o,style:n[n.length-1]}),e}const Yf=[10,13],Hf=new Set(Yf),Nf=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],$f=new Set(Nf),Vf=[9,32],jf=new Set(Vf),qf=[45,8208,8211,8212,173],Kf=new Set(qf),Zf=/(\r\n|\r|\n)/,Qf=/(?:\r\n|\r|\n)/;function Ws(i){return typeof i!="string"?!1:Hf.has(i.charCodeAt(0))}function wt(i,t){return typeof i!="string"?!1:$f.has(i.charCodeAt(0))}function po(i){return typeof i!="string"?!1:jf.has(i.charCodeAt(0))}function Qa(i){return typeof i!="string"?!1:Kf.has(i.charCodeAt(0))}function Pn(i){return i==="normal"||i==="pre-line"}function Mn(i){return i==="normal"}function zt(i){if(typeof i!="string")return"";let t=i.length-1;for(;t>=0&&wt(i[t]);)t--;return t<i.length-1?i.slice(0,t+1):i}function Ja(i){const t=[],e=[];if(typeof i!="string")return t;for(let s=0;s<i.length;s++){const n=i[s],r=i[s+1];if(wt(n)||Ws(n)){e.length>0&&(t.push(e.join("")),e.length=0),n==="\r"&&r===`
|
|
504
|
-
`?(t.push(`\r
|
|
505
|
-
`),s++):t.push(n);continue}e.push(n),Qa(n)&&r&&!wt(r)&&!Ws(r)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function th(i,t,e,s){const n=e(i),r=[];for(let o=0;o<n.length;o++){let a=n[o],h=a,l=1;for(;n[o+l];){const c=n[o+l];if(!s(h,c,i,o,t))a+=c,h=c,l++;else break}o+=l-1,r.push(a)}return r}const Jf=/\r\n|\r|\n/g;function tp(i,t,e,s,n,r,o,a,h){const l=Xf(i,t);if(Mn(t.whiteSpace))for(let L=0;L<l.length;L++){const H=l[L];l[L]={text:H.text.replace(Jf," "),style:H.style}}const u=[];let d=[];for(const L of l){const H=L.text.split(Zf);for(let M=0;M<H.length;M++){const E=H[M];E===`\r
|
|
506
|
-
`||E==="\r"||E===`
|
|
507
|
-
`?(u.push(d),d=[]):E.length>0&&d.push({text:E,style:L.style})}}(d.length>0||u.length===0)&&u.push(d);const f=e?ep(u,t,s,r,a,h):u,p=[],g=[],m=[],_=[],x=[];let b=0;const y=t._fontString,v=o(y);v.fontSize===0&&(v.fontSize=t.fontSize,v.ascent=t.fontSize);let w="",S=!!t.dropShadow,C=t._stroke?.width||0;for(const L of f){let H=0,M=v.ascent,E=v.descent,X="";for(const V of L){const nt=V.style._fontString,gt=o(nt);nt!==w&&(s.font=nt,w=nt);const tt=n(V.text,V.style.letterSpacing,s);H+=tt,M=Math.max(M,gt.ascent),E=Math.max(E,gt.descent),X+=V.text;const ft=V.style._stroke?.width||0;ft>C&&(C=ft),!S&&V.style.dropShadow&&(S=!0)}L.length===0&&(M=v.ascent,E=v.descent),p.push(H),g.push(M),m.push(E),x.push(X);const I=t.lineHeight||M+E;_.push(I+t.leading),b=Math.max(b,H)}const P=C,T=b+P+(t.dropShadow?t.dropShadow.distance:0);let A=0;for(let L=0;L<_.length;L++)A+=_[L];A=Math.max(A,_[0]+P);const F=A+(t.dropShadow?t.dropShadow.distance:0),O=t.lineHeight||v.fontSize;return{width:T,height:F,lines:x,lineWidths:p,lineHeight:O+t.leading,maxLineWidth:b,fontProperties:v,runsByLine:f,lineAscents:g,lineDescents:m,lineHeights:_,hasDropShadow:S}}function ep(i,t,e,s,n,r){const{letterSpacing:o,whiteSpace:a,wordWrapWidth:h,breakWords:l}=t,c=Pn(a),u=h+o,d={};let f="";const p=(m,_)=>{const x=`${m}|${_.styleKey}`;let b=d[x];if(b===void 0){const y=_._fontString;y!==f&&(e.font=y,f=y),b=s(m,_.letterSpacing,e)+_.letterSpacing,d[x]=b}return b},g=[];for(const m of i){const _=sp(m),x=g.length,b=A=>{let F=0,O=A;do{const{token:L,style:H}=_[O];F+=p(L,H),O++}while(O<_.length&&_[O].continuesFromPrevious);return F},y=A=>{const F=[];let O=A;do F.push({token:_[O].token,style:_[O].style}),O++;while(O<_.length&&_[O].continuesFromPrevious);return F};let v=[],w=0,S=!c,C=null;const P=()=>{C&&C.text.length>0&&v.push(C),C=null},T=()=>{if(P(),v.length>0){const A=v[v.length-1];A.text=zt(A.text),A.text.length===0&&v.pop()}g.push(v),v=[],w=0,S=!1};for(let A=0;A<_.length;A++){const{token:F,style:O,continuesFromPrevious:L}=_[A],H=p(F,O);if(c){const X=wt(F),I=C?.text[C.text.length-1]??v[v.length-1]?.text.slice(-1)??"",V=I?wt(I):!1;if(X&&V)continue}const M=!L,E=M?b(A):H;if(E>u&&M)if(w>0&&T(),l){const X=y(A);for(let I=0;I<X.length;I++){const V=X[I].token,nt=X[I].style,gt=th(V,l,r,n);for(const tt of gt){const ft=p(tt,nt);ft+w>u&&T(),!C||C.style!==nt?(P(),C={text:tt,style:nt}):C.text+=tt,w+=ft}}A+=X.length-1}else{const X=y(A);P(),g.push(X.map(I=>({text:I.token,style:I.style}))),S=!1,A+=X.length-1}else if(E+w>u&&M){if(wt(F)){S=!1;continue}T(),C={text:F,style:O},w=H}else if(L&&!l)!C||C.style!==O?(P(),C={text:F,style:O}):C.text+=F,w+=H;else{const X=wt(F);if(w===0&&X&&!S)continue;!C||C.style!==O?(P(),C={text:F,style:O}):C.text+=F,w+=H}}if(P(),v.length>0){const A=v[v.length-1];A.text=zt(A.text),A.text.length===0&&v.pop()}(v.length>0||g.length===x)&&g.push(v)}return g}function sp(i){const t=[];let e=!1;for(const s of i){const n=Ja(s.text);let r=!0;for(const o of n){const a=wt(o)||Ws(o),h=r&&e&&!a;t.push({token:o,style:s.style,continuesFromPrevious:h}),e=!a,r=!1}}return t}const ip={willReadFrequently:!0};function go(i,t,e,s,n){let r=e[i];return typeof r!="number"&&(r=n(i,t,s)+t,e[i]=r),r}function np(i,t,e,s,n,r,o){const a=e.getContext("2d",ip);a.font=t._fontString;let h=0,l="";const c=[],u=Object.create(null),{letterSpacing:d,whiteSpace:f}=t,p=Pn(f),g=Mn(f);let m=!p;const _=t.wordWrapWidth+d,x=Ja(i);for(let y=0;y<x.length;y++){let v=x[y];if(Ws(v)){if(!g){c.push(zt(l)),m=!p,l="",h=0;continue}v=" "}if(p){const S=wt(v),C=wt(l[l.length-1]);if(S&&C)continue}const w=go(v,d,u,a,s);if(w>_)if(l!==""&&(c.push(zt(l)),l="",h=0),n(v,t.breakWords)){const S=th(v,t.breakWords,o,r);for(const C of S){const P=go(C,d,u,a,s);P+h>_&&(c.push(zt(l)),m=!1,l="",h=0),l+=C,h+=P}}else l.length>0&&(c.push(zt(l)),l="",h=0),c.push(zt(v)),m=!1,l="",h=0;else w+h>_&&(m=!1,c.push(zt(l)),l="",h=0),(l.length>0||!wt(v)||m)&&(l+=v,h+=w)}const b=zt(l);return b.length>0&&c.push(b),c.join(`
|
|
508
|
-
`)}const mo={willReadFrequently:!0},Nt=class R{static get experimentalLetterSpacingSupported(){let t=R._experimentalLetterSpacingSupported;if(t===void 0){const e=N.get().getCanvasRenderingContext2D().prototype;t=R._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,r,o,a,h,l,c){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=r,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,s=R._canvas,n=e.wordWrap){const r=`${t}-${e.styleKey}-wordWrap-${n}`;if(R._measurementCache.has(r))return R._measurementCache.get(r);if(Ka(e)&&Za(t)){const y=tp(t,e,n,R._context,R._measureText,R._measureTextAdvance,R.measureFont,R.canBreakChars,R.wordWrapSplit),v=new R(t,e,y.width,y.height,y.lines,y.lineWidths,y.lineHeight,y.maxLineWidth,y.fontProperties,{runsByLine:y.runsByLine,lineAscents:y.lineAscents,lineDescents:y.lineDescents,lineHeights:y.lineHeights,hasDropShadow:y.hasDropShadow});return R._measurementCache.set(r,v),v}const a=e._fontString,h=R.measureFont(a);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const l=R._context;l.font=a;const u=(n?R._wordWrap(t,e,s):t).split(Qf),d=new Array(u.length);let f=0;for(let y=0;y<u.length;y++){const v=R._measureText(u[y],e.letterSpacing,l);d[y]=v,f=Math.max(f,v)}const p=e._stroke?.width??0,g=e.lineHeight||h.fontSize,m=R._adjustWidthForStyle(f,e),_=Math.max(g,h.fontSize+p)+(u.length-1)*(g+e.leading),x=R._adjustHeightForStyle(_,e),b=new R(t,e,m,x,u,d,g+e.leading,f,h);return R._measurementCache.set(r,b),b}static _adjustWidthForStyle(t,e){const s=e._stroke?.width||0;let n=t+s;return e.dropShadow&&(n+=e.dropShadow.distance),n}static _adjustHeightForStyle(t,e){let s=t;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _measureText(t,e,s){const{metricWidth:n,metrics:r,letterSpacingVal:o}=R._measureTextCore(t,e,s),a=-(r.actualBoundingBoxLeft??0);let l=(r.actualBoundingBoxRight??0)-a;return r.width>0&&(l+=o),Math.max(n,l)}static _measureTextAdvance(t,e,s){return R._measureTextCore(t,e,s).metricWidth}static _measureTextCore(t,e,s){let n=!1;R.experimentalLetterSpacingSupported&&(R.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,n=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const r=s.measureText(t);let o=r.width,a=0;return o>0&&(n?a=-e:a=(R.graphemeSegmenter(t).length-1)*e,o+=a),{metricWidth:o,metrics:r,letterSpacingVal:a}}static _wordWrap(t,e,s=R._canvas){return np(t,e,s,R._measureTextAdvance,R.canBreakWords,R.canBreakChars,R.wordWrapSplit)}static isBreakingSpace(t,e){return wt(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,n,r){return!0}static wordWrapSplit(t){return R.graphemeSegmenter(t)}static measureFont(t){if(R._fonts[t])return R._fonts[t];const e=R._context;e.font=t;const s=e.measureText(R.METRICS_STRING+R.BASELINE_SYMBOL),n=s.actualBoundingBoxAscent??0,r=s.actualBoundingBoxDescent??0,o={ascent:n,descent:r,fontSize:n+r};return R._fonts[t]=o,o}static clearMetrics(t=""){t?delete R._fonts[t]:R._fonts={}}static get _canvas(){if(!R.__canvas){let t;try{const e=new OffscreenCanvas(0,0);if(e.getContext("2d",mo)?.measureText)return R.__canvas=e,e;t=N.get().createCanvas()}catch{t=N.get().createCanvas()}t.width=t.height=10,R.__canvas=t}return R.__canvas}static get _context(){return R.__context||(R.__context=R._canvas.getContext("2d",mo)),R.__context}};Nt.METRICS_STRING="|ÉqÅ";Nt.BASELINE_SYMBOL="M";Nt.BASELINE_MULTIPLIER=1.4;Nt.HEIGHT_MULTIPLIER=2;Nt.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const i=new Intl.Segmenter;return t=>{const e=i.segment(t),s=[];let n=0;for(const r of e)s[n++]=r.segment;return s}}return i=>[...i]})();Nt.experimentalLetterSpacing=!1;Nt._fonts={};Nt._measurementCache=qa(1e3);let At=Nt;const rp=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function cs(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!rp.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const _o=1e5;function Se(i,t,e,s=0,n=0,r=0){if(i.texture===G.WHITE&&!i.fill)return st.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Vs){const o=i.fill,a=t.createPattern(o.texture.source.resource,"repeat");return K.applyPatternTransform(a,o.transform,!1),a}else if(i.fill instanceof Ht){const o=i.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&e&&(l=e.width+s,c=e.height+s);let u,d=!1;if(a){const{start:f,end:p}=o;u=t.createLinearGradient(f.x*l+n,f.y*c+r,p.x*l+n,p.y*c+r),d=Math.abs(p.x-f.x)<Math.abs((p.y-f.y)*.1)}else{const{center:f,innerRadius:p,outerCenter:g,outerRadius:m}=o;u=t.createRadialGradient(f.x*l+n,f.y*c+r,p*l,g.x*l+n,g.y*c+r,m*l)}if(d&&h&&e){const f=e.lineHeight/c;for(let p=0;p<e.lines.length;p++){const g=(p*e.lineHeight+s/2)/c;o.colorStops.forEach(m=>{let _=g+m.offset*f;_=Math.max(0,Math.min(1,_)),u.addColorStop(Math.floor(_*_o)/_o,st.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(f=>{u.addColorStop(f.offset,st.shared.setValue(f.color).toHex())});return u}}else{const o=t.createPattern(i.texture.source.resource,"repeat"),a=i.matrix.copyTo(z.shared);return a.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),o.setTransform(a),o}return Y("FillStyle not recognised",i),"red"}const yo=new W;function ve(i){let t=0;for(let e=0;e<i.length;e++)i.charCodeAt(e)===32&&t++;return t}class op{getCanvasAndContext(t){const{text:e,style:s,resolution:n=1}=t,r=s._getFinalPadding(),o=At.measureText(e||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+r*2)*n),h=Math.ceil(Math.ceil(Math.max(1,o.height)+r*2)*n),l=Ie.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(s,r,n,l,o);const c=s.trim?zf({canvas:l.canvas,width:a,height:h,resolution:1,output:yo}):yo.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){Ie.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,n,r){if(r.runsByLine&&r.runsByLine.length>0){this._renderTaggedTextToCanvas(r,t,e,s,n);return}const{canvas:o,context:a}=n,h=cs(t),l=r.lines,c=r.lineHeight,u=r.lineWidths,d=r.maxLineWidth,f=r.fontProperties,p=o.height;if(a.resetTransform(),a.scale(s,s),a.textBaseline=t.textBaseline,t._stroke?.width){const v=t._stroke;a.lineWidth=v.width,a.miterLimit=v.miterLimit,a.lineJoin=v.join,a.lineCap=v.cap}a.font=h;let g,m;const _=t.dropShadow?2:1,b=(t._stroke?.width??0)/2;let y=(c-f.fontSize)/2;c-f.fontSize<0&&(y=0);for(let v=0;v<_;++v){const w=t.dropShadow&&v===0,S=w?Math.ceil(Math.max(1,p)+e*2):0,C=S*s;if(w)this._setupDropShadow(a,t,s,C);else{const P=t._gradientBounds,T=t._gradientOffset;if(P){const A={width:P.width,height:P.height,lineHeight:P.height,lines:r.lines};this._setFillAndStrokeStyles(a,t,A,e,b,T?.x??0,T?.y??0)}else T?this._setFillAndStrokeStyles(a,t,r,e,b,T.x,T.y):this._setFillAndStrokeStyles(a,t,r,e,b);a.shadowColor="rgba(0,0,0,0)"}for(let P=0;P<l.length;P++){g=b,m=b+P*c+f.ascent+y,g+=this._getAlignmentOffset(u[P],d,t.align);let T=0;if(t.align==="justify"&&t.wordWrap&&P<l.length-1){const A=ve(l[P]);A>0&&(T=(d-u[P])/A)}t._stroke?.width&&this._drawLetterSpacing(l[P],t,n,g+e,m+e-S,!0,T),t._fill!==void 0&&this._drawLetterSpacing(l[P],t,n,g+e,m+e-S,!1,T)}}}_renderTaggedTextToCanvas(t,e,s,n,r){const{canvas:o,context:a}=r,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:u,lineHeights:d,hasDropShadow:f}=t,p=o.height;a.resetTransform(),a.scale(n,n),a.textBaseline=e.textBaseline;const g=f?2:1;let m=e._stroke?.width??0;for(const b of h)for(const y of b){const v=y.style._stroke?.width??0;v>m&&(m=v)}const _=m/2,x=[];for(let b=0;b<h.length;b++){const y=h[b],v=[];for(const w of y){const S=cs(w.style);a.font=S,v.push({width:At._measureText(w.text,w.style.letterSpacing,a),font:S})}x.push(v)}for(let b=0;b<g;++b){const y=f&&b===0,v=y?Math.ceil(Math.max(1,p)+s*2):0,w=v*n;y||(a.shadowColor="rgba(0,0,0,0)");let S=_;for(let C=0;C<h.length;C++){const P=h[C],T=l[C],A=u[C],F=d[C],O=x[C];let L=_;L+=this._getAlignmentOffset(T,c,e.align);let H=0;if(e.align==="justify"&&e.wordWrap&&C<h.length-1){let X=0;for(const I of P)X+=ve(I.text);X>0&&(H=(c-T)/X)}const M=S+A;let E=L+s;for(let X=0;X<P.length;X++){const I=P[X],{width:V,font:nt}=O[X];if(a.font=nt,a.textBaseline=I.style.textBaseline,I.style._stroke?.width){const tt=I.style._stroke;if(a.lineWidth=tt.width,a.miterLimit=tt.miterLimit,a.lineJoin=tt.join,a.lineCap=tt.cap,y)if(I.style.dropShadow)this._setupDropShadow(a,I.style,n,w);else{const ft=ve(I.text);E+=V+ft*H;continue}else{const ft=At.measureFont(nt),Ot=I.style.lineHeight||ft.fontSize,Kt={width:V,height:Ot,lineHeight:Ot,lines:[I.text]};a.strokeStyle=Se(tt,a,Kt,s*2,E-s,S)}this._drawLetterSpacing(I.text,I.style,r,E,M+s-v,!0,H)}const gt=ve(I.text);E+=V+gt*H}E=L+s;for(let X=0;X<P.length;X++){const I=P[X],{width:V,font:nt}=O[X];if(a.font=nt,a.textBaseline=I.style.textBaseline,I.style._fill!==void 0){if(y)if(I.style.dropShadow)this._setupDropShadow(a,I.style,n,w);else{const tt=ve(I.text);E+=V+tt*H;continue}else{const tt=At.measureFont(nt),ft=I.style.lineHeight||tt.fontSize,Ot={width:V,height:ft,lineHeight:ft,lines:[I.text]};a.fillStyle=Se(I.style._fill,a,Ot,s*2,E-s,S)}this._drawLetterSpacing(I.text,I.style,r,E,M+s-v,!1,H)}const gt=ve(I.text);E+=V+gt*H}S+=F}}}_setFillAndStrokeStyles(t,e,s,n,r,o=0,a=0){if(t.fillStyle=e._fill?Se(e._fill,t,s,n*2,o,a):null,e._stroke?.width){const h=r+n*2;t.strokeStyle=Se(e._stroke,t,s,h,o,a)}}_setupDropShadow(t,e,s,n){t.fillStyle="black",t.strokeStyle="black";const r=e.dropShadow,o=r.color,a=r.alpha;t.shadowColor=st.shared.setValue(o).setAlpha(a).toRgbaString();const h=r.blur*s,l=r.distance*s;t.shadowBlur=h,t.shadowOffsetX=Math.cos(r.angle)*l,t.shadowOffsetY=Math.sin(r.angle)*l+n}_getAlignmentOffset(t,e,s){return s==="right"?e-t:s==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,s,n,r,o=!1,a=0){const{context:h}=s,l=e.letterSpacing;let c=!1;if(At.experimentalLetterSpacingSupported&&(At.experimentalLetterSpacing?(h.letterSpacing=`${l}px`,h.textLetterSpacing=`${l}px`,c=!0):(h.letterSpacing="0px",h.textLetterSpacing="0px")),(l===0||c)&&a===0){o?h.strokeText(t,n,r):h.fillText(t,n,r);return}if(a!==0&&(l===0||c)){const g=t.split(" ");let m=n;const _=h.measureText(" ").width;for(let x=0;x<g.length;x++)o?h.strokeText(g[x],m,r):h.fillText(g[x],m,r),m+=h.measureText(g[x]).width+_+a;return}let u=n;const d=At.graphemeSegmenter(t);let f=h.measureText(t).width,p=0;for(let g=0;g<d.length;++g){const m=d[g];o?h.strokeText(m,u,r):h.fillText(m,u,r);let _="";for(let x=g+1;x<d.length;++x)_+=d[x];p=h.measureText(_).width,u+=f-p+l,m===" "&&(u+=a),f=p}}}const Te=new op,kn=class le extends Rt{constructor(t={}){super(),this.uid=et("textStyle"),this._tick=0,this._cachedFontString=null,ap(t),t instanceof le&&(t=t._toObject());const n={...le.defaultTextStyle,...t};for(const r in n){const o=r;this[o]=n[r]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...le.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...le.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...Ct.defaultFillStyle,...t},()=>{this._fill=ce({...this._originalFill},Ct.defaultFillStyle)})),this._fill=ce(t===0?"black":t,Ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...Ct.defaultStrokeStyle,...t},()=>{this._stroke=zs({...this._originalStroke},Ct.defaultStrokeStyle)})),this._stroke=zs(t,Ct.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=le.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const s=e;this[s]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=cs(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new le(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){if(this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){const s=typeof t=="boolean"?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(s),this._originalFill?.texture&&this._originalFill.texture.destroy(s),this._stroke?.texture&&this._stroke.texture.destroy(s),this._originalStroke?.texture&&this._originalStroke.texture.destroy(s)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,n,r)=>(s[n]===r||(s[n]=r,e?.(n,r),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(st.isColorLike(t)||t instanceof Ht||t instanceof Vs)}};kn.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};kn.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let pe=kn;function ap(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=pe.defaultDropShadow;i.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){D(j,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(st.isColorLike(e))s.color=e;else if(e instanceof Ht||e instanceof Vs)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(D(j,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&Y("The number of fill colors must match the number of fill gradient stops.");const e=new Ht({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=t.fillGradientStops.slice(),n=t.fill.map(r=>st.shared.setValue(r).toNumber());s.forEach((r,o)=>{e.addColorStop(r,n[o])}),i.fill={fill:e}}}function hp(i,t){const{texture:e,bounds:s}=i,n=t._style._getFinalPadding();Io(s,t._anchor,e);const r=t._anchor._x*n*2,o=t._anchor._y*n*2;s.minX-=n-r,s.minY-=n-o,s.maxX-=n-r,s.maxY-=n-o}class lp{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class cp extends lp{}class eh{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new fs({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e?._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s?!0:t._didTextUpdate}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t._resolution!==n)&&this._updateGpuText(t),t._didTextUpdate=!1,hp(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new cp;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:s}=this._renderer;s.getReferenceCount(e.currentKey)>0?s.decreaseReferenceCount(e.currentKey):e.texture&&s.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}eh.extension={type:[k.WebGLPipes,k.WebGPUPipes,k.CanvasPipes],name:"text"};class sh{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,n){typeof t=="string"&&(D("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof pe||(t.style=new pe(t.style)),t.textureStyle instanceof jt||(t.textureStyle=new jt(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:r,style:o,textureStyle:a,autoGenerateMipmaps:h}=t,l=t.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=Te.getCanvasAndContext({text:r,style:o,resolution:l}),d=Ua(u.canvas,c.width,c.height,l,h);if(a&&(d.source.style=a),o.trim&&(c.pad(o.padding),d.frame.copyFrom(c),d.frame.scale(1/l),d.updateUvs()),o.filters){const f=this._applyFilters(d,o.filters);return this.returnTexture(d),Te.returnCanvasAndContext(u),f}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Te.returnCanvasAndContext(u),d}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&s?.getContext){const n=s.getContext("2d");n&&Te.returnCanvasAndContext({canvas:s,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",lt.returnTexture(t,!0)}renderTextToCanvas(){D("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const s=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:s,usageCount:1},s}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){return this._activeTextures[t]?.usageCount??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const s=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(s,!1),n}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class ih extends sh{constructor(t){super(t,!0)}}ih.extension={type:[k.CanvasSystem],name:"canvasText"};class nh extends sh{constructor(t){super(t,!1)}}nh.extension={type:[k.WebGLSystem,k.WebGPUSystem],name:"canvasText"};$.add(ih);$.add(nh);$.add(eh);class up extends Of{constructor(...t){const e=Df(t,"Text");super(e,pe),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof jt?e.textureStyle:new jt(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??Mt.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,n=0;if(this._style.trim){const{frame:r,canvasAndContext:o}=Te.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Te.returnCanvasAndContext(o),s=r.width,n=r.height}else{const r=At.measureText(this._text,this._style);s=r.width,n=r.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}}class rh extends Rt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return D(j,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return D(j,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return D(j,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return D(j,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return D(j,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const e in this.chars)this.chars[e].texture?.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}}const oh=class ah extends rh{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const e={...ah.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const s=e.style.clone();e.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=G.WHITE,s._fill.fill=null),this.applyFillAsTint=e.overrideFill;const n=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const r=cs(s);e.overrideSize?(s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/n),s.dropShadow&&(s.dropShadow.blur*=this.baseRenderedFontSize/n,s.dropShadow.distance*=this.baseRenderedFontSize/n)):s.fontSize=this.baseRenderedFontSize=n,this._style=s,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,e.textureStyle&&(this._textureStyle=e.textureStyle instanceof jt?e.textureStyle:new jt(e.textureStyle)),this.fontMetrics=At.measureFont(r),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(t){const e=At.graphemeSegmenter(t).filter(_=>!this._currentChars.includes(_)).filter((_,x,b)=>b.indexOf(_)===x);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:n,context:r}=s.canvasAndContext,o=s.texture.source;const a=this._style;let h=this._currentX,l=this._currentY,c=this._currentMaxCharHeight;const u=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=(a.dropShadow?.distance??0)+(a._stroke?.width??0),f=this._padding+d;let p=!1;const g=n.width/this.resolution,m=n.height/this.resolution;for(let _=0;_<e.length;_++){const x=e[_],b=At.measureText(x,a,n,!1);b.lineHeight=b.height;const y=b.width*u,v=Math.ceil((a.fontStyle==="italic"?2:1)*y),w=b.height*u,S=v+f*2,C=w+f*2;if(p=!1,x!==`
|
|
509
|
-
`&&x!=="\r"&&x!==" "&&x!==" "&&(p=!0,c=Math.ceil(Math.max(C,c))),h+S>g&&(l+=c,c=C,h=0,l+c>m)){o.update();const T=this._nextPage();n=T.canvasAndContext.canvas,r=T.canvasAndContext.context,o=T.texture.source,h=0,l=0,c=0}const P=r.measureText(x).width/u;if(this.chars[x]={id:x.codePointAt(0),xOffset:-(f/u),yOffset:-(f/u),xAdvance:P,kerning:{}},p){this._drawGlyph(r,b,h+f,l+f,u,a);const T=o.width*u,A=o.height*u,F=new W(h/T*o.width,l/A*o.height,S/T*o.width,C/A*o.height);this.chars[x].texture=new G({source:o,frame:F}),h+=Math.ceil(S)}}o.update(),this._currentX=h,this._currentY=l,this._currentMaxCharHeight=c,this._skipKerning||this._applyKerning(e,r,u)}get pageTextures(){return D(j,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e,s){const n=this._measureCache;for(let r=0;r<t.length;r++){const o=t[r];for(let a=0;a<this._currentChars.length;a++){const h=this._currentChars[a];let l=n[o];l||(l=n[o]=e.measureText(o).width);let c=n[h];c||(c=n[h]=e.measureText(h).width);let u=e.measureText(o+h).width,d=u-(l+c);d&&this.chars[o]&&(this.chars[o].kerning[h]=d/s),u=e.measureText(o+h).width,d=u-(l+c),d&&this.chars[h]&&(this.chars[h].kerning[o]=d/s)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Ie.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const s=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new G({source:new ue({resource:e.canvas,resolution:s,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(n.source.style=this._textureStyle);const r={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=r,r}_setupContext(t,e,s){e.fontSize=this.baseRenderedFontSize,t.scale(s,s),t.font=cs(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,r=n?.width??0;if(n&&(t.lineWidth=r,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=Se(n,t)),e._fill&&(t.fillStyle=Se(e._fill,t)),e.dropShadow){const o=e.dropShadow,a=st.shared.setValue(o.color).toArray(),h=o.blur*s,l=o.distance*s;t.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(o.angle)*l,t.shadowOffsetY=Math.sin(o.angle)*l}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,s,n,r,o){const a=e.text,h=e.fontProperties,c=(o._stroke?.width??0)*r,u=s+c/2,d=n-c/2,f=h.descent*r,p=e.lineHeight*r;let g=!1;o.stroke&&c&&(g=!0,t.strokeText(a,u,d+p-f));const{shadowBlur:m,shadowOffsetX:_,shadowOffsetY:x}=t;o._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(a,u,d+p-f)),g&&(t.shadowBlur=m,t.shadowOffsetX=_,t.shadowOffsetY=x)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:s}=this.pages[t];Ie.returnCanvasAndContext(e),s.destroy(!0)}this.pages=null}};oh.defaultOptions={textureSize:512,style:new pe,mipmap:!0};let xo=oh;function dp(i,t,e,s){const n={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};n.offsetY=e.baseLineOffset;let r=n.lines[0],o=null,a=!0;const h={width:0,start:0,index:0,positions:[],chars:[]},l=e.baseMeasurementFontSize/t.fontSize,c=t.letterSpacing*l,u=t.wordWrapWidth*l,d=t.lineHeight?t.lineHeight*l:e.lineHeight,f=t.wordWrap&&t.breakWords,p=Pn(t.whiteSpace),g=Mn(t.whiteSpace);if(p||g){const b=[];let y=p;for(let v=0;v<i.length;v++){let w=i[v];if(w==="\r"||w===`
|
|
510
|
-
`)if(g)w==="\r"&&i[v+1]===`
|
|
511
|
-
`&&v++,w=" ";else{p&&(y=!0),b.push(w);continue}if(wt(w))if(p&&po(w)){if(y)continue;y=!0,b.push(" ")}else y=!1,b.push(w);else y=!1,b.push(w)}i=b}const m=b=>{const y=r.width;for(let v=0;v<h.index;v++){const w=b.positions[v];r.chars.push(b.chars[v]),r.charPositions.push(w+y)}r.width+=b.width,(h.index>0||!p)&&(a=!1),h.width=0,h.index=0,h.chars.length=0},_=()=>{let b=r.chars.length-1;if(s){let y=r.chars[b];for(;po(y);)r.width-=e.chars[y].xAdvance,r.spacesIndex.pop(),y=r.chars[--b]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,n.lines.push(r),n.height+=d},x=b=>b-c>u;for(let b=0;b<i.length+1;b++){let y;const v=b===i.length;v||(y=i[b]);const w=e.chars[y];if(/(?:\s)/.test(y)||y==="\r"||y===`
|
|
512
|
-
`||v){if(!a&&t.wordWrap&&x(r.width+h.width)?(_(),m(h),!v&&w&&r.charPositions.push(0)):(h.start=r.width,m(h),!v&&w&&r.charPositions.push(0)),y==="\r"||y===`
|
|
513
|
-
`)_();else if(!v&&w){const T=w.xAdvance+(w.kerning?.[o]||0)+c;r.width+=T,r.spaceWidth=T,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else if(w){const P=w.kerning?.[o]||0,T=w.xAdvance+P+c;f&&x(h.width+T)&&(a||_(),m(h),_()),h.positions[h.index++]=h.width+P,h.chars.push(y),h.width+=T,Qa(y)&&(!a&&t.wordWrap&&x(r.width+h.width)&&_(),m(h))}o=y}return _(),t.align==="center"?fp(n):t.align==="right"?pp(n):t.align==="justify"&&gp(n),n}function fp(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width/2-e.width/2;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=s}}function pp(i){for(let t=0;t<i.lines.length;t++){const e=i.lines[t],s=i.width-e.width;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=s}}function gp(i){const t=i.width;for(let e=0;e<i.lines.length-2;e++){const s=i.lines[e];let n=0,r=s.spacesIndex[n++],o=0;const a=s.spacesIndex.length,l=(t-s.width)/a;for(let c=0;c<s.charPositions.length;c++)c===r&&(r=s.spacesIndex[n++],o+=l),s.charPositions[c]+=o}}function mp(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e<s;e++){const n=i[e];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(n[0].length===0||n[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const r=n[0].charCodeAt(0),o=n[1].charCodeAt(0);if(o<r)throw new Error("[BitmapFont]: Invalid character range.");for(let a=r,h=o;a<=h;a++)t.push(String.fromCharCode(a))}else t.push(...Array.from(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}let Is=0;class _p{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=qa(1e3)}getFont(t,e){let s=`${e.fontFamily}-bitmap`,n=!0;if(q.has(s)){const o=q.get(s);return o.ensureCharacters?.(t),o}if(e._fill.fill&&!e._stroke?(s+=e._fill.fill.styleKey,n=!1):(e._stroke||e.dropShadow)&&(s=`${e.styleKey}-bitmap`,n=!1),s+=`-${e.fontStyle}`,s+=`-${e.fontVariant}`,s+=`-${e.fontWeight}`,!q.has(s)){const o=Object.create(e);o._lineHeight=0;const a=new xo({style:o,overrideFill:n,overrideSize:!0,...this.defaultOptions});Is++,Is>50&&Y("BitmapText",`You have dynamically created ${Is} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{Is--,q.remove(s)}),q.set(s,a)}const r=q.get(s);return r.ensureCharacters?.(t),r}getLayout(t,e,s=!0){const n=this.getFont(t,e),r=`${t}-${e.styleKey}-${s}`;if(this.measureCache.has(r))return this.measureCache.get(r);const o=At.graphemeSegmenter(t),a=dp(o,e,n,s);return this.measureCache.set(r,a),a}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},D(j,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e?.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const n=e.style,r=n instanceof pe?n:new pe(n),o=e.dynamicFill??this._canUseTintForStyle(r),a=new xo({style:r,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),h=mp(e.chars);return a.ensureCharacters(h.join("")),q.set(`${s}-bitmap`,a),a.once("destroy",()=>q.remove(`${s}-bitmap`)),a}uninstall(t){const e=`${t}-bitmap`,s=q.get(e);s&&s.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}}const bo=new _p;class yp extends rh{constructor(t,e){super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(r=>{const o=n.pages[parseInt(r,10)],a=s[o.id];this.pages.push({texture:a})}),Object.keys(n.chars).forEach(r=>{const o=n.chars[r],{frame:a,source:h,rotate:l}=s[o.page],c=U.transformRectCoords(o,a,l,new W),u=new G({frame:c,orig:new W(0,0,o.width,o.height),source:h,rotate:l});this.chars[r]={id:r.codePointAt(0),xOffset:o.xOffset,yOffset:o.yOffset,xAdvance:o.xAdvance,kerning:o.kerning??{},texture:u}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){bo.install(t)}static uninstall(t){bo.uninstall(t)}}const xp=Object.freeze(Object.defineProperty({__proto__:null,BitmapFont:yp},Symbol.toStringTag,{value:"Module"}));$.add(vh,wh);const bt=(i,t,e)=>i+(t-i)*e,nn=(i,t,e)=>Math.min(e,Math.max(t,i)),bp=i=>i*(Math.PI/180),vp=i=>{for(;i>Math.PI;)i-=Math.PI*2;for(;i<-Math.PI;)i+=Math.PI*2;return i},vt=(i,t)=>Math.random()*(t-i)+i;let wp=class extends it{constructor(t,e,s){super(),this._baseTexturePromise=null,this._assetUrl=null,this._renderer=s.renderer,this.scale=t.scale,this.sprite=null,this.mapSprite=null,t.type==="static"?(this._assetUrl=`/img/${t.spriteSheet.img}`,this._baseTexturePromise=Vt.load(this._assetUrl),this._map=t.map,this._tiles=t.tiles,this._spriteSheetData=t.spriteSheet,this._step=t.step,this.zIndex=t.layer||1,this.createStatic()):t.type==="dynamic"&&(this._assetUrl=`/img/${t.img}`,this._baseTexturePromise=Vt.load(this._assetUrl),this.zIndex=t.layer||2,this._rotation=bp(t.angle),this._width=t.width,this._height=t.height,this._x=t.position[0],this._y=t.position[1],this.createDynamic())}async createDynamic(){try{const t=await this._baseTexturePromise;this.sprite=new ot(t),this.sprite.x=this._x,this.sprite.y=this._y,this.sprite.width=this._width,this.sprite.height=this._height,this.sprite.rotation=this._rotation,this.addChild(this.sprite)}catch(t){console.error(`Failed to create dynamic map with asset ${this._assetUrl}:`,t)}}async createStatic(){try{const t={};this._spriteSheetData.frames.forEach((l,c)=>{const[u,d,f,p]=l;t[`frame${c}`]={frame:{x:u,y:d,w:f,h:p}}});const e={frames:t,meta:{scale:"1"}},s=await this._baseTexturePromise,n=new zi(s,e);await n.parse();const r=this._map[0].length*this._step,o=this._map.length*this._step,a=new it;for(let l=0,c=this._map.length;l<c;l+=1)for(let u=0,d=this._map[l].length;u<d;u+=1){const f=this._map[l][u];if(this._tiles.includes(f)){const p=`frame${f}`,g=n.textures[p];if(g){const m=new ot(g);m.x=u*this._step,m.y=l*this._step,a.addChild(m)}else console.warn(`Texture not found. Tile: ${f}, sprite: ${p}`)}}const h=this._renderer.generateTexture({target:a,frame:new W(0,0,r,o)});a.destroy({children:!0}),this.mapSprite=new ot(h),this.addChild(this.mapSprite)}catch(t){console.error(`Failed to create static map with asset ${this._assetUrl}:`,t)}}update(t){this.sprite&&(this.sprite.x=t[0]/this.scale.x,this.sprite.y=t[1]/this.scale.y,this.sprite.rotation=t[2])}destroy(t){this.mapSprite&&(this.mapSprite.destroy({children:!0,texture:!0}),this.mapSprite=null),super.destroy({children:!0,texture:!1,baseTexture:!1,...t}),this._assetUrl&&Vt.cache.has(this._assetUrl)&&Vt.unload(this._assetUrl).catch(e=>console.warn(`Failed to unload asset ${this._assetUrl} (was in cache):`,e)),this.sprite=null,this._baseTexturePromise=null,this._assetUrl=null,this._map=null,this._tiles=null,this._spriteSheetData=null,this._renderer=null}};class Sp extends it{constructor(t){super(),this._map=t.map,this._physicsStatic=t.physicsStatic,this._step=t.step,this.zIndex=2,this.scale=t.scale,this.radarGraphics=new ut,this.addChild(this.radarGraphics),this.createRadarMap()}createRadarMap(){const t=this.radarGraphics;if(t.clear(),Array.isArray(this._map))for(let e=0;e<this._map.length;e+=1){const s=this._map[e];if(Array.isArray(s))for(let n=0;n<s.length;n+=1){const r=s[n];this._physicsStatic.includes(r)&&t.rect(n*this._step,e*this._step,this._step/2,this._step/2)}}t.fill(16777215)}update(){}destroy(t){super.destroy({children:!0,texture:!1,baseTexture:!1,...t}),this.radarGraphics=null,this._map=null,this._physicsStatic=null}}class Tp extends it{constructor(t,e){super(),this.zIndex=2,this._textures=e.tankRadarTexture,this.body=new ot,this.body.anchor.set(.5),this.addChild(this.body),this.x=t[0]||0,this.y=t[1]||0,this._condition=t[7],this._teamId=t[9],this.scale.set(5,5),this.create()}create(){this._condition===0?this.body.texture=this._textures.destroyed:this._teamId===1?this.body.texture=this._textures.liveTeamId1:this._teamId===2&&(this.body.texture=this._textures.liveTeamId2)}update(t){this.x=t[0],this.y=t[1];const e=t[7],s=t[9];let n=!1;e!==void 0&&e!==this._condition&&(this._condition=e,n=!0),s!==void 0&&s!==this._teamId&&(this._teamId=s,n=!0),n&&this.create()}destroy(t){super.destroy({children:!0,texture:!1,baseTexture:!1,...t}),this.body=null,this._textures=null}}const Ap=1,vo=1.1,Cp=1.18,Pp=.9,Mp=1;function kp(i){const t=nn(i,0,1),e=Math.max(0,i-1),s=bt(Ap,vo,t)+(Cp-vo)*e,n=bt(Pp,Mp,t);return{rate:s,volumeFactor:n}}class Ep extends it{constructor(t,e,s){super(),this.zIndex=3,this.body=new ot,this.gun=new ot,this.wreck=new ot,this.body.anchor.set(.5),this.wreck.anchor.set(.5),this.addChild(this.body,this.gun,this.wreck),this._textures=e.tankTexture,this.x=t[0]||0,this.y=t[1]||0,this.rotation=t[2]||0,this.gun.rotation=t[3]||0,this._engineLoad=t[6]||0,this._condition=t[7],this._size=t[8],this._teamId=t[9];const n=this._teamId===1?this._textures.liveTeamId1:this._textures.liveTeamId2,r=n?n.gunAnchor:null;r?this.gun.anchor.set(r.x,r.y):this.gun.anchor.set(.5);const a=this._size/10;this.body.scale.set(a),this.gun.scale.set(a),this.wreck.scale.set(a),this._soundManager=s.soundManager,this._soundId=null;const h=this._soundManager.getSoundConfig("tankEngine")||{};this._baseEngineVolume=h.volume||0,this.create()}_initSounds(){this._soundId||this._condition===0||(this._soundId=this._soundManager.registerSound("tankEngine",this._getSoundData()))}_getSoundData(){const{rate:t,volumeFactor:e}=kp(this._engineLoad);return{position:{x:this.x,y:this.y},rate:t,volume:this._baseEngineVolume*e}}create(){if(this._condition===0)this.body.visible=!1,this.gun.visible=!1,this.wreck.texture=this._textures.destroyed,this.wreck.visible=!0,this.gun.rotation=0,this.destroySounds();else{this.wreck.visible=!1;let t;this._teamId===1?t=this._textures.liveTeamId1:this._teamId===2&&(t=this._textures.liveTeamId2),this.body.texture=t.body,this.gun.texture=t.gun,this.body.visible=!0,this.gun.visible=!0,this._initSounds()}}update(t){this.x=t[0],this.y=t[1],this.rotation=t[2],this.gun.rotation=t[3],this._engineLoad=t[6],this._soundId&&this._condition>0&&this._soundManager.updateSoundData(this._soundId,this._getSoundData());const e=t[7],s=t[9];let n=!1;e!==void 0&&e!==this._condition&&(this._condition=e,n=!0),s!==void 0&&s!==this._teamId&&(this._teamId=s,n=!0),n&&this.create()}destroySounds(){this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null)}destroy(t){this.destroySounds(),super.destroy({children:!0,texture:!1,baseTexture:!1,...t})}}class Ip extends it{constructor(t,e,s){super(),this.zIndex=2,this.body=new ot(e.bombTexture),this.body.anchor.set(.5),this.x=t[0],this.y=t[1],this.rotation=t[2],this._size=t[3],this._totalDurationMs=t[4],this._soundManager=s.soundManager,this._soundId=null;const n=e.bombTexture.width,r=this._size/n;this.body.scale.set(r);const o=64,a=this._size/1.2/o;this.text=new up({style:{fontFamily:"Arial",fontSize:o,fill:16777215,align:"center"}}),this.text.anchor.set(.5),this.text.scale.set(a),this.text.x=0,this.text.y=0,this._accumulatedTimeMs=0,this._secondsLeft="",this.addChild(this.body,this.text),this._updateTimerDisplay(this._totalDurationMs),this._tickListener=h=>this._updateTimer(h.deltaMS),ct.shared.add(this._tickListener),this._soundId=this._soundManager.registerSound("bombHasBeenPlanted",{position:{x:this.x,y:this.y}})}_updateTimer(t){this._accumulatedTimeMs+=t;const e=Math.max(0,this._totalDurationMs-this._accumulatedTimeMs);this._updateTimerDisplay(e),e<=0&&(this._stopTimer(),this._updateTimerDisplay(0))}_updateTimerDisplay(t){const e=Math.round(t/1e3);this._secondsLeft!==e&&(this._secondsLeft=e,this.text.text=`${this._secondsLeft}`)}update(){}_stopTimer(){this._tickListener&&(ct.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer(),this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null),super.destroy({children:!0,texture:!1,baseTexture:!1,...t}),this.body=null,this.text=null}}class gs extends it{constructor(t){super(),this._tickListener=null,this._isStarted=!1,this.isComplete=!1,this.onComplete=t}run(){this.isComplete||this._isStarted||(this._isStarted=!0,this._tickListener=t=>this._update(t.deltaMS),ct.shared.add(this._tickListener),this._onEffectStart(),this.isComplete||this._update(0))}_onEffectStart(){}_update(){}_completeEffect(){this.isComplete||(this.isComplete=!0,this._tickListener&&(ct.shared.remove(this._tickListener),this._tickListener=null),typeof this.onComplete=="function"&&this.onComplete())}destroy(t){this.isComplete=!0,this._tickListener&&(ct.shared.remove(this._tickListener),this._tickListener=null),this.parent&&this.parent.removeChild(this),super.destroy({children:!0,texture:!1,baseTexture:!1,...t})}}const wo=50;class Fp extends gs{constructor(t,e,s,n,r){super(n);const o=r.explosionTexture;this.x=t,this.y=e,this._radius=s,this._durationMs=3e3,this._elapsedMs=0;const a=this._radius/wo;this._mainBody=new ot(o),this._mainBody.anchor.set(.5),this._mainBody.tint=11393254,this._mainBody.scale.set(a),this._core=new ot(o),this._core.anchor.set(.5),this._core.tint=13882323,this._core.scale.set(a),this.addChild(this._mainBody,this._core)}_update(t){if(!this.isComplete)if(this._elapsedMs+=t,this._elapsedMs<=this._durationMs){const e=this._elapsedMs/this._durationMs;this._draw(e)}else this._completeEffect()}_draw(t){const e=r=>r*r,s=this._radius/wo;this._mainBody.alpha=.6*(1-e(t));const n=Math.min(1,t*1.5);this._core.alpha=.7-n,this._core.scale.set(s*(1-n))}destroy(t){super.destroy(t)}}const Ei=[],Pe={get(i){if(Ei.length>0){const t=Ei.pop();return t.texture=i,t.alpha=1,t.scale.set(1),t.rotation=0,t.tint=16777215,t.anchor.set(.5),t.visible=!0,t}return new ot(i)},release(i){i&&(i.parent&&i.parent.removeChild(i),i.customData&&(i.customData=null),Ei.push(i))}};class Rp extends gs{constructor(t){super(),this.explosionTexture=t.explosionTexture,this._particles=[],this._isSpawning=!0,this._particleSpawnRateMs=50,this._particleMaxLifeMs=2e3,this._minStartScale=.02,this._maxStartScale=.05,this._startAlpha=.1,this._initialOffsetX=15,this._initialOffsetY=15,this._lastSpawnTime=0;for(let e=0;e<30;e+=1)this._createParticle()}stopSpawning(){this._isSpawning=!1}_createParticle(){const t=Pe.get(this.explosionTexture);t.anchor.set(.5);const e=.2+Math.random()*.4,s=Math.floor(e*255);t.tint=s<<16|s<<8|s;const n=this._minStartScale+Math.random()*(this._maxStartScale-this._minStartScale),r=.6+Math.random()*.8,o=.6+Math.random()*.8;t.scale.set(n*r,n*o),t.alpha=this._startAlpha+Math.random()*.1,t.rotation=Math.random()*Math.PI*2,t.x=(Math.random()-.5)*this._initialOffsetX,t.y=(Math.random()-.5)*this._initialOffsetY,t.customData={life:0,maxLife:this._particleMaxLifeMs*(.7+Math.random()*.6),aspectRatioX:r,aspectRatioY:o,vx:(Math.random()-.5)*.2,vy:-.3-Math.random()*.4,swaySpeed:.002+Math.random()*.003,swayAmp:.025+Math.random()*.05,swayOffset:Math.random()*100,rotationSpeed:(Math.random()-.5)*.05,targetScale:.08+Math.random()*.08,startScale:n},this.addChild(t),this._particles.push(t)}_update(t){if(!this.isComplete){if(t=Math.min(t,100),this._isSpawning)for(this._lastSpawnTime+=t;this._lastSpawnTime>this._particleSpawnRateMs;)this._createParticle(),this._lastSpawnTime-=this._particleSpawnRateMs;for(let e=this._particles.length-1;e>=0;e-=1){const s=this._particles[e],n=s.customData;if(n.life+=t,n.life>=n.maxLife)Pe.release(s),this._particles.splice(e,1);else{const r=n.life/n.maxLife;n.vy*=.98,n.vx*=.95;const o=Math.sin(n.life*n.swaySpeed+n.swayOffset)*n.swayAmp;s.x+=(n.vx+o)*(t/16),s.y+=n.vy*(t/16),s.rotation+=n.rotationSpeed*(t/16);const a=1-Math.pow(1-r,3),h=n.startScale+(n.targetScale-n.startScale)*a;if(s.scale.set(h*n.aspectRatioX,h*n.aspectRatioY),r<.1)s.alpha=r/.1*this._startAlpha;else if(r>.4){const l=(r-.4)/.6;s.alpha=this._startAlpha*(1-l)}else s.alpha=this._startAlpha}}!this._isSpawning&&this._particles.length===0&&this._isStarted&&(this._completeEffect(),this.destroyed||this.destroy())}}destroy(t){for(let e=0;e<this._particles.length;e+=1)Pe.release(this._particles[e]);this._particles=[],super.destroy(t)}}const Bp=50,Lp=15;class Op extends gs{constructor(t,e,s,n){super(s),this._assets=n,this.x=t,this.y=e,this._funnelDurationMs=2e4,this._funnelFadeDurationMs=4e3,this._elapsedMs=0,this._isFading=!1,this._smokeDurationMs=4e3,this._smokeSpawningStopped=!1,this._funnel=this._createFunnelSprite(),this._smoke=new Rp(this._assets),this.addChild(this._funnel,this._smoke)}_createFunnelSprite(){const t=this._assets.funnelTexture,e=new ot(t);e.anchor.set(.5),e.tint=3815994;const s=Lp/(Bp*2);return e.scale.set(s),e}_onEffectStart(){super._onEffectStart(),this._smoke&&this._smoke.run()}_update(t){if(this.isComplete)return;this._elapsedMs+=t,!this._smokeSpawningStopped&&this._elapsedMs>=this._smokeDurationMs&&(this._smoke.stopSpawning(),this._smokeSpawningStopped=!0);const e=this._funnelDurationMs-this._elapsedMs;if(e<=this._funnelFadeDurationMs){this._isFading||(this._isFading=!0);const s=e/this._funnelFadeDurationMs;this._funnel.alpha=Math.max(0,s)}e<=0&&this._completeEffect()}destroy(t){this._smoke&&(this._smoke.destroy(),this._smoke=null),this._funnel=null,super.destroy(t)}}class Dp extends it{constructor(t,e,s){super(),this.originX=t[0],this.originY=t[1],this.radius=t[2],this._assets=e,this._soundManager=s.soundManager,this.x=this.originX,this.y=this.originY,this.explosion=null,this.funnel=null,this._isDestroyed=!1,this._soundId=this._soundManager.registerSound("explosion",{position:{x:this.originX,y:this.originY}})}run(){if(this._isDestroyed)return;const t=this.parent;this.funnel=new Op(this.originX,this.originY,this._onFunnelComplete.bind(this),this._assets),this.funnel.zIndex=2,t.addChild(this.funnel),this.explosion=new Fp(this.originX,this.originY,this.radius,this._onExplosionComplete.bind(this),this._assets),this.explosion.zIndex=4,t.addChild(this.explosion),this.funnel.run(),this.explosion.run()}_onExplosionComplete(){this._isDestroyed||this.explosion&&(this.explosion.destroy(),this.explosion=null)}_onFunnelComplete(){this._isDestroyed||this.destroy()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null),this.explosion&&(this.explosion.destroy(),this.explosion=null),this.funnel&&(this.funnel.destroy(),this.funnel=null),this.parent&&this.parent.removeChild(this),super.destroy({children:!0,texture:!0,baseTexture:!0}))}}const Gp=0,zp=0,dt={particleLifetime:{min:800,max:1800},particleStartSizeFactor:{1:2,2:1,0:.25},particleEndSizeFactor:{1:3,2:2,0:1},particleStartAlpha:.08,particleEndAlpha:0,particleColor:3355443,particleSpawnRate:{1:60,2:50,0:30},particleInitialVelocity:{away:{min:-10,max:100},side:{min:-30,max:30}},airResistance:.92,particleVelocityVariance:10,streamOffsetFactor:.1,burstParticleCount:3};class Up extends it{constructor(t,e){super(),this.zIndex=4,this._smokeTexture=e.smokeTexture,this._emitterX=t[0],this._emitterY=t[1],this._emitterRotation=t[2],this._emitterVX=t[4],this._emitterVY=t[5],this._engineLoad=t[6],this._condition=t[7],this._size=t[8],this._width=this._size*4,this._height=this._size*3,this._particleScaleMultiplier=Math.max(.5,Math.sqrt(this._width*this._height*.001)),this._particles=[],this._particleContainer=new it,this.addChild(this._particleContainer),this._timeSinceLastSpawn=0,this._tickListener=s=>this._updateParticles(s.deltaMS),ct.shared.add(this._tickListener)}update(t){const e=this._condition;this._emitterX=t[0],this._emitterY=t[1],this._emitterRotation=t[2],this._emitterVX=t[4],this._emitterVY=t[5],this._engineLoad=t[6],this._condition=t[7],this._condition!==e&&this._condition!==3&&this._triggerSmokeBurst()}_triggerSmokeBurst(){let t=0;if(this._condition===1?t=2:(this._condition===2||this._condition===0)&&(t=1),t>0){const e=dt.burstParticleCount,s=Math.ceil(e/t);for(let n=0;n<s;n+=1)for(let r=0;r<t;r+=1)this.spawnParticle(r,t,!0)}}_updateParticles(t){if(t<=0)return;const e=t/1e3;this._timeSinceLastSpawn+=t;let s=0;this._condition===3?s=0:this._condition===1?s=2:(this._condition===2||this._condition===0)&&(s=1);const n=dt.particleSpawnRate[this._condition]||0,r=n>0?1e3/n:1/0;if(s>0&&n>0)for(;this._timeSinceLastSpawn>=r;){for(let h=0;h<s;h+=1)this.spawnParticle(h,s);this._timeSinceLastSpawn-=r}else this._timeSinceLastSpawn=0;const a=1-Math.pow(dt.airResistance,t/16);for(let h=this._particles.length-1;h>=0;h-=1){const l=this._particles[h];if(l.age+=t,l.age>=l.lifetime){this._particleContainer.removeChild(l.graphics),Pe.release(l.graphics),this._particles.splice(h,1);continue}l.vx=l.vx+(Gp-l.vx)*a,l.vy=l.vy+(zp-l.vy)*a,l.x+=l.vx*e,l.y+=l.vy*e;const c=l.age/l.lifetime,u=1-(1-c)*(1-c),d=bt(l.startSizeFactor,l.endSizeFactor,u),f=bt(l.startAlpha,l.endAlpha,c),p=d*this._particleScaleMultiplier,g=l.graphics;g.x=l.x,g.y=l.y,g.scale.set(p),g.alpha=f,g.rotation+=l.rotSpeed*e}}spawnParticle(t,e,s=!1){const n=vt(dt.particleLifetime.min,dt.particleLifetime.max);let r=dt.particleStartSizeFactor[this._condition]||.3,o=dt.particleEndSizeFactor[this._condition]||1,a=dt.particleStartAlpha,h=1;s&&(r*=2,o*=2.5,a=.8,h=2);const l=this._emitterRotation,c=l+Math.PI,u=Math.cos(c),d=Math.sin(c),f=l+Math.PI/2,p=Math.cos(f),g=Math.sin(f);let m=0;const _=this._width/2*dt.streamOffsetFactor;e===2?m=t===0?-_:_:e===3&&(m=(t-1)*_);const x=this._height*.22,b=this._emitterX+u*x+p*m,y=this._emitterY+d*x+g*m;let v=vt(dt.particleInitialVelocity.away.min,dt.particleInitialVelocity.away.max),w=vt(dt.particleInitialVelocity.side.min,dt.particleInitialVelocity.side.max);v*=h,w*=h;let S=u*v+p*w,C=d*v+g*w;const P=dt.particleVelocityVariance;S+=vt(-P,P),C+=vt(-P,P),S+=this._emitterVX,C+=this._emitterVY;const T=Pe.get(this._smokeTexture);T.anchor.set(.5),T.tint=dt.particleColor,T.x=b,T.y=y,T.alpha=a,T.scale.set(r*this._particleScaleMultiplier),T.rotation=vt(0,Math.PI*2);const A={graphics:T,x:b,y,vx:S,vy:C,age:0,lifetime:n,startSizeFactor:r,endSizeFactor:o,startAlpha:a,endAlpha:dt.particleEndAlpha,rotSpeed:vt(-1,1)};this._particleContainer.addChild(T),this._particles.push(A)}_stopTimer(){this._tickListener&&(ct.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer();for(let e=0;e<this._particles.length;e+=1)Pe.release(this._particles[e].graphics);this._particles=[],super.destroy({children:!0,texture:!1,baseTexture:!1,...t})}}class Wp extends ot{constructor(t,e,s,n,r,o,a){super(a),this.anchor.set(.5),this.x=t,this.y=e,this.rotation=s,this.width=r,this.height=n,this.alpha=o,this._initialAlpha=o,this._elapsedTime=0,this._fadeDuration=1800+Math.random()*700}update(t){this._elapsedTime+=t;const e=Math.min(this._elapsedTime/this._fadeDuration,1);return this.alpha=(1-e)*this._initialAlpha,e>=1}}class Xp extends it{constructor(t,e){super(),this.zIndex=1,this._currentX=t[0]||0,this._currentY=t[1]||0,this._currentRotation=t[2]||0,this._engineLoad=t[6]||0,this._condition=t[7],this._size=t[8],this._prevX=this._currentX,this._prevY=this._currentY,this._prevRotation=this._currentRotation,this._prevSpeed=0,this._prevAngularSpeed=0,this._assets=e,this._trackMarkCooldown=2,this._lastTrackMarkTime=0,this._minAbsAccelerationForMark=4,this._minAngularSpeedForMark=.02,this._minRotationAccelerationForMark=.4,this._minSpeedForRotationMarks=1.4,this._trackWidth=this._size*.4,this._trackLength=this._size*.5;const s=this._size*3;this._trackOffset=s/2*.7,this._backwardOffset=s*.4,this._trackInitialAlpha=.4,this._tickListener=n=>this._internalUpdate(n.deltaMS),ct.shared.add(this._tickListener)}update(t){this._currentX=t[0],this._currentY=t[1],this._currentRotation=t[2],this._engineLoad=t[6],this._condition=t[7]}_internalUpdate(t){if(t<=0)return;for(let f=this.children.length-1;f>=0;f-=1){const p=this.children[f];p.update(t)&&p.destroy()}const e=this._currentX-this._prevX,s=this._currentY-this._prevY,n=Math.sqrt(e*e+s*s),r=vp(this._currentRotation-this._prevRotation),o=Math.abs(r),a=n-this._prevSpeed,h=Math.abs(a),l=o-this._prevAngularSpeed,c=Math.abs(l),u=performance.now();let d=!1;this._condition!==0&&u-this._lastTrackMarkTime>this._trackMarkCooldown&&(h>this._minAbsAccelerationForMark&&(d=!0),n>this._minSpeedForRotationMarks&&(o>this._minAngularSpeedForMark||c>this._minRotationAccelerationForMark)&&(d=!0)),this._engineLoad>1&&(d=!0),d&&(this.createTrackMarksAtPreviousPosition(),this._lastTrackMarkTime=u),this._prevX=this._currentX,this._prevY=this._currentY,this._prevRotation=this._currentRotation,this._prevSpeed=n,this._prevAngularSpeed=o}createTrackMarksAtPreviousPosition(){for(let t=-1;t<=1;t+=2){const e=Math.cos(this._prevRotation+Math.PI/2)*this._trackOffset*t,s=Math.sin(this._prevRotation+Math.PI/2)*this._trackOffset*t,n=-Math.cos(this._prevRotation)*this._backwardOffset,r=-Math.sin(this._prevRotation)*this._backwardOffset,o=this._prevX+e+n,a=this._prevY+s+r,h=new Wp(o,a,this._prevRotation,this._trackWidth,this._trackLength,this._trackInitialAlpha,this._assets.trackMarkTexture);this.addChild(h)}}_stopTimer(){this._tickListener&&(ct.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer(),super.destroy({children:!0,texture:!1,baseTexture:!1,...t})}}class Yp extends gs{constructor(t,e,s,n,r){super(r),this.startPositionX=t,this.startPositionY=e,this.endPositionX=s,this.endPositionY=n,this.config={color:16777113,alphaStart:1,alphaEnd:.6,trailLength:55,tracerSpeed:19e3,minDuration:45,maxDuration:80,trailShrinkPower:1,trailStartOffset:30,segmentCount:12,segmentRadius:1,alphaPulseFrequency:.1,alphaPulseAmplitude:.15},this.graphics=new ut,this.addChild(this.graphics),this.elapsedTime=0,this.dx=this.endPositionX-this.startPositionX,this.dy=this.endPositionY-this.startPositionY,this.totalDist=Math.hypot(this.dx,this.dy),this.totalDist>.001?(this.nx=this.dx/this.totalDist,this.ny=this.dy/this.totalDist,this.animationDuration=this.totalDist/this.config.tracerSpeed*1e3):(this.nx=0,this.ny=0,this.totalDist=0,this.animationDuration=this.config.minDuration),this.animationDuration=Math.max(this.config.minDuration,this.animationDuration),this.animationDuration=Math.min(this.config.maxDuration,this.animationDuration),this.animationDuration<=0&&(this.animationDuration=this.config.minDuration)}_drawSegment(t,e,s,n,r){this.graphics.circle(t,e,s),this.graphics.fill({color:n,alpha:nn(r,0,1)})}_update(t){if(this.isComplete)return;this.elapsedTime+=t,this.graphics.clear();const e=Math.min(this.elapsedTime/this.animationDuration,1);if(e>0){const s=bt(this.startPositionX,this.endPositionX,e),n=bt(this.startPositionY,this.endPositionY,e),r=bt(this.config.alphaStart,this.config.alphaEnd,e),o=Math.sin(this.elapsedTime*this.config.alphaPulseFrequency)*this.config.alphaPulseAmplitude;let a=r+o;a=nn(a,0,this.config.alphaStart);const h=Math.pow(e,this.config.trailShrinkPower),l=bt(this.config.trailLength,0,h),c=this.totalDist*e;if(c>=this.config.trailStartOffset){let u=c;this.totalDist>.001&&(u=Math.max(0,c-this.config.trailStartOffset));const d=Math.min(u,l);let f,p;this.totalDist>.001?(f=s-this.nx*d,p=n-this.ny*d):(f=s,p=n);const g=Math.hypot(s-f,n-p);if(g<this.config.segmentRadius*.5&&this.totalDist===0)this._drawSegment(s,n,this.config.segmentRadius,this.config.color,a);else if(g>=this.config.segmentRadius*.5){const m=Math.max(1,this.config.segmentCount);for(let _=0;_<m;_++){let x=.5;m>1&&(x=_/(m-1));const b=bt(f,s,x),y=bt(p,n,x),v=bt(1,.8,x);this._drawSegment(b,y,this.config.segmentRadius,this.config.color,a*v)}}}}this.elapsedTime>=this.animationDuration&&(this.graphics.clear(),this._completeEffect())}destroy(t){this.graphics&&this.graphics.clear(),super.destroy(t)}}const Hp=10;class Np extends gs{constructor(t,e,s,n,r,o){super(r),this.x=t,this.y=e,this._assets=o,this._particleTexture=this._assets.impactParticleTexture,this.config={particleCount:vt(2,4),particleMinSize:1,particleMaxSize:3,minInitialSpeed:10,maxInitialSpeed:300,minLifetime:8e3,maxLifetime:15e3,color:[3355443,2236962,4473924],fadeOutStart:.8,impactDirectionX:s,impactDirectionY:n,spreadAngle:60,dragCoefficient:13,minSpeedThreshold:1,lingerDuration:6e3},this.config.impactDirectionX===0&&this.config.impactDirectionY===0?this.useOmnidirectionalSpread=!0:this.useOmnidirectionalSpread=!1,this.particlesData=[],this.elapsedTime=0,this._createParticles()}_createParticles(){let t;this.useOmnidirectionalSpread||(t=Math.atan2(this.config.impactDirectionY,this.config.impactDirectionX));const s=this.config.spreadAngle*(Math.PI/180)/2;for(let n=0,r=this.config.particleCount;n<r;n+=1){let o;this.useOmnidirectionalSpread?o=Math.random()*Math.PI*2:o=t+vt(-s,s);const a=vt(this.config.minInitialSpeed,this.config.maxInitialSpeed),h=new ot(this._particleTexture);h.anchor.set(.5);const l={sprite:h,x:0,y:0,vx:Math.cos(o)*a,vy:Math.sin(o)*a,size:vt(this.config.particleMinSize,this.config.particleMaxSize),color:Array.isArray(this.config.color)?this.config.color[Math.floor(Math.random()*this.config.color.length)]:this.config.color,lifetime:vt(this.config.minLifetime,this.config.maxLifetime),age:0,alpha:1,active:!0,isMoving:!0,timeSinceStopped:0};h.tint=l.color,this.particlesData.push(l),this.addChild(h)}}_update(t){if(this.isComplete)return;this.elapsedTime+=t;const e=t/1e3;let s=0;for(let n=0,r=this.particlesData.length;n<r;n+=1){const o=this.particlesData[n];if(!o.active)continue;if(s+=1,o.age+=t,o.isMoving){const c=Math.hypot(o.vx,o.vy);if(c>0){const d=c*this.config.dragCoefficient*e,f=Math.max(0,1-d/c);o.vx*=f,o.vy*=f}o.x+=o.vx*e,o.y+=o.vy*e,Math.hypot(o.vx,o.vy)<this.config.minSpeedThreshold&&(o.isMoving=!1,o.vx=0,o.vy=0)}else o.timeSinceStopped+=t;const a=o.age/o.lifetime;if(!o.isMoving&&o.timeSinceStopped>=this.config.lingerDuration){const c=o.timeSinceStopped-this.config.lingerDuration,u=Math.min(500,o.lifetime*(1-this.config.fadeOutStart));o.alpha=bt(1,0,Math.min(c/u,1))}else if(a>=this.config.fadeOutStart){const c=o.age-o.lifetime*this.config.fadeOutStart,u=o.lifetime*(1-this.config.fadeOutStart);o.alpha=u>0?bt(1,0,Math.min(c/u,1)):0}(o.age>=o.lifetime||o.alpha<.01)&&(o.active=!1,o.alpha=0);const h=o.sprite;h.position.set(o.x,o.y),h.alpha=o.alpha,h.visible=o.active;const l=o.size/Hp;h.scale.set(l)}s===0&&this._isStarted&&this._completeEffect()}destroy(t){this.particlesData=[],super.destroy(t)}}class $p extends it{constructor(t,e,s){super(),this.zIndex=2,this.startPositionX=t[0],this.startPositionY=t[1],this.endPositionX=t[2],this.endPositionY=t[3],this.soundPositionX=t[4],this.soundPositionY=t[5],this.hit=t[6],this._assets=e,this._soundManager=s.soundManager,this.tracer=null,this.impact=null,this._isDestroyed=!1,this._visualsComplete=!1,this._soundComplete=!1,this._soundId=this._soundManager.registerSound("shot",{position:{x:this.soundPositionX,y:this.soundPositionY}},()=>{this._soundComplete=!0,this._soundId=null,this._tryDestroy()}),this._soundId||(this._soundComplete=!0)}run(){this._isDestroyed||(this.tracer=new Yp(this.startPositionX,this.startPositionY,this.endPositionX,this.endPositionY,this._onTracerComplete.bind(this)),this.addChild(this.tracer),this.tracer.run())}_onTracerComplete(){if(!this._isDestroyed)if(this.hit){const t=this.endPositionX-this.startPositionX,e=this.endPositionY-this.startPositionY,s=Math.hypot(t,e);let n=0,r=0;s>.001&&(n=-(t/s),r=-(e/s)),this.impact=new Np(this.endPositionX,this.endPositionY,n,r,this._onImpactComplete.bind(this),this._assets),this.addChild(this.impact),this.impact.run()}else this._visualsComplete=!0,this._tryDestroy()}_onImpactComplete(){this._isDestroyed||(this._visualsComplete=!0,this._tryDestroy())}_tryDestroy(){this._visualsComplete&&this._soundComplete&&this.destroy()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null),this.tracer&&(this.tracer.destroy(),this.tracer=null),this.impact&&(this.impact.destroy(),this.impact=null),this.parent&&this.parent.removeChild(this),super.destroy({children:!0,texture:!0,baseTexture:!0}))}}const Vp={Map:wp,MapRadar:Sp,TankRadar:Tp,Tank:Ep,Bomb:Ip,ExplosionEffect:Dp,Smoke:Up,Tracks:Xp,ShotEffect:$p};function jp(i,t){const{radius:e,blur:s,color:n}=i,r=new ut;r.circle(e+s,e+s,e),r.fill(n),r.filters=[new ps({strength:s,quality:40})];const o=t.generateTexture({target:r,frame:new W(0,0,(e+s)*2,(e+s)*2)});return r.destroy(!0),o}function qp(i,t){const{baseRadius:e,irregularity:s,blur:n,numPoints:r}=i,o=new ut,a=(e+s+n)*2,h=a/2,l=[];for(let u=0;u<r;u+=1){const d=u/r*Math.PI*2,f=e+vt(-s,s);l.push(h+f*Math.cos(d),h+f*Math.sin(d))}o.poly(l).fill(16777215),o.filters=[new ps({strength:n,quality:10})];const c=t.generateTexture({target:o,frame:new W(0,0,a,a)});return o.destroy(!0),c}function Kp(i,t){const{radius:e,blur:s,color:n}=i,r=new ut;r.circle(e+s,e+s,e),r.fill(n),r.filters=[new ps({strength:s,quality:40})];const o=t.generateTexture({target:r,frame:new W(0,0,(e+s)*2,(e+s)*2)});return r.destroy(!0),o}function Zp(i,t){const{colors:e}=i,s={},n=10,r=n*4,o=n*3,a=15658734,h=c=>{const u=new ut,d=new ut,f=r,p=o;u.rect(-f/2,-p/2,f,p).fill(5592405).rect(-f/2+1,-p/2+1,f-2,p-2).fill(10066329).rect(-f/2+2,-p/2+2,f-4,p-4).fill(13421772).rect(-f/2+3,-p/2+3,f-6,p-6).fill(a),d.moveTo(1.33*n,-.42*n).lineTo(.42*n,-1*n).lineTo(-.42*n,-1*n).lineTo(-1.33*n,-.42*n).lineTo(-1.33*n,.42*n).lineTo(-.42*n,1*n).lineTo(.42*n,1*n).lineTo(1.33*n,.42*n).closePath().fill(c).stroke({width:.17*n,color:11184810}).moveTo(2.33*n,-.25*n).lineTo(.25*n,-.25*n).lineTo(.25*n,.25*n).lineTo(2.33*n,.25*n).closePath().stroke({width:.17*n,color:11184810}).fill(c);const g=u.getBounds(),m=t.generateTexture({target:u,frame:new W(g.x,g.y,g.width,g.height)}),_=d.getBounds(),x=t.generateTexture({target:d,frame:new W(_.x,_.y,_.width,_.height)}),b={x:-_.x/_.width,y:-_.y/_.height};return u.destroy(!0),d.destroy(!0),{body:m,gun:x,gunAnchor:b}},l=()=>{const c=new it,u=new ut,d=new ut;c.addChild(u,d);const f=3815994,p=2434341,g=3158064,m=1579032,_=5263440,x=r,b=o,y=n;u.moveTo(-x/2-y*.1,-b/2+y*.2).lineTo(x/2+y*.2,-b/2-y*.1).lineTo(x/2-y*.1,b/2+y*.3).lineTo(-x/2+y*.3,b/2-y*.2).closePath().fill(f).stroke({width:y*.2,color:_,alignment:.5}),u.moveTo(-x/2+y*.4,-b/2+y*.5).lineTo(x/2-y*.3,-b/2+y*.2).lineTo(x/2-y*.4,b/2-y*.1).lineTo(-x/2+y*.2,b/2-y*.4).closePath().fill(p),u.circle(x*.15,b*.1,y*1.2).fill(m),u.circle(-x*.3,-b*.25,y*.5).fill(m),d.position.set(y*.3,-y*.2);const v=[y*1.1,-y*.7,y*.2,-y*1,-y*.6,-y*.9,-y*1.3,-y*.2,-y*1.1,y*.6,-y*.2,y*1,y*.7,y*.8,y*1.3,y*.1];d.poly(v).fill(g).stroke({width:y*.15,color:_,alignment:0});const w=[y*.8,-y*.25,y*1.5,-y*.4,y*1.4,y*.15,y*.7,y*.05];d.poly(w).fill(g).stroke({width:y*.1,color:_,alignment:0}),d.circle(y*.1,-y*.2,y*.4).fill(m);const S=c.getBounds(),C=t.generateTexture({target:c,frame:new W(S.x,S.y,S.width,S.height)});return c.destroy({children:!0}),C};return s.liveTeamId1=h(e.teamId1),s.liveTeamId2=h(e.teamId2),s.destroyed=l(),s}function Qp(i,t){const{radius:e,borderWidth:s,crossSize:n,crossThickness:r,colors:o}=i,a={},h=(e+s)*2,l=h/2,c=15658734,u=3355443,d=p=>{const g=new ut;g.circle(l,l,e).fill(c),g.circle(l,l,e-s).fill(p);const m=t.generateTexture({target:g,frame:new W(0,0,h,h)});return g.destroy(!0),m},f=()=>{const p=new ut,g=n/2;p.moveTo(l-g,l-g).lineTo(l+g,l+g).moveTo(l-g,l+g).lineTo(l+g,l-g).stroke({width:r,color:u});const m=t.generateTexture({target:p,frame:new W(0,0,h,h)});return p.destroy(!0),m};return a.liveTeamId1=d(o.teamId1),a.liveTeamId2=d(o.teamId2),a.destroyed=f(),a}function Jp(i,t){const{colorOuter:e,colorInner:s}=i,n=new ut,r=20,o=1;n.rect(0,0,r,r).fill(e),n.rect(o,o,r-o*2,r-o*2).fill(s);const a=t.generateTexture({target:n,frame:new W(0,0,r,r)});return n.destroy(!0),a}function tg(i,t){const{width:e,length:s,color:n}=i,r=new ut;r.rect(0,0,s,e).fill(n);const o=t.generateTexture({target:r,frame:new W(0,0,s,e)});return r.destroy(!0),o}function eg(i,t){const{radius:e,blur:s,color:n}=i,r=new ut,o=(e+s)*2,a=o/2;r.circle(a,a,e),r.fill(n),r.filters=[new ps({strength:s,quality:10})];const h=t.generateTexture({target:r,frame:new W(0,0,o,o)});return r.destroy(!0),h}const So=new WeakSet;function sg(i){if(So.has(i))return;const t=new it;i.render(t),t.destroy(),So.add(i)}const ig={explosionTexture:jp,funnelTexture:qp,smokeTexture:Kp,tankTexture:Zp,tankRadarTexture:Qp,bombTexture:Jp,trackMarkTexture:tg,impactParticleTexture:eg},ng=Object.fromEntries(Object.entries(ig).map(([i,t])=>[i,(e,s)=>(sg(s),t(e,s))])),cg={id:"tanks",engineApi:1,async createClientCore(i,{wasmUrl:t}){const e=await _h(t);return{core:new Ii(i),memory:e.memory}},parts:Vp,bakers:ng,styles:yh,hooks:{onAuth(i,t){i.set_model(t.model)},onPanel(i,t){i.sync_panel(JSON.stringify(t))},onLocalAction(i,t,e,s){return t!=="down"?null:e==="fire"?i.try_fire(s)||null:((e==="nextWeapon"||e==="prevWeapon")&&i.cycle_weapon(e==="prevWeapon"),null)}}};$.add(Bl);$.mixin(it,Ll);$.add(Da);$.add(Ga);$.mixin(it,pf);$.add($a,Wa);$.add(Na);const rg=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),og=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{cg as default};
|