screeps-client 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/embedded/assets/CodePanel-BCwhfeJ7.js +1 -0
  2. package/dist/embedded/assets/MapViewer-DoywRdNM.js +1 -0
  3. package/dist/embedded/assets/index-Y34ajerm.js +4 -0
  4. package/dist/embedded/assets/vendor-codemirror-BbK0dVBs.js +24 -0
  5. package/dist/embedded/assets/vendor-pixi-c1qrZX58.js +906 -0
  6. package/dist/embedded/index.html +3 -1
  7. package/dist/standalone/assets/CodePanel-CZcHnk5g.js +1 -0
  8. package/dist/standalone/assets/MapViewer-asmYbMaF.js +1 -0
  9. package/dist/standalone/assets/index-DnY5-s_V.js +4 -0
  10. package/dist/standalone/assets/vendor-codemirror-BbK0dVBs.js +24 -0
  11. package/dist/standalone/assets/vendor-pixi-CqiKBxHw.js +906 -0
  12. package/dist/standalone/index.html +3 -1
  13. package/dist/xxscreeps-mod/assets/CodePanel-DRYHwbX3.js +1 -0
  14. package/dist/xxscreeps-mod/assets/MapViewer-C9f0YwKS.js +1 -0
  15. package/dist/xxscreeps-mod/assets/index-BxXWi67a.js +4 -0
  16. package/dist/xxscreeps-mod/assets/vendor-codemirror-BbK0dVBs.js +24 -0
  17. package/dist/xxscreeps-mod/assets/vendor-pixi-CqiKBxHw.js +906 -0
  18. package/dist/xxscreeps-mod/index.html +3 -1
  19. package/package.json +4 -2
  20. package/dist/embedded/assets/BufferResource-BaQPK-V7.js +0 -185
  21. package/dist/embedded/assets/CanvasRenderer-PSblDCb7.js +0 -1
  22. package/dist/embedded/assets/Filter-D4pZOpc_.js +0 -1
  23. package/dist/embedded/assets/RenderTargetSystem-RBdRUxEE.js +0 -184
  24. package/dist/embedded/assets/WebGLRenderer-B8_Hqbp3.js +0 -156
  25. package/dist/embedded/assets/WebGPURenderer-DRt8eJ5g.js +0 -41
  26. package/dist/embedded/assets/browserAll-BDwT5mR2.js +0 -14
  27. package/dist/embedded/assets/canvasUtils-BYjxCPau.js +0 -1
  28. package/dist/embedded/assets/index-Pf1rCDHu.js +0 -274
  29. package/dist/embedded/assets/webworkerAll-D81v1dCp.js +0 -83
  30. package/dist/standalone/assets/BufferResource-C7cuPJ_p.js +0 -185
  31. package/dist/standalone/assets/CanvasRenderer-QY3I2Ik-.js +0 -1
  32. package/dist/standalone/assets/Filter-Ciqmecbs.js +0 -1
  33. package/dist/standalone/assets/RenderTargetSystem-l6SPJ7_m.js +0 -184
  34. package/dist/standalone/assets/WebGLRenderer-uPjAJqZs.js +0 -156
  35. package/dist/standalone/assets/WebGPURenderer-n9UczIr_.js +0 -41
  36. package/dist/standalone/assets/browserAll-D_MMKcyh.js +0 -14
  37. package/dist/standalone/assets/canvasUtils-BThzuUuN.js +0 -1
  38. package/dist/standalone/assets/index-B6UNpeEn.js +0 -274
  39. package/dist/standalone/assets/webworkerAll-B0QfJus3.js +0 -83
  40. package/dist/xxscreeps-mod/assets/BufferResource-CE78HmbQ.js +0 -185
  41. package/dist/xxscreeps-mod/assets/CanvasRenderer-BH4PjMGX.js +0 -1
  42. package/dist/xxscreeps-mod/assets/Filter-ZZPoYeTC.js +0 -1
  43. package/dist/xxscreeps-mod/assets/RenderTargetSystem-EVgeaEAK.js +0 -184
  44. package/dist/xxscreeps-mod/assets/WebGLRenderer-DDvszQ53.js +0 -156
  45. package/dist/xxscreeps-mod/assets/WebGPURenderer-UUnYdUOg.js +0 -41
  46. package/dist/xxscreeps-mod/assets/browserAll-CppuWcbH.js +0 -14
  47. package/dist/xxscreeps-mod/assets/canvasUtils-Dmy9CrII.js +0 -1
  48. package/dist/xxscreeps-mod/assets/index-CINA8e_Z.js +0 -274
  49. package/dist/xxscreeps-mod/assets/webworkerAll-D7azZfkM.js +0 -83
@@ -0,0 +1,906 @@
1
+ const Tc="modulepreload",Sc=function(r){return"/"+r},yn={},ns=function(t,e,s){let i=Promise.resolve();if(e&&e.length>0){let o=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 a=document.querySelector("meta[property=csp-nonce]"),h=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(e.map(l=>{if(l=Sc(l),l in yn)return;yn[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":Tc,c||(d.as="script"),d.crossOrigin="",d.href=l,h&&d.setAttribute("nonce",h),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 n(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&n(a.reason);return t().catch(n)})};var b=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(b||{});const Nr=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Ss=(r,t)=>Nr(r).priority??t,W={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Nr).forEach(t=>{t.type.forEach(e=>{var s,i;return(i=(s=this._removeHandlers)[e])==null?void 0:i.call(s,t)})}),this},add(...r){return r.map(Nr).forEach(t=>{t.type.forEach(e=>{var n,o;const s=this._addHandlers,i=this._queue;s[e]?(o=s[e])==null||o.call(s,t):(i[e]=i[e]||[],(n=i[e])==null||n.push(t))})}),this},handle(r,t,e){var o;const s=this._addHandlers,i=this._removeHandlers;if(s[r]||i[r])throw new Error(`Extension type ${r} already has a handler`);s[r]=t,i[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,s=>{t.findIndex(n=>n.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((n,o)=>Ss(o.value,e)-Ss(n.value,e)))},s=>{const i=t.findIndex(n=>n.name===s.name);i!==-1&&t.splice(i,1)})},handleByList(r,t,e=-1){return this.handle(r,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((i,n)=>Ss(n,e)-Ss(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}},Cc={extension:{type:b.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ns(()=>Promise.resolve().then(()=>m_),void 0)}},wc={extension:{type:b.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ns(()=>Promise.resolve().then(()=>g_),void 0)}};class gt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new gt(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 oa(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var hr={exports:{}},bn;function Ec(){return bn||(bn=1,(function(r){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new i(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,y;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(y=1,x=new Array(_-1);y<_;y++)x[y-1]=arguments[y];m.fn.apply(m.context,x)}else{var v=m.length,S;for(y=0;y<v;y++)switch(m[y].once&&this.removeListener(l,m[y].fn,void 0,!0),_){case 1:m[y].fn.call(m[y].context);break;case 2:m[y].fn.call(m[y].context,c);break;case 3:m[y].fn.call(m[y].context,c,u);break;case 4:m[y].fn.call(m[y].context,c,u,d);break;default:if(!x)for(S=1,x=new Array(_-1);S<_;S++)x[S-1]=arguments[S];m[y].fn.apply(m[y].context,x)}}return!0},a.prototype.on=function(l,c,u){return n(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return n(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,r.exports=a})(hr)),hr.exports}var Pc=Ec();const kt=oa(Pc),Mc=Math.PI*2,Ac=180/Math.PI,Rc=Math.PI/180;class st{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new st(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 lr.x=0,lr.y=0,lr}}const lr=new st;class G{constructor(t=1,e=0,s=0,i=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,i,n,o){return this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,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 st;const s=t.x,i=t.y;return e.x=this.a*s+this.c*i+this.tx,e.y=this.b*s+this.d*i+this.ty,e}applyInverse(t,e){e=e||new st;const s=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(s*o+n*-i),c=t.x,u=t.y;return e.x=o*l*c+-n*l*u+(h*n-a*o)*l,e.y=s*l*u+-i*l*c+(-h*s+a*i)*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),i=this.a,n=this.c,o=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=n*e-this.d*s,this.d=n*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,i=this.c,n=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*i,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}appendFrom(t,e){const s=t.a,i=t.b,n=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+i*u,this.b=s*c+i*d,this.c=n*l+o*u,this.d=n*c+o*d,this.tx=a*l+h*u+e.tx,this.ty=a*c+h*d+e.ty,this}setTransform(t,e,s,i,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(s*this.a+i*this.c),this.ty=e-(s*this.b+i*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,i=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*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,i=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-i,n),h=Math.atan2(s,e),l=Math.abs(a+h);return l<1e-5||Math.abs(Mc-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(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*s+o.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,i=this.d,n=this.tx,o=t*i-e*s;return this.a=i/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-i*n)/o,this.ty=-(t*this.ty-e*n)/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 G;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 Bc.identity()}static get shared(){return kc.identity()}}const kc=new G,Bc=new G,he=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],le=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ce=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ue=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Hr=[],aa=[],Cs=Math.sign;function Ic(){for(let r=0;r<16;r++){const t=[];Hr.push(t);for(let e=0;e<16;e++){const s=Cs(he[r]*he[e]+ce[r]*le[e]),i=Cs(le[r]*he[e]+ue[r]*le[e]),n=Cs(he[r]*ce[e]+ce[r]*ue[e]),o=Cs(le[r]*ce[e]+ue[r]*ue[e]);for(let a=0;a<16;a++)if(he[a]===s&&le[a]===i&&ce[a]===n&&ue[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new G;t.set(he[r],le[r],ce[r],ue[r],0,0),aa.push(t)}}Ic();const $={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>he[r],uY:r=>le[r],vX:r=>ce[r],vY:r=>ue[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Hr[r][t],sub:(r,t)=>Hr[r][$.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?$.S:$.N:Math.abs(t)*2<=Math.abs(r)?r>0?$.E:$.W:t>0?r>0?$.SE:$.SW:r>0?$.NE:$.NW,matrixAppendRotationInv:(r,t,e=0,s=0,i=0,n=0)=>{const o=aa[$.inv(t)],a=o.a,h=o.b,l=o.c,c=o.d,u=e-Math.min(0,a*i,l*n,a*i+l*n),d=s-Math.min(0,h*i,c*n,h*i+c*n),f=r.a,p=r.b,g=r.c,m=r.d;r.a=a*f+h*g,r.b=a*p+h*m,r.c=l*f+c*g,r.d=l*p+c*m,r.tx=u*f+d*g+r.tx,r.ty=u*p+d*m+r.ty},transformRectCoords:(r,t,e,s)=>{const{x:i,y:n,width:o,height:a}=r,{x:h,y:l,width:c,height:u}=t;return e===$.E?(s.set(i+h,n+l,o,a),s):e===$.S?s.set(c-n-a+h,i+l,a,o):e===$.W?s.set(c-i-o+h,u-n-a+l,o,a):e===$.N?s.set(n+h,u-i-o+l,a,o):s.set(i+h,n+l,o,a)}},ws=[new st,new st,new st,new st];class tt{constructor(t=0,e=0,s=0,i=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(i)}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 tt(0,0,0,0)}clone(){return new tt(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,i=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,h=this.y,l=s*(1-i),c=s-l,u=a-l,d=a+n+l,f=h-l,p=h+o+l,g=a+c,m=a+n-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 k=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=k)return!1;const w=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>w}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=ws[0].set(t.left,t.top),h=ws[1].set(t.left,t.bottom),l=ws[2].set(t.right,t.top),c=ws[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)>=i||Math.max(a.y,h.y,l.y,c.y)<=n||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*n,g=d*i+f*n,m=d*s+f*o,_=d*i+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),y=u*(l.x-a.x),v=x*s+y*n,S=x*i+y*n,T=x*s+y*o,C=x*i+y*o;return!(Math.max(v,S,T,C)<=x*a.x+y*a.y||Math.min(v,S,T,C)>=x*c.x+y*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),i=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,i=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=i-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),i=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=i,this.height=n-i,this}getBounds(t){return t||(t=new tt),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,i=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&s>=this.y&&s<this.y+this.height&&i>=this.x&&i<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,s,i){return this.x=t,this.y=e,this.width=s,this.height=i,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const cr={default:-1};function et(r="default"){return cr[r]===void 0&&(cr[r]=-1),++cr[r]}const vn=new Set,ot="8.0.0",Gc="8.3.4",Ge={quiet:!1,noColor:!1},H=((r,t,e=3)=>{if(Ge.quiet||vn.has(t))return;let s=new Error().stack;const i=`${t}
2
+ Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!Ge.noColor;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",i):(s=s.split(`
3
+ `).splice(e).join(`
4
+ `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",i),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i),console.warn(s))),vn.add(t)});Object.defineProperties(H,{quiet:{get:()=>Ge.quiet,set:r=>{Ge.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Ge.noColor,set:r=>{Ge.noColor=r},enumerable:!0,configurable:!1}});const ha=()=>{};function Oe(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Tn(r){return!(r&r-1)&&!!r}function la(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}const Sn=Object.create(null);function Fc(r){const t=Sn[r];return t===void 0&&(Sn[r]=et("resource")),t}const ca=class ua extends kt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...ua.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){H(ot,"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=Fc(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};ca.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let _e=ca;const da=class fa extends kt{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._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...fa.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.alphaMode=t.alphaMode,this.style=new _e(la(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.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(){var t,e;this._resourceId=et("resource"),this.emit("change",this),this.emit("unload",this);for(const s in this._gpuData)(e=(t=this._gpuData[s])==null?void 0:t.destroy)==null||e.call(t);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 i=Math.round(t*s),n=Math.round(e*s);return this.width=i/s,this.height=n/s,this._resolution=s,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,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=Tn(this.pixelWidth)&&Tn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};da.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 ft=da;class fi extends ft{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}}fi.extension=b.TextureSource;const Cn=new G;class pa{constructor(t,e){this.mapCoord=new G,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){var e;this._texture!==t&&((e=this._texture)==null||e.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 i=0;i<t.length;i+=2){const n=t[i],o=t[i+1];e[i]=n*s.a+o*s.c+s.tx,e[i+1]=n*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,i=t.trim;i&&(Cn.set(s.width/i.width,0,0,s.height/i.height,-i.x/i.width,-i.y/i.height),this.mapCoord.append(Cn));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+h)/n.width,o[1]=(t.frame.y+a+h)/n.height,o[2]=(t.frame.x+t.frame.width-a+h)/n.width,o[3]=(t.frame.y+t.frame.height-a+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class L extends kt{constructor({source:t,label:e,frame:s,orig:i,trim:n,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 tt,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new ft,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=i||this.frame,this.trim=n,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 pa(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:i}=this._source,n=e.x/s,o=e.y/i,a=e.width/s,h=e.height/i;let l=this.rotate;if(l){const c=a/2,u=h/2,d=n+c,f=o+u;l=$.add(l,$.NW),t.x0=d+c*$.uX(l),t.y0=f+u*$.uY(l),l=$.add(l,2),t.x1=d+c*$.uX(l),t.y1=f+u*$.uY(l),l=$.add(l,2),t.x2=d+c*$.uX(l),t.y2=f+u*$.uY(l),l=$.add(l,2),t.x3=d+c*$.uX(l),t.y3=f+u*$.uY(l)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+h,t.x3=n,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 H(ot,"Texture.baseTexture is now Texture.source"),this._source}}L.EMPTY=new L({label:"EMPTY",source:new ft({label:"EMPTY"})});L.EMPTY.destroy=ha;L.WHITE=new L({source:new fi({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});L.WHITE.destroy=ha;function ma(r,t,e){const{width:s,height:i}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*s,r.maxX=r.minX+o,r.minY=n.y-t._y*i,r.maxY=r.minY+a}else r.minX=-t._x*s,r.maxX=r.minX+s,r.minY=-t._y*i,r.maxY=r.minY+i}const wn=new G;class _t{constructor(t=1/0,e=1/0,s=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=wn,this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new tt);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=wn,this}set(t,e,s,i){this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}addFrame(t,e,s,i,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.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*i+c,_=a*t+l*i+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*s+h*i+c,_=a*s+l*i+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,i=this.maxX,n=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*i+h*s+c,f=a*i+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*n+c,f=a*e+l*n+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*i+h*n+c,f=a*i+l*n+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,i){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>i&&(this.maxY=i),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,i){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;i||(i=this.matrix);const l=i.a,c=i.b,u=i.c,d=i.d,f=i.tx,p=i.ty;for(let g=e;g<s;g+=2){const m=t[g],_=t[g+1],x=l*m+u*_+f,y=c*m+d*_+p;n=x<n?x:n,o=y<o?y:o,a=x>a?x:a,h=y>h?y:h}this.minX=n,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 Dc={grad:.9,turn:360,rad:360/(2*Math.PI)},Vt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},pt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Mt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},ga=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},En=function(r){return{r:Mt(r.r,0,255),g:Mt(r.g,0,255),b:Mt(r.b,0,255),a:Mt(r.a)}},ur=function(r){return{r:pt(r.r),g:pt(r.g),b:pt(r.b),a:pt(r.a,3)}},Uc=/^#([0-9a-f]{3,8})$/i,Es=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},_a=function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=Math.max(t,e,s),o=n-Math.min(t,e,s),a=o?n===t?(e-s)/o:n===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},xa=function(r){var t=r.h,e=r.s,s=r.v,i=r.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),o=s*(1-e),a=s*(1-(t-n)*e),h=s*(1-(1-t+n)*e),l=n%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:i}},Pn=function(r){return{h:ga(r.h),s:Mt(r.s,0,100),l:Mt(r.l,0,100),a:Mt(r.a)}},Mn=function(r){return{h:pt(r.h),s:pt(r.s),l:pt(r.l),a:pt(r.a,3)}},An=function(r){return xa((e=(t=r).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},os=function(r){return{h:(t=_a(r)).h,s:(i=(200-(e=t.s))*(s=t.v)/100)>0&&i<200?e*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,s,i},Oc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Nc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Hc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wr={string:[[function(r){var t=Uc.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?pt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?pt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Nc.exec(r)||Hc.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:En({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=Oc.exec(r)||Lc.exec(r);if(!t)return null;var e,s,i=Pn({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(Dc[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return An(i)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=i===void 0?1:i;return Vt(t)&&Vt(e)&&Vt(s)?En({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,s=r.l,i=r.a,n=i===void 0?1:i;if(!Vt(t)||!Vt(e)||!Vt(s))return null;var o=Pn({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return An(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!Vt(t)||!Vt(e)||!Vt(s))return null;var o=(function(a){return{h:ga(a.h),s:Mt(a.s,0,100),v:Mt(a.v,0,100),a:Mt(a.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return xa(o)},"hsv"]]},Rn=function(r,t){for(var e=0;e<t.length;e++){var s=t[e][0](r);if(s)return[s,t[e][1]]}return[null,void 0]},Wc=function(r){return typeof r=="string"?Rn(r.trim(),Wr.string):typeof r=="object"&&r!==null?Rn(r,Wr.object):[null,void 0]},dr=function(r,t){var e=os(r);return{h:e.h,s:Mt(e.s+100*t,0,100),l:e.l,a:e.a}},fr=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},kn=function(r,t){var e=os(r);return{h:e.h,s:e.s,l:Mt(e.l+100*t,0,100),a:e.a}},zr=(function(){function r(t){this.parsed=Wc(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return pt(fr(this.rgba),2)},r.prototype.isDark=function(){return fr(this.rgba)<.5},r.prototype.isLight=function(){return fr(this.rgba)>=.5},r.prototype.toHex=function(){return t=ur(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?Es(pt(255*n)):"","#"+Es(e)+Es(s)+Es(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return ur(this.rgba)},r.prototype.toRgbString=function(){return t=ur(this.rgba),e=t.r,s=t.g,i=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+i+", "+n+")":"rgb("+e+", "+s+", "+i+")";var t,e,s,i,n},r.prototype.toHsl=function(){return Mn(os(this.rgba))},r.prototype.toHslString=function(){return t=Mn(os(this.rgba)),e=t.h,s=t.s,i=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+i+"%, "+n+")":"hsl("+e+", "+s+"%, "+i+"%)";var t,e,s,i,n},r.prototype.toHsv=function(){return t=_a(this.rgba),{h:pt(t.h),s:pt(t.s),v:pt(t.v),a:pt(t.a,3)};var t},r.prototype.invert=function(){return Ut({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),Ut(dr(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ut(dr(this.rgba,-t))},r.prototype.grayscale=function(){return Ut(dr(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Ut(kn(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Ut(kn(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?Ut({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):pt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=os(this.rgba);return typeof t=="number"?Ut({h:t,s:e.s,l:e.l,a:e.a}):pt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Ut(t).toHex()},r})(),Ut=function(r){return r instanceof zr?r:new zr(r)},Bn=[],zc=function(r){r.forEach(function(t){Bn.indexOf(t)<0&&(t(zr,Wr),Bn.push(t))})};function Vc(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in e)s[e[i]]=i;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=s[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var p in e){var g=(a=c,h=n[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 r(h).toRgb():null},"name"])}zc([Vc]);const Le=class ss{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 ss)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((n,o)=>n===e[o]);if(t!==null&&e!==null){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,s,i]=this._components;return{r:t,g:e,b:s,a:i}}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,i]=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(i*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,i,n]=this._components;return t[0]=e,t[1]=s,t[2]=i,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,i]=this._components;return t[0]=e,t[1]=s,t[2]=i,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,i,n]=ss._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(i<<8)+n}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,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,n=255]=t,e/=255,s/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=ss.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ut(t);o.isValid()&&({r:e,g:s,b:i,a:n}=o.rgba,e/=255,s/=255,i/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=i,this._components[3]=n,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((i,n)=>{t[n]=Math.min(Math.max(i,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof ss||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}};Le.shared=new Le;Le._temp=new Le;Le.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Q=Le;const Xc={cullArea:null,cullable:!1,cullableChildren:!0};let pr=0;const In=500;function z(...r){pr!==In&&(pr++,pr===In?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}const Xe={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class $c{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){var s;let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),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 jc{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 $c(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 mt=new jc;Xe.register(mt);const Yc={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){H("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(r)}};function ya(r,t,e){const s=r.length;let i;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(i=t;i<n;++i)r[i]=r[i+e];r.length=n}const qc={allowChildren:!0,removeChildren(r=0,t){var n;const e=t??this.children.length,s=e-r,i=[];if(s>0&&s<=e){for(let a=e-1;a>=r;a--){const h=this.children[a];h&&(i.push(h),h.parent=null)}ya(this.children,r,e);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(i);for(let a=0;a<i.length;++a){const h=i[a];(n=h.parentRenderLayer)==null||n.detach(h),this.emit("childRemoved",h,this,a),i[a].emit("removed",this)}return i.length>0&&this._didViewChangeTick++,i}else if(s===0&&this.children.length===0)return i;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){this.allowChildren||H(ot,"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(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const s=r.parent===this;if(r.parent){const n=r.parent.children.indexOf(r);if(s){if(n===t)return r;r.parent.children.splice(n,1)}else r.removeFromParent()}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),s||(this.emit("childAdded",r,this,t),r.emit("added",this)),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=r;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},Kc={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const s=this.children,i=s.length;for(let n=0;n<i;n++)s[n].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){const{renderPipes:s}=t;for(let i=0;i<this.effects.length;i++){const n=this.effects[i];s[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,t,e);for(let i=this.effects.length-1;i>=0;i--){const n=this.effects[i];s[n.pipe].pop(n,this,r)}}};class js{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 Zc{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 mt.get(s.maskClass,t)}return t}returnMaskEffect(t){mt.return(t)}}const Vr=new Zc;W.handleByList(b.MaskEffect,Vr._effectClasses);const Qc={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((e,s)=>e.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),Vr.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=Vr.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions={...this._maskOptions,...r},r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var n;!Array.isArray(r)&&r&&(r=[r]);const t=this._filterEffect||(this._filterEffect=new js);r=r;const e=(r==null?void 0:r.length)>0,s=((n=t.filters)==null?void 0:n.length)>0,i=e!==s;r=Array.isArray(r)?r.slice(0):r,t.filters=Object.freeze(r),i&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=r??null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new js),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Jc={label:null,get name(){return H(ot,"Container.name property has been removed, use Container.label instead"),this.label},set name(r){H(ot,"Container.name property has been removed, use Container.label instead"),this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const i=e[s];if(i.label===r||r instanceof RegExp&&r.test(i.label))return i}if(t)for(let s=0;s<e.length;s++){const n=e[s].getChildByLabel(r,!0);if(n)return n}return null},getChildrenByLabel(r,t=!1,e=[]){const s=this.children;for(let i=0;i<s.length;i++){const n=s[i];(n.label===r||r instanceof RegExp&&r.test(n.label))&&e.push(n)}if(t)for(let i=0;i<s.length;i++)s[i].getChildrenByLabel(r,!0,e);return e}},bt=mt.getPool(G),qt=mt.getPool(_t),tu=new G,eu={getFastGlobalBounds(r,t){t||(t=new _t),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let s=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(s=qt.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 n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,s,e)}if(i){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,s.applyMatrix(o.worldTransform)),this.effects[a].addBounds(s,!0));n&&s.applyMatrix(o.worldTransform.copyTo(tu).invert()),t.addBounds(s),qt.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),qt.return(s))}};function pi(r,t,e){e.clear();let s,i;return r.parent?t?s=r.parent.worldTransform:(i=bt.get().identity(),s=mi(r,i)):s=G.IDENTITY,ba(r,e,s,t),i&&bt.return(i),e.isValid||e.set(0,0,0,0),e}function ba(r,t,e,s){var a,h;if(!r.visible||!r.measurable)return;let i;s?i=r.worldTransform:(r.updateLocalTransform(),i=bt.get(),i.appendFrom(r.localTransform,e));const n=t,o=!!r.effects.length;if(o&&(t=qt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,i);else{const l=r.bounds;l&&!l.isEmpty()&&(t.matrix=i,t.addBounds(l));for(let c=0;c<r.children.length;c++)ba(r.children[c],t,i,s)}if(o){for(let l=0;l<r.effects.length;l++)(h=(a=r.effects[l]).addBounds)==null||h.call(a,t);n.addBounds(t,G.IDENTITY),qt.return(t)}s||bt.return(i)}function mi(r,t){const e=r.parent;return e&&(mi(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function De(r,t){if(r===16777215||!t)return t;if(t===16777215||!r)return r;const e=r>>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255|0,l=s*o/255|0,c=i*a/255|0;return(h<<16)+(l<<8)+c}const Gn=16777215;function Ys(r,t){return r===Gn?t:t===Gn?r:De(r,t)}function Ue(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const su={getGlobalAlpha(r){if(r)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(r=new G,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=mi(this,bt.get().identity());return r.appendFrom(this.localTransform,e),bt.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?Ue(this.renderGroup.worldColor):this.parentRenderGroup?Ue(Ys(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Ys(t,e.localColor),e=e.parent;return Ue(t)}};function gi(r,t,e){return t.clear(),e||(e=G.IDENTITY),va(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function va(r,t,e,s,i){var h,l;let n;if(i)n=bt.get(),n=e.copyTo(n);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;n=bt.get(),n.appendFrom(c,e)}const o=t,a=!!r.effects.length;if(a&&(t=qt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,n);else{r.renderPipeId&&(t.matrix=n,t.addBounds(r.bounds));const c=r.children;for(let u=0;u<c.length;u++)va(c[u],t,n,s,!1)}if(a){for(let c=0;c<r.effects.length;c++)(l=(h=r.effects[c]).addLocalBounds)==null||l.call(h,t,s);o.addBounds(t,G.IDENTITY),qt.return(t)}bt.return(n)}function Ta(r,t){const e=r.children;for(let s=0;s<e.length;s++){const i=e[s],n=i.uid,o=(i._didViewChangeTick&65535)<<16|i._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,i.children.length&&Ta(i,t)}return t.didChange}const ru=new G,iu={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=r/t*e:this.scale.x=e},_setHeight(r,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=r/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new _t});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),Ta(this,r),r.didChange&&gi(this,r.localBounds,ru),r.localBounds},getBounds(r,t){return pi(this,r,t||new _t)}},nu={_onRender:null,set onRender(r){const t=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},ou={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,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(au))}};function au(r,t){return r._zIndex-t._zIndex}const hu={getGlobalPosition(r=new st,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){const s=this.getGlobalTransform(bt.get(),e);return t=s.apply(r,t),bt.return(s),t},toLocal(r,t,e,s){t&&(r=t.toGlobal(r,e,s));const i=this.getGlobalTransform(bt.get(),s);return e=i.applyInverse(r,e),bt.return(i),e}};class _i{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 lu=0;class cu{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new _e(this.textureOptions)}createTexture(t,e,s,i){const n=new ft({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:i});return new L({source:n,label:`texturePool_${lu++}`})}getOptimalTexture(t,e,s=1,i,n=!1){let o=Math.ceil(t*s-1e-6),a=Math.ceil(e*s-1e-6);o=Oe(o),a=Oe(a);const h=i?1:0,l=n?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,i,n)),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 i=0;i<s.length;i++)s[i].destroy(!0)}this._texturePool={}}}const yt=new cu;Xe.register(yt);class Xr{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new G,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 _i,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 i=e[s];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(yt.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 i=0;i<s.length;i++)this._getChildren(s[i],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new G),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new G),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 G),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 uu(r,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(r[s]=t[s])}const mr=new gt(null),Ps=new gt(null),gr=new gt(null,1,1),Ms=new gt(null),qs=1,xi=2,as=4;class vt extends kt{constructor(t={}){var e,s;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 G,this.relativeGroupTransform=new G,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new gt(this,0,0),this._scale=gr,this._pivot=Ps,this._origin=Ms,this._skew=mr,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=[],uu(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(i=>this.addChild(i)),(s=t.parent)==null||s.addChild(this)}static mixin(t){H("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),W.mixin(vt,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||H(ot,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let i=0;i<t.length;i++)this.addChild(t[i]);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 i=0;i<t.length;i++)this.removeChild(t[i]);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==null||t.removeChild(this),this.renderGroup=mt.get(Xr,this),this.groupTransform=G.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),mt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new G),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*Ac}set angle(t){this.rotation=t*Rc}get pivot(){return this._pivot===Ps&&(this._pivot=new gt(this,0,0)),this._pivot}set pivot(t){this._pivot===Ps&&(this._pivot=new gt(this,0,0),this._origin!==Ms&&z("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===mr&&(this._skew=new gt(this,0,0)),this._skew}set skew(t){this._skew===mr&&(this._skew=new gt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===gr&&(this._scale=new gt(this,1,1)),this._scale}set scale(t){this._scale===gr&&(this._scale=new gt(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===Ms&&(this._origin=new gt(this,0,0)),this._origin}set origin(t){this._origin===Ms&&(this._origin=new gt(this,0,0),this._pivot!==Ps&&z("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||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1: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,i=this._pivot,n=this._origin,o=this._position,a=s._x,h=s._y,l=i._x,c=i._y,u=-n._x,d=-n._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|=qs,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Q.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=qs,this._onUpdate())}get tint(){return Ue(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=xi,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|=as,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|=as,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|=as,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var i;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==null?void 0:t.children)&&e)for(let n=0;n<e.length;++n)e[n].destroy(t);(i=this.renderGroup)==null||i.destroy(),this.renderGroup=null}}W.mixin(vt,qc,eu,hu,nu,iu,Qc,Jc,ou,Xc,Yc,su,Kc);class yi extends vt{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:i}=t;return s>=e.minX&&s<=e.maxX&&i>=e.minY&&i<=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(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||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:i}=e;i.blendMode.pushBlendMode(this,this.groupBlendMode,t);const o=i[this.renderPipeId];o!=null&&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);i.blendMode.popBlendMode(t)}}class Ne extends yi{constructor(t=L.EMPTY){t instanceof L&&(t={texture:t});const{texture:e=L.EMPTY,anchor:s,roundPixels:i,width:n,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 gt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=i??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof L?new Ne(t):new Ne(L.from(t,e))}set texture(t){t||(t=L.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 ma(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return H("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:i,height:n}=e.orig;s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*n,s.maxY=s.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0: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 du=new _t;function Sa(r,t,e){const s=du;r.measurable=!0,pi(r,e,s),t.addBoundsMask(s),r.measurable=!1}function Ca(r,t,e){const s=qt.get();r.measurable=!0;const i=bt.get().identity(),n=wa(r,e,i);gi(r,s,n),r.measurable=!1,t.addBoundsMask(s),bt.return(i),qt.return(s)}function wa(r,t,e){return r?(r!==t&&(wa(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e):(z("Mask bounds, renderable is not inside the root container"),e)}class Ea{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Ne),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||Sa(this.mask,t,e)}addLocalBounds(t,e){Ca(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Ne}}Ea.extension=b.MaskEffect;class Pa{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Pa.extension=b.MaskEffect;class Ma{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&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){Sa(this.mask,t,e)}addLocalBounds(t,e){Ca(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof vt}}Ma.extension=b.MaskEffect;const fu={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let Fn=fu;const j={get(){return Fn},set(r){Fn=r}};class Lt extends ft{constructor(t){t.resource||(t.resource=j.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 i=super.resize(t,e,s);return i&&this.resizeCanvas(),i}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"))}}Lt.extension=b.TextureSource;class Ks extends ft{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}}Ks.extension=b.TextureSource;var He=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(He||{});class _r{constructor(t,e=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=i}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 Aa=class Ct{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 _r(null,null,1/0),this.deltaMS=1/Ct.targetFPMS,this.elapsedMS=1/Ct.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=He.NORMAL){return this._addListener(new _r(t,e,s))}addOnce(t,e,s=He.NORMAL){return this._addListener(new _r(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 n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Ct.targetFPMS;const s=this._head;let i=s.next;for(;i;)i=i.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,Ct.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(!Ct._shared){const t=Ct._shared=new Ct;t.autoStart=!0,t._protected=!0}return Ct._shared}static get system(){if(!Ct._system){const t=Ct._system=new Ct;t.autoStart=!0,t._protected=!0}return Ct._system}};Aa.targetFPMS=.06;let At=Aa,xr;async function pu(){return xr??(xr=(async()=>{var o;const t=j.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const h=document.createElement("video");h.onloadeddata=()=>a(h),h.onerror=()=>a(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),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 n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(s),(o=t.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),xr}const ir=class Ra extends ft{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Ra.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=At.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 pu(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,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&&(At.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||(At.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(At.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};ir.extension=b.TextureSource;ir.defaultOptions={...ft.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};ir.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let mu=ir;const ke=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);class gu{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||z(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=ke(t);let i;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){i=l.getCacheableAssets(s,e);break}}const n=new Map(Object.entries(i||{}));i||s.forEach(h=>{n.set(h,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=i?i[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&z("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){z(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Be=new gu,$r=[];W.handleByList(b.TextureSource,$r);function ka(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i<$r.length;i++){const n=$r[i];if(n.test(e))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function _u(r={},t=!1){const e=r&&r.resource,s=e?r.resource:r,i=e?r:{resource:r};if(!t&&Be.has(s))return Be.get(s);const n=new L({source:ka(i)});return n.on("destroy",()=>{Be.has(s)&&Be.remove(s)}),t||Be.set(s,n),n}function xu(r,t=!1){return typeof r=="string"?Be.get(r):r instanceof ft?new L({source:r}):_u(r,t)}L.from=xu;ft.from=ka;W.add(Ea,Pa,Ma,mu,Ks,Lt,fi);var Ba=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ba||{});function It(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function qe(r){return r.split("?")[0].split("#")[0]}function yu(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bu(r,t,e){return r.replace(new RegExp(yu(t),"g"),e)}function vu(r,t){let e="",s=0,i=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||n===1))if(i!==a-1&&n===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("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,i=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(i+1,a)}`:e=r.slice(i+1,a),s=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const ds={toPosix(r){return bu(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){It(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(It(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=qe(this.toPosix(t??j.get().getBaseUrl())),i=qe(this.toPosix(e??this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?ds.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(It(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const s=r.endsWith("/");return r=vu(r),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return It(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const s=r[e];if(It(s),s.length>0)if(t===void 0)t=s;else{const i=r[e-1]??"";this.joinExtensions.includes(this.extname(i).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(It(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let s=-1,i=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!i){s=a;break}}else i=!1;return s===-1?e?"/":this.isUrl(o)?n+r:n:e&&s===1?"//":n+r.slice(0,s)},rootname(r){It(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){It(r),t&&It(t),r=qe(this.toPosix(r));let e=0,s=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const h=r.charCodeAt(n);if(h===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=r.length),r.slice(e,s)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!i){e=n+1;break}}else s===-1&&(i=!1,s=n+1);return s===-1?"":r.slice(e,s)},extname(r){It(r),r=qe(this.toPosix(r));let t=-1,e=0,s=-1,i=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!i){e=o+1;break}continue}s===-1&&(i=!1,s=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":r.slice(t,s)},parse(r){It(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=qe(this.toPosix(r));let e=r.charCodeAt(0);const s=this.isAbsolute(r);let i;t.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let n=-1,o=0,a=-1,h=!0,l=r.length-1,c=0;for(;l>=i;--l){if(e=r.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&s?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&s?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Ia(r,t,e,s,i){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Ia(r.replace(s[e],a),t,e+1,s,i):i.push(r.replace(s[e],a))}}function Tu(r){const t=/\{(.*?)\}/g,e=r.match(t),s=[];if(e){const i=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");i.push(o)}),Ia(r,i,0,e,s)}else s.push(r);return s}const Dn=r=>!Array.isArray(r);class Ga{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 ke(e||s,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&z("[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 i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),i.forEach(n=>{const o=n.src,a=n.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({...n,alias:h,src:o})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=n=>{this.hasKey(n)&&z(`[Resolver] already has key: ${n} overwriting`)},ke(e).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const u=ke(o).map(g=>typeof g=="string"?Tu(g):Array.isArray(g)?g:[g]),d=this.getAlias(n);Array.isArray(d)?d.forEach(s):s(d);const f=[],p=g=>{const m=this._parsers.find(_=>_.test(g));return{src:g,...m==null?void 0: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:n.progressSize}),f.push(_)})}),d.forEach(g=>{this._assetMap[g]=f})})}resolveBundle(t){const e=Dn(t);t=ke(t);const s={};return t.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(i,h)]=l}s[i]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const i in e)s[i]=e[i].src;return s}return e.src}resolve(t){const e=Dn(t);t=ke(t);const s={};return t.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let n=this._assetMap[i];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),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],i=this._preferredOrder.find(n=>n.params.format.includes(s.format));if(i)return i}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:i,loadParser:n,parser:o,format:a,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=ds.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...i||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??Su(t.src),h!==void 0&&(t.progressSize=h),t}}Ga.RETINA_PREFIX=/@([0-9\.]+)x/;function Su(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Un=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},Fa=class rs{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof ft&&(s={texture:t,data:e});const{texture:i,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=i instanceof L?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,i.source.resolution=this.resolution):this.resolution=i.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<=rs.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 i=e?1/0:rs.BATCH_SIZE;for(;s-t<i&&s<this._frameKeys.length;){const n=this._frameKeys[s],o=this._frames[n],a=o.frame;if(a){let h=null,l=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,u=new tt(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?h=new tt(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 tt(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 tt(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[n]=new L({source:this.textureSource,frame:h,orig:u,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.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 i=t[e][s];this.animations[e].push(this.textures[i])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*rs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*rs.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Fa.BATCH_SIZE=1e3;let On=Fa;const Cu=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Da(r,t,e){const s={};if(r.forEach(i=>{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[`${t.cachePrefix}${i}`]=t.textures[i]}),!e){const i=ds.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Da([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const wu={extension:b.Asset,cache:{test:r=>r instanceof On,getCacheableAssets:(r,t)=>Da(r,t,!1)},resolver:{extension:{type:b.ResolveParser,name:"resolveSpritesheet"},test:r=>{const e=r.split("?")[0].split("."),s=e.pop(),i=e.pop();return s==="json"&&Cu.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=Ga.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:b.LoadParser,priority:Ba.Normal,name:"spritesheetLoader"},async testParse(r,t){return ds.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var u,d;const{texture:s,imageFilename:i,textureOptions:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let a=ds.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(s instanceof L)h=s;else{const f=Un(a+(i??r.meta.image),t.src);h=(await e.load([{src:f,data:n}]))[f]}const l=new On({texture:h.source,data:r,cachePrefix:o});await l.parse();const c=(u=r==null?void 0:r.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(c)){const f=[];for(const g of c){if(typeof g!="string")continue;let m=a+g;(d=t.data)!=null&&d.ignoreMultiPack||(m=Un(m,t.src),f.push(e.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}const p=await Promise.all(f);l.linkedSheets=p,p.forEach(g=>{g.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==g))})}return l},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};W.add(wu);class Ua{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,i=this._canvas.height,n=e.width/s*this._renderer.resolution,o=e.height/i*this._renderer.resolution,a=e.left,h=e.top,l=`translate(${a}px, ${h}px) scale(${n}, ${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,i=this.canvas.height,n=e.contentRect.width/s*this._renderer.resolution,o=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||At.shared.add(this.updateTranslation,this,He.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&At.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 ys{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ys.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new st,this.page=new st,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,i,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var yr=/iPhone/i,Ln=/iPod/i,Nn=/iPad/i,Hn=/\biOS-universal(?:.+)Mac\b/i,br=/\bAndroid(?:.+)Mobile\b/i,Wn=/Android/i,Ce=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,As=/Silk/i,Xt=/Windows Phone/i,zn=/\bWindows(?:.+)ARM\b/i,Vn=/BlackBerry/i,Xn=/BB10/i,$n=/Opera Mini/i,jn=/\b(CriOS|Chrome)(?:.+)Mobile/i,Yn=/Mobile(?:.+)Firefox\b/i,qn=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Eu(r){return function(t){return t.test(r)}}function Kn(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]<"u"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]<"u"&&(e=s[0]);var i=Eu(e),n={apple:{phone:i(yr)&&!i(Xt),ipod:i(Ln),tablet:!i(yr)&&(i(Nn)||qn(t))&&!i(Xt),universal:i(Hn),device:(i(yr)||i(Ln)||i(Nn)||i(Hn)||qn(t))&&!i(Xt)},amazon:{phone:i(Ce),tablet:!i(Ce)&&i(As),device:i(Ce)||i(As)},android:{phone:!i(Xt)&&i(Ce)||!i(Xt)&&i(br),tablet:!i(Xt)&&!i(Ce)&&!i(br)&&(i(As)||i(Wn)),device:!i(Xt)&&(i(Ce)||i(As)||i(br)||i(Wn))||i(/\bokhttp\b/i)},windows:{phone:i(Xt),tablet:i(zn),device:i(Xt)||i(zn)},other:{blackberry:i(Vn),blackberry10:i(Xn),opera:i($n),firefox:i(Yn),chrome:i(jn),device:i(Vn)||i(Xn)||i($n)||i(Yn)||i(jn)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Pu=Kn.default??Kn,Mu=Pu(globalThis.navigator),Au=9,Zn=100,Ru=0,ku=0,Qn=2,Jn=1,Bu=-1e3,Iu=-1e3,Gu=2,bi=class Oa{constructor(t,e=Mu){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=`${Jn}px`,t.style.height=`${Jn}px`,t.style.position="absolute",t.style.top=`${Bu}px`,t.style.left=`${Iu}px`,t.style.zIndex=Gu.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=`${Ru}px`,this._div.style.left=`${ku}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=Qn.toString(),this._canvasObserver=new Ua({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(){var t,e;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 s of this._children)(t=s._accessibleDiv)!=null&&t.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1;for(const s in this._pools)this._pools[s].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[s];(e=this._div)!=null&&e.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:{...Oa.defaultOptions,...(t==null?void 0: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 i=this._children[s];e.has(s)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,ya(this._children,s,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let s=0;s<this._children.length;s++){const i=this._children[s];if(!i._accessibleActive||!i._accessibleDiv)continue;const n=i._accessibleDiv,o=i.hitArea||i.getBounds().rectangle;if(i.hitArea){const a=i.worldTransform;n.style.left=`${a.tx+o.x*a.a}px`,n.style.top=`${a.ty+o.y*a.d}px`,n.style.width=`${o.width*a.a}px`,n.style.height=`${o.height*a.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.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=`${Zn}px`,s.style.height=`${Zn}px`,s.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",s.style.position="absolute",s.style.zIndex=Qn.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,i=this._renderer.events.rootBoundary,n=Object.assign(new ys(i),{target:s});i.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>i.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode!==Au||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),(t=this._canvasObserver)==null||t.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]}};bi.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"accessibility"};bi.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Fu=bi;const Du={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1},vr=Object.create(null),to=Object.create(null);function fs(r,t){let e=to[r];return e===void 0&&(vr[t]===void 0&&(vr[t]=1),to[r]=e=vr[t]++),e}let we;function La(){return(!we||we!=null&&we.isContextLost())&&(we=j.get().createCanvas().getContext("webgl",{})),we}let Rs;function Uu(){if(!Rs){Rs="mediump";const r=La();r&&r.getShaderPrecisionFormat&&(Rs=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Rs}function Ou(r,t,e){return t?r:e?(r=r.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
+ ${r}
25
+ `):`
26
+
27
+ #ifdef GL_ES // This checks if it is WebGL1
28
+ #define in attribute
29
+ #define out varying
30
+ #endif
31
+ ${r}
32
+ `}function Lu(r,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let i=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i==="highp"&&s!=="highp"&&(i="mediump"),`precision ${i} float;
33
+ ${r}`}else if(s!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function Nu(r,t){return t?`#version 300 es
34
+ ${r}`:r}const Hu={},Wu={};function zu(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Hu:Wu;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
35
+ ${r}`}function Vu(r,t){return t?r.replace("#version 300 es",""):r}const Tr={stripVersion:Vu,ensurePrecision:Lu,addProgramDefines:Ou,setProgramName:zu,insertVersion:Nu},Ke=Object.create(null),Na=class jr{constructor(t){t={...jr.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Uu()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(Tr).forEach(o=>{const a=s[o];i=Tr[o](i,a,!0),n=Tr[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=fs(`${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,Ke[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Ke[e]||(Ke[e]=new jr(t),Ke[e]._cacheKey=e),Ke[e]}};Na.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let $e=Na;const eo={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 ps(r){return eo[r]??eo.float32}const Xu={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"},so=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function ro(r,t){let e;for(;(e=so.exec(r))!==null;){const s=Xu[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:s,stride:ps(s).stride,offset:0,instance:!1,start:0}}so.lastIndex=0}function $u(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function ju({source:r,entryPoint:t}){const e={},s=$u(r),i=s.indexOf(`fn ${t}(`);if(i===-1)return e;const n=s.indexOf("->",i);if(n===-1)return e;const o=s.substring(i,n);if(ro(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&&ro(c[1],e)}}return e}function Sr(r){var u,d;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,i=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(u=r.match(t))==null?void 0:u.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(s)[1],10),name:f.match(i)[2],isUniform:f.match(i)[1]==="<uniform>",type:f.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((d=r.match(o))==null?void 0:d.map(f=>{const p=f.match(h)[1],g=f.match(a).reduce((m,_)=>{const[x,y]=_.split(":");return m[x.trim()]=y.trim(),m},{});return g?{name:p,members:g}:null}).filter(({name:f})=>l.some(p=>p.type===f||p.type.includes(`<${f}>`))))??[];return{groups:l,structs:c}}var de=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(de||{});function Yu({groups:r}){const t=[];for(let e=0;e<r.length;e++){const s=r[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:de.VERTEX|de.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:de.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:de.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:de.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:de.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function qu({groups:r}){const t=[];for(let e=0;e<r.length;e++){const s=r[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function Ku(r,t){const e=new Set,s=new Set,i=[...r.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:i,groups:n}}const Ze=Object.create(null);class ye{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:i,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=s,e.source===s.source){const l=Sr(e.source);this.structsAndGroups=l}else{const l=Sr(s.source),c=Sr(e.source);this.structsAndGroups=Ku(l,c)}this.layout=i??qu(this.structsAndGroups),this.gpuLayout=n??Yu(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=fs(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=ju(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Ze[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Ze[e]||(Ze[e]=new ye(t),Ze[e]._cacheKey=e),Ze[e]}}const Ha=["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>"],Zu=Ha.reduce((r,t)=>(r[t]=!0,r),{});function Qu(r,t){switch(r){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 Wa=class za{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={...za.defaultOptions,...e},this.uniformStructures=t;const s={};for(const i in t){const n=t[i];if(n.name=i,n.size=n.size??1,!Zu[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Ha.join(", ")}`)}n.value??(n.value=Qu(n.type,n.size)),s[i]=n.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=fs(Object.keys(s).map(i=>`${i}-${t[i].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Wa.defaultOptions={ubo:!1,isStatic:!1};let Wt=Wa;class re{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const i=t[s];this.setResource(i,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){var i,n;const s=this.resources[e];t!==s&&((i=s==null?void 0:s.off)==null||i.call(s,"change",this.onResourceChange,this),(n=t.on)==null||n.call(t,"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 i in s)s[i]._gcLastUsed=t,s[i]._touched=e}destroy(){var e;const t=this.resources;for(const s in t){const i=t[s];(e=i==null?void 0:i.off)==null||e.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var Nt=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Nt||{});class Zt extends kt{constructor(t){super(),this.uid=et("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=Nt.WEBGPU),s&&(o|=Nt.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&i&&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&&i&&!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(n){i={},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 n)h[c]||(i[99]||(i[99]=new re,this._ownedBindGroups.push(i[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const u=c;let d=n[c];!d.source&&!d._resourceType&&(d=new Wt(d));const f=h[u];f&&(i[f.group]||(i[f.group]=new re,this._ownedBindGroups.push(i[f.group])),i[f.group].setResource(d,f.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,h)}addResource(t,e,s){var i,n;(i=this._uniformBindMap)[e]||(i[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new re,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const i in e){const n=e[i];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return s}destroy(t=!1){var e,s;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(i=>{i.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:s,...i}=t;let n,o;return e&&(n=ye.from(e)),s&&(o=$e.from(s)),new Zt({gpuProgram:n,glProgram:o,...i})}}const Ju={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},Cr=0,wr=1,Er=2,Pr=3,Mr=4,Ar=5,Yr=class Va{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Cr)}set blend(t){!!(this.data&1<<Cr)!==t&&(this.data^=1<<Cr)}get offsets(){return!!(this.data&1<<wr)}set offsets(t){!!(this.data&1<<wr)!==t&&(this.data^=1<<wr)}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<<Er)}set culling(t){!!(this.data&1<<Er)!==t&&(this.data^=1<<Er)}get depthTest(){return!!(this.data&1<<Pr)}set depthTest(t){!!(this.data&1<<Pr)!==t&&(this.data^=1<<Pr)}get depthMask(){return!!(this.data&1<<Ar)}set depthMask(t){!!(this.data&1<<Ar)!==t&&(this.data^=1<<Ar)}get clockwiseFrontFace(){return!!(this.data&1<<Mr)}set clockwiseFrontFace(t){!!(this.data&1<<Mr)!==t&&(this.data^=1<<Mr)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=Ju[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 Va;return t.depthTest=!1,t.blend=!0,t}};Yr.default2d=Yr.for2d();let Qt=Yr;const Xa=class qr extends Zt{constructor(t){t={...qr.defaultOptions,...t},super(t),this.enabled=!0,this._state=Qt.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,i){t.applyFilter(this,e,s,i)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:s,...i}=t;let n,o;return e&&(n=ye.from(e)),s&&(o=$e.from(s)),new qr({gpuProgram:n,glProgram:o,...i})}};Xa.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let $a=Xa;const Kr=[];W.handleByNamedList(b.Environment,Kr);async function td(r){if(!r)for(let t=0;t<Kr.length;t++){const e=Kr[t];if(e.value.test()){await e.value.load();return}}}let Qe;function ja(){if(typeof Qe=="boolean")return Qe;try{Qe=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Qe=!1}return Qe}function io(r,t,e=2){const s=t&&t.length,i=s?t[0]*e:r.length;let n=Ya(r,0,i,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(s&&(n=nd(r,t,n,e)),r.length>80*e){a=r[0],h=r[1];let c=a,u=h;for(let d=e;d<i;d+=e){const f=r[d],p=r[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 ms(n,o,e,a,h,l,0),o}function Ya(r,t,e,s,i){let n;if(i===gd(r,t,e,s)>0)for(let o=t;o<e;o+=s)n=no(o/s|0,r[o],r[o+1],n);else for(let o=e-s;o>=t;o-=s)n=no(o/s|0,r[o],r[o+1],n);return n&&We(n,n.next)&&(_s(n),n=n.next),n}function xe(r,t){if(!r)return r;t||(t=r);let e=r,s;do if(s=!1,!e.steiner&&(We(e,e.next)||at(e.prev,e,e.next)===0)){if(_s(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function ms(r,t,e,s,i,n,o){if(!r)return;!o&&n&&cd(r,s,i,n);let a=r;for(;r.prev!==r.next;){const h=r.prev,l=r.next;if(n?sd(r,s,i,n):ed(r)){t.push(h.i,r.i,l.i),_s(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=rd(xe(r),t),ms(r,t,e,s,i,n,2)):o===2&&id(r,t,e,s,i,n):ms(xe(r),t,e,s,i,n,1);break}}}function ed(r){const t=r.prev,e=r,s=r.next;if(at(t,e,s)>=0)return!1;const i=t.x,n=e.x,o=s.x,a=t.y,h=e.y,l=s.y,c=Math.min(i,n,o),u=Math.min(a,h,l),d=Math.max(i,n,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&&is(i,a,n,h,o,l,p.x,p.y)&&at(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function sd(r,t,e,s){const i=r.prev,n=r,o=r.next;if(at(i,n,o)>=0)return!1;const a=i.x,h=n.x,l=o.x,c=i.y,u=n.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),_=Zr(f,p,t,e,s),x=Zr(g,m,t,e,s);let y=r.prevZ,v=r.nextZ;for(;y&&y.z>=_&&v&&v.z<=x;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==i&&y!==o&&is(a,c,h,u,l,d,y.x,y.y)&&at(y.prev,y,y.next)>=0||(y=y.prevZ,v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==i&&v!==o&&is(a,c,h,u,l,d,v.x,v.y)&&at(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==i&&y!==o&&is(a,c,h,u,l,d,y.x,y.y)&&at(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==i&&v!==o&&is(a,c,h,u,l,d,v.x,v.y)&&at(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function rd(r,t){let e=r;do{const s=e.prev,i=e.next.next;!We(s,i)&&Ka(s,e,e.next,i)&&gs(s,i)&&gs(i,s)&&(t.push(s.i,e.i,i.i),_s(e),_s(e.next),e=r=i),e=e.next}while(e!==r);return xe(e)}function id(r,t,e,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&fd(o,a)){let h=Za(o,a);o=xe(o,o.next),h=xe(h,h.next),ms(o,t,e,s,i,n,0),ms(h,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function nd(r,t,e,s){const i=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*s,h=n<o-1?t[n+1]*s:r.length,l=Ya(r,a,h,s,!1);l===l.next&&(l.steiner=!0),i.push(dd(l))}i.sort(od);for(let n=0;n<i.length;n++)e=ad(i[n],e);return e}function od(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const s=(r.next.y-r.y)/(r.next.x-r.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=s-i}return e}function ad(r,t){const e=hd(r,t);if(!e)return t;const s=Za(e,r);return xe(s,s.next),xe(e,e.next)}function hd(r,t){let e=t;const s=r.x,i=r.y;let n=-1/0,o;if(We(r,e))return e;do{if(We(r,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const u=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=s&&u>n&&(n=u,o=e.x<e.next.x?e:e.next,u===s))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;e=o;do{if(s>=e.x&&e.x>=h&&s!==e.x&&qa(i<l?s:n,i,h,l,i<l?n:s,i,e.x,e.y)){const u=Math.abs(i-e.y)/(s-e.x);gs(e,r)&&(u<c||u===c&&(e.x>o.x||e.x===o.x&&ld(o,e)))&&(o=e,c=u)}e=e.next}while(e!==a);return o}function ld(r,t){return at(r.prev,r,t.prev)<0&&at(t.next,r,r.next)<0}function cd(r,t,e,s){let i=r;do i.z===0&&(i.z=Zr(i.x,i.y,t,e,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,ud(i)}function ud(r){let t,e=1;do{let s=r,i;r=null;let n=null;for(t=0;s;){t++;let o=s,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let h=e;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||s.z<=o.z)?(i=s,s=s.nextZ,a--):(i=o,o=o.nextZ,h--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;s=o}n.nextZ=null,e*=2}while(t>1);return r}function Zr(r,t,e,s,i){return r=(r-e)*i|0,t=(t-s)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function dd(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function qa(r,t,e,s,i,n,o,a){return(i-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(s-a)}function is(r,t,e,s,i,n,o,a){return!(r===o&&t===a)&&qa(r,t,e,s,i,n,o,a)}function fd(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!pd(r,t)&&(gs(r,t)&&gs(t,r)&&md(r,t)&&(at(r.prev,r,t.prev)||at(r,t.prev,t))||We(r,t)&&at(r.prev,r,r.next)>0&&at(t.prev,t,t.next)>0)}function at(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function We(r,t){return r.x===t.x&&r.y===t.y}function Ka(r,t,e,s){const i=Bs(at(r,t,e)),n=Bs(at(r,t,s)),o=Bs(at(e,s,r)),a=Bs(at(e,s,t));return!!(i!==n&&o!==a||i===0&&ks(r,e,t)||n===0&&ks(r,s,t)||o===0&&ks(e,r,s)||a===0&&ks(e,t,s))}function ks(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Bs(r){return r>0?1:r<0?-1:0}function pd(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Ka(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function gs(r,t){return at(r.prev,r,r.next)<0?at(r,t,r.next)>=0&&at(r,r.prev,t)>=0:at(r,t,r.prev)<0||at(r,r.next,t)<0}function md(r,t){let e=r,s=!1;const i=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&i<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==r);return s}function Za(r,t){const e=Qr(r.i,r.x,r.y),s=Qr(t.i,t.x,t.y),i=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function no(r,t,e,s){const i=Qr(r,t,e);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function _s(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Qr(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function gd(r,t,e,s){let i=0;for(let n=t,o=e-s;n<e;n+=s)i+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return i}const _d=io.default||io;var wt=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(wt||{});class Qa{constructor(t){this.items=[],this._name=t}emit(t,e,s,i,n,o,a,h){const{name:l,items:c}=this;for(let u=0,d=c.length;u<d;u++)c[u][l](t,e,s,i,n,o,a,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const xd=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Ja=class th extends kt{constructor(t){super(),this.tick=0,this.uid=et("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...xd,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await td(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...th.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(t);this._initOptions=t}render(t,e){this.tick++;let s=t;if(s instanceof vt&&(s={container:s},e&&(H(ot,"passing a second argument is deprecated, please use render options instead"),s.target=e.renderTexture)),s.target||(s.target=this.view.renderTarget),s.target===this.view.renderTarget&&(this._lastObjectRendered=s.container,s.clearColor??(s.clearColor=this.background.colorRgba),s.clear??(s.clear=this.background.clearBeforeRender)),s.clearColor){const i=Array.isArray(s.clearColor)&&s.clearColor.length===4;s.clearColor=i?s.clearColor:Q.shared.setValue(s.clearColor).toArray()}s.transform||(s.container.updateLocalTransform(),s.transform=s.container.localTransform),s.container.visible&&(s.container.enableRenderGroup(),this.runners.prerender.emit(s),this.runners.renderStart.emit(s),this.runners.render.emit(s),this.runners.renderEnd.emit(s),this.runners.postrender.emit(s))}resize(t,e,s){const i=this.view.resolution;this.view.resize(t,e,s),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),s!==void 0&&s!==i&&this.runners.resolutionChange.emit(s)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=wt.ALL);const{clear:s,clearColor:i,target:n,mipLevel:o,layer:a}=t;Q.shared.setValue(i??this.background.colorRgba),e.renderTarget.clear(n,s,Q.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Qa(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const i in this.runners)this.runners[i].add(s);return this}_addPipes(t,e){const s=e.reduce((i,n)=>(i[n.name]=n.value,i),{});t.forEach(i=>{const n=i.value,o=i.name,a=s[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Xe.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ja())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Ja.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let bs=Ja,Is;function yd(r){return Is!==void 0||(Is=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:r??bs.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let i=j.get().createCanvas().getContext("webgl",t);const n=!!((e=i==null?void 0:i.getContextAttributes())!=null&&e.stencil);if(i){const o=i.getExtension("WEBGL_lose_context");o&&o.loseContext()}return i=null,n}catch{return!1}})()),Is}let Gs;async function bd(r={}){return Gs!==void 0||(Gs=await(async()=>{const t=j.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),Gs}const oo=["webgl","webgpu","canvas"];async function vd(r){let t=[];r.preference?Array.isArray(r.preference)?t=r.preference.slice():(t.push(r.preference),oo.forEach(n=>{n!==r.preference&&t.push(n)})):t=oo.slice();let e,s={};for(let n=0;n<t.length;n++){const o=t[n];if(o==="webgpu"&&await bd()){const{WebGPURenderer:a}=await ns(async()=>{const{WebGPURenderer:h}=await Promise.resolve().then(()=>p_);return{WebGPURenderer:h}},void 0);e=a,s={...r,...r.webgpu};break}else if(o==="webgl"&&yd(r.failIfMajorPerformanceCaveat??bs.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await ns(async()=>{const{WebGLRenderer:h}=await Promise.resolve().then(()=>$g);return{WebGLRenderer:h}},void 0);e=a,s={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await ns(async()=>{const{CanvasRenderer:h}=await Promise.resolve().then(()=>Xm);return{CanvasRenderer:h}},void 0);e=a,s={...r,...r.canvasOptions};break}}if(delete s.webgpu,delete s.webgl,delete s.canvasOptions,!e)throw new Error("No available renderer for the current environment");const i=new e;return await i.init(s),i}const Zs="8.18.1";class eh{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Zs)}static destroy(){}}eh.extension=b.Application;class sh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Zs)}destroy(){this._renderer=null}}sh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"initHook",priority:-10};class rh{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,s=n}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}rh.extension=b.Application;class ih{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,He.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?At.shared:new At,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}ih.extension=b.Application;W.add(rh);W.add(ih);const nh=class Jr{constructor(...t){this.stage=new vt,t[0]!==void 0&&H(ot,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new vt),this.renderer=await vd(t),Jr._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return H(ot,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var t;return(t=this.renderer.renderPipes.dom)==null?void 0:t._domElement}destroy(t=!1,e=!1){const s=Jr._plugins.slice(0);s.reverse(),s.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};nh._plugins=[];let Td=nh;W.handleByList(b.Application,Td._plugins);W.add(eh);var Rr,ao;function Sd(){if(ao)return Rr;ao=1,Rr=e;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(n){var o=[];return n.replace(t,function(a,h,l){var c=h.toLowerCase();for(l=i(l),c=="m"&&l.length>2&&(o.push([h].concat(l.splice(0,2))),c="l",h=h=="m"?"l":"L");;){if(l.length==r[c])return l.unshift(h),o.push(l);if(l.length<r[c])throw new Error("malformed path data");o.push([h].concat(l.splice(0,r[c])))}}),o}var s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function i(n){var o=n.match(s);return o?o.map(Number):[]}return Rr}var Cd=Sd();const wd=oa(Cd);function Ed(r,t){const e=wd(r),s=[];let i=null,n=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case"M":n=c[1],o=c[2],t.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],t.moveTo(n,o);break;case"H":n=c[1],t.lineTo(n,o);break;case"h":n+=c[1],t.lineTo(n,o);break;case"V":o=c[1],t.lineTo(n,o);break;case"v":o+=c[1],t.lineTo(n,o);break;case"L":n=c[1],o=c[2],t.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],t.lineTo(n,o);break;case"C":n=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":t.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],n,o);break;case"s":t.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],n,o);break;case"q":t.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],t.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],t.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":t.closePath(),s.length>0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:z(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return t}class vi{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new vi(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-t,n=this.y-e;return i*=i,n*=n,i+n<=s}strokeContains(t,e,s,i=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,h=(1-i)*s,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(s-h)}getBounds(t){return t||(t=new tt),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 Ti{constructor(t=0,e=0,s=0,i=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=i}clone(){return new Ti(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,i=(e-this.y)/this.halfHeight;return s*=s,i*=i,s+i<=1}strokeContains(t,e,s,i=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=s*(1-i),h=s-a,l=n-h,c=o-h,u=n+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 tt),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 Pd(r,t,e,s,i,n){const o=r-e,a=t-s,h=i-e,l=n-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=i,p=n):(f=e+d*h,p=s+d*l);const g=r-f,m=t-p;return g*g+m*m}let Md,Ad;class hs{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let i=0,n=e.length;i<n;i++)s.push(e[i].x,e[i].y);e=s}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,s=e.length;for(let i=0;i<s;i+=2){const n=e[i],o=e[i+1],a=e[(i+2)%s],h=e[(i+3)%s];t+=(a-n)*(h+o)}return t<0}containsPolygon(t){const e=this.getBounds(Md),s=t.getBounds(Ad);if(!e.containsRect(s))return!1;const i=t.points;for(let n=0;n<i.length;n+=2){const o=i[n],a=i[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new hs(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const i=this.points.length/2;for(let n=0,o=i-1;n<i;o=n++){const a=this.points[n*2],h=this.points[n*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,i=.5){const n=s*s,o=n*(1-i),a=n-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=Pd(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 tt);const e=this.points;let s=1/0,i=-1/0,n=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,i=l>i?l:i,n=c<n?c:n,o=c>o?c:o}return t.x=s,t.width=i-s,t.y=n,t.height=o-n,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 H("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return H("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 Fs=(r,t,e,s,i,n,o)=>{const a=r-e,h=t-s,l=Math.sqrt(a*a+h*h);return l>=i-n&&l<=i+o};class Si{constructor(t=0,e=0,s=0,i=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=i,this.radius=n}getBounds(t){return t||(t=new tt),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Si(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 i=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=t-(this.x+this.width-s),i*i+n*n<=o)||(n=e-(this.y+this.height-s),i*i+n*n<=o)||(i=t-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,s,i=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=s*(1-i),u=s-c,d=n+l,f=o+l,p=a-l*2,g=h-l*2,m=n+a,_=o+h;return(t>=n-c&&t<=n+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&&Fs(t,e,d,f,l,u,c)||t>m-l&&e<f&&Fs(t,e,m-l,f,l,u,c)||t>m-l&&e>_-l&&Fs(t,e,m-l,_-l,l,u,c)||t<d&&e>_-l&&Fs(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 oh={};function Ci(r,t,e){let s=2166136261;for(let i=0;i<t;i++)s^=r[i].uid,s=Math.imul(s,16777619),s>>>=0;return oh[s]||Rd(r,t,s,e)}function Rd(r,t,e,s){const i={};let n=0;for(let a=0;a<s;a++){const h=a<t?r[a]:L.EMPTY.source;i[n++]=h.source,i[n++]=h.style}const o=new re(i);return oh[e]=o,o}class ho{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 ti(r,t,e,s){if(e??(e=0),s??(s=Math.min(r.byteLength-e,t.byteLength)),!(e&7)&&!(s&7)){const i=s/8;new Float64Array(t,0,i).set(new Float64Array(r,e,i))}else if(!(e&3)&&!(s&3)){const i=s/4;new Float32Array(t,0,i).set(new Float32Array(r,e,i))}else new Uint8Array(t).set(new Uint8Array(r,e,s))}const kd={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var ut=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(ut||{});function lo(r,t){return t.alphaMode==="no-premultiply-alpha"&&kd[r]||r}const Bd=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
36
+ `);function Id(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
37
+ else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function ah(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=Bd.replace(/%forloop%/gi,Id(r));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}}finally{t.deleteShader(e)}return r}let Ee=null;function Gd(){var t;if(Ee)return Ee;const r=La();return Ee=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),Ee=ah(Ee,r),(t=r.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Ee}class Fd{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 Dd{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Fd,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 ls=[];let Qs=0;Xe.register({clear:()=>{if(ls.length>0)for(const r of ls)r&&r.destroy();ls.length=0,Qs=0}});function co(){return Qs>0?ls[--Qs]:new Dd}function uo(r){r.elements=null,ls[Qs++]=r}let Je=0;const hh=class lh{constructor(t){this.uid=et("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...lh.defaultOptions,...t},t.maxTextures||(H("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Gd());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:i}=t;this.attributeBuffer=new ho(s*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)uo(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=co(),i=s.textures;i.clear();const n=e[this.elementStart];let o=lo(n.blendMode,n.texture._source),a=n.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 y=_.texture._source,v=lo(_.blendMode,y),S=o!==v||a!==_.topology;if(y._batchTick===Je&&!S){_._textureId=y._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}y._batchTick=Je,(i.count>=g||S)&&(this._finishBatch(s,d,u-d,i,o,a,t,f,p),f="renderBatch",d=u,o=v,a=_.topology,s=co(),i=s.textures,i.clear(),p=[],++Je),_._textureId=y._textureBindLocation=i.count,i.ids[y.uid]=i.count,i.textures[i.count++]=y,_._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))}i.count>0&&(this._finishBatch(s,d,u-d,i,o,a,t,f,p),d=u,++Je),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(t,e,s,i,n,o,a,h,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=i,t.blendMode=n,t.topology=o,t.start=e,t.size=s,t.elements=l,++Je,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 ho(e);ti(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 i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)i[n]=e[n];else ti(e.buffer,i.buffer);this.indexBuffer=i}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,i){const n=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[s++]=i+n[l+a]-h}destroy(t={}){var e;if(this.batches!==null){for(let s=0;s<this.batchIndex;s++)uo(this.batches[s]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let s=0;s<this._elements.length;s++)this._elements[s]&&(this._elements[s]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};hh.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Ud=hh;var it=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(it||{});class ie extends kt{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,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==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:s,usage:i,mappedAtCreation:a,label:n},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&it.STATIC)}set static(t){t?this.descriptor.usage|=it.STATIC:this.descriptor.usage&=~it.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 i=this._data;if(this._data=t,this._dataInt32=null,!i||i.length!==t.length){!this.shrinkToFit&&i&&t.byteLength<i.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(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||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 ch(r,t){if(!(r instanceof ie)){let e=t?it.INDEX:it.VERTEX;r instanceof Array&&(t?(r=new Uint32Array(r),e=it.INDEX|it.COPY_DST):(r=new Float32Array(r),e=it.VERTEX|it.COPY_DST)),r=new ie({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function Od(r,t,e){const s=r.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const i=s.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=i.BYTES_PER_ELEMENT,c=(s.offset||0)/l,u=(s.stride||8)/l;for(let d=c;d<i.length;d+=u){const f=i[d],p=i[d+1];f>a&&(a=f),p>h&&(h=p),f<n&&(n=f),p<o&&(o=p)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=h,e}function Ld(r){return(r instanceof ie||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=ch(r.buffer,!1),r}class wi extends kt{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:i}=t;if(this.buffers=[],this.attributes={},e)for(const n in e)this.addAttribute(n,e[n]);this.instanceCount=t.instanceCount??1,s&&this.addIndex(s),this.topology=i||"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=Ld(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=ch(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Od(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(s=>s.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Nd=new Float32Array(1),Hd=new Uint32Array(1);class Wd extends wi{constructor(){const e=new ie({data:Nd,label:"attribute-batch-buffer",usage:it.VERTEX|it.COPY_DST,shrinkToFit:!1}),s=new ie({data:Hd,label:"index-batch-buffer",usage:it.INDEX|it.COPY_DST,shrinkToFit:!1}),i=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aUV:{buffer:e,format:"float32x2",stride:i,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:i,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:i,offset:20}},indexBuffer:s})}}function fo(r,t,e){if(r)for(const s in r){const i=s.toLocaleLowerCase(),n=t[i];if(n){let o=r[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else z(`${s} placement hook does not exist in shader`)}}const zd=/\{\{(.*?)\}\}/g;function po(r){var s;const t={};return(((s=r.match(zd))==null?void 0:s.map(i=>i.replace(/[{()}]/g,"")))??[]).forEach(i=>{t[i]=[]}),t}function mo(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function go(r,t,e=!1){const s=[];mo(t,s),r.forEach(a=>{a.header&&mo(a.header,s)});const i=s;e&&i.sort();const n=i.map((a,h)=>` @location(${h}) ${a},`).join(`
38
+ `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
39
+ ${n}
40
+ `),o}function _o(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function Vd(r){const e=/\b(\w+)\s*:/g.exec(r);return e?e[1]:""}function Xd(r){const t=/@.*?\s+/g;return r.replace(t,"")}function $d(r,t){const e=[];_o(t,e),r.forEach(h=>{h.header&&_o(h.header,e)});let s=0;const i=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
41
+ `),n=e.sort().map(h=>` var ${Xd(h)};`).join(`
42
+ `),o=`return VSOutput(
43
+ ${e.sort().map(h=>` ${Vd(h)}`).join(`,
44
+ `)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
45
+ ${i}
46
+ `),a=a.replace("{{start}}",`
47
+ ${n}
48
+ `),a=a.replace("{{return}}",`
49
+ ${o}
50
+ `),a}function xo(r,t){let e=r;for(const s in t){const i=t[s];i.join(`
51
+ `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
52
+ ${i.join(`
53
+ `)}
54
+ //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const se=Object.create(null),kr=new Map;let jd=0;function Yd({template:r,bits:t}){const e=uh(r,t);if(se[e])return se[e];const{vertex:s,fragment:i}=Kd(r,t);return se[e]=dh(s,i,t),se[e]}function qd({template:r,bits:t}){const e=uh(r,t);return se[e]||(se[e]=dh(r.vertex,r.fragment,t)),se[e]}function Kd(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=go(e,r.vertex,!0);i=$d(e,i);const n=go(s,r.fragment,!0);return{vertex:i,fragment:n}}function uh(r,t){return t.map(e=>(kr.has(e)||kr.set(e,jd++),kr.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function dh(r,t,e){const s=po(r),i=po(t);return e.forEach(n=>{fo(n.vertex,s,n.name),fo(n.fragment,i,n.name)}),{vertex:xo(r,s),fragment:xo(t,i)}}const Zd=`
55
+ @in aPosition: vec2<f32>;
56
+ @in aUV: vec2<f32>;
57
+
58
+ @out @builtin(position) vPosition: vec4<f32>;
59
+ @out vUV : vec2<f32>;
60
+ @out vColor : vec4<f32>;
61
+
62
+ {{header}}
63
+
64
+ struct VSOutput {
65
+ {{struct}}
66
+ };
67
+
68
+ @vertex
69
+ fn main( {{in}} ) -> VSOutput {
70
+
71
+ var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
72
+ var modelMatrix = mat3x3<f32>(
73
+ 1.0, 0.0, 0.0,
74
+ 0.0, 1.0, 0.0,
75
+ 0.0, 0.0, 1.0
76
+ );
77
+ var position = aPosition;
78
+ var uv = aUV;
79
+
80
+ {{start}}
81
+
82
+ vColor = vec4<f32>(1., 1., 1., 1.);
83
+
84
+ {{main}}
85
+
86
+ vUV = uv;
87
+
88
+ var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
89
+
90
+ vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
91
+
92
+ vColor *= globalUniforms.uWorldColorAlpha;
93
+
94
+ {{end}}
95
+
96
+ {{return}}
97
+ };
98
+ `,Qd=`
99
+ @in vUV : vec2<f32>;
100
+ @in vColor : vec4<f32>;
101
+
102
+ {{header}}
103
+
104
+ @fragment
105
+ fn main(
106
+ {{in}}
107
+ ) -> @location(0) vec4<f32> {
108
+
109
+ {{start}}
110
+
111
+ var outColor:vec4<f32>;
112
+
113
+ {{main}}
114
+
115
+ var finalColor:vec4<f32> = outColor * vColor;
116
+
117
+ {{end}}
118
+
119
+ return finalColor;
120
+ };
121
+ `,Jd=`
122
+ in vec2 aPosition;
123
+ in vec2 aUV;
124
+
125
+ out vec4 vColor;
126
+ out vec2 vUV;
127
+
128
+ {{header}}
129
+
130
+ void main(void){
131
+
132
+ mat3 worldTransformMatrix = uWorldTransformMatrix;
133
+ mat3 modelMatrix = mat3(
134
+ 1.0, 0.0, 0.0,
135
+ 0.0, 1.0, 0.0,
136
+ 0.0, 0.0, 1.0
137
+ );
138
+ vec2 position = aPosition;
139
+ vec2 uv = aUV;
140
+
141
+ {{start}}
142
+
143
+ vColor = vec4(1.);
144
+
145
+ {{main}}
146
+
147
+ vUV = uv;
148
+
149
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
150
+
151
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
152
+
153
+ vColor *= uWorldColorAlpha;
154
+
155
+ {{end}}
156
+ }
157
+ `,tf=`
158
+
159
+ in vec4 vColor;
160
+ in vec2 vUV;
161
+
162
+ out vec4 finalColor;
163
+
164
+ {{header}}
165
+
166
+ void main(void) {
167
+
168
+ {{start}}
169
+
170
+ vec4 outColor;
171
+
172
+ {{main}}
173
+
174
+ finalColor = outColor * vColor;
175
+
176
+ {{end}}
177
+ }
178
+ `,ef={name:"global-uniforms-bit",vertex:{header:`
179
+ struct GlobalUniforms {
180
+ uProjectionMatrix:mat3x3<f32>,
181
+ uWorldTransformMatrix:mat3x3<f32>,
182
+ uWorldColorAlpha: vec4<f32>,
183
+ uResolution: vec2<f32>,
184
+ }
185
+
186
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
187
+ `}},sf={name:"global-uniforms-bit",vertex:{header:`
188
+ uniform mat3 uProjectionMatrix;
189
+ uniform mat3 uWorldTransformMatrix;
190
+ uniform vec4 uWorldColorAlpha;
191
+ uniform vec2 uResolution;
192
+ `}};function Ei({bits:r,name:t}){const e=Yd({template:{fragment:Qd,vertex:Zd},bits:[ef,...r]});return ye.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Pi({bits:r,name:t}){return new $e({name:t,...qd({template:{vertex:Jd,fragment:tf},bits:[sf,...r]})})}const fh={name:"color-bit",vertex:{header:`
193
+ @in aColor: vec4<f32>;
194
+ `,main:`
195
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
196
+ `}},ph={name:"color-bit",vertex:{header:`
197
+ in vec4 aColor;
198
+ `,main:`
199
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
200
+ `}},Br={};function rf(r){const t=[];if(r===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<r;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(`
201
+ `)}function nf(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<r;e++)e===r-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(`
202
+ `)}function mh(r){return Br[r]||(Br[r]={name:"texture-batch-bit",vertex:{header:`
203
+ @in aTextureIdAndRound: vec2<u32>;
204
+ @out @interpolate(flat) vTextureId : u32;
205
+ `,main:`
206
+ vTextureId = aTextureIdAndRound.y;
207
+ `,end:`
208
+ if(aTextureIdAndRound.x == 1)
209
+ {
210
+ vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
211
+ }
212
+ `},fragment:{header:`
213
+ @in @interpolate(flat) vTextureId: u32;
214
+
215
+ ${rf(r)}
216
+ `,main:`
217
+ var uvDx = dpdx(vUV);
218
+ var uvDy = dpdy(vUV);
219
+
220
+ ${nf(r)}
221
+ `}}),Br[r]}const Ir={};function of(r){const t=[];for(let e=0;e<r;e++)e>0&&t.push("else"),e<r-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
222
+ `)}function gh(r){return Ir[r]||(Ir[r]={name:"texture-batch-bit",vertex:{header:`
223
+ in vec2 aTextureIdAndRound;
224
+ out float vTextureId;
225
+
226
+ `,main:`
227
+ vTextureId = aTextureIdAndRound.y;
228
+ `,end:`
229
+ if(aTextureIdAndRound.x == 1.)
230
+ {
231
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
232
+ }
233
+ `},fragment:{header:`
234
+ in float vTextureId;
235
+
236
+ uniform sampler2D uTextures[${r}];
237
+
238
+ `,main:`
239
+
240
+ ${of(r)}
241
+ `}}),Ir[r]}const Mi={name:"round-pixels-bit",vertex:{header:`
242
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
243
+ {
244
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
245
+ }
246
+ `}},Ai={name:"round-pixels-bit",vertex:{header:`
247
+ vec2 roundPixels(vec2 position, vec2 targetSize)
248
+ {
249
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
250
+ }
251
+ `}},yo={};function _h(r){let t=yo[r];if(t)return t;const e=new Int32Array(r);for(let s=0;s<r;s++)e[s]=s;return t=yo[r]=new Wt({uTextures:{value:e,type:"i32",size:r}},{isStatic:!0}),t}class bo extends Zt{constructor(t){const e=Pi({name:"batch",bits:[ph,gh(t),Ai]}),s=Ei({name:"batch",bits:[fh,mh(t),Mi]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:_h(t)}}),this.maxTextures=t}}let ts=null;const xh=class yh extends Ud{constructor(t){super(t),this.geometry=new Wd,this.name=yh.extension.name,this.vertexSize=6,ts??(ts=new bo(t.maxTextures)),this.shader=ts}packAttributes(t,e,s,i,n){const o=n<<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 y=_;y<x;y++){const v=y*2,S=p[v],T=p[v+1];e[i++]=h*S+c*T+d,e[i++]=u*T+l*S+f,e[i++]=g[v],e[i++]=g[v+1],s[i++]=m,s[i++]=o}}packQuadAttributes(t,e,s,i,n){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,y=o.uvs,v=t.color,S=n<<16|t.roundPixels&65535;e[i+0]=h*m+c*x+d,e[i+1]=u*x+l*m+f,e[i+2]=y.x0,e[i+3]=y.y0,s[i+4]=v,s[i+5]=S,e[i+6]=h*g+c*x+d,e[i+7]=u*x+l*g+f,e[i+8]=y.x1,e[i+9]=y.y1,s[i+10]=v,s[i+11]=S,e[i+12]=h*g+c*_+d,e[i+13]=u*_+l*g+f,e[i+14]=y.x2,e[i+15]=y.y2,s[i+16]=v,s[i+17]=S,e[i+18]=h*m+c*_+d,e[i+19]=u*_+l*m+f,e[i+20]=y.x3,e[i+21]=y.y3,s[i+22]=v,s[i+23]=S}_updateMaxTextures(t){this.shader.maxTextures!==t&&(ts=new bo(t),this.shader=ts)}destroy(){this.shader=null,super.destroy()}};xh.extension={type:[b.Batcher],name:"default"};let Ri=xh;class zt{constructor(t){this.items=Object.create(null);const{renderer:e,type:s,onUnload:i,priority:n,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",s,n??0),this._onUnload=i,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){var i;if(!this.items[t.uid])return;const s=t._gpuData[this._renderer.uid];s&&((i=this._onUnload)==null||i.call(this,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 af(r,t,e,s,i,n,o,a=null){let h=0;e*=t,i*=n;const l=a.a,c=a.b,u=a.c,d=a.d,f=a.tx,p=a.ty;for(;h<o;){const g=r[e],m=r[e+1];s[i]=l*g+u*m+f,s[i+1]=c*g+d*m+p,i+=n,e+=t,h++}}function hf(r,t,e,s){let i=0;for(t*=e;i<s;)r[t]=0,r[t+1]=0,t+=e,i++}function bh(r,t,e,s,i){const n=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,c=t.ty;e||(e=0),s||(s=2),i||(i=r.length/s-e);let u=e*s;for(let d=0;d<i;d++){const f=r[u],p=r[u+1];r[u]=n*f+a*p+l,r[u+1]=o*f+h*p+c,u+=s}}const lf=new G;class ki{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?De(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||lf}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 xs={extension:{type:b.ShapeBuilder,name:"circle"},build(r,t){let e,s,i,n,o,a;if(r.type==="circle"){const v=r;if(o=a=v.radius,o<=0)return!1;e=v.x,s=v.y,i=n=0}else if(r.type==="ellipse"){const v=r;if(o=v.halfWidth,a=v.halfHeight,o<=0||a<=0)return!1;e=v.x,s=v.y,i=n=0}else{const v=r,S=v.width/2,T=v.height/2;e=v.x+S,s=v.y+T,o=a=Math.max(0,Math.min(v.radius,Math.min(S,T))),i=S-o,n=T-a}if(i<0||n<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(i?4:0)+(n?4:0);if(l===0)return!1;if(h===0)return t[0]=t[6]=e+i,t[1]=t[3]=s+n,t[2]=t[4]=e-i,t[5]=t[7]=s-n,!0;let c=0,u=h*4+(i?2:0)+2,d=u,f=l,p=i+o,g=n,m=e+p,_=e-p,x=s+g;if(t[c++]=m,t[c++]=x,t[--u]=x,t[--u]=_,n){const v=s-g;t[d++]=_,t[d++]=v,t[--f]=v,t[--f]=m}for(let v=1;v<h;v++){const S=Math.PI/2*(v/h),T=i+Math.cos(S)*o,C=n+Math.sin(S)*a,k=e+T,M=e-T,w=s+C,P=s-C;t[c++]=k,t[c++]=w,t[--u]=w,t[--u]=M,t[d++]=M,t[d++]=P,t[--f]=P,t[--f]=k}p=i,g=n+a,m=e+p,_=e-p,x=s+g;const y=s-g;return t[c++]=m,t[c++]=x,t[--f]=y,t[--f]=m,i&&(t[c++]=_,t[c++]=x,t[--f]=y,t[--f]=_),!0},triangulate(r,t,e,s,i,n){if(r.length===0)return;let o=0,a=0;for(let c=0;c<r.length;c+=2)o+=r[c],a+=r[c+1];o/=r.length/2,a/=r.length/2;let h=s;t[h*e]=o,t[h*e+1]=a;const l=h++;for(let c=0;c<r.length;c+=2)t[h*e]=r[c],t[h*e+1]=r[c+1],c>0&&(i[n++]=h,i[n++]=l,i[n++]=h-1),h++;i[n++]=l+1,i[n++]=l,i[n++]=h-1}},cf={...xs,extension:{...xs.extension,name:"ellipse"}},uf={...xs,extension:{...xs.extension,name:"roundedRectangle"}},vh=1e-4,vo=1e-4;function df(r){const t=r.length;if(t<6)return 1;let e=0;for(let s=0,i=r[t-2],n=r[t-1];s<t;s+=2){const o=r[s],a=r[s+1];e+=(o-i)*(a+n),i=o,n=a}return e<0?-1:1}function To(r,t,e,s,i,n,o,a){const h=r-e*i,l=t-s*i,c=r+e*n,u=t+s*n;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 oe(r,t,e,s,i,n,o,a){const h=e-r,l=s-t;let c=Math.atan2(h,l),u=Math.atan2(i-r,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),g=Math.sqrt(h*h+l*l),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/m;if(d+=_,a){o.push(r,t),o.push(e,s);for(let x=1,y=d;x<m;x++,y+=_)o.push(r,t),o.push(r+Math.sin(y)*g,t+Math.cos(y)*g);o.push(r,t),o.push(i,n)}else{o.push(e,s),o.push(r,t);for(let x=1,y=d;x<m;x++,y+=_)o.push(r+Math.sin(y)*g,t+Math.cos(y)*g),o.push(r,t);o.push(i,n),o.push(r,t)}return m*2}function Bi(r,t,e,s,i,n){const o=vh;if(r.length===0)return;const a=t;let h=a.alignment;if(t.alignment!==.5){let R=df(r);h=(h-.5)*R+.5}const l=new st(r[0],r[1]),c=new st(r[r.length-2],r[r.length-1]),u=s,d=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(u){r=r.slice(),d&&(r.pop(),r.pop(),c.set(r[r.length-2],r[r.length-1]));const R=(l.x+c.x)*.5,O=(c.y+l.y)*.5;r.unshift(R,O),r.push(R,O)}const f=i,p=r.length/2;let g=r.length;const m=f.length/2,_=a.width/2,x=_*_,y=a.miterLimit*a.miterLimit;let v=r[0],S=r[1],T=r[2],C=r[3],k=0,M=0,w=-(S-C),P=v-T,A=0,I=0,F=Math.sqrt(w*w+P*P);w/=F,P/=F,w*=_,P*=_;const ht=h,E=(1-ht)*2,B=ht*2;u||(a.cap==="round"?g+=oe(v-w*(E-B)*.5,S-P*(E-B)*.5,v-w*E,S-P*E,v+w*B,S+P*B,f,!0)+2:a.cap==="square"&&(g+=To(v,S,w,P,E,B,!0,f))),f.push(v-w*E,S-P*E),f.push(v+w*B,S+P*B);for(let R=1;R<p-1;++R){v=r[(R-1)*2],S=r[(R-1)*2+1],T=r[R*2],C=r[R*2+1],k=r[(R+1)*2],M=r[(R+1)*2+1],w=-(S-C),P=v-T,F=Math.sqrt(w*w+P*P),w/=F,P/=F,w*=_,P*=_,A=-(C-M),I=T-k,F=Math.sqrt(A*A+I*I),A/=F,I/=F,A*=_,I*=_;const O=T-v,Y=S-C,D=T-k,q=M-C,rt=O*D+Y*q,nt=Y*D-q*O,Z=nt<0;if(Math.abs(nt)<.001*Math.abs(rt)){f.push(T-w*E,C-P*E),f.push(T+w*B,C+P*B),rt>=0&&(a.join==="round"?g+=oe(T,C,T-w*E,C-P*E,T-A*E,C-I*E,f,!1)+4:g+=2,f.push(T-A*B,C-I*B),f.push(T+A*E,C+I*E));continue}const dt=(-w+v)*(-P+C)-(-w+T)*(-P+S),xt=(-A+k)*(-I+C)-(-A+T)*(-I+M),V=(O*xt-D*dt)/nt,St=(q*dt-Y*xt)/nt,Et=(V-T)*(V-T)+(St-C)*(St-C),ct=T+(V-T)*E,Dt=C+(St-C)*E,Bt=T-(V-T)*B,Pt=C-(St-C)*B,be=Math.min(O*O+Y*Y,D*D+q*q),ve=Z?E:B,Ye=be+ve*ve*x;Et<=Ye?a.join==="bevel"||Et/x>y?(Z?(f.push(ct,Dt),f.push(T+w*B,C+P*B),f.push(ct,Dt),f.push(T+A*B,C+I*B)):(f.push(T-w*E,C-P*E),f.push(Bt,Pt),f.push(T-A*E,C-I*E),f.push(Bt,Pt)),g+=2):a.join==="round"?Z?(f.push(ct,Dt),f.push(T+w*B,C+P*B),g+=oe(T,C,T+w*B,C+P*B,T+A*B,C+I*B,f,!0)+4,f.push(ct,Dt),f.push(T+A*B,C+I*B)):(f.push(T-w*E,C-P*E),f.push(Bt,Pt),g+=oe(T,C,T-w*E,C-P*E,T-A*E,C-I*E,f,!1)+4,f.push(T-A*E,C-I*E),f.push(Bt,Pt)):(f.push(ct,Dt),f.push(Bt,Pt)):(f.push(T-w*E,C-P*E),f.push(T+w*B,C+P*B),a.join==="round"?Z?g+=oe(T,C,T+w*B,C+P*B,T+A*B,C+I*B,f,!0)+2:g+=oe(T,C,T-w*E,C-P*E,T-A*E,C-I*E,f,!1)+2:a.join==="miter"&&Et/x<=y&&(Z?(f.push(Bt,Pt),f.push(Bt,Pt)):(f.push(ct,Dt),f.push(ct,Dt)),g+=2),f.push(T-A*E,C-I*E),f.push(T+A*B,C+I*B),g+=2)}v=r[(p-2)*2],S=r[(p-2)*2+1],T=r[(p-1)*2],C=r[(p-1)*2+1],w=-(S-C),P=v-T,F=Math.sqrt(w*w+P*P),w/=F,P/=F,w*=_,P*=_,f.push(T-w*E,C-P*E),f.push(T+w*B,C+P*B),u||(a.cap==="round"?g+=oe(T-w*(E-B)*.5,C-P*(E-B)*.5,T-w*E,C-P*E,T+w*B,C+P*B,f,!1)+2:a.cap==="square"&&(g+=To(T,C,w,P,E,B,!1,f)));const U=vo*vo;for(let R=m;R<g+m-2;++R)v=f[R*2],S=f[R*2+1],T=f[(R+1)*2],C=f[(R+1)*2+1],k=f[(R+2)*2],M=f[(R+2)*2+1],!(Math.abs(v*(C-M)+T*(M-S)+k*(S-C))<U)&&n.push(R,R+1,R+2)}function ff(r,t,e,s){const i=vh;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],h=r[r.length-1],l=t||Math.abs(n-a)<i&&Math.abs(o-h)<i,c=e,u=r.length/2,d=c.length/2;for(let f=0;f<u;f++)c.push(r[f*2]),c.push(r[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 Th(r,t,e,s,i,n,o){const a=_d(r,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)n[o++]=a[l]+i,n[o++]=a[l+1]+i,n[o++]=a[l+2]+i;let h=i*s;for(let l=0;l<r.length;l+=2)e[h]=r[l],e[h+1]=r[l+1],h+=s}const pf=[],mf={extension:{type:b.ShapeBuilder,name:"polygon"},build(r,t){for(let e=0;e<r.points.length;e++)t[e]=r.points[e];return!0},triangulate(r,t,e,s,i,n){Th(r,pf,t,e,s,i,n)}},gf={extension:{type:b.ShapeBuilder,name:"rectangle"},build(r,t){const e=r,s=e.x,i=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=s,t[1]=i,t[2]=s+n,t[3]=i,t[4]=s+n,t[5]=i+o,t[6]=s,t[7]=i+o,!0):!1},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[6],t[s+o+1]=r[7],o+=e,t[s+o]=r[4],t[s+o+1]=r[5],o+=e;const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},_f={extension:{type:b.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[4],t[s+o+1]=r[5];const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2}},So=[{offset:0,color:"white"},{offset:1,color:"black"}],Ii=class ei{constructor(...t){this.uid=et("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=xf(t);e={...e.type==="radial"?ei.defaultRadialOptions:ei.defaultLinearOptions,...la(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(i=>{this.addColorStop(i.offset,i.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Q.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:i}=this.end,n=s-t,o=i-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=t;t=s,s=m,n*=-1}if(o<0){const m=e;e=i,i=m,o*=-1}}const h=this.colorStops.length?this.colorStops:So,l=this._textureSize,{canvas:c,context:u}=wo(l,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Co(d,h),u.fillStyle=d,u.fillRect(0,0,l,1),this.texture=new L({source:new Ks({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),g=new G;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:So,e=this._textureSize,{canvas:s,context:i}=wo(e,e),{x:n,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=(n-u)*f,g=(o-d)*f,m=i.createRadialGradient(p,g,l*f,(a-u)*f,(h-d)*f,c*f);Co(m,t),i.fillStyle=t[t.length-1].color,i.fillRect(0,0,e,e),i.fillStyle=m,i.translate(p,g),i.rotate(this.rotation),i.scale(1,this.scale),i.translate(-p,-g),i.fillRect(0,0,e,e),this.texture=new L({source:new Ks({resource:s,addressMode:this._wrapMode})});const _=new G;_.scale(1/f,1/f),_.translate(u,d),this.textureSpace==="local"&&_.scale(e,e),this.transform=_}destroy(){var t;(t=this.texture)==null||t.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}`}};Ii.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Ii.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Ht=Ii;function Co(r,t){for(let e=0;e<t.length;e++){const s=t[e];r.addColorStop(s.offset,s.color)}}function wo(r,t){const e=j.get().createCanvas(r,t),s=e.getContext("2d");return{canvas:e,context:s}}function xf(r){let t=r[0]??{};return(typeof t=="number"||r[1])&&(H("8.5.2","use options object instead"),t={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:r[5]??Ht.defaultLinearOptions.textureSize}),t}const yf=new G,bf=new tt;function Sh(r,t,e,s){const i=t.matrix?r.copyFrom(t.matrix).invert():r.identity();if(t.textureSpace==="local"){const o=e.getBounds(bf);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=i.a,p=i.b,g=i.c,m=i.d;i.a*=l,i.b*=l,i.c*=c,i.d*=c,i.tx=u*f+d*g+i.tx,i.ty=u*p+d*m+i.ty}else i.translate(t.texture.frame.x,t.texture.frame.y),i.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof Ht)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),s&&i.append(yf.copyFrom(s).invert()),i}const je={};W.handleByMap(b.ShapeBuilder,je);W.add(gf,mf,_f,xs,cf,uf);const vf=new tt,Tf=new G;function Sf(r,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let i=0;i<r.instructions.length;i++){const n=r.instructions[i];if(n.action==="texture")Cf(n.data,s,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,h=n.data.style,l=n.data.hole;o&&l&&Eo(l.shapePath,h,!0,s,e),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),Eo(a,h,o,s,e)}}}function Cf(r,t,e){const s=[],i=je.rectangle,n=vf;n.x=r.dx,n.y=r.dy,n.width=r.dw,n.height=r.dh;const o=r.transform;if(!i.build(n,s))return;const{vertices:a,uvs:h,indices:l}=e,c=l.length,u=a.length/2;o&&bh(s,o),i.triangulate(s,a,2,u,l,c);const d=r.image,f=d.uvs;h.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=mt.get(ki);p.indexOffset=c,p.indexSize=l.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=r.style,p.alpha=r.alpha,p.texture=d,p.geometryData=e,t.push(p)}function Eo(r,t,e,s,i){const{vertices:n,uvs:o,indices:a}=i;r.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const u=[],d=je[h.type];if(!d.build(h,u))return;const f=a.length,p=n.length/2;let g="triangle-list";if(l&&bh(u,l),e){const y=h.closePath??!0,v=t;v.pixelLine?(ff(u,y,n,a),g="line-list"):Bi(u,v,!1,y,n,a)}else if(c){const y=[],v=u.slice();wf(c).forEach(T=>{y.push(v.length/2),v.push(...T)}),Th(v,y,n,2,p,a,f)}else d.triangulate(u,n,2,p,a,f);const m=o.length/2,_=t.texture;if(_!==L.WHITE){const y=Sh(Tf,t,h,l);af(n,2,p,o,m,2,n.length/2-p,y)}else hf(o,m,2,n.length/2-p);const x=mt.get(ki);x.indexOffset=f,x.indexSize=a.length-f,x.attributeOffset=p,x.attributeSize=n.length/2-p,x.baseColor=t.color,x.alpha=t.alpha,x.texture=_,x.geometryData=i,x.topology=g,s.push(x)})}function wf(r){const t=[];for(let e=0;e<r.length;e++){const s=r[e].shape,i=[];je[s.type].build(s,i)&&t.push(i)}return t}class Ef{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{mt.return(t)}),this.graphicsData&&mt.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 Pf{constructor(){this.instructions=new _i}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Ri({maxTextures:e}),this.instructions.reset()}get geometry(){return H(Gc,"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 Gi=class si{constructor(t){this._renderer=t,this._managedContexts=new zt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){si.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??si.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(),Sf(t,s);const i=t.batchMode;t.customShader||i==="no-batch"?s.isBatchable=!1:i==="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=mt.get(Pf,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:i,geometryData:n}=s;s.graphicsData=e;const o=n.vertices.length,a=n.indices.length;for(let u=0;u<i.length;u++)i[u].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let u=0;u<i.length;u++){const d=i[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=Ci(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new Ef;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Gi.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"graphicsContext"};Gi.defaultOptions={bezierSmoothness:.5};let Fi=Gi;const Mf=8,Ds=11920929e-14,Af=1;function Ch(r,t,e,s,i,n,o,a,h,l){const u=Math.min(.99,Math.max(0,l??Fi.defaultOptions.bezierSmoothness));let d=(Af-u)/1;return d*=d,Rf(t,e,s,i,n,o,a,h,r,d),r}function Rf(r,t,e,s,i,n,o,a,h,l){ri(r,t,e,s,i,n,o,a,h,l,0),h.push(o,a)}function ri(r,t,e,s,i,n,o,a,h,l,c){if(c>Mf)return;const u=(r+e)/2,d=(t+s)/2,f=(e+i)/2,p=(s+n)/2,g=(i+o)/2,m=(n+a)/2,_=(u+f)/2,x=(d+p)/2,y=(f+g)/2,v=(p+m)/2,S=(_+y)/2,T=(x+v)/2;if(c>0){let C=o-r,k=a-t;const M=Math.abs((e-o)*k-(s-a)*C),w=Math.abs((i-o)*k-(n-a)*C);if(M>Ds&&w>Ds){if((M+w)*(M+w)<=l*(C*C+k*k)){h.push(S,T);return}}else if(M>Ds){if(M*M<=l*(C*C+k*k)){h.push(S,T);return}}else if(w>Ds){if(w*w<=l*(C*C+k*k)){h.push(S,T);return}}else if(C=S-(r+o)/2,k=T-(t+a)/2,C*C+k*k<=l){h.push(S,T);return}}ri(r,t,u,d,_,x,S,T,h,l,c+1),ri(S,T,y,v,g,m,o,a,h,l,c+1)}const kf=8,Bf=11920929e-14,If=1;function Gf(r,t,e,s,i,n,o,a){const l=Math.min(.99,Math.max(0,a??Fi.defaultOptions.bezierSmoothness));let c=(If-l)/1;return c*=c,Ff(t,e,s,i,n,o,r,c),r}function Ff(r,t,e,s,i,n,o,a){ii(o,r,t,e,s,i,n,a,0),o.push(i,n)}function ii(r,t,e,s,i,n,o,a,h){if(h>kf)return;const l=(t+s)/2,c=(e+i)/2,u=(s+n)/2,d=(i+o)/2,f=(l+u)/2,p=(c+d)/2;let g=n-t,m=o-e;const _=Math.abs((s-n)*m-(i-o)*g);if(_>Bf){if(_*_<=a*(g*g+m*m)){r.push(f,p);return}}else if(g=f-(t+n)/2,m=p-(e+o)/2,g*g+m*m<=a){r.push(f,p);return}ii(r,t,e,l,c,f,p,a,h+1),ii(r,f,p,u,d,n,o,a,h+1)}function wh(r,t,e,s,i,n,o,a){let h=Math.abs(i-n);(!o&&i>n||o&&n>i)&&(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=i;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;r.push(p,g),c+=l}}function Df(r,t,e,s,i,n){const o=r[r.length-2],h=r[r.length-1]-e,l=o-t,c=i-e,u=s-t,d=Math.abs(h*u-l*c);if(d<1e-8||n===0){(r[r.length-2]!==t||r[r.length-1]!==e)&&r.push(t,e);return}const f=h*h+l*l,p=c*c+u*u,g=h*c+l*u,m=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,x=m*g/f,y=_*g/p,v=m*u+_*l,S=m*c+_*h,T=l*(_+x),C=h*(_+x),k=u*(m+y),M=c*(m+y),w=Math.atan2(C-S,T-v),P=Math.atan2(M-S,k-v);wh(r,v+t,S+e,n,w,P,l*c>u*h)}const cs=Math.PI*2,Gr={centerX:0,centerY:0,ang1:0,ang2:0},Fr=({x:r,y:t},e,s,i,n,o,a,h)=>{r*=e,t*=s;const l=i*r-n*t,c=n*r+i*t;return h.x=l+o,h.y=c+a,h};function Uf(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,i=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Po=(r,t,e,s)=>{const i=r*s-t*e<0?-1:1;let n=r*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},Of=(r,t,e,s,i,n,o,a,h,l,c,u,d)=>{const f=Math.pow(i,2),p=Math.pow(n,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=_*i/n*u,y=_*-n/i*c,v=l*x-h*y+(r+e)/2,S=h*x+l*y+(t+s)/2,T=(c-x)/i,C=(u-y)/n,k=(-c-x)/i,M=(-u-y)/n,w=Po(1,0,T,C);let P=Po(T,C,k,M);a===0&&P>0&&(P-=cs),a===1&&P<0&&(P+=cs),d.centerX=v,d.centerY=S,d.ang1=w,d.ang2=P};function Lf(r,t,e,s,i,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*cs/360),u=Math.cos(a*cs/360),d=u*(t-s)/2+c*(e-i)/2,f=-c*(t-s)/2+u*(e-i)/2;if(d===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);p>1&&(n*=Math.sqrt(p),o*=Math.sqrt(p)),Of(t,e,s,i,n,o,h,l,c,u,d,f,Gr);let{ang1:g,ang2:m}=Gr;const{centerX:_,centerY:x}=Gr;let y=Math.abs(m)/(cs/4);Math.abs(1-y)<1e-7&&(y=1);const v=Math.max(Math.ceil(y),1);m/=v;let S=r[r.length-2],T=r[r.length-1];const C={x:0,y:0};for(let k=0;k<v;k++){const M=Uf(g,m),{x:w,y:P}=Fr(M[0],n,o,u,c,_,x,C),{x:A,y:I}=Fr(M[1],n,o,u,c,_,x,C),{x:F,y:ht}=Fr(M[2],n,o,u,c,_,x,C);Ch(r,S,T,w,P,A,I,F,ht),S=F,T=ht,g+=m}}function Nf(r,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}},i=(o,a)=>{o===0?r.moveTo(a.x,a.y):r.lineTo(a.x,a.y)};let n=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){i(o,a),n=a;continue}const l=t[(o+1)%t.length],c=s(a,n),u=s(a,l);if(c.len<1e-4||u.len<1e-4){i(o,a),n=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,y=a.y+u.ny*_+u.nx*m*f,v=Math.atan2(c.ny,c.nx)+Math.PI/2*f,S=Math.atan2(u.ny,u.nx)-Math.PI/2*f;o===0&&r.moveTo(x+Math.cos(v)*m,y+Math.sin(v)*m),r.arc(x,y,m,v,S,p),n=a}}function Hf(r,t,e,s){const i=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(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?r.moveTo(h.x,h.y):r.lineTo(h.x,h.y);continue}const c=t[a],u=t[(a+2)%o],d=i(c,h);let f;if(d<1e-4)f=h;else{const m=Math.min(d/2,l);f=n(h,c,m/d)}const p=i(u,h);let g;if(p<1e-4)g=h;else{const m=Math.min(p/2,l);g=n(h,u,m/p)}a===0?r.moveTo(f.x,f.y):r.lineTo(f.x,f.y),r.quadraticCurveTo(h.x,h.y,g.x,g.y,s)}}const Wf=new tt;class zf{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,i=s[s.length-2],n=s[s.length-1];return(i!==t||n!==e)&&s.push(t,e),this}arc(t,e,s,i,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return wh(a,t,e,s,i,n,o),this}arcTo(t,e,s,i,n){this._ensurePoly();const o=this._currentPoly.points;return Df(o,t,e,s,i,n),this}arcToSvg(t,e,s,i,n,o,a){const h=this._currentPoly.points;return Lf(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,s,i,n),this}bezierCurveTo(t,e,s,i,n,o,a){this._ensurePoly();const h=this._currentPoly;return Ch(this._currentPoly.points,h.lastX,h.lastY,t,e,s,i,n,o,a),this}quadraticCurveTo(t,e,s,i,n){this._ensurePoly();const o=this._currentPoly;return Gf(this._currentPoly.points,o.lastX,o.lastY,t,e,s,i,n),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,i=s.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&s.length-i>1){let n=null;for(let o=i;o<s.length;o++){const a=s[o];if(a.shape.type==="polygon"){const h=a.shape,l=n==null?void 0:n.shape;l&&l.containsPolygon(h)?(n.holes||(n.holes=[]),n.holes.push(a),s.copyWithin(o,o+1),s.length--,o--):n=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,i,n){return this.drawShape(new tt(t,e,s,i),n),this}circle(t,e,s,i){return this.drawShape(new vi(t,e,s),i),this}poly(t,e,s){const i=new hs(t);return i.closePath=e,this.drawShape(i,s),this}regularPoly(t,e,s,i,n=0,o){i=Math.max(i|0,3);const a=-1*Math.PI/2+n,h=Math.PI*2/i,l=[];for(let c=0;c<i;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,i,n,o=0,a){if(i=Math.max(i|0,3),n<=0)return this.regularPoly(t,e,s,i,o);const h=s*Math.sin(Math.PI/i)-.001;n=Math.min(n,h);const l=-1*Math.PI/2+o,c=Math.PI*2/i,u=(i-2)*Math.PI/i/2;for(let d=0;d<i;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+n*Math.cos(m),y=g+n*Math.sin(m),v=p+n*Math.cos(_),S=g+n*Math.sin(_);d===0?this.moveTo(x,y):this.lineTo(x,y),this.quadraticCurveTo(p,g,v,S,a)}return this.closePath()}roundShape(t,e,s=!1,i){return t.length<3?this:(s?Hf(this,t,e,i):Nf(this,t,e),this.closePath())}filletRect(t,e,s,i,n){if(n===0)return this.rect(t,e,s,i);const o=Math.min(s,i)/2,a=Math.min(o,Math.max(-o,n)),h=t+s,l=e+i,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,i,n,o){if(n<=0)return this.rect(t,e,s,i);const a=Math.min(n,Math.min(s,i)/2),h=t+s,l=e+i,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,i,n){return this.drawShape(new Ti(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new Si(t,e,s,i,n),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 hs,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 hs,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,i=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=s;s=n.a*s+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(s,i)}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 i=e[s],n=i.shape.getBounds(Wf);i.transform?t.addRect(n,i.transform):t.addRect(n)}return t}}class Kt{constructor(t,e=!1){this.instructions=[],this.uid=et("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?Ed(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new zf(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,i,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(st.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,i,n]}),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 i=this.instructions[this.instructions.length-1],n=this.getLastPoint(st.shared);let o=0,a=0;if(!i||i.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=i.data[0],a=i.data[1];const h=n.x,l=n.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,i,n){return this.instructions.push({action:"rect",data:[t,e,s,i,n]}),this._dirty=!0,this}circle(t,e,s,i){return this.instructions.push({action:"circle",data:[t,e,s,i]}),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,i,n,o,a){n||(n=i/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?n:i,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 Kt;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const i=this.instructions[s];e.instructions.push({action:i.action,data:i.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,i=t.c,n=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+i*l+o,x[1]=s*h+n*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+i*u+o,x[1]=s*c+n*u+a,x[2]=e*d+i*f+o,x[3]=s*d+n*f+a,x[4]=e*h+i*l+o,x[5]=s*h+n*l+a;break;case"quadraticCurveTo":c=x[0],u=x[1],h=x[2],l=x[3],x[0]=e*c+i*u+o,x[1]=s*c+n*u+a,x[2]=e*h+i*l+o,x[3]=s*h+n*l+a;break;case"arcToSvg":h=x[5],l=x[6],p=x[0],g=x[1],x[0]=e*p+i*g,x[1]=s*p+n*g,x[5]=e*h+i*l+o,x[6]=s*h+n*l+a;break;case"circle":x[4]=Pe(x[3],t);break;case"rect":x[4]=Pe(x[4],t);break;case"ellipse":x[8]=Pe(x[8],t);break;case"roundRect":x[5]=Pe(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=Pe(x[2],t);break;case"regularPoly":case"chamferRect":x[5]=Pe(x[5],t);break;case"closePath":break;default:z("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 Pe(r,t){return r?r.prepend(t):t.clone()}function lt(r,t,e){const s=r.getAttribute(t);return s?Number(s):e}function Vf(r,t){const e=r.querySelectorAll("defs");for(let s=0;s<e.length;s++){const i=e[s];for(let n=0;n<i.children.length;n++){const o=i.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=Xf(o);break;case"radialgradient":t.defs[o.id]=$f();break}}}}function Xf(r){const t=lt(r,"x1",0),e=lt(r,"y1",0),s=lt(r,"x2",1),i=lt(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new Ht(t,e,s,i,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const h=r.children[a],l=lt(h,"offset",0),c=Q.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function $f(r){return z("[SVG Parser] Radial gradients are not yet supported"),new Ht(0,0,1,0)}function Mo(r){const t=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const Ao={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 Eh(r,t){const e=r.getAttribute("style"),s={},i={},n={strokeStyle:s,fillStyle:i,useFill:!1,useStroke:!1};for(const o in Ao){const a=r.getAttribute(o);a&&Ro(t,n,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(":");Ao[l]&&Ro(t,n,l,c.trim())}}return{strokeStyle:n.useStroke?s:null,fillStyle:n.useFill?i:null,useFill:n.useFill,useStroke:n.useStroke}}function Ro(r,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const i=Mo(s);t.strokeStyle.fill=r.defs[i]}else t.strokeStyle.color=Q.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 i=Mo(s);t.fillStyle.fill=r.defs[i]}else t.fillStyle.color=Q.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 jf(r){if(r.length<=2)return!0;const t=r.map(a=>a.area).sort((a,h)=>h-a),[e,s]=t,i=t[t.length-1],n=e/s,o=s/i;return!(n>3&&o<2)}function Yf(r){return r.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function qf(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],i=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(s.push(e[c]),i.push(e[c+1]));if(s.length===0||i.length===0)return 0;const n=Math.min(...s),o=Math.max(...s),a=Math.min(...i),h=Math.max(...i);return(o-n)*(h-a)}function ko(r,t){const e=new Kt(r,!1);for(const s of e.instructions)t.instructions.push(s)}function Kf(r,t){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const e={context:t,defs:{},path:new Kt};Vf(r,e);const s=r.children,{fillStyle:i,strokeStyle:n}=Eh(r,e);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&Ph(a,e,i,n)}return t}function Ph(r,t,e,s){const i=r.children,{fillStyle:n,strokeStyle:o}=Eh(r,t);n&&e?e={...e,...n}:n&&(e=n),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,y,v,S,T,C,k;switch(r.nodeName.toLowerCase()){case"path":{S=r.getAttribute("d");const M=r.getAttribute("fill-rule"),w=Yf(S),P=M==="evenodd",A=w.length>1;if(P&&A){const F=w.map(E=>({path:E,area:qf(E)}));if(F.sort((E,B)=>B.area-E.area),w.length>3||!jf(F))for(let E=0;E<F.length;E++){const B=F[E],U=E===0;t.context.beginPath();const R=new Kt(void 0,!0);ko(B.path,R),t.context.path(R),U?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let E=0;E<F.length;E++){const B=F[E],U=E%2===1;t.context.beginPath();const R=new Kt(void 0,!0);ko(B.path,R),t.context.path(R),U?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const F=M?M==="evenodd":!0;T=new Kt(S,F),t.context.path(T),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":p=lt(r,"cx",0),g=lt(r,"cy",0),m=lt(r,"r",0),t.context.ellipse(p,g,m,m),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":h=lt(r,"x",0),l=lt(r,"y",0),C=lt(r,"width",0),k=lt(r,"height",0),_=lt(r,"rx",0),x=lt(r,"ry",0),_||x?t.context.roundRect(h,l,C,k,_||x):t.context.rect(h,l,C,k),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":p=lt(r,"cx",0),g=lt(r,"cy",0),_=lt(r,"rx",0),x=lt(r,"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=lt(r,"x1",0),u=lt(r,"y1",0),d=lt(r,"x2",0),f=lt(r,"y2",0),t.context.beginPath(),t.context.moveTo(c,u),t.context.lineTo(d,f),s&&t.context.stroke(s);break;case"polygon":v=r.getAttribute("points"),y=v.match(/-?\d+/g).map(M=>parseInt(M,10)),t.context.poly(y,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":v=r.getAttribute("points"),y=v.match(/-?\d+/g).map(M=>parseInt(M,10)),t.context.poly(y,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{z(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let M=0;M<i.length;M++)Ph(i[M],t,e,s)}const Bo={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 G,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Bo[e].addressModeU,t.source.style.addressModeV=Bo[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),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 Zf(r){return Q.isColorLike(r)}function Io(r){return r instanceof vs}function Go(r){return r instanceof Ht}function Qf(r){return r instanceof L}function Jf(r,t,e){const s=Q.shared.setValue(t??0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=L.WHITE,{...e,...r}}function tp(r,t,e){return r.texture=t,{...e,...r}}function Fo(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,{...e,...r}}function Do(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,{...e,...r}}function ep(r,t){const e={...t,...r},s=Q.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function me(r,t){if(r==null)return null;const e={},s=r;return Zf(r)?Jf(e,r,t):Qf(r)?tp(e,r,t):Io(r)?Fo(e,r,t):Go(r)?Do(e,r,t):s.fill&&Io(s.fill)?Fo(s,s.fill,t):s.fill&&Go(s.fill)?Do(s,s.fill,t):ep(s,t)}function Js(r,t){const{width:e,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...h}=t,l=me(r,h);return l?{width:e,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...l}:null}function sp(r,t){let e=1;const s=r.shapePath.shapePrimitives;for(let i=0;i<s.length;i++){const n=s[i].shape;if(n.type!=="polygon")continue;const o=n.points,a=o.length;if(a<6)continue;const h=n.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,y=f-g,v=m-p,S=_-g,T=x*x+y*y,C=v*v+S*S;if(T<1e-12||C<1e-12)continue;let w=(x*v+y*S)/Math.sqrt(T*C);w<-1?w=-1:w>1&&(w=1);const P=Math.sqrt((1-w)*.5);if(P<1e-6)continue;const A=Math.min(1/P,t);A>e&&(e=A)}}return e}const rp=new st,Uo=new G,Di=class Ot extends kt{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 Kt,this._transform=new G,this._fillStyle={...Ot.defaultFillStyle},this._strokeStyle={...Ot.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new _t,this._boundsDirty=!0}clone(){const t=new Ot;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=me(t,Ot.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Js(t,Ot.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=me(t,Ot.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=me(t,Ot.defaultStrokeStyle),this}texture(t,e,s,i,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:i||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?Q.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Kt,this}fill(t,e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="stroke"?s=i.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(H(ot,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=me(t,Ot.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(st.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==null?void 0:s.action)==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Js(t,Ot.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,i,n,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,i,n,o),this}arcTo(t,e,s,i,n){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*i+o.tx,o.b*s+o.d*i+o.ty,n),this}arcToSvg(t,e,s,i,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,i,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,s,i,n,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*i+h.tx,h.b*s+h.d*i+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,i){return this._tick++,this._activePath.ellipse(t,e,s,i,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,i=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return i.length===1&&i[0].action==="moveTo"?(i[0].data[0]=n,i[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,s,i,n){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*i+o.tx,o.b*s+o.d*i+o.ty,n),this}rect(t,e,s,i){return this._tick++,this._activePath.rect(t,e,s,i,this._transform.clone()),this}roundRect(t,e,s,i,n){return this._tick++,this._activePath.roundRect(t,e,s,i,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,i,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,i,n,o),this}roundPoly(t,e,s,i,n,o){return this._tick++,this._activePath.roundPoly(t,e,s,i,n,o),this}roundShape(t,e,s,i){return this._tick++,this._activePath.roundShape(t,e,s,i),this}filletRect(t,e,s,i,n){return this._tick++,this._activePath.filletRect(t,e,s,i,n),this}chamferRect(t,e,s,i,n,o){return this._tick++,this._activePath.chamferRect(t,e,s,i,n,o),this}star(t,e,s,i,n=0,o=0){return this._tick++,this._activePath.star(t,e,s,i,n,o,this._transform.clone()),this}svg(t){return this._tick++,Kf(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,i,n,o){return t instanceof G?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,i,n,o),this)}transform(t,e,s,i,n,o){return t instanceof G?(this._transform.append(t),this):(Uo.set(t,e,s,i,n,o),this._transform.append(Uo),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],i=s.action;if(i==="fill"){const n=s.data;t.addBounds(n.path.bounds)}else if(i==="texture"){const n=s.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(i==="stroke"){const n=s.data,o=n.style.alignment;let a=n.style.width*(1-o);n.style.join==="miter"&&(a*=sp(n.path,n.style.miterLimit));const h=n.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){var i;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 o=e[n],a=o.data,h=a.path;if(!o.action||!h)continue;const l=a.style,c=h.shapePath.shapePrimitives;for(let u=0;u<c.length;u++){const d=c[u].shape;if(!l||!d)continue;const f=c[u].transform,p=f?f.applyInverse(t,rp):t;if(o.action==="fill")s=d.contains(p.x,p.y);else{const m=l;s=d.strokeContains(p.x,p.y,m.width,m.alignment)}const g=a.hole;if(g){const m=(i=g.shapePath)==null?void 0:i.shapePrimitives;if(m)for(let _=0;_<m.length;_++)m[_].shape.contains(p.x,p.y)&&(s=!1)}if(s)return!0}}return s}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||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==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0: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}};Di.defaultFillStyle={color:16777215,alpha:1,texture:L.WHITE,matrix:null,fill:null,textureSpace:"local"};Di.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:L.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Ft=Di;class Mh{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 Ua({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],i=s.element;if(!s.parent||s.globalDisplayStatus<7)i==null||i.remove(),t.splice(e,1),e--;else{this._domElement.contains(i)||(i.style.position="absolute",i.style.pointerEvents="auto",this._domElement.appendChild(i));const n=s.worldTransform,o=s._anchor,a=s.width*o.x,h=s.height*o.y;i.style.transformOrigin=`${a}px ${h}px`,i.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-h})`,i.style.opacity=s.groupAlpha.toString()}}}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)(t=this._attachedDomElements[e].element)==null||t.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Mh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"dom"};class ip{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||(At.system.add(this._tickerUpdate,this,He.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(At.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 jt=new ip;class tr extends ys{constructor(){super(...arguments),this.client=new st,this.movement=new st,this.offset=new st,this.global=new st,this.screen=new st}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,i,n,o,a,h,l,c,u,d,f,p,g){throw new Error("Method not implemented.")}}class Gt extends tr{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 ze extends tr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}ze.DOM_DELTA_PIXEL=0;ze.DOM_DELTA_LINE=1;ze.DOM_DELTA_PAGE=2;const np=2048,op=new st,es=new st;class ap{constructor(t){this.dispatch=new kt,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,i)=>s.priority-i.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,i=e.length;s<i;s++)e[s].fn(t);else z(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){jt.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,op.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;const s=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,n=s.length-1;i<n;i++)if(t.currentTarget=s[i],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 i=s.length-2;i>=0;i--)if(t.currentTarget=s[i],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 i=Array.isArray(e)?e:[e];for(let n=s.length-1;n>=0;n--)i.forEach(o=>{t.currentTarget=s[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let s=0;s<np&&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,i,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(jt.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,i,n,o||n(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&&!n(t,s)&&i(t,s)?l?[t]:[]:null}hitTestRecursive(t,e,s,i,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(jt.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,i,n);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&&i(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,es),!t.hitArea.contains(es.x,es.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s<t.effects.length;s++){const i=t.effects[s];if(i.containsPoint&&!i.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,es),t.containsPoint(es)):!1}notifyTarget(t,e){var n,o;if(!t.currentTarget.isInteractive())return;e??(e=t.type);const s=`on${e}`;(o=(n=t.currentTarget)[s])==null||o.call(n,t);const i=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,i),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Gt)){z("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 i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const s=this.trackingData(t.pointerId);s.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var h,l;if(!(t instanceof Gt)){z("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",i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.overTargets);if(((h=i.overTargets)==null?void 0:h.length)>0&&n!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,n);if(this.dispatchEvent(u,"pointerout"),s&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),s&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),s&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(u)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),s&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(l=e.target)==null?void 0:l.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,i.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof Gt)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),s=this.createPointerEvent(t),i=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),i&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=(o=s.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(s,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Gt)){z("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",i=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);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(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Gt)){z("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 i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[t.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;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 i.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,i.clicksByButton[t.button]||(i.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const h=i.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 Gt)){z("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]),i=this.createPointerEvent(t);if(s){let n=s;for(;n;)i.currentTarget=n,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof ze)){z("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 i=this.allocateEvent(Gt);return this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.nativeEvent=t.nativeEvent,i.originalEvent=t,i.target=s??this.hitTest(i.global.x,i.global.y)??this._hitElements[0],typeof e=="string"&&(i.type=e),i}createWheelEvent(t){const e=this.allocateEvent(ze);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(Gt);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 Gt&&e instanceof Gt&&(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 tr&&e instanceof tr&&(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 i=0,n=s.length;i<n&&!t.propagationImmediatelyStopped;i++)s[i].once&&t.currentTarget.removeListener(e,s[i].fn,void 0,!0),s[i].fn.call(s[i].context,t)}}const hp=1,lp={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ui=class ni{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new ap(null),jt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Gt(null),this._rootWheelEvent=new ze(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...ni.defaultEventFeatures},{set:(e,s,i)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),e[s]=i,!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,ni._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){jt.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,i=e.length;s<i;s++){const n=e[s],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,jt.pointerMoved();const e=this._normalizeToPointerData(t);for(let s=0,i=e.length;s<i;s++){const n=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",i=this._normalizeToPointerData(t);for(let n=0,o=i.length;n<o;n++){const a=this._bootstrapEvent(this._rootPointerEvent,i[n]);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,i=e.length;s<i;s++){const n=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,jt.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;jt.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;jt.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 i=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-i.left)*(this.domElement.width/i.width)*n,t.y=(s-i.top)*(this.domElement.height/i.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let s=0,i=t.changedTouches.length;s<i;s++){const n=t.changedTouches[s];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,n.altKey??(n.altKey=t.altKey),n.ctrlKey??(n.ctrlKey=t.ctrlKey),n.metaKey??(n.metaKey=t.metaKey),n.shiftKey??(n.shiftKey=t.shiftKey),e.push(n)}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=hp),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=lp[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}};Ui.extension={name:"events",type:[b.WebGLSystem,b.CanvasSystem,b.WebGPUSystem],priority:-1};Ui.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ah=Ui;const cp={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(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ah.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=s?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,h=this;i&&i.addEventListener("abort",()=>{h.off(r,a,o)}),n?h.once(r,a,o):h.on(r,a,o)},removeEventListener(r,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof t=="function"?void 0:t;r=s?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,i)},dispatchEvent(r){if(!(r instanceof ys))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};let Me;function Oo(r){const t=j.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function Rh(){if(Me!==void 0)return Me;try{const r=Oo("#ff00ff"),t=Oo("#ffff00"),s=j.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(r,0,0),s.drawImage(t,2,0);const i=s.getImageData(2,0,1,1);if(!i)Me=!1;else{const n=i.data;Me=n[0]===255&&n[1]===0&&n[2]===0}}catch{Me=!1}return Me}const X={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Rh(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{const t=r.source,e=t==null?void 0:t.resource;if(!e)return null;const s=t.alphaMode==="premultiplied-alpha",i=t.resourceWidth??t.pixelWidth,n=t.resourceHeight??t.pixelHeight,o=i!==t.pixelWidth||n!==t.pixelHeight;if(s){if((e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)&&!o)return e;const a=X._unpremultipliedCache.get(t);if((a==null?void 0: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=X._canvasSourceCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas;const h=j.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),X._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}if(s){const a=j.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),X._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){const a=X._canvasSourceCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas;const h=j.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d");return h.width=t.pixelWidth,h.height=t.pixelHeight,l.drawImage(e,0,0),X._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}return e},getTintedCanvas:(r,t)=>{const e=r.texture,s=Q.shared.setValue(t).toHex(),i=e.tintCache||(e.tintCache={}),n=i[s],o=e.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:j.get().createCanvas();return X.tintMethod(e,t,a),a.tintId=o,i[s]=a,i[s]},getTintedPattern:(r,t)=>{const e=Q.shared.setValue(t).toHex(),s=r.patternCache||(r.patternCache={}),i=r.source._resourceId;let n=s[e];return(n==null?void 0:n.tintId)===i||(X.canvas||(X.canvas=j.get().createCanvas()),X.tintMethod(r,t,X.canvas),n=X.canvas.getContext("2d").createPattern(X.canvas,"repeat"),n.tintId=i,s[e]=n),n},applyPatternTransform:(r,t,e=!0)=>{if(!t)return;const s=r;if(!s.setTransform)return;const i=globalThis.DOMMatrix;if(!i)return;const n=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);s.setTransform(e?n.inverse():n)},tintWithMultiply:(r,t,e)=>{const s=e.getContext("2d"),i=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=$.isVertical(o),h=a?i.height:i.width,l=a?i.width:i.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.fillStyle=Q.shared.setValue(t).toHex(),s.fillRect(0,0,h,l),s.globalCompositeOperation="multiply";const c=X.getCanvasSource(r);if(!c){s.restore();return}o&&X._applyInverseRotation(s,o,i.width,i.height),s.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height),s.globalCompositeOperation="destination-atop",s.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height),s.restore()},tintWithOverlay:(r,t,e)=>{const s=e.getContext("2d"),i=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=$.isVertical(o),h=a?i.height:i.width,l=a?i.width:i.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.globalCompositeOperation="copy",s.fillStyle=Q.shared.setValue(t).toHex(),s.fillRect(0,0,h,l),s.globalCompositeOperation="destination-atop";const c=X.getCanvasSource(r);if(!c){s.restore();return}o&&X._applyInverseRotation(s,o,i.width,i.height),s.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height),s.restore()},tintWithPerPixel:(r,t,e)=>{const s=e.getContext("2d"),i=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=$.isVertical(o),h=a?i.height:i.width,l=a?i.width:i.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.globalCompositeOperation="copy";const c=X.getCanvasSource(r);if(!c){s.restore();return}o&&X._applyInverseRotation(s,o,i.width,i.height),s.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.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:(r,t,e,s)=>{const i=$.inv(t),n=$.uX(i),o=$.uY(i),a=$.vX(i),h=$.vY(i),l=-Math.min(0,n*e,a*s,n*e+a*s),c=-Math.min(0,o*e,h*s,o*e+h*s);r.transform(n,o,a,h,l,c)}};X.tintMethod=X.canUseMultiply?X.tintWithMultiply:X.tintWithPerPixel;class up{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=j.get().createCanvas();s.width=t,s.height=e;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=Oe(t),e=Oe(e);const i=(t<<17)+(e<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:i}=e,n=(s<<17)+(i<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,i),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Ve=new up;Xe.register(Ve);const Lo=new G;function kh(r,t){t.clear();const e=t.matrix;for(let s=0;s<r.length;s++){const i=r[s];if(i.globalDisplayStatus<7)continue;const n=i.renderGroup??i.parentRenderGroup;n!=null&&n.isCachedAsTexture?t.matrix=Lo.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n!=null&&n._parentCacheAsTextureRenderGroup?t.matrix=Lo.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):t.matrix=i.worldTransform,t.addBounds(i.bounds)}return t.matrix=e,t}const dp=new _t;function Bh(r,t,e,s,i=!1){const n=dp;n.minX=0,n.minY=0,n.maxX=r.width/s|0,n.maxY=r.height/s|0;const o=yt.getOptimalTexture(n.width,n.height,s,!1,i);return o.source.uploadMethodId="image",o.source.resource=r,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 No(r){return typeof r.getCanvasFilterString=="function"}class fp{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new _t,this.cssFilterString=""}}class Ih{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 i=[],n=1;for(const h of s){if(!h.enabled)continue;if(!No(h)){this._warnUnsupportedFilter(h);continue}const l=h.getCanvasFilterString();if(l===null){this._warnUnsupportedFilter(h);continue}l&&i.push(l)}if(i.length===0&&n===1){e.skip=!0;return}e.cssFilterString=i.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!=null&&e.length)||e.every(_=>!_.enabled))return t;const s=[],i=1;for(const _ of e){if(!_.enabled)continue;if(!No(_)){this._warnUnsupportedFilter(_);continue}const x=_.getCanvasFilterString();if(x===null){this._warnUnsupportedFilter(_);continue}x&&s.push(x)}if(s.length===0&&i===1)return t;const n=X.getCanvasSource(t);if(!n)return t;const o=t.frame,a=t.source._resolution??t.source.resolution??1,h=o.width,l=o.height,c=Ve.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(n,f,p,g,m,0,0,g,m),d.filter="none",d.globalAlpha=1,Bh(u,h,l,a)}_calculateFilterArea(t,e){if(t.renderables?kh(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 s=t.container.renderGroup||t.container.parentRenderGroup,i=s==null?void 0:s.cacheToLocalTransform;i&&e.applyMatrix(i)}}_warnUnsupportedFilter(t){var s;const e=((s=t==null?void 0:t.constructor)==null?void 0:s.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 fp),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}}Ih.extension={type:[b.CanvasSystem],name:"filter"};var pp=`in vec2 aPosition;
252
+ out vec2 vTextureCoord;
253
+
254
+ uniform vec4 uInputSize;
255
+ uniform vec4 uOutputFrame;
256
+ uniform vec4 uOutputTexture;
257
+
258
+ vec4 filterVertexPosition( void )
259
+ {
260
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
261
+
262
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
263
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
264
+
265
+ return vec4(position, 0.0, 1.0);
266
+ }
267
+
268
+ vec2 filterTextureCoord( void )
269
+ {
270
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
271
+ }
272
+
273
+ void main(void)
274
+ {
275
+ gl_Position = filterVertexPosition();
276
+ vTextureCoord = filterTextureCoord();
277
+ }
278
+ `,mp=`in vec2 vTextureCoord;
279
+ out vec4 finalColor;
280
+ uniform sampler2D uTexture;
281
+ void main() {
282
+ finalColor = texture(uTexture, vTextureCoord);
283
+ }
284
+ `,Ho=`struct GlobalFilterUniforms {
285
+ uInputSize: vec4<f32>,
286
+ uInputPixel: vec4<f32>,
287
+ uInputClamp: vec4<f32>,
288
+ uOutputFrame: vec4<f32>,
289
+ uGlobalFrame: vec4<f32>,
290
+ uOutputTexture: vec4<f32>,
291
+ };
292
+
293
+ @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
294
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
295
+ @group(0) @binding(2) var uSampler: sampler;
296
+
297
+ struct VSOutput {
298
+ @builtin(position) position: vec4<f32>,
299
+ @location(0) uv: vec2<f32>
300
+ };
301
+
302
+ fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
303
+ {
304
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
305
+
306
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
307
+ position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
308
+
309
+ return vec4(position, 0.0, 1.0);
310
+ }
311
+
312
+ fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
313
+ {
314
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
315
+ }
316
+
317
+ @vertex
318
+ fn mainVertex(
319
+ @location(0) aPosition: vec2<f32>,
320
+ ) -> VSOutput {
321
+ return VSOutput(
322
+ filterVertexPosition(aPosition),
323
+ filterTextureCoord(aPosition)
324
+ );
325
+ }
326
+
327
+ @fragment
328
+ fn mainFragment(
329
+ @location(0) uv: vec2<f32>,
330
+ ) -> @location(0) vec4<f32> {
331
+ return textureSample(uTexture, uSampler, uv);
332
+ }
333
+ `;class gp extends $a{constructor(){const t=ye.from({vertex:{source:Ho,entryPoint:"mainVertex"},fragment:{source:Ho,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=$e.from({vertex:pp,fragment:mp,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}class Gh{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}}Gh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"};const _p=new wi({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 xp{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 Fh{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Wt({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 re({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,s=t.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=s,i.container=t.container,i.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(s.every(f=>!f.enabled)){i.skip=!0;return}const h=i.bounds;if(this._calculateFilterArea(t,h),this._calculateFilterBounds(i,e.renderTarget.rootViewPort,a,o,1),i.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(i,u,d,c,n.width,n.height),this._setupFilterTextures(i,h,e,l)}generateFilteredTexture({texture:t,filters:e}){const s=this._pushFilterData();this._activeFilterData=s,s.skip=!1,s.filters=e;const i=t.source,n=i.resolution,o=i.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,n,0),s.skip)return t;const h=n;this._calculateGlobalFrame(s,0,0,h,i.width,i.height),s.outputRenderSurface=yt.getOptimalTexture(a.width,a.height,s.resolution,s.antialias),s.backTexture=L.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&&yt.returnTexture(e.backTexture),yt.returnTexture(e.inputTexture))}getBackTexture(t,e,s){const i=t.colorTexture.source._resolution,n=yt.getOptimalTexture(e.width,e.height,i,!1);let o=e.minX,a=e.minY;s&&(o-=s.minX,a-=s.minY),o=Math.floor(o*i),a=Math.floor(a*i);const h=Math.ceil(e.width*i),l=Math.ceil(e.height*i);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:h,height:l},{x:0,y:0}),n}applyFilter(t,e,s,i){const n=this.renderer,o=this._activeFilterData,h=o.outputRenderSurface===s,l=n.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,i);const f=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,e,n)}calculateSpriteMatrix(t,e){const s=this._activeFilterData,i=t.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),n=e.worldTransform.copyTo(G.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/e.texture.orig.width,1/e.texture.orig.height),i.translate(e.anchor.x,e.anchor.y),i}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new gp),this._passthroughFilter}_setupBindGroupsAndRender(t,e,s){if(s.renderPipes.uniformBatch){const i=s.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,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:_p,shader:t,state:t._state,topology:"triangle-list"}),s.type===Nt.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,s,i){if(t.backTexture=L.EMPTY,t.inputTexture=yt.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){s.renderTarget.finishRenderPass();const n=s.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,i==null?void 0:i.bounds)}s.renderTarget.bind(t.inputTexture,!0),s.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,s,i,n,o){const a=t.globalFrame;a.x=e*i,a.y=s*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(t,e,s,i,n,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-i,c[1]=s.bounds.minY-n):(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]=i*o,p[1]=n*o,p[2]=m.source.width*o,p[3]=m.source.height*o,e instanceof L&&(e.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!h),e instanceof L?(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 i=this._filterStack[s];if(!i.skip){t=i.bounds.minX,e=i.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?kh(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 i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const s=t.inputTexture,i=t.bounds,n=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)n[o].apply(this,s,t.outputRenderSurface,e);else{let h=t.inputTexture;const l=yt.getOptimalTexture(i.width,i.height,h.source._resolution,!1);let c=l;for(let u=o;u<a;u++){const d=n[u];if(!d.enabled)continue;d.apply(this,h,c,!0);const f=h;h=c,c=f}n[a].apply(this,h,t.outputRenderSurface,e),yt.returnTexture(l)}}_calculateFilterBounds(t,e,s,i,n){var _;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 x=0;x<h.length;x++){const y=h[x];if(!y.enabled)continue;if(g===-1&&(g=x),m=x,l=Math.min(l,y.resolution==="inherit"?i:y.resolution),c+=y.padding,y.antialias==="off"?u=!1:y.antialias==="inherit"&&u&&(u=s),y.clipToViewport||(p=!1),!!!(y.compatibleRenderers&o.type)){f=!1;break}if(y.blendRequired&&!(((_=o.backBuffer)==null?void 0:_.useBackBuffer)??!0)){z("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,d||(d=y.blendRequired)}if(!f){t.skip=!0;return}if(p&&a.fitBounds(0,e.width/i,0,e.height/i),a.scale(l).ceil().scale(1/l).pad((c|0)*n),!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 xp),this._filterStackIndex++,t}}Fh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"};var yp=`in vec2 vMaskCoord;
334
+ in vec2 vTextureCoord;
335
+
336
+ uniform sampler2D uTexture;
337
+ uniform sampler2D uMaskTexture;
338
+
339
+ uniform float uAlpha;
340
+ uniform vec4 uMaskClamp;
341
+ uniform float uInverse;
342
+ uniform float uChannel;
343
+
344
+ out vec4 finalColor;
345
+
346
+ void main(void)
347
+ {
348
+ float clip = step(3.5,
349
+ step(uMaskClamp.x, vMaskCoord.x) +
350
+ step(uMaskClamp.y, vMaskCoord.y) +
351
+ step(vMaskCoord.x, uMaskClamp.z) +
352
+ step(vMaskCoord.y, uMaskClamp.w));
353
+
354
+ // TODO look into why this is needed
355
+ float npmAlpha = uAlpha;
356
+ vec4 original = texture(uTexture, vTextureCoord);
357
+ vec4 masky = texture(uMaskTexture, vMaskCoord);
358
+
359
+ float a;
360
+ if (uChannel == 1.0) {
361
+ a = masky.a * npmAlpha * clip;
362
+ } else {
363
+ float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
364
+ a = alphaMul * masky.r * npmAlpha * clip;
365
+ }
366
+
367
+ if (uInverse == 1.0) {
368
+ a = 1.0 - a;
369
+ }
370
+
371
+ finalColor = original * a;
372
+ }
373
+ `,bp=`in vec2 aPosition;
374
+
375
+ out vec2 vTextureCoord;
376
+ out vec2 vMaskCoord;
377
+
378
+
379
+ uniform vec4 uInputSize;
380
+ uniform vec4 uOutputFrame;
381
+ uniform vec4 uOutputTexture;
382
+ uniform mat3 uFilterMatrix;
383
+
384
+ vec4 filterVertexPosition( vec2 aPosition )
385
+ {
386
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
387
+
388
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
389
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
390
+
391
+ return vec4(position, 0.0, 1.0);
392
+ }
393
+
394
+ vec2 filterTextureCoord( vec2 aPosition )
395
+ {
396
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
397
+ }
398
+
399
+ vec2 getFilterCoord( vec2 aPosition )
400
+ {
401
+ return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
402
+ }
403
+
404
+ void main(void)
405
+ {
406
+ gl_Position = filterVertexPosition(aPosition);
407
+ vTextureCoord = filterTextureCoord(aPosition);
408
+ vMaskCoord = getFilterCoord(aPosition);
409
+ }
410
+ `,Wo=`struct GlobalFilterUniforms {
411
+ uInputSize:vec4<f32>,
412
+ uInputPixel:vec4<f32>,
413
+ uInputClamp:vec4<f32>,
414
+ uOutputFrame:vec4<f32>,
415
+ uGlobalFrame:vec4<f32>,
416
+ uOutputTexture:vec4<f32>,
417
+ };
418
+
419
+ struct MaskUniforms {
420
+ uFilterMatrix:mat3x3<f32>,
421
+ uMaskClamp:vec4<f32>,
422
+ uAlpha:f32,
423
+ uInverse:f32,
424
+ uChannel:f32,
425
+ };
426
+
427
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
428
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
429
+ @group(0) @binding(2) var uSampler : sampler;
430
+
431
+ @group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
432
+ @group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
433
+
434
+ struct VSOutput {
435
+ @builtin(position) position: vec4<f32>,
436
+ @location(0) uv : vec2<f32>,
437
+ @location(1) filterUv : vec2<f32>,
438
+ };
439
+
440
+ fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
441
+ {
442
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
443
+
444
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
445
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
446
+
447
+ return vec4(position, 0.0, 1.0);
448
+ }
449
+
450
+ fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
451
+ {
452
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
453
+ }
454
+
455
+ fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
456
+ {
457
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
458
+ }
459
+
460
+ fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
461
+ {
462
+ return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
463
+ }
464
+
465
+ fn getSize() -> vec2<f32>
466
+ {
467
+ return gfu.uGlobalFrame.zw;
468
+ }
469
+
470
+ @vertex
471
+ fn mainVertex(
472
+ @location(0) aPosition : vec2<f32>,
473
+ ) -> VSOutput {
474
+ return VSOutput(
475
+ filterVertexPosition(aPosition),
476
+ filterTextureCoord(aPosition),
477
+ getFilterCoord(aPosition)
478
+ );
479
+ }
480
+
481
+ @fragment
482
+ fn mainFragment(
483
+ @location(0) uv: vec2<f32>,
484
+ @location(1) filterUv: vec2<f32>,
485
+ @builtin(position) position: vec4<f32>
486
+ ) -> @location(0) vec4<f32> {
487
+
488
+ var maskClamp = filterUniforms.uMaskClamp;
489
+ var uAlpha = filterUniforms.uAlpha;
490
+
491
+ var clip = step(3.5,
492
+ step(maskClamp.x, filterUv.x) +
493
+ step(maskClamp.y, filterUv.y) +
494
+ step(filterUv.x, maskClamp.z) +
495
+ step(filterUv.y, maskClamp.w));
496
+
497
+ var mask = textureSample(uMaskTexture, uSampler, filterUv);
498
+ var source = textureSample(uTexture, uSampler, uv);
499
+
500
+ var a: f32;
501
+ if (filterUniforms.uChannel == 1.0) {
502
+ a = mask.a * uAlpha * clip;
503
+ } else {
504
+ var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
505
+ a = alphaMul * mask.r * uAlpha * clip;
506
+ }
507
+
508
+ if (filterUniforms.uInverse == 1.0) {
509
+ a = 1.0 - a;
510
+ }
511
+
512
+ return source * a;
513
+ }
514
+ `;class vp extends $a{constructor(t){const{sprite:e,...s}=t,i=new pa(e.texture),n=new Wt({uFilterMatrix:{value:new G,type:"mat3x3<f32>"},uMaskClamp:{value:i.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"},uChannel:{value:t.channel==="alpha"?1:0,type:"f32"}}),o=ye.from({vertex:{source:Wo,entryPoint:"mainVertex"},fragment:{source:Wo,entryPoint:"mainFragment"}}),a=$e.from({vertex:bp,fragment:yp,name:"mask-filter"});super({...s,gpuProgram:o,glProgram:a,clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=i}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(t){this.resources.filterUniforms.uniforms.uChannel=t==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(t,e,s,i){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,s,i)}}class Tp{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Sp{constructor(){this.instructions=new _i}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Oi=class oi{constructor(t){this._renderer=t,this._managedContexts=new zt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){oi.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??oi.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,s=!!e[this._renderer.uid],i=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!s)&&(s&&i.reset(),i.isBatchable=!1,t.dirty=!1),i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new Sp,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new Tp;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Oi.extension={type:[b.CanvasSystem],name:"graphicsContext"};Oi.defaultOptions={bezierSmoothness:.5};let Cp=Oi;class Dh{constructor(t,e){this.state=Qt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new zt({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}}Dh.extension={type:[b.CanvasPipes],name:"graphics"};function Uh(r,t,e){const s=(r>>24&255)/255;t[e++]=(r&255)/255*s,t[e++]=(r>>8&255)/255*s,t[e++]=(r>>16&255)/255*s,t[e++]=s}class wp{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{mt.return(t)}),this.batches.length=0}}class Oh{constructor(t,e){this.state=Qt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new zt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,n=this.renderer.graphicsContext.updateGpuContext(e);return!!(n.isBatchable||s!==n.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const s=this._getGpuDataForRenderable(t).batches;for(let i=0;i<s.length;i++){const n=s[i];n._batcher.updateElement(n)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const n=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const o=n.resources.localUniforms.uniforms;o.uTransformMatrix=t.groupTransform,o.uRound=e._roundPixels|t._roundPixels,Uh(t.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const s=this.renderer.renderPipes.batch,i=this._getGpuDataForRenderable(t).batches;for(let n=0;n<i.length;n++){const o=i[n];s.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new wp;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const s=t.context,n=this.renderer.graphicsContext.getGpuContext(s),o=this.renderer._roundPixels|t._roundPixels;e.batches=n.batches.map(a=>{const h=mt.get(ki);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}}Oh.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"graphics"};W.add(Dh);W.add(Oh);W.add(Cp);W.add(Fi);class er extends yi{constructor(t){t instanceof Ft&&(t={context:t});const{context:e,roundPixels:s,...i}=t||{};super({label:"Graphics",...i}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new Ft,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==null?void 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 er(this._context.clone()):(this._ownedContext=null,new er(this._context))}lineStyle(t,e,s){H(ot,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const i={};return t&&(i.width=t),e&&(i.color=e),s&&(i.alpha=s),this.context.strokeStyle=i,this}beginFill(t,e){H(ot,"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(){H(ot,"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!==Ft.defaultStrokeStyle.width||t.color!==Ft.defaultStrokeStyle.color||t.alpha!==Ft.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return H(ot,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return H(ot,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return H(ot,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return H(ot,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return H(ot,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return H(ot,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Ws={name:"local-uniform-bit",vertex:{header:`
515
+
516
+ struct LocalUniforms {
517
+ uTransformMatrix:mat3x3<f32>,
518
+ uColor:vec4<f32>,
519
+ uRound:f32,
520
+ }
521
+
522
+ @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
523
+ `,main:`
524
+ vColor *= localUniforms.uColor;
525
+ modelMatrix *= localUniforms.uTransformMatrix;
526
+ `,end:`
527
+ if(localUniforms.uRound == 1)
528
+ {
529
+ vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
530
+ }
531
+ `}},Ep={...Ws,vertex:{...Ws.vertex,header:Ws.vertex.header.replace("group(1)","group(2)")}},Lh={name:"local-uniform-bit",vertex:{header:`
532
+
533
+ uniform mat3 uTransformMatrix;
534
+ uniform vec4 uColor;
535
+ uniform float uRound;
536
+ `,main:`
537
+ vColor *= uColor;
538
+ modelMatrix = uTransformMatrix;
539
+ `,end:`
540
+ if(uRound == 1.)
541
+ {
542
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
543
+ }
544
+ `}};class Pp extends yi{constructor(t,e){const{text:s,resolution:i,style:n,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=n,this.resolution=i??null,this.allowChildren=!1,this._anchor=new gt({_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){var e;t||(t={}),(e=this._style)==null||e.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,i=-e*this.anchor.x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+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!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Mp(r,t){let e=r[0]??{};return(typeof e=="string"||r[1])&&(H(ot,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:r[1]}),e}let ae=null,Yt=null;function Ap(r,t){ae||(ae=j.get().createCanvas(256,128),Yt=ae.getContext("2d",{willReadFrequently:!0}),Yt.globalCompositeOperation="copy",Yt.globalAlpha=1),(ae.width<r||ae.height<t)&&(ae.width=Oe(r),ae.height=Oe(t))}function zo(r,t,e){for(let s=0,i=4*e*t;s<t;++s,i+=4)if(r[i+3]!==0)return!1;return!0}function Vo(r,t,e,s,i){const n=4*t;for(let o=s,a=s*n+4*e;o<=i;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function Rp(...r){let t=r[0];t.canvas||(t={canvas:r[0],resolution:r[1]});const{canvas:e}=t,s=Math.min(t.resolution??1,1),i=t.width??e.width,n=t.height??e.height;let o=t.output;if(Ap(i,n),!Yt)throw new TypeError("Failed to get canvas 2D context");Yt.drawImage(e,0,0,i,n,0,0,i*s,n*s);const h=Yt.getImageData(0,0,i,n).data;let l=0,c=0,u=i-1,d=n-1;for(;c<n&&zo(h,i,c);)++c;if(c===n)return tt.EMPTY;for(;zo(h,i,d);)--d;for(;Vo(h,i,l,c,d);)++l;for(;Vo(h,i,u,c,d);)--u;return++u,++d,Yt.globalCompositeOperation="source-over",Yt.strokeRect(l,c,u-l,d-c),Yt.globalCompositeOperation="copy",o??(o=new tt),o.set(l/s,c/s,(u-l)/s,(d-c)/s),o}/**
545
+ * tiny-lru
546
+ *
547
+ * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
548
+ * @license BSD-3-Clause
549
+ * @version 11.4.7
550
+ */class kp{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 i=t[s];e[s]=[i,this.get(i)]}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 i=null;if(this.has(t))this.set(t,e,!0,s);else{this.max>0&&this.size===this.max&&(i={...this.first},this.evict(!0));let n=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=n:this.last.next=n,this.last=n}return i}set(t,e,s=!1,i=this.resetTtl){let n=this.items[t];return s||n!==void 0?(n.value=e,s===!1&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=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=n:this.last.next=n,this.last=n),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 Bp(r=1e3,t=0,e=!1){if(isNaN(r)||r<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 kp(r,t,e)}function Nh(r){return!!r.tagStyles&&Object.keys(r.tagStyles).length>0}function Hh(r){return r.includes("<")}function Ip(r,t){return r.clone().assign(t)}function Gp(r,t){const e=[],s=t.tagStyles;if(!Nh(t)||!Hh(r))return e.push({text:r,style:t}),e;const i=[t],n=[];let o="",a=0;for(;a<r.length;){const h=r[a];if(h==="<"){const l=r.indexOf(">",a);if(l===-1){o+=h,a++;continue}const c=r.indexOf("<",a+1);if(c!==-1&&c<l){o+=h,a++;continue}const u=r.slice(a+1,l);if(u.startsWith("/")){const d=u.slice(1).trim();if(n.length>0&&n[n.length-1]===d){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o=""),i.pop(),n.pop(),a=l+1;continue}else{o+=r.slice(a,l+1),a=l+1;continue}}else{const d=u.trim();if(s[d]){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o="");const f=i[i.length-1],p=Ip(f,s[d]);i.push(p),n.push(d),a=l+1;continue}else{o+=r.slice(a,l+1),a=l+1;continue}}}else o+=h,a++}return o.length>0&&e.push({text:o,style:i[i.length-1]}),e}const Fp=[10,13],Dp=new Set(Fp),Up=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Op=new Set(Up),Lp=[9,32];new Set(Lp);const Np=[45,8208,8211,8212,173],Hp=new Set(Np),Wp=/(\r\n|\r|\n)/,zp=/(?:\r\n|\r|\n)/;function sr(r){return typeof r!="string"?!1:Dp.has(r.charCodeAt(0))}function Rt(r,t){return typeof r!="string"?!1:Op.has(r.charCodeAt(0))}function Vp(r){return typeof r!="string"?!1:Hp.has(r.charCodeAt(0))}function Wh(r){return r==="normal"||r==="pre-line"}function zh(r){return r==="normal"}function $t(r){if(typeof r!="string")return"";let t=r.length-1;for(;t>=0&&Rt(r[t]);)t--;return t<r.length-1?r.slice(0,t+1):r}function Vh(r){const t=[],e=[];if(typeof r!="string")return t;for(let s=0;s<r.length;s++){const i=r[s],n=r[s+1];if(Rt(i)||sr(i)){e.length>0&&(t.push(e.join("")),e.length=0),i==="\r"&&n===`
551
+ `?(t.push(`\r
552
+ `),s++):t.push(i);continue}e.push(i),Vp(i)&&n&&!Rt(n)&&!sr(n)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function Xh(r,t,e,s){const i=e(r),n=[];for(let o=0;o<i.length;o++){let a=i[o],h=a,l=1;for(;i[o+l];){const c=i[o+l];if(!s(h,c,r,o,t))a+=c,h=c,l++;else break}o+=l-1,n.push(a)}return n}const Xp=/\r\n|\r|\n/g;function $p(r,t,e,s,i,n,o,a,h){var F,ht;const l=Gp(r,t);if(zh(t.whiteSpace))for(let E=0;E<l.length;E++){const B=l[E];l[E]={text:B.text.replace(Xp," "),style:B.style}}const u=[];let d=[];for(const E of l){const B=E.text.split(Wp);for(let U=0;U<B.length;U++){const R=B[U];R===`\r
553
+ `||R==="\r"||R===`
554
+ `?(u.push(d),d=[]):R.length>0&&d.push({text:R,style:E.style})}}(d.length>0||u.length===0)&&u.push(d);const f=e?jp(u,t,s,n,a,h):u,p=[],g=[],m=[],_=[],x=[];let y=0;const v=t._fontString,S=o(v);S.fontSize===0&&(S.fontSize=t.fontSize,S.ascent=t.fontSize);let T="",C=!!t.dropShadow,k=((F=t._stroke)==null?void 0:F.width)||0;for(const E of f){let B=0,U=S.ascent,R=S.descent,O="";for(const D of E){const q=D.style._fontString,rt=o(q);q!==T&&(s.font=q,T=q);const nt=i(D.text,D.style.letterSpacing,s);B+=nt,U=Math.max(U,rt.ascent),R=Math.max(R,rt.descent),O+=D.text;const Z=((ht=D.style._stroke)==null?void 0:ht.width)||0;Z>k&&(k=Z),!C&&D.style.dropShadow&&(C=!0)}E.length===0&&(U=S.ascent,R=S.descent),p.push(B),g.push(U),m.push(R),x.push(O);const Y=t.lineHeight||U+R;_.push(Y+t.leading),y=Math.max(y,B)}const M=k,w=y+M+(t.dropShadow?t.dropShadow.distance:0);let P=0;for(let E=0;E<_.length;E++)P+=_[E];P=Math.max(P,_[0]+M);const A=P+(t.dropShadow?t.dropShadow.distance:0),I=t.lineHeight||S.fontSize;return{width:w,height:A,lines:x,lineWidths:p,lineHeight:I+t.leading,maxLineWidth:y,fontProperties:S,runsByLine:f,lineAscents:g,lineDescents:m,lineHeights:_,hasDropShadow:C}}function jp(r,t,e,s,i,n){var m;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:h,breakWords:l}=t,c=Wh(a),u=h+o,d={};let f="";const p=(_,x)=>{const y=`${_}|${x.styleKey}`;let v=d[y];if(v===void 0){const S=x._fontString;S!==f&&(e.font=S,f=S),v=s(_,x.letterSpacing,e)+x.letterSpacing,d[y]=v}return v},g=[];for(const _ of r){const x=Yp(_),y=g.length,v=A=>{let I=0,F=A;do{const{token:ht,style:E}=x[F];I+=p(ht,E),F++}while(F<x.length&&x[F].continuesFromPrevious);return I},S=A=>{const I=[];let F=A;do I.push({token:x[F].token,style:x[F].style}),F++;while(F<x.length&&x[F].continuesFromPrevious);return I};let T=[],C=0,k=!c,M=null;const w=()=>{M&&M.text.length>0&&T.push(M),M=null},P=()=>{if(w(),T.length>0){const A=T[T.length-1];A.text=$t(A.text),A.text.length===0&&T.pop()}g.push(T),T=[],C=0,k=!1};for(let A=0;A<x.length;A++){const{token:I,style:F,continuesFromPrevious:ht}=x[A],E=p(I,F);if(c){const R=Rt(I),O=(M==null?void 0:M.text[M.text.length-1])??((m=T[T.length-1])==null?void 0:m.text.slice(-1))??"",Y=O?Rt(O):!1;if(R&&Y)continue}const B=!ht,U=B?v(A):E;if(U>u&&B)if(C>0&&P(),l){const R=S(A);for(let O=0;O<R.length;O++){const Y=R[O].token,D=R[O].style,q=Xh(Y,l,n,i);for(const rt of q){const nt=p(rt,D);nt+C>u&&P(),!M||M.style!==D?(w(),M={text:rt,style:D}):M.text+=rt,C+=nt}}A+=R.length-1}else{const R=S(A);w(),g.push(R.map(O=>({text:O.token,style:O.style}))),k=!1,A+=R.length-1}else if(U+C>u&&B){if(Rt(I)){k=!1;continue}P(),M={text:I,style:F},C=E}else if(ht&&!l)!M||M.style!==F?(w(),M={text:I,style:F}):M.text+=I,C+=E;else{const R=Rt(I);if(C===0&&R&&!k)continue;!M||M.style!==F?(w(),M={text:I,style:F}):M.text+=I,C+=E}}if(w(),T.length>0){const A=T[T.length-1];A.text=$t(A.text),A.text.length===0&&T.pop()}(T.length>0||g.length===y)&&g.push(T)}return g}function Yp(r){const t=[];let e=!1;for(const s of r){const i=Vh(s.text);let n=!0;for(const o of i){const a=Rt(o)||sr(o),h=n&&e&&!a;t.push({token:o,style:s.style,continuesFromPrevious:h}),e=!a,n=!1}}return t}const qp={willReadFrequently:!0};function Xo(r,t,e,s,i){let n=e[r];return typeof n!="number"&&(n=i(r,t,s)+t,e[r]=n),n}function Kp(r,t,e,s,i,n,o){const a=e.getContext("2d",qp);a.font=t._fontString;let h=0,l="";const c=[],u=Object.create(null),{letterSpacing:d,whiteSpace:f}=t,p=Wh(f),g=zh(f);let m=!p;const _=t.wordWrapWidth+d,x=Vh(r);for(let v=0;v<x.length;v++){let S=x[v];if(sr(S)){if(!g){c.push($t(l)),m=!p,l="",h=0;continue}S=" "}if(p){const C=Rt(S),k=Rt(l[l.length-1]);if(C&&k)continue}const T=Xo(S,d,u,a,s);if(T>_)if(l!==""&&(c.push($t(l)),l="",h=0),i(S,t.breakWords)){const C=Xh(S,t.breakWords,o,n);for(const k of C){const M=Xo(k,d,u,a,s);M+h>_&&(c.push($t(l)),m=!1,l="",h=0),l+=k,h+=M}}else l.length>0&&(c.push($t(l)),l="",h=0),c.push($t(S)),m=!1,l="",h=0;else T+h>_&&(m=!1,c.push($t(l)),l="",h=0),(l.length>0||!Rt(S)||m)&&(l+=S,h+=T)}const y=$t(l);return y.length>0&&c.push(y),c.join(`
555
+ `)}const $o={willReadFrequently:!0},Jt=class N{static get experimentalLetterSpacingSupported(){let t=N._experimentalLetterSpacingSupported;if(t===void 0){const e=j.get().getCanvasRenderingContext2D().prototype;t=N._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,n,o,a,h,l,c){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=n,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=N._canvas,i=e.wordWrap){var v;const n=`${t}-${e.styleKey}-wordWrap-${i}`;if(N._measurementCache.has(n))return N._measurementCache.get(n);if(Nh(e)&&Hh(t)){const S=$p(t,e,i,N._context,N._measureText,N._measureTextAdvance,N.measureFont,N.canBreakChars,N.wordWrapSplit),T=new N(t,e,S.width,S.height,S.lines,S.lineWidths,S.lineHeight,S.maxLineWidth,S.fontProperties,{runsByLine:S.runsByLine,lineAscents:S.lineAscents,lineDescents:S.lineDescents,lineHeights:S.lineHeights,hasDropShadow:S.hasDropShadow});return N._measurementCache.set(n,T),T}const a=e._fontString,h=N.measureFont(a);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const l=N._context;l.font=a;const u=(i?N._wordWrap(t,e,s):t).split(zp),d=new Array(u.length);let f=0;for(let S=0;S<u.length;S++){const T=N._measureText(u[S],e.letterSpacing,l);d[S]=T,f=Math.max(f,T)}const p=((v=e._stroke)==null?void 0:v.width)??0,g=e.lineHeight||h.fontSize,m=N._adjustWidthForStyle(f,e),_=Math.max(g,h.fontSize+p)+(u.length-1)*(g+e.leading),x=N._adjustHeightForStyle(_,e),y=new N(t,e,m,x,u,d,g+e.leading,f,h);return N._measurementCache.set(n,y),y}static _adjustWidthForStyle(t,e){var n;const s=((n=e._stroke)==null?void 0:n.width)||0;let i=t+s;return e.dropShadow&&(i+=e.dropShadow.distance),i}static _adjustHeightForStyle(t,e){let s=t;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _measureText(t,e,s){const{metricWidth:i,metrics:n,letterSpacingVal:o}=N._measureTextCore(t,e,s),a=-(n.actualBoundingBoxLeft??0);let l=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(l+=o),Math.max(i,l)}static _measureTextAdvance(t,e,s){return N._measureTextCore(t,e,s).metricWidth}static _measureTextCore(t,e,s){let i=!1;N.experimentalLetterSpacingSupported&&(N.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,i=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const n=s.measureText(t);let o=n.width,a=0;return o>0&&(i?a=-e:a=(N.graphemeSegmenter(t).length-1)*e,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(t,e,s=N._canvas){return Kp(t,e,s,N._measureTextAdvance,N.canBreakWords,N.canBreakChars,N.wordWrapSplit)}static isBreakingSpace(t,e){return Rt(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,i,n){return!0}static wordWrapSplit(t){return N.graphemeSegmenter(t)}static measureFont(t){if(N._fonts[t])return N._fonts[t];const e=N._context;e.font=t;const s=e.measureText(N.METRICS_STRING+N.BASELINE_SYMBOL),i=s.actualBoundingBoxAscent??0,n=s.actualBoundingBoxDescent??0,o={ascent:i,descent:n,fontSize:i+n};return N._fonts[t]=o,o}static clearMetrics(t=""){t?delete N._fonts[t]:N._fonts={}}static get _canvas(){if(!N.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",$o);if(s!=null&&s.measureText)return N.__canvas=e,e;t=j.get().createCanvas()}catch{t=j.get().createCanvas()}t.width=t.height=10,N.__canvas=t}return N.__canvas}static get _context(){return N.__context||(N.__context=N._canvas.getContext("2d",$o)),N.__context}};Jt.METRICS_STRING="|ÉqÅ";Jt.BASELINE_SYMBOL="M";Jt.BASELINE_MULTIPLIER=1.4;Jt.HEIGHT_MULTIPLIER=2;Jt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),s=[];let i=0;for(const n of e)s[i++]=n.segment;return s}}return r=>[...r]})();Jt.experimentalLetterSpacing=!1;Jt._fonts={};Jt._measurementCache=Bp(1e3);let ee=Jt;const Zp=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ai(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let i=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!Zp.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const jo=1e5;function Us(r,t,e,s=0,i=0,n=0){if(r.texture===L.WHITE&&!r.fill)return Q.shared.setValue(r.color).setAlpha(r.alpha??1).toHexa();if(r.fill){if(r.fill instanceof vs){const o=r.fill,a=t.createPattern(o.texture.source.resource,"repeat"),h=o.transform.copyTo(G.shared);return h.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(h),a}else if(r.fill instanceof Ht){const o=r.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+i,f.y*c+n,p.x*l+i,p.y*c+n),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+i,f.y*c+n,p*l,g.x*l+i,g.y*c+n,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(_*jo)/jo,Q.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(f=>{u.addColorStop(f.offset,Q.shared.setValue(f.color).toHex())});return u}}else{const o=t.createPattern(r.texture.source.resource,"repeat"),a=r.matrix.copyTo(G.shared);return a.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(a),o}return z("FillStyle not recognised",r),"red"}const Yo=new tt;function Ae(r){let t=0;for(let e=0;e<r.length;e++)r.charCodeAt(e)===32&&t++;return t}class Qp{getCanvasAndContext(t){const{text:e,style:s,resolution:i=1}=t,n=s._getFinalPadding(),o=ee.measureText(e||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*i),h=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*i),l=Ve.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(s,n,i,l,o);const c=s.trim?Rp({canvas:l.canvas,width:a,height:h,resolution:1,output:Yo}):Yo.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){Ve.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,i,n){var S,T,C;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,t,e,s,i);return}const{canvas:o,context:a}=i,h=ai(t),l=n.lines,c=n.lineHeight,u=n.lineWidths,d=n.maxLineWidth,f=n.fontProperties,p=o.height;if(a.resetTransform(),a.scale(s,s),a.textBaseline=t.textBaseline,(S=t._stroke)!=null&&S.width){const k=t._stroke;a.lineWidth=k.width,a.miterLimit=k.miterLimit,a.lineJoin=k.join,a.lineCap=k.cap}a.font=h;let g,m;const _=t.dropShadow?2:1,y=(((T=t._stroke)==null?void 0:T.width)??0)/2;let v=(c-f.fontSize)/2;c-f.fontSize<0&&(v=0);for(let k=0;k<_;++k){const M=t.dropShadow&&k===0,w=M?Math.ceil(Math.max(1,p)+e*2):0,P=w*s;if(M)this._setupDropShadow(a,t,s,P);else{const A=t._gradientBounds,I=t._gradientOffset;if(A){const F={width:A.width,height:A.height,lineHeight:A.height,lines:n.lines};this._setFillAndStrokeStyles(a,t,F,e,y,(I==null?void 0:I.x)??0,(I==null?void 0:I.y)??0)}else I?this._setFillAndStrokeStyles(a,t,n,e,y,I.x,I.y):this._setFillAndStrokeStyles(a,t,n,e,y);a.shadowColor="rgba(0,0,0,0)"}for(let A=0;A<l.length;A++){g=y,m=y+A*c+f.ascent+v,g+=this._getAlignmentOffset(u[A],d,t.align);let I=0;if(t.align==="justify"&&t.wordWrap&&A<l.length-1){const F=Ae(l[A]);F>0&&(I=(d-u[A])/F)}(C=t._stroke)!=null&&C.width&&this._drawLetterSpacing(l[A],t,i,g+e,m+e-w,!0,I),t._fill!==void 0&&this._drawLetterSpacing(l[A],t,i,g+e,m+e-w,!1,I)}}}_renderTaggedTextToCanvas(t,e,s,i,n){var y,v,S;const{canvas:o,context:a}=n,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:u,lineHeights:d,hasDropShadow:f}=t,p=o.height;a.resetTransform(),a.scale(i,i),a.textBaseline=e.textBaseline;const g=f?2:1;let m=((y=e._stroke)==null?void 0:y.width)??0;for(const T of h)for(const C of T){const k=((v=C.style._stroke)==null?void 0:v.width)??0;k>m&&(m=k)}const _=m/2,x=[];for(let T=0;T<h.length;T++){const C=h[T],k=[];for(const M of C){const w=ai(M.style);a.font=w,k.push({width:ee._measureText(M.text,M.style.letterSpacing,a),font:w})}x.push(k)}for(let T=0;T<g;++T){const C=f&&T===0,k=C?Math.ceil(Math.max(1,p)+s*2):0,M=k*i;C||(a.shadowColor="rgba(0,0,0,0)");let w=_;for(let P=0;P<h.length;P++){const A=h[P],I=l[P],F=u[P],ht=d[P],E=x[P];let B=_;B+=this._getAlignmentOffset(I,c,e.align);let U=0;if(e.align==="justify"&&e.wordWrap&&P<h.length-1){let Y=0;for(const D of A)Y+=Ae(D.text);Y>0&&(U=(c-I)/Y)}const R=w+F;let O=B+s;for(let Y=0;Y<A.length;Y++){const D=A[Y],{width:q,font:rt}=E[Y];if(a.font=rt,a.textBaseline=D.style.textBaseline,(S=D.style._stroke)!=null&&S.width){const Z=D.style._stroke;if(a.lineWidth=Z.width,a.miterLimit=Z.miterLimit,a.lineJoin=Z.join,a.lineCap=Z.cap,C)if(D.style.dropShadow)this._setupDropShadow(a,D.style,i,M);else{const dt=Ae(D.text);O+=q+dt*U;continue}else{const dt=ee.measureFont(rt),xt=D.style.lineHeight||dt.fontSize,V={width:q,height:xt,lineHeight:xt,lines:[D.text]};a.strokeStyle=Us(Z,a,V,s*2,O-s,w)}this._drawLetterSpacing(D.text,D.style,n,O,R+s-k,!0,U)}const nt=Ae(D.text);O+=q+nt*U}O=B+s;for(let Y=0;Y<A.length;Y++){const D=A[Y],{width:q,font:rt}=E[Y];if(a.font=rt,a.textBaseline=D.style.textBaseline,D.style._fill!==void 0){if(C)if(D.style.dropShadow)this._setupDropShadow(a,D.style,i,M);else{const Z=Ae(D.text);O+=q+Z*U;continue}else{const Z=ee.measureFont(rt),dt=D.style.lineHeight||Z.fontSize,xt={width:q,height:dt,lineHeight:dt,lines:[D.text]};a.fillStyle=Us(D.style._fill,a,xt,s*2,O-s,w)}this._drawLetterSpacing(D.text,D.style,n,O,R+s-k,!1,U)}const nt=Ae(D.text);O+=q+nt*U}w+=ht}}}_setFillAndStrokeStyles(t,e,s,i,n,o=0,a=0){var h;if(t.fillStyle=e._fill?Us(e._fill,t,s,i*2,o,a):null,(h=e._stroke)!=null&&h.width){const l=n+i*2;t.strokeStyle=Us(e._stroke,t,s,l,o,a)}}_setupDropShadow(t,e,s,i){t.fillStyle="black",t.strokeStyle="black";const n=e.dropShadow,o=n.color,a=n.alpha;t.shadowColor=Q.shared.setValue(o).setAlpha(a).toRgbaString();const h=n.blur*s,l=n.distance*s;t.shadowBlur=h,t.shadowOffsetX=Math.cos(n.angle)*l,t.shadowOffsetY=Math.sin(n.angle)*l+i}_getAlignmentOffset(t,e,s){return s==="right"?e-t:s==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,s,i,n,o=!1,a=0){const{context:h}=s,l=e.letterSpacing;let c=!1;if(ee.experimentalLetterSpacingSupported&&(ee.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,i,n):h.fillText(t,i,n);return}if(a!==0&&(l===0||c)){const g=t.split(" ");let m=i;const _=h.measureText(" ").width;for(let x=0;x<g.length;x++)o?h.strokeText(g[x],m,n):h.fillText(g[x],m,n),m+=h.measureText(g[x]).width+_+a;return}let u=i;const d=ee.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,n):h.fillText(m,u,n);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 Fe=new Qp,Li=class fe extends kt{constructor(t={}){super(),this.uid=et("textStyle"),this._tick=0,this._cachedFontString=null,Jp(t),t instanceof fe&&(t=t._toObject());const i={...fe.defaultTextStyle,...t};for(const n in i){const o=n;this[o]=i[n]}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({...fe.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...fe.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({...Ft.defaultFillStyle,...t},()=>{this._fill=me({...this._originalFill},Ft.defaultFillStyle)})),this._fill=me(t===0?"black":t,Ft.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...Ft.defaultStrokeStyle,...t},()=>{this._stroke=Js({...this._originalStroke},Ft.defaultStrokeStyle)})),this._stroke=Js(t,Ft.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=fe.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=ai(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 fe(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){var s,i,n,o;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const a=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(a),(i=this._originalFill)!=null&&i.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(a),(o=this._originalStroke)!=null&&o.texture&&this._originalStroke.texture.destroy(a)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,i,n)=>(s[i]===n||(s[i]=n,e==null||e(i,n),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Q.isColorLike(t)||t instanceof Ht||t instanceof vs)}};Li.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Li.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 rr=Li;function Jp(r){const t=r;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=rr.defaultDropShadow;r.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){H(ot,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Q.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.");r.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(H(ot,"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&&z("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(),i=t.fill.map(n=>Q.shared.setValue(n).toNumber());s.forEach((n,o)=>{e.addColorStop(n,i[o])}),r.fill={fill:e}}}function tm(r,t){const{texture:e,bounds:s}=r,i=t._style._getFinalPadding();ma(s,t._anchor,e);const n=t._anchor._x*i*2,o=t._anchor._y*i*2;s.minX-=i-n,s.minY-=i-o,s.maxX-=i-n,s.maxY-=i-o}class Ni{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 em extends Ni{}class $h{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new zt({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!=null&&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 i=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t._resolution!==i)&&this._updateGpuText(t),t._didTextUpdate=!1,tm(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 em;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}}$h.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};class jh{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,i){typeof t=="string"&&(H("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof rr||(t.style=new rr(t.style)),t.textureStyle instanceof _e||(t.textureStyle=new _e(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:n,style:o,textureStyle:a,autoGenerateMipmaps:h}=t,l=t.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=Fe.getCanvasAndContext({text:n,style:o,resolution:l}),d=Bh(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),Fe.returnCanvasAndContext(u),f}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Fe.returnCanvasAndContext(u),d}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&(s!=null&&s.getContext)){const i=s.getContext("2d");i&&Fe.returnCanvasAndContext({canvas:s,context:i})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",yt.returnTexture(t,!0)}renderTextToCanvas(){H("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){var e;return((e=this._activeTextures[t])==null?void 0:e.usageCount)??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const s=this._renderer.renderTarget.renderTarget,i=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(s,!1),i}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class Yh extends jh{constructor(t){super(t,!0)}}Yh.extension={type:[b.CanvasSystem],name:"canvasText"};class qh extends jh{constructor(t){super(t,!1)}}qh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"canvasText"};W.add(Yh);W.add(qh);W.add($h);class __ extends Pp{constructor(...t){const e=Mp(t,"Text");super(e,rr),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof _e?e.textureStyle:new _e(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,i=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Fe.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Fe.returnCanvasAndContext(o),s=n.width,i=n.height}else{const n=ee.measureText(this._text,this._style);s=n.width,i=n.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}}function sm(){const{userAgent:r}=j.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Hi=class pe{static _getPatternRepeat(t,e){const s=t&&t!=="clamp-to-edge",i=e&&e!=="clamp-to-edge";return s&&i?"repeat":s?"repeat-x":i?"repeat-y":"no-repeat"}start(t,e,s){}execute(t,e){var a,h,l,c;const s=e.elements;if(!s||!s.length)return;const i=t.renderer,n=i.canvasContext,o=n.activeContext;for(let u=0;u<s.length;u++){const d=s[u];if(!d.packAsQuad)continue;const f=d,p=f.texture,g=p?X.getCanvasSource(p):null;if(!g)continue;const m=p.source.style,_=n.smoothProperty,x=m.scaleMode!=="nearest";o[_]!==x&&(o[_]=x),n.setBlendMode(e.blendMode);const y=((a=i.globalUniforms.globalUniformData)==null?void 0:a.worldColor)??4294967295,v=f.color,S=(y>>>24&255)/255,T=(v>>>24&255)/255,C=((h=i.filter)==null?void 0:h.alphaMultiplier)??1,k=S*T*C;if(k<=0)continue;o.globalAlpha=k;const M=y&16777215,w=v&16777215,P=Ue(De(w,M)),A=p.frame,I=m.addressModeU??m.addressMode,F=m.addressModeV??m.addressMode,ht=pe._getPatternRepeat(I,F),E=p.source._resolution??p.source.resolution??1,B=(c=(l=f.renderable)==null?void 0:l.renderGroup)==null?void 0:c.isCachedAsTexture,U=A.x*E,R=A.y*E,O=A.width*E,Y=A.height*E,D=f.bounds,q=i.renderTarget.renderTarget.isRoot,rt=D.minX,nt=D.minY,Z=D.maxX-D.minX,dt=D.maxY-D.minY,xt=p.rotate,V=p.uvs,St=Math.min(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),Et=Math.max(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),ct=ht!=="no-repeat"&&(St<0||Et>1),Bt=xt&&!(!ct&&(P!==16777215||xt));Bt?(pe._tempPatternMatrix.copyFrom(f.transform),$.matrixAppendRotationInv(pe._tempPatternMatrix,xt,rt,nt,Z,dt),n.setContextTransform(pe._tempPatternMatrix,f.roundPixels===1,void 0,B&&q)):n.setContextTransform(f.transform,f.roundPixels===1,void 0,B&&q);const Pt=Bt?0:rt,be=Bt?0:nt,ve=Z,Ye=dt;if(ct){let Ts=g;const Te=P!==16777215&&!xt,Se=A.width<=p.source.width&&A.height<=p.source.height;Te&&Se&&(Ts=X.getTintedCanvas({texture:p},P));const nr=o.createPattern(Ts,ht);if(!nr)continue;const un=ve,dn=Ye;if(un===0||dn===0)continue;const fn=1/un,pn=1/dn,mn=(V.x1-V.x0)*fn,gn=(V.y1-V.y0)*fn,_n=(V.x3-V.x0)*pn,xn=(V.y3-V.y0)*pn,bc=V.x0-mn*Pt-_n*be,vc=V.y0-gn*Pt-xn*be,or=p.source.pixelWidth,ar=p.source.pixelHeight;pe._tempPatternMatrix.set(mn*or,gn*ar,_n*or,xn*ar,bc*or,vc*ar),X.applyPatternTransform(nr,pe._tempPatternMatrix),o.fillStyle=nr,o.fillRect(Pt,be,ve,Ye)}else{const Te=P!==16777215||xt?X.getTintedCanvas({texture:p},P):g,Se=Te!==g;o.drawImage(Te,Se?0:U,Se?0:R,Se?Te.width:O,Se?Te.height:Y,Pt,be,ve,Ye)}}}};Hi._tempPatternMatrix=new G;Hi.extension={type:[b.CanvasPipesAdaptor],name:"batch"};let rm=Hi;class Kh{constructor(){this._tempState=Qt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,s){const i=t.renderer,n=this._didUploadHash[s.uid];i.shader.bind(s,n),n||(this._didUploadHash[s.uid]=!0),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,s.glProgram)}execute(t,e){const s=t.renderer;this._tempState.blendMode=e.blendMode,s.state.set(this._tempState);const i=e.textures.textures;for(let n=0;n<e.textures.count;n++)s.texture.bind(i[n],n);s.geometry.draw(e.topology,e.size,e.start)}}Kh.extension={type:[b.WebGLPipesAdaptor],name:"batch"};const Os=Qt.for2d();class Zh{start(t,e,s){const i=t.renderer,n=i.encoder,o=s.gpuProgram;this._shader=s,this._geometry=e,n.setGeometry(e,o),Os.blendMode="normal",i.pipeline.getPipeline(e,o,Os);const a=i.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(t,e){const s=this._shader.gpuProgram,i=t.renderer,n=i.encoder;if(!e.bindGroup){const h=e.textures;e.bindGroup=Ci(h.textures,h.count,i.limits.maxBatchableTextures)}Os.blendMode=e.blendMode;const o=i.bindGroup.getBindGroup(e.bindGroup,s,1),a=i.pipeline.getPipeline(this._geometry,s,Os,e.topology);e.bindGroup._touch(i.gc.now,i.tick),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Zh.extension={type:[b.WebGPUPipesAdaptor],name:"batch"};const Wi=class Qh{constructor(t,e){var s,i;this.state=Qt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,(i=(s=this._adaptor).init)==null||i.call(s,this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new Ri({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const s in this._activeBatches)this._activeBatches[s].begin()}addToBatch(t,e){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(e);let s=this._activeBatches[t.batcherName];s||(s=this._activeBatches[t.batcherName]=Qh.getBatcher(t.batcherName),s.begin()),this._activeBatch=s}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const s in e){const i=e[s],n=i.geometry;n.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),n.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const s in e){const i=e[s],n=i.geometry;i.dirty&&(i.dirty=!1,n.buffers[0].update(i.attributeSize*4))}}execute(t){if(t.action==="startBatch"){const e=t.batcher,s=e.geometry,i=e.shader;this._adaptor.start(this,s,i)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};Wi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"batch"};Wi._availableBatchers=Object.create(null);let zi=Wi;W.handleByMap(b.Batcher,zi._availableBatchers);W.add(Ri);const im={name:"texture-bit",vertex:{header:`
556
+
557
+ struct TextureUniforms {
558
+ uTextureMatrix:mat3x3<f32>,
559
+ }
560
+
561
+ @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
562
+ `,main:`
563
+ uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
564
+ `},fragment:{header:`
565
+ @group(2) @binding(0) var uTexture: texture_2d<f32>;
566
+ @group(2) @binding(1) var uSampler: sampler;
567
+
568
+
569
+ `,main:`
570
+ outColor = textureSample(uTexture, uSampler, vUV);
571
+ `}},nm={name:"texture-bit",vertex:{header:`
572
+ uniform mat3 uTextureMatrix;
573
+ `,main:`
574
+ uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
575
+ `},fragment:{header:`
576
+ uniform sampler2D uTexture;
577
+
578
+
579
+ `,main:`
580
+ outColor = texture(uTexture, vUV);
581
+ `}},om=new _t;class am extends js{constructor(){super(),this.filters=[new vp({sprite:new Ne(L.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}get channel(){return this.filters[0].channel}set channel(t){this.filters[0].channel=t}}class Vi{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,s){const i=this._renderer;if(i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.channel=e._maskOptions.channel??"red",t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,n.collectRenderables(s,i,null),n.includeInBuild=!1}i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const i=mt.get(am);if(i.inverse=t.inverse,i.channel=t.mask.channel,s){t.mask.mask.measurable=!0;const n=pi(t.mask.mask,!0,om);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=yt.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const h=i.sprite;h.texture=a,h.worldTransform.tx=n.minX,h.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:a})}else i.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const i=this._activeMaskStage[this._activeMaskStage.length-1];s&&(e.type===Nt.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const i=this._activeMaskStage.pop();s&&yt.returnTexture(i.filterTexture),mt.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Vi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"alphaMask"};class Jh{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;this._colorStackIndex--;const n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){}destroy(){this._renderer=null,this._colorStack=null}}Jh.extension={type:[b.CanvasPipes],name:"colorMask"};class tl{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}tl.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"colorMask"};function hm(r,t,e,s,i,n){n=Math.max(0,Math.min(n,Math.min(s,i)/2)),r.moveTo(t+n,e),r.lineTo(t+s-n,e),r.quadraticCurveTo(t+s,e,t+s,e+n),r.lineTo(t+s,e+i-n),r.quadraticCurveTo(t+s,e+i,t+s-n,e+i),r.lineTo(t+n,e+i),r.quadraticCurveTo(t,e+i,t,e+i-n),r.lineTo(t,e+n),r.quadraticCurveTo(t,e,t+n,e)}function el(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;hm(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.moveTo(e.x+e.radius,e.y),r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?(r.moveTo(e.x+e.halfWidth,e.y),r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2)):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.moveTo(1,0),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}case"polygon":default:{const e=t,s=e.points;if(!(s!=null&&s.length))break;r.moveTo(s[0],s[1]);for(let i=2;i<s.length;i+=2)r.lineTo(s[i],s[i+1]);e.closePath&&r.closePath();break}}}function lm(r,t,e){const s=[],i=[],n=[],o=je[t.type];if(!(o!=null&&o.build(t,s)))return!1;const a=t.closePath??!0;Bi(s,e,!1,a,i,n);for(let h=0;h<n.length;h+=3){const l=n[h]*2,c=n[h+1]*2,u=n[h+2]*2;r.moveTo(i[l],i[l+1]),r.lineTo(i[c],i[c+1]),r.lineTo(i[u],i[u+1]),r.closePath()}return!0}function cm(r,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const s=t[e];if(!(s!=null&&s.shape))continue;const i=s.transform,n=i&&!i.isIdentity();n&&(r.save(),r.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),el(r,s.shape),n&&r.restore()}return!0}class sl{constructor(t){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){var c,u,d;if(t.action!=="pushMaskBegin"&&t.action!=="popMaskEnd")return;const e=this._renderer,s=e.canvasContext,i=s==null?void 0:s.activeContext;if(!i)return;if(t.action==="popMaskEnd"){this._canvasMaskStack.pop()&&i.restore();return}t.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const n=t.mask.mask;if(!(n instanceof er)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=n,a=(c=o.context)==null?void 0:c.instructions;if(!(a!=null&&a.length)){this._canvasMaskStack.push(!1);return}i.save(),s.setContextTransform(o.groupTransform,(e._roundPixels|o._roundPixels)===1),i.beginPath();let h=!1,l=!1;for(let f=0;f<a.length;f++){const p=a[f],g=p.action;if(g!=="fill"&&g!=="stroke")continue;const m=p.data,_=(u=m==null?void 0:m.path)==null?void 0:u.shapePath;if(!((d=_==null?void 0:_.shapePrimitives)!=null&&d.length))continue;const x=g==="stroke",y=_.shapePrimitives;for(let v=0;v<y.length;v++){const S=y[v];if(!(S!=null&&S.shape))continue;const T=S.transform,C=T&&!T.isIdentity();C&&(i.save(),i.transform(T.a,T.b,T.c,T.d,T.tx,T.ty)),x&&m.style?h=lm(i,S.shape,m.style)||h:(el(i,S.shape),l=cm(i,S.holes)||l,h=!0),C&&i.restore()}}if(!h){i.restore(),this._canvasMaskStack.push(!1);return}l?i.clip("evenodd"):i.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(t,e){this._warnedMaskTypes.has(t)||(this._warnedMaskTypes.add(t),z(e))}}sl.extension={type:[b.CanvasPipes],name:"stencilMask"};class rl{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,s){var i;const n=t,o=this._renderer;o.renderPipes.batch.break(s),o.renderPipes.blendMode.setBlendMode(n.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const a=n.mask;a.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const h=this._maskHash.get(n);h.instructionsStart=s.instructionSize,a.collectRenderables(s,o,null),a.includeInBuild=!1,o.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=s.instructionSize-h.instructionsStart-1;h.instructionsLength=l;const c=o.renderTarget.renderTarget.uid;(i=this._maskStackHash)[c]??(i[c]=0)}pop(t,e,s){const i=t,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(i.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a<o.instructionsLength;a++)s.instructions[s.instructionSize++]=s.instructions[o.instructionsStart++];s.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const s=this._renderer,i=s,n=s.renderTarget.renderTarget.uid;let o=(e=this._maskStackHash)[n]??(e[n]=0);t.action==="pushMaskBegin"?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(ut.RENDERING_MASK_ADD,o),o++,i.colorMask.setMask(0)):t.action==="pushMaskEnd"?(t.inverse?i.stencil.setStencilMode(ut.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(ut.MASK_ACTIVE,o),i.colorMask.setMask(15)):t.action==="popMaskBegin"?(i.colorMask.setMask(0),o!==0?i.stencil.setStencilMode(ut.RENDERING_MASK_REMOVE,o):(i.renderTarget.clear(null,wt.STENCIL),i.stencil.setStencilMode(ut.DISABLED,o)),o--):t.action==="popMaskEnd"&&(t.inverse?i.stencil.setStencilMode(ut.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(ut.MASK_ACTIVE,o),i.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}rl.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"stencilMask"};const J="source-over";function um(){const r=Rh(),t=Object.create(null);return t.inherit=J,t.none=J,t.normal="source-over",t.add="lighter",t.multiply=r?"multiply":J,t.screen=r?"screen":J,t.overlay=r?"overlay":J,t.darken=r?"darken":J,t.lighten=r?"lighten":J,t["color-dodge"]=r?"color-dodge":J,t["color-burn"]=r?"color-burn":J,t["hard-light"]=r?"hard-light":J,t["soft-light"]=r?"soft-light":J,t.difference=r?"difference":J,t.exclusion=r?"exclusion":J,t.saturation=r?"saturation":J,t.color=r?"color":J,t.luminosity=r?"luminosity":J,t["linear-burn"]=r?"color-burn":J,t["linear-dodge"]=r?"color-dodge":J,t["linear-light"]=r?"hard-light":J,t["pin-light"]=r?"hard-light":J,t["vivid-light"]=r?"hard-light":J,t["hard-mix"]=J,t.negation=r?"difference":J,t["normal-npm"]=t.normal,t["add-npm"]=t.add,t["screen-npm"]=t.screen,t.erase="destination-out",t.subtract=J,t.divide=J,t.min=J,t.max=J,t}const dm=new G;class il{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=um(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=t}resolutionChange(t){this.activeResolution=t}init(){const t=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,s,i){var l;const n=i?G.IDENTITY:((l=this._renderer.globalUniforms.globalUniformData)==null?void 0:l.worldTransformMatrix)||G.IDENTITY;let o=dm;o.copyFrom(n),o.append(t);const a=this._projTransform,h=this.activeResolution;if(s=s||h,a){const c=G.shared;c.copyFrom(o),c.prepend(a),o=c}e?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*h|0,o.ty*h|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*h,o.ty*h)}clear(t,e){const s=this.activeContext,i=this._renderer;if(s.clearRect(0,0,i.width,i.height),t){const n=Q.shared.setValue(t);s.globalAlpha=e??n.alpha,s.fillStyle=n.toHex(),s.fillRect(0,0,i.width,i.height),s.globalAlpha=1}}setBlendMode(t){if(this._activeBlendMode===t)return;this._activeBlendMode=t,this._outerBlend=!1;const e=this.blendModes[t];if(!e){this._warnedBlendModes.has(t)||(console.warn(`CanvasRenderer: blend mode "${t}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(t)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=e}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}il.extension={type:[b.CanvasSystem],name:"canvasContext"};class nl{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}nl.extension={type:[b.CanvasSystem],name:"limits"};class Xi{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}Xi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"customRender"};function hi(r,t){const e=r.instructionSet,s=e.instructions;for(let i=0;i<e.instructionSize;i++){const n=s[i];t[n.renderPipeId].execute(n)}}class $i{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(mt.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){const s=t._batchableRenderGroup??(t._batchableRenderGroup=mt.get(Ni));s.renderable=t.root,s.transform=t.root.relativeGroupTransform,s.texture=t.texture,s.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(s,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=new G().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),hi(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),hi(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}$i.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"renderGroup"};const fm="#808080",Ls=new G,pm=new G,mm=new G,Dr=new G;function gm(r,t,e){r.beginPath();for(let s=0;s<e.length;s+=3){const i=e[s]*2,n=e[s+1]*2,o=e[s+2]*2;r.moveTo(t[i],t[i+1]),r.lineTo(t[n],t[n+1]),r.lineTo(t[o],t[o+1]),r.closePath()}r.fill()}function _m(r){return`#${(r&16777215).toString(16).padStart(6,"0")}`}function xm(r,t,e,s,i,n){n=Math.max(0,Math.min(n,Math.min(s,i)/2)),r.moveTo(t+n,e),r.lineTo(t+s-n,e),r.quadraticCurveTo(t+s,e,t+s,e+n),r.lineTo(t+s,e+i-n),r.quadraticCurveTo(t+s,e+i,t+s-n,e+i),r.lineTo(t+n,e+i),r.quadraticCurveTo(t,e+i,t,e+i-n),r.lineTo(t,e+n),r.quadraticCurveTo(t,e,t+n,e)}function zs(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;xm(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}case"polygon":default:{const e=t,s=e.points;if(!(s!=null&&s.length))break;r.moveTo(s[0],s[1]);for(let i=2;i<s.length;i+=2)r.lineTo(s[i],s[i+1]);e.closePath&&r.closePath();break}}}function ym(r,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const s=t[e];if(!(s!=null&&s.shape))continue;const i=s.transform,n=i&&!i.isIdentity();n&&(r.save(),r.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),zs(r,s.shape),n&&r.restore()}return!0}function bm(r,t,e,s){const i=r.fill;if(i instanceof Ht){i.buildGradient();const o=i.texture;if(o){const a=X.getTintedPattern(o,t),h=e?Dr.copyFrom(e).scale(o.source.pixelWidth,o.source.pixelHeight):Dr.copyFrom(i.transform);return s&&!r.textureSpace&&h.append(s),X.applyPatternTransform(a,h),a}}if(i instanceof vs){const o=X.getTintedPattern(i.texture,t);return X.applyPatternTransform(o,i.transform),o}const n=r.texture;if(n&&n!==L.WHITE){if(!n.source.resource)return fm;const o=X.getTintedPattern(n,t),a=e?Dr.copyFrom(e).scale(n.source.pixelWidth,n.source.pixelHeight):r.matrix;return X.applyPatternTransform(o,a),o}return _m(t)}class ol{constructor(){this.shader=null}contextChange(t){}execute(t,e){var x,y,v,S,T,C,k;const s=t.renderer,i=s.canvasContext,n=i.activeContext,o=e.groupTransform,a=((x=s.globalUniforms.globalUniformData)==null?void 0:x.worldColor)??4294967295,h=e.groupColorAlpha,l=(a>>>24&255)/255,c=(h>>>24&255)/255,u=((y=s.filter)==null?void 0:y.alphaMultiplier)??1,d=l*c*u;if(d<=0)return;const f=a&16777215,p=h&16777215,g=Ue(De(p,f)),m=s._roundPixels|e._roundPixels;n.save(),i.setContextTransform(o,m===1),i.setBlendMode(e.groupBlendMode);const _=e.context.instructions;for(let M=0;M<_.length;M++){const w=_[M];if(w.action==="texture"){const U=w.data,R=U.image,O=R?X.getCanvasSource(R):null;if(!O)continue;const Y=U.alpha*d;if(Y<=0)continue;const D=De(U.style,g);n.globalAlpha=Y;let q=O;D!==16777215&&(q=X.getTintedCanvas({texture:R},D));const rt=R.frame,nt=R.source._resolution??R.source.resolution??1;let Z=rt.x*nt,dt=rt.y*nt;const xt=rt.width*nt,V=rt.height*nt;q!==O&&(Z=0,dt=0);const St=U.transform,Et=St&&!St.isIdentity(),ct=R.rotate;Et||ct?(Ls.copyFrom(o),Et&&Ls.append(St),ct&&$.matrixAppendRotationInv(Ls,ct,U.dx,U.dy,U.dw,U.dh),i.setContextTransform(Ls,m===1)):i.setContextTransform(o,m===1),n.drawImage(q,Z,dt,q===O?xt:q.width,q===O?V:q.height,ct?0:U.dx,ct?0:U.dy,U.dw,U.dh),(Et||ct)&&i.setContextTransform(o,m===1);continue}const P=w.data,A=(v=P==null?void 0:P.path)==null?void 0:v.shapePath;if(!((S=A==null?void 0:A.shapePrimitives)!=null&&S.length))continue;const I=P.style,F=De(I.color,g),ht=I.alpha*d;if(ht<=0)continue;const E=w.action==="stroke";if(n.globalAlpha=ht,E){const U=I;n.lineWidth=U.width,n.lineCap=U.cap,n.lineJoin=U.join,n.miterLimit=U.miterLimit}const B=A.shapePrimitives;if(!E&&((k=(C=(T=P.hole)==null?void 0:T.shapePath)==null?void 0:C.shapePrimitives)!=null&&k.length)){const U=B[B.length-1];U.holes=P.hole.shapePath.shapePrimitives}for(let U=0;U<B.length;U++){const R=B[U];if(!(R!=null&&R.shape))continue;const O=R.transform,Y=O&&!O.isIdentity(),D=I.texture&&I.texture!==L.WHITE,q=I.textureSpace==="global"?O:null,rt=D?Sh(pm,I,R.shape,q):null,nt=Y?mm.copyFrom(o).append(O):o,Z=bm(I,F,rt,nt);if(Y&&(n.save(),n.transform(O.a,O.b,O.c,O.d,O.tx,O.ty)),E){const dt=I;if(dt.alignment!==.5&&!dt.pixelLine){const V=[],St=[],Et=[],ct=je[R.shape.type];if(ct!=null&&ct.build(R.shape,V)){const Dt=R.shape.closePath??!0;Bi(V,dt,!1,Dt,St,Et),n.fillStyle=Z,gm(n,St,Et)}else n.strokeStyle=Z,n.beginPath(),zs(n,R.shape),n.stroke()}else n.strokeStyle=Z,n.beginPath(),zs(n,R.shape),n.stroke()}else n.fillStyle=Z,n.beginPath(),zs(n,R.shape),ym(n,R.holes)?n.fill("evenodd"):n.fill();Y&&n.restore()}}n.restore()}destroy(){this.shader=null}}ol.extension={type:[b.CanvasPipesAdaptor],name:"graphics"};class ji{constructor(t){this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new Ni;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}ji.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"sprite"};const us={};W.handle(b.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");us[r.name]=r.ref},r=>{delete us[r.name]});class Yi{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,s){this._blendModeStack.push(e),this.setBlendMode(t,e,s)}popBlendMode(t){this._blendModeStack.pop();const e=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,e,t)}setBlendMode(t,e,s){var n;const i=t instanceof Xr;if(this._activeBlendMode===e){this._isAdvanced&&t&&!i&&((n=this._renderableList)==null||n.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(s),this._activeBlendMode=e,t&&(this._isAdvanced=!!us[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,s))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const s=this._activeBlendMode;if(!us[s]){z(`Unable to assign BlendMode: '${s}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const i=this._ensureFilterEffect(s),n=t instanceof Xr,o={renderPipeId:"filter",action:"pushFilter",filterEffect:i,renderables:n?null:[t],container:n?t.root:null,canBundle:!1};this._renderableList=o.renderables,e.add(o)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new js,e.filters=[new us[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Yi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"blendMode"};function li(r,t){t||(t=0);for(let e=t;e<r.length&&r[e];e++)r[e]=null}const vm=new vt,qo=as|qs|xi;function al(r,t=!1){Tm(r);const e=r.childrenToUpdate,s=r.updateTick++;for(const i in e){const n=Number(i),o=e[i],a=o.list,h=o.index;for(let l=0;l<h;l++){const c=a[l];c.parentRenderGroup===r&&c.relativeRenderGroupDepth===n&&hl(c,s,0)}li(a,h),o.index=0}if(t)for(let i=0;i<r.renderGroupChildren.length;i++)al(r.renderGroupChildren[i],t)}function Tm(r){const t=r.root;let e;if(r.renderGroupParent){const s=r.renderGroupParent;r.worldTransform.appendFrom(t.relativeGroupTransform,s.worldTransform),r.worldColor=Ys(t.groupColor,s.worldColor),e=t.groupAlpha*s.worldAlpha}else r.worldTransform.copyFrom(t.localTransform),r.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function hl(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const s=r.localTransform;r.updateLocalTransform();const i=r.parent;if(i&&!i.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),e&qo&&Ko(r,i,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(s),e&qo&&Ko(r,vm,e)),!r.renderGroup){const n=r.children,o=n.length;for(let l=0;l<o;l++)hl(n[l],t,e);const a=r.parentRenderGroup,h=r;h.renderPipeId&&!a.structureDidChange&&a.updateRenderable(h)}}function Ko(r,t,e){if(e&qs){r.groupColor=Ys(r.localColor,t.groupColor);let s=r.localAlpha*t.groupAlpha;s=s<0?0:s>1?1:s,r.groupAlpha=s,r.groupColorAlpha=r.groupColor+((s*255|0)<<24)}e&xi&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&as&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function Sm(r,t){const{list:e}=r.childrenRenderablesToUpdate;let s=!1;for(let i=0;i<r.childrenRenderablesToUpdate.index;i++){const n=e[i];if(s=t[n.renderPipeId].validateRenderable(n),s)break}return r.structureDidChange=s,s}const Cm=new G;class ll{constructor(t){this._renderer=t}render({container:t,transform:e}){const s=t.parent,i=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,o=Cm;e&&(o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const a=n.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),hi(t.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=s,t.renderGroup.renderGroupParent=i}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let s=t.renderGroupChildren.length-1;s>=0;s--)this._updateCachedRenderGroups(t.renderGroupChildren[s],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const s=t.root.getLocalBounds(),i=this._renderer,n=t.textureOptions.resolution||i.view.resolution,o=t.textureOptions.antialias??i.view.antialias,a=t.textureOptions.scaleMode??"linear",h=t.texture;s.ceil(),t.texture&&yt.returnTexture(t.texture,!0);const l=yt.getOptimalTexture(s.width,s.height,n,o);l._source.style=new _e({scaleMode:a}),t.texture=l,t._textureBounds||(t._textureBounds=new _t),t._textureBounds.copyFrom(s),h!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(yt.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,s=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=s,t.structureDidChange?li(t.childrenRenderablesToUpdate.list,0):Sm(t,s),al(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!(t.isCachedAsTexture&&!t.textureNeedsUpdate))for(let i=0;i<t.renderGroupChildren.length;i++)this._updateRenderGroups(t.renderGroupChildren[i])}_updateRenderables(t){const{list:e,index:s}=t.childrenRenderablesToUpdate;for(let i=0;i<s;i++){const n=e[i];n.didViewUpdate&&t.updateRenderable(n)}li(e,s)}_buildInstructions(t,e){const s=t.root,i=t.instructionSet;i.reset();const n=e.renderPipes?e:e.batch.renderer,o=n.renderPipes;o.batch.buildStart(i),o.blendMode.buildStart(),o.colorMask.buildStart(),s.sortableChildren&&s.sortChildren(),s.collectRenderablesWithEffects(i,n,null),o.batch.buildEnd(i),o.blendMode.buildEnd(i)}}ll.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderGroup"};const qi=class cl{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Q(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...cl.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){Q.shared.setValue(t).alpha<1&&this._backgroundColor.alpha===1&&z("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};qi.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"background",priority:0};qi.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let wm=qi;const Ur={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Ki=class ul{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof vt||t instanceof L?{target:t,...e}:{...e,...t}}async image(t){const e=j.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,ul.defaultImageOptions);const{format:e,quality:s}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((n,o)=>{i.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>n(h.result),h.onerror=o,h.readAsDataURL(a)},Ur[e],s)});if(i.toDataURL!==void 0)return i.toDataURL(Ur[e],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:Ur[e],quality:s});return new Promise((o,a)=>{const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer;if(e instanceof L)return s.texture.generateCanvas(e);const i=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(i);return i.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,i=e instanceof L?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(i);return e instanceof vt&&i.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof L?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);const e=this.canvas(t),s=document.createElement("a");s.download=t.filename??"image.png",s.href=e.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){const e=t.width??200;t=this._normalizeOptions(t);const s=this.canvas(t),i=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const n=["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};Ki.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"extract"};Ki.defaultImageOptions={format:"png",quality:1};let Em=Ki;class Zi extends L{static create(t){const{dynamic:e,textureOptions:s,...i}=t;return new Zi({...s,source:new ft(i),dynamic:e??!1})}resize(t,e,s){return this.source.resize(t,e,s),this}}const Pm=new tt,Mm=new _t,Am=[0,0,0,0];class dl{constructor(t){this._renderer=t}generateTexture(t){var c;t instanceof vt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,s=t.antialias||this._renderer.view.antialias,i=t.target;let n=t.clearColor;n?n=Array.isArray(n)&&n.length===4?n:Q.shared.setValue(n).toArray():n=Am;const o=((c=t.frame)==null?void 0:c.copyTo(Pm))||gi(i,Mm).rectangle,a=t.defaultAnchor&&{defaultAnchor:t.defaultAnchor};o.width=Math.max(o.width,1/e)|0,o.height=Math.max(o.height,1/e)|0;const h=Zi.create({...t.textureSourceOptions,width:o.width,height:o.height,resolution:e,antialias:s,textureOptions:a}),l=G.shared.translate(-o.x,-o.y);return this._renderer.render({container:i,transform:l,target:h,clearColor:n}),h.source.updateMipmaps(),h}destroy(){this._renderer=null}}dl.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"textureGenerator"};function Rm(r){let t=!1;for(const s in r)if(r[s]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const s in r){const i=r[s];i&&(e[s]=i)}return e}function km(r){let t=0;for(let e=0;e<r.length;e++)r[e]==null?t++:r[e-t]=r[e];return r.length-=t,r}const Qi=class fl{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=t}init(t){t={...fl.defaultOptions,...t},this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedCollections){const{context:s,collection:i,type:n}=e;n==="hash"?s[i]=Rm(s[i]):s[i]=km(s[i])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e,t.gcTick=e;for(const s of t.renderGroupChildren)this._updateInstructionGCTick(s,e)}addCollection(t,e,s){this._managedCollections.push({context:t,collection:e,type:s})}addResource(t,e){var i,n;if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,(i=t._onTouch)==null||i.call(t,this.now);return}const s=this._managedResources.length;t._gcData={index:s,type:e},t._gcLastUsed=this.now,(n=t._onTouch)==null||n.call(t,this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){const e=t._gcData;if(!e)return;const s=e.index,i=this._managedResources.length-1;if(s!==i){const n=this._managedResources[i];this._managedResources[s]=n,n._gcData.index=s}this._managedResources.length--,t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,s,i=0){this._managedResourceHashes.push({context:t,hash:e,type:s,priority:i}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){const t=performance.now(),e=this._managedResourceHashes;for(const i of e)this.runOnHash(i,t);let s=0;for(let i=0;i<this._managedResources.length;i++){const n=this._managedResources[i];s=this.runOnResource(n,t,s)}this._managedResources.length=s}updateRenderableGCTick(t,e){var n,o;const s=t.renderGroup??t.parentRenderGroup,i=((n=s==null?void 0:s.instructionSet)==null?void 0:n.gcTick)??-1;((s==null?void 0:s.gcTick)??0)===i&&(t._gcLastUsed=e,(o=t._onTouch)==null||o.call(t,e))}runOnResource(t,e,s){const i=t._gcData;return i.type==="renderable"&&this.updateRenderableGCTick(t,e),e-t._gcLastUsed<this.maxUnusedTime||!t.autoGarbageCollect?(this._managedResources[s]=t,i.index=s,s++):(t.unload(),t._gcData=null,t._gcLastUsed=-1,t.off("unload",this.removeResource,this)),s}_createHashClone(t,e){const s=Object.create(null);for(const i in t){if(i===e)break;t[i]!==null&&(s[i]=t[i])}return s}runOnHash(t,e){var l;const{context:s,hash:i,type:n}=t,o=s[i];let a=null,h=0;for(const c in o){const u=o[c];if(u===null){h++,h===1e4&&!a&&(a=this._createHashClone(o,c));continue}if(u._gcLastUsed===-1){u._gcLastUsed=e,(l=u._onTouch)==null||l.call(u,e),a&&(a[c]=u);continue}if(n==="renderable"&&this.updateRenderableGCTick(u,e),!(e-u._gcLastUsed<this.maxUnusedTime)&&u.autoGarbageCollect){if(a||(h+1!==1e4?(o[c]=null,h++):a=this._createHashClone(o,c)),n==="renderable"){const f=u,p=f.renderGroup??f.parentRenderGroup;p&&(p.structureDidChange=!0)}u.unload(),u._gcData=null,u._gcLastUsed=-1}else a&&(a[c]=u)}a&&(s[i]=a)}destroy(){this.enabled=!1,this._managedResources.forEach(t=>{t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Qi.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"gc",priority:0};Qi.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Bm=Qi;class pl{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:s,worldColor:i,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new G,worldColor:4294967295,offset:new st},h={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:s||a.worldTransformMatrix,worldColor:i||a.worldColor,offset:n||a.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);const c=l.uniforms;c.uProjectionMatrix=h.projectionMatrix,c.uResolution=h.resolution,c.uWorldTransformMatrix.copyFrom(h.worldTransformMatrix),c.uWorldTransformMatrix.tx-=h.offset.x,c.uWorldTransformMatrix.ty-=h.offset.y,Uh(h.worldColor,c.uWorldColorAlpha,0),l.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(u=this._bindGroupPool.pop()||new re,this._activeBindGroups.push(u),u.setResource(l,0)),h.bindGroup=u,this._currentGlobalUniformData=h}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Nt.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new Wt({uProjectionMatrix:{value:new G,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new G,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}pl.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"globalUniforms"};let Im=1;class ml{constructor(){this._tasks=[],this._offset=0}init(){At.system.add(this._update,this)}repeat(t,e,s=!0){const i=Im++;let n=0;return s&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:i}),i}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t){this._tasks.splice(e,1);return}}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const s=this._tasks[e];if(t-s.offset-s.last>=s.duration){const i=t-s.start;s.func(i),s.last=t}}}destroy(){At.system.remove(this._update,this),this._tasks.length=0}}ml.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"scheduler",priority:0};let Zo=!1;function Gm(r){if(!Zo){if(j.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Zs} (${r}) http://www.pixijs.com/
582
+
583
+ `,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${Zs} - ${r} - http://www.pixijs.com/`);Zo=!0}}class Ji{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Nt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Gm(e)}}}Ji.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"hello",priority:-2};Ji.defaultOptions={hello:!1};const tn=class gl{constructor(t){this._renderer=t}init(t){t={...gl.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return H("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(t){H("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=t}addManagedHash(t,e){H("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,e,"hash")}addManagedArray(t,e){H("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,e,"array")}addRenderable(t){H("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(t,"renderable")}run(){H("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};tn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderableGC",priority:0};tn.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Fm=tn;const en=class Vs{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){H("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(t){H("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=t/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(t){H("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(t){H("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){t.textureGCActive!==Vs.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==Vs.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==Vs.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){H("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};en.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGC"};en.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Dm=en;const _l=class xl{constructor(t={}){if(this.uid=et("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...xl.defaultOptions,...t},this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new ft({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(s=>s.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof L||t.depthStencilTexture instanceof ft?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ft({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,s=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(t,e,s)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,s)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};_l.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let ci=_l;const Ie=new Map;Xe.register(Ie);function yl(r,t){if(!Ie.has(r)){const e=new L({source:new Lt({resource:r,...t})}),s=()=>{Ie.get(r)===e&&Ie.delete(r)};e.once("destroy",s),e.source.once("destroy",s),Ie.set(r,e)}return Ie.get(r)}const sn=class bl{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t={...bl.defaultOptions,...t},t.view&&(H(ot,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view),this.screen=new tt(0,0,t.width,t.height),this.canvas=t.canvas||j.get().createCanvas(),this.antialias=!!t.antialias,this.texture=yl(this.canvas,t),this.renderTarget=new ci({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,s){this.texture.source.resize(t,e,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:!!(t!=null&&t.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};sn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"view",priority:0};sn.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Um=sn;const rn=[wm,pl,Ji,Um,ll,Bm,Dm,dl,Em,sh,Fm,ml],vl=[Yi,zi,ji,$i,Vi,rl,tl,Xi];function Om(r,t,e,s,i,n){const o=n?1:-1;return r.identity(),r.a=1/s*2,r.d=o*(1/i*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}function Lm(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}class nn{constructor(t){this.rootViewPort=new tt,this.viewport=new tt,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Qa("onRenderTargetChange"),this.projectionMatrix=new G,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:s,frame:i,mipLevel:n,layer:o}){var a,h;this._renderTargetStack.length=0,this.push(t,e,s,i,n??0,o??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Lm(this.rootRenderTarget),(h=(a=this.adaptor).prerender)==null||h.call(a,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,s,i,n=0,o=0){const a=this.getRenderTarget(t),h=this.renderTarget!==a;this.renderTarget=a,this.renderSurface=t;const l=this.getGpuRenderTarget(a);(a.pixelWidth!==l.width||a.pixelHeight!==l.height)&&(this.adaptor.resizeGpuRenderTarget(a),l.width=a.pixelWidth,l.height=a.pixelHeight);const c=a.colorTexture,u=this.viewport,d=c.arrayLayerCount||1;if((o|0)!==o&&(o|=0),o<0||o>=d)throw new Error(`[RenderTargetSystem] layer ${o} is out of bounds (arrayLayerCount=${d}).`);this.mipLevel=n|0,this.layer=o|0;const f=Math.max(c.pixelWidth>>n,1),p=Math.max(c.pixelHeight>>n,1);if(!i&&t instanceof L&&(i=t.frame),i){const g=c._resolution,m=1<<Math.max(n|0,0),_=i.x*g+.5|0,x=i.y*g+.5|0,y=i.width*g+.5|0,v=i.height*g+.5|0;let S=Math.floor(_/m),T=Math.floor(x/m),C=Math.ceil(y/m),k=Math.ceil(v/m);S=Math.min(Math.max(S,0),f-1),T=Math.min(Math.max(T,0),p-1),C=Math.min(Math.max(C,1),f-S),k=Math.min(Math.max(k,1),p-T),u.x=S,u.y=T,u.width=C,u.height=k}else u.x=0,u.y=0,u.width=f,u.height=p;return Om(this.projectionMatrix,0,0,u.width/c.resolution,u.height/c.resolution,!a.isRoot),this.adaptor.startRenderPass(a,e,s,u,n,o),h&&this.onRenderTargetChange.emit(a),a}clear(t,e=wt.ALL,s,i=this.mipLevel,n=this.layer){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,s,this.viewport,i,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=wt.ALL,s,i,n=0,o=0){const a=this.bind(t,e,s,i,n,o);return this._renderTargetStack.push({renderTarget:a,frame:i,mipLevel:n,layer:o}),a}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame,t.mipLevel,t.layer)}getRenderTarget(t){return t.isTexture&&(t=t.source),this._renderSurfaceToRenderTargetHash.get(t)??this._initRenderTarget(t)}copyToTexture(t,e,s,i,n){s.x<0&&(i.width+=s.x,n.x-=s.x,s.x=0),s.y<0&&(i.height+=s.y,n.y-=s.y,s.y=0);const{pixelWidth:o,pixelHeight:a}=t;return i.width=Math.min(i.width,o-s.x),i.height=Math.min(i.height,a-s.y),this.adaptor.copyToTexture(t,e,s,i,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Lt.test(t)&&(t=yl(t).source),t instanceof ci?e=t:t instanceof ft&&(e=new ci({colorTextures:[t]}),t.source instanceof Lt&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const s=this._gpuRenderTargetHash[e.uid];s&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(s))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}class Nm{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){const e=t.colorTexture,{canvas:s,context:i}=this._ensureCanvas(e);return{canvas:s,context:i,width:s.width,height:s.height}}resizeGpuRenderTarget(t){const e=t.colorTexture,{canvas:s}=this._ensureCanvas(e);s.width=t.pixelWidth,s.height=t.pixelHeight}startRenderPass(t,e,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,s,i)}clear(t,e,s,i){const o=this._renderTargetSystem.getGpuRenderTarget(t).context,a=i||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(a.x,a.y,a.width,a.height),s){const h=Q.shared.setValue(s);h.alpha>0&&(o.globalAlpha=h.alpha,o.fillStyle=h.toHex(),o.fillRect(a.x,a.y,a.width,a.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,s,i,n){const a=this._renderTargetSystem.getGpuRenderTarget(t).canvas,h=e.source,{context:l}=this._ensureCanvas(h),c=(n==null?void 0:n.x)??0,u=(n==null?void 0:n.y)??0;return l.drawImage(a,s.x,s.y,i.width,i.height,c,u,i.width,i.height),h.update(),e}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!Lt.test(e))&&(e=j.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);const s=e.getContext("2d");return{canvas:e,context:s}}}class Tl extends nn{constructor(t){super(t),this.adaptor=new Nm,this.adaptor.init(t,this)}}Tl.extension={type:[b.CanvasSystem],name:"renderTarget"};class Sl{constructor(t){}init(){}initSource(t){}generateCanvas(t){const e=j.get().createCanvas(),s=e.getContext("2d"),i=X.getCanvasSource(t);if(!i)return e;const n=t.frame,o=t.source._resolution??t.source.resolution??1,a=n.x*o,h=n.y*o,l=n.width*o,c=n.height*o;return e.width=Math.ceil(l),e.height=Math.ceil(c),s.drawImage(i,a,h,l,c,0,0,l,c),e}getPixels(t){const e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}}Sl.extension={type:[b.CanvasSystem],name:"texture"};const Hm=[...rn,il,nl,Sl,Tl],Wm=[Yi,zi,ji,$i,Vi,sl,Jh,Xi],zm=[rm,ol],Cl=[],wl=[],El=[];W.handleByNamedList(b.CanvasSystem,Cl);W.handleByNamedList(b.CanvasPipes,wl);W.handleByNamedList(b.CanvasPipesAdaptor,El);W.add(...Hm,...Wm,...zm);class Vm extends bs{constructor(){const t={name:"canvas",type:Nt.CANVAS,systems:Cl,renderPipes:wl,renderPipeAdaptors:El};super(t)}}const Xm=Object.freeze(Object.defineProperty({__proto__:null,CanvasRenderer:Vm},Symbol.toStringTag,{value:"Module"}));var Xs=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Xs||{});class $m{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class Pl{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new zt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,s=this.getGlBuffer(t);e.bindBuffer(s.type,s.buffer)}bindBufferBase(t,e){const{_gl:s}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,s.bindBufferBase(s.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let s=0,i=this._nextBindBaseIndex;for(;s<2;){i>=this._maxBindings&&(i=this._minBaseLocation,s++);const n=this._boundBufferBases[i];if(n&&n._lastBindCallId===this._bindCallId){i++;continue}break}return e=i,this._nextBindBaseIndex=i+1,s>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,s,i){const{_gl:n}=this;s||(s=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,s*256,i||256)}updateBuffer(t){const{_gl:e}=this,s=this.getGlBuffer(t);if(t._updateID===s.updateID)return s;s.updateID=t._updateID,e.bindBuffer(s.type,s.buffer);const i=t.data,n=t.descriptor.usage&it.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return i?s.byteLength>=i.byteLength?e.bufferSubData(s.type,0,i,0,t._updateSize/i.BYTES_PER_ELEMENT):(s.byteLength=i.byteLength,e.bufferData(s.type,i,n)):(s.byteLength=t.descriptor.size,e.bufferData(s.type,s.byteLength,n)),s}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];s&&(e||this._gl.deleteBuffer(s.buffer))}createGLBuffer(t){const{_gl:e}=this;let s=Xs.ARRAY_BUFFER;t.descriptor.usage&it.INDEX?s=Xs.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&it.UNIFORM&&(s=Xs.UNIFORM_BUFFER);const i=new $m(e.createBuffer(),s);return t._gpuData[this._renderer.uid]=i,this._managedBuffers.add(t),i}resetState(){this._boundBufferBases=Object.create(null)}}Pl.extension={type:[b.WebGLSystem],name:"buffer"};const on=class Ml{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){t={...Ml.defaultOptions,...t};let e=this.multiView=t.multiView;if(t.context&&e&&(z("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),e=!1),e?this.canvas=j.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const s=this._renderer.background.alpha<1,i=t.premultipliedAlpha??!0,n=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:s,premultipliedAlpha:i,antialias:n,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&z("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof j.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let s;const i=this.canvas;if(t===2&&(s=i.getContext("webgl2",e)),!s&&(s=i.getContext("webgl",e),!s))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=s,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...e,drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")};else{this.extensions={...e,colorBufferFloat:t.getExtension("EXT_color_buffer_float")};const s=t.getExtension("WEBGL_provoking_vertex");s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var e;const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(e=this.extensions.loseContext)==null||e.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&z("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=this.supports,i=this.webGLVersion===2,n=this.extensions;s.uint32Indices=i||!!n.uint32ElementIndex,s.uniformBufferObject=i,s.vertexArrayObject=i||!!n.vertexArrayObject,s.srgbTextures=i||!!n.srgb,s.nonPowOf2wrapping=i,s.nonPowOf2mipmaps=i,s.msaa=i,s.uint32Indices||z("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};on.extension={type:[b.WebGLSystem],name:"context"};on.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let jm=on;function Al(r,t){for(const e in r.attributes){const s=r.attributes[e],i=t[e];i?(s.format??(s.format=i.format),s.offset??(s.offset=i.offset),s.instance??(s.instance=i.instance)):z(`Attribute ${e} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}Ym(r)}function Ym(r){const{buffers:t,attributes:e}=r,s={},i={};for(const n in t){const o=t[n];s[o.uid]=0,i[o.uid]=0}for(const n in e){const o=e[n];s[o.buffer.uid]+=ps(o.format).stride}for(const n in e){const o=e[n];o.stride??(o.stride=s[o.buffer.uid]),o.start??(o.start=i[o.buffer.uid]),i[o.buffer.uid]+=ps(o.format).stride}}var ui=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(ui||{}),an=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(an||{}),K=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(K||{});const Qo={uint8x2:K.UNSIGNED_BYTE,uint8x4:K.UNSIGNED_BYTE,sint8x2:K.BYTE,sint8x4:K.BYTE,unorm8x2:K.UNSIGNED_BYTE,unorm8x4:K.UNSIGNED_BYTE,snorm8x2:K.BYTE,snorm8x4:K.BYTE,uint16x2:K.UNSIGNED_SHORT,uint16x4:K.UNSIGNED_SHORT,sint16x2:K.SHORT,sint16x4:K.SHORT,unorm16x2:K.UNSIGNED_SHORT,unorm16x4:K.UNSIGNED_SHORT,snorm16x2:K.SHORT,snorm16x4:K.SHORT,float16x2:K.HALF_FLOAT,float16x4:K.HALF_FLOAT,float32:K.FLOAT,float32x2:K.FLOAT,float32x3:K.FLOAT,float32x4:K.FLOAT,uint32:K.UNSIGNED_INT,uint32x2:K.UNSIGNED_INT,uint32x3:K.UNSIGNED_INT,uint32x4:K.UNSIGNED_INT,sint32:K.INT,sint32x2:K.INT,sint32x3:K.INT,sint32x4:K.INT};function qm(r){return Qo[r]??Qo.float32}const Km={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Zm{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class Rl{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new zt({renderer:t,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=i=>e.bindVertexArrayOES(i),t.deleteVertexArray=i=>e.deleteVertexArrayOES(i));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(t.drawArraysInstanced=(i,n,o,a)=>{s.drawArraysInstancedANGLE(i,n,o,a)},t.drawElementsInstanced=(i,n,o,a,h)=>{s.drawElementsInstancedANGLE(i,n,o,a,h)},t.vertexAttribDivisor=(i,n)=>s.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null}bind(t,e){const s=this.gl;this._activeGeometry=t;const i=this.getVao(t,e);this._activeVao!==i&&(this._activeVao=i,s.bindVertexArray(i)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let s=0;s<t.buffers.length;s++){const i=t.buffers[s];e.updateBuffer(i)}t._gcLastUsed=this._renderer.gc.now}checkCompatibility(t,e){const s=t.attributes,i=e._attributeData;for(const n in i)if(!s[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const s=t.attributes,i=e._attributeData,n=["g",t.uid];for(const o in s)i[o]&&n.push(o,i[o].location);return n.join("-")}getVao(t,e){var s;return((s=t._gpuData[this._renderer.uid])==null?void 0:s.vaoCache[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,s=!0){const i=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const o=this.getSignature(t,e);let a=t._gpuData[this._renderer.uid];a||(a=new Zm,t._gpuData[this._renderer.uid]=a,this._managedGeometries.add(t));const h=a.vaoCache;let l=h[o];if(l)return h[e._key]=l,l;Al(t,e._attributeData);const c=t.buffers;l=i.createVertexArray(),i.bindVertexArray(l);for(let u=0;u<c.length;u++){const d=c[u];n.bind(d)}return this.activateVao(t,e),h[e._key]=l,h[o]=l,i.bindVertexArray(null),l}onGeometryUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];if(!s)return;const i=s.vaoCache;if(!e)for(const n in i)this._activeVao!==i[n]&&this.resetState(),this.gl.deleteVertexArray(i[n])}destroyAll(t=!1){this._managedGeometries.removeAll(t)}activateVao(t,e){var a;const s=this._renderer.gl,i=this._renderer.buffer,n=t.attributes;t.indexBuffer&&i.bind(t.indexBuffer);let o=null;for(const h in n){const l=n[h],c=l.buffer,u=i.getGlBuffer(c),d=e._attributeData[h];if(d){o!==u&&(i.bind(c),o=u);const f=d.location;s.enableVertexAttribArray(f);const p=ps(l.format),g=qm(l.format);if(((a=d.format)==null?void 0:a.substring(1,4))==="int"?s.vertexAttribIPointer(f,p.size,g,l.stride,l.offset):s.vertexAttribPointer(f,p.size,g,p.normalised,l.stride,l.offset),l.instance)if(this.hasInstance){const m=l.divisor??1;s.vertexAttribDivisor(f,m)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,s,i){const{gl:n}=this._renderer,o=this._activeGeometry,a=Km[t||o.topology];if(i??(i=o.instanceCount),o.indexBuffer){const h=o.indexBuffer.data.BYTES_PER_ELEMENT,l=h===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;i!==1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,l,(s||0)*h,i):n.drawElements(a,e||o.indexBuffer.data.length,l,(s||0)*h)}else i!==1?n.drawArraysInstanced(a,s||0,e||o.getSize(),i):n.drawArrays(a,s||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}Rl.extension={type:[b.WebGLSystem],name:"geometry"};const Qm=new wi({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),hn=class kl{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}={...kl.defaultOptions,...t};this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(z("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Qt.for2d();const i=new $e({vertex:`
584
+ attribute vec2 aPosition;
585
+ out vec2 vUv;
586
+
587
+ void main() {
588
+ gl_Position = vec4(aPosition, 0.0, 1.0);
589
+
590
+ vUv = (aPosition + 1.0) / 2.0;
591
+
592
+ // flip dem UVs
593
+ vUv.y = 1.0 - vUv.y;
594
+ }`,fragment:`
595
+ in vec2 vUv;
596
+ out vec4 finalColor;
597
+
598
+ uniform sampler2D uTexture;
599
+
600
+ void main() {
601
+ finalColor = texture(uTexture, vUv);
602
+ }`,name:"big-triangle"});this._bigTriangleShader=new Zt({glProgram:i,resources:{uTexture:L.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:Qm,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new L({source:new ft({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};hn.extension={type:[b.WebGLSystem],name:"backBuffer",priority:1};hn.defaultOptions={useBackBuffer:!1};let Jm=hn;class Bl{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}Bl.extension={type:[b.WebGLSystem],name:"colorMask"};class Il{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:s,shader:i,state:n,skipSync:o,topology:a,size:h,start:l,instanceCount:c}=t;e.shader.bind(i,o),e.geometry.bind(s,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,h,l,c??s.instanceCount)}destroy(){this._renderer=null}}Il.extension={type:[b.WebGLSystem],name:"encoder"};class Gl{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=ah(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}Gl.extension={type:[b.WebGLSystem],name:"limits"};class tg{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const ne=[];ne[ut.NONE]=void 0;ne[ut.DISABLED]={stencilWriteMask:0,stencilReadMask:0};ne[ut.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};ne[ut.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};ne[ut.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};ne[ut.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Fl{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:ut.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ut.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=ut.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=ne[t],o=this._stencilCache;if(s.stencilMode=t,s.stencilReference=e,t===ut.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,i.disable(i.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,i.enable(i.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}Fl.extension={type:[b.WebGLSystem],name:"stencil"};class Dl{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!ja())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new ie({data:new Float32Array(e.layout.size/4),usage:it.UNIFORM|it.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let s=this._syncFunctionHash[e];if(!s){const i=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,s){const i=this.getUniformGroupData(t);t.buffer||(t.buffer=new ie({data:new Float32Array(i.layout.size/4),usage:it.UNIFORM|it.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),s||(s=0),i.syncFunction(t.uniforms,e,n,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const Ul={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function eg(r){const t=r.map(n=>({data:n,offset:0,size:0})),e=16;let s=0,i=0;for(let n=0;n<t.length;n++){const o=t[n];if(s=Ul[o.data.type],!s)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(s=Math.max(s,e)*o.data.size);const a=s===12?16:s;o.size=s;const h=i%e;h>0&&e-h<a?i+=(e-h)%16:i+=(s-h%s)%s,o.offset=i,i+=s}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}const ge=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
603
+ var matrix = uv[name].toArray(true);
604
+ data[offset] = matrix[0];
605
+ data[offset + 1] = matrix[1];
606
+ data[offset + 2] = matrix[2];
607
+ data[offset + 4] = matrix[3];
608
+ data[offset + 5] = matrix[4];
609
+ data[offset + 6] = matrix[5];
610
+ data[offset + 8] = matrix[6];
611
+ data[offset + 9] = matrix[7];
612
+ data[offset + 10] = matrix[8];
613
+ `,uniform:`
614
+ gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
615
+ `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
616
+ v = uv[name];
617
+ data[offset] = v.x;
618
+ data[offset + 1] = v.y;
619
+ data[offset + 2] = v.width;
620
+ data[offset + 3] = v.height;
621
+ `,uniform:`
622
+ cv = ud[name].value;
623
+ v = uv[name];
624
+ if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
625
+ cv[0] = v.x;
626
+ cv[1] = v.y;
627
+ cv[2] = v.width;
628
+ cv[3] = v.height;
629
+ gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
630
+ }
631
+ `},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
632
+ v = uv[name];
633
+ data[offset] = v.x;
634
+ data[offset + 1] = v.y;
635
+ `,uniform:`
636
+ cv = ud[name].value;
637
+ v = uv[name];
638
+ if (cv[0] !== v.x || cv[1] !== v.y) {
639
+ cv[0] = v.x;
640
+ cv[1] = v.y;
641
+ gl.uniform2f(ud[name].location, v.x, v.y);
642
+ }
643
+ `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
644
+ v = uv[name];
645
+ data[offset] = v.red;
646
+ data[offset + 1] = v.green;
647
+ data[offset + 2] = v.blue;
648
+ data[offset + 3] = v.alpha;
649
+ `,uniform:`
650
+ cv = ud[name].value;
651
+ v = uv[name];
652
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
653
+ cv[0] = v.red;
654
+ cv[1] = v.green;
655
+ cv[2] = v.blue;
656
+ cv[3] = v.alpha;
657
+ gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
658
+ }
659
+ `},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
660
+ v = uv[name];
661
+ data[offset] = v.red;
662
+ data[offset + 1] = v.green;
663
+ data[offset + 2] = v.blue;
664
+ `,uniform:`
665
+ cv = ud[name].value;
666
+ v = uv[name];
667
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
668
+ cv[0] = v.red;
669
+ cv[1] = v.green;
670
+ cv[2] = v.blue;
671
+ gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
672
+ }
673
+ `}];function Ol(r,t,e,s){const i=[`
674
+ var v = null;
675
+ var v2 = null;
676
+ var t = 0;
677
+ var index = 0;
678
+ var name = null;
679
+ var arrayOffset = null;
680
+ `];let n=0;for(let a=0;a<r.length;a++){const h=r[a],l=h.data.name;let c=!1,u=0;for(let d=0;d<ge.length;d++)if(ge[d].test(h.data)){u=h.offset/4,i.push(`name = "${l}";`,`offset += ${u-n};`,ge[d][t]||ge[d].ubo),c=!0;break}if(!c)if(h.data.size>1)u=h.offset/4,i.push(e(h,u-n));else{const d=s[h.data.type];u=h.offset/4,i.push(`
681
+ v = uv.${l};
682
+ offset += ${u-n};
683
+ ${d};
684
+ `)}n=u}const o=i.join(`
685
+ `);return new Function("uv","data","dataInt32","offset",o)}function Re(r,t){return`
686
+ for (let i = 0; i < ${r*t}; i++) {
687
+ data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
688
+ }
689
+ `}const Ll={f32:`
690
+ data[offset] = v;`,i32:`
691
+ dataInt32[offset] = v;`,"vec2<f32>":`
692
+ data[offset] = v[0];
693
+ data[offset + 1] = v[1];`,"vec3<f32>":`
694
+ data[offset] = v[0];
695
+ data[offset + 1] = v[1];
696
+ data[offset + 2] = v[2];`,"vec4<f32>":`
697
+ data[offset] = v[0];
698
+ data[offset + 1] = v[1];
699
+ data[offset + 2] = v[2];
700
+ data[offset + 3] = v[3];`,"vec2<i32>":`
701
+ dataInt32[offset] = v[0];
702
+ dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
703
+ dataInt32[offset] = v[0];
704
+ dataInt32[offset + 1] = v[1];
705
+ dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
706
+ dataInt32[offset] = v[0];
707
+ dataInt32[offset + 1] = v[1];
708
+ dataInt32[offset + 2] = v[2];
709
+ dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
710
+ data[offset] = v[0];
711
+ data[offset + 1] = v[1];
712
+ data[offset + 4] = v[2];
713
+ data[offset + 5] = v[3];`,"mat3x3<f32>":`
714
+ data[offset] = v[0];
715
+ data[offset + 1] = v[1];
716
+ data[offset + 2] = v[2];
717
+ data[offset + 4] = v[3];
718
+ data[offset + 5] = v[4];
719
+ data[offset + 6] = v[5];
720
+ data[offset + 8] = v[6];
721
+ data[offset + 9] = v[7];
722
+ data[offset + 10] = v[8];`,"mat4x4<f32>":`
723
+ for (let i = 0; i < 16; i++) {
724
+ data[offset + i] = v[i];
725
+ }`,"mat3x2<f32>":Re(3,2),"mat4x2<f32>":Re(4,2),"mat2x3<f32>":Re(2,3),"mat4x3<f32>":Re(4,3),"mat2x4<f32>":Re(2,4),"mat3x4<f32>":Re(3,4)},sg={...Ll,"mat2x2<f32>":`
726
+ data[offset] = v[0];
727
+ data[offset + 1] = v[1];
728
+ data[offset + 2] = v[2];
729
+ data[offset + 3] = v[3];
730
+ `};function rg(r,t){const e=Math.max(Ul[r.data.type]/16,1),s=r.data.value.length/r.data.size,i=(4-s%4)%4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
731
+ v = uv.${r.data.name};
732
+ offset += ${t};
733
+
734
+ arrayOffset = offset;
735
+
736
+ t = 0;
737
+
738
+ for(var i=0; i < ${r.data.size*e}; i++)
739
+ {
740
+ for(var j = 0; j < ${s}; j++)
741
+ {
742
+ ${n}[arrayOffset++] = v[t++];
743
+ }
744
+ ${i!==0?`arrayOffset += ${i};`:""}
745
+ }
746
+ `}function ig(r){return Ol(r,"uboStd40",rg,Ll)}class Nl extends Dl{constructor(){super({createUboElements:eg,generateUboSync:ig})}}Nl.extension={type:[b.WebGLSystem],name:"ubo"};class ng{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new tt}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new tt;const t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(s,i)=>t.COLOR_ATTACHMENT0+i)}copyToTexture(t,e,s,i,n){const o=this._renderTargetSystem,a=this._renderer,h=o.getGpuRenderTarget(t),l=a.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,h.resolveTargetFramebuffer),a.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,n.x,n.y,s.x,s.y,i.width,i.height),e}startRenderPass(t,e=!0,s,i,n=0,o=0){const a=this._renderTargetSystem,h=t.colorTexture,l=a.getGpuRenderTarget(t);if(o!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(n>0){if(l.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let c=i.y;t.isRoot&&(c=h.pixelHeight-i.height-i.y),t.colorTextures.forEach(f=>{this._renderer.texture.unbind(f)});const u=this._renderer.gl;u.bindFramebuffer(u.FRAMEBUFFER,l.framebuffer),!t.isRoot&&(l._attachedMipLevel!==n||l._attachedLayer!==o)&&(t.colorTextures.forEach((f,p)=>{const g=this._renderer.texture.getGlSource(f);if(g.target===u.TEXTURE_2D){if(o!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+p,u.TEXTURE_2D,g.texture,n)}else if(g.target===u.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");u.framebufferTextureLayer(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+p,g.texture,n,o)}else if(g.target===u.TEXTURE_CUBE_MAP){if(o<0||o>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+p,u.TEXTURE_CUBE_MAP_POSITIVE_X+o,g.texture,n)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),l._attachedMipLevel=n,l._attachedLayer=o),t.colorTextures.length>1&&this._setDrawBuffers(t,u);const d=this._viewPortCache;(d.x!==i.x||d.y!==c||d.width!==i.width||d.height!==i.height)&&(d.x=i.x,d.y=c,d.width=i.width,d.height=i.height,u.viewport(i.x,c,i.width,i.height)),!l.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(l),this.clear(t,e,s)}finishRenderPass(t){const s=this._renderTargetSystem.getGpuRenderTarget(t);if(!s.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,s.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,s.framebuffer),i.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,s.framebuffer)}initGpuRenderTarget(t){const s=this._renderer.gl,i=new tg;return i._attachedMipLevel=0,i._attachedLayer=0,t.colorTexture instanceof Lt?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),s.bindFramebuffer(s.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(s=>{e.deleteRenderbuffer(s)}),t.msaaRenderBuffer=null}clear(t,e,s,i,n=0,o=0){if(!e)return;if(o!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const a=this._renderTargetSystem;typeof e=="boolean"&&(e=e?wt.ALL:wt.NONE);const h=this._renderer.gl;if(e&wt.COLOR){s??(s=a.defaultClearColor);const l=this._clearColorCache,c=s;(l[0]!==c[0]||l[1]!==c[1]||l[2]!==c[2]||l[3]!==c[3])&&(l[0]=c[0],l[1]=c[1],l[2]=c[2],l[3]=c[3],h.clearColor(c[0],c[1],c[2],c[3]))}h.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const s=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,s),(t.stencil||t.depth)&&this._resizeStencil(s)}_initColor(t,e){const s=this._renderer,i=s.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((a,h)=>{const l=a.source;l.antialias&&(s.context.supports.msaa?e.msaa=!0:z("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(l,0);const c=s.texture.getGlSource(l),u=c.texture;if(c.target===i.TEXTURE_2D)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+h,i.TEXTURE_2D,u,0);else if(c.target===i.TEXTURE_2D_ARRAY){if(s.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+h,u,0,0)}else if(c.target===i.TEXTURE_CUBE_MAP)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+h,i.TEXTURE_CUBE_MAP_POSITIVE_X,u,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),e.msaa){const a=i.createFramebuffer();e.framebuffer=a,i.bindFramebuffer(i.FRAMEBUFFER,a),t.colorTextures.forEach((h,l)=>{const c=i.createRenderbuffer();e.msaaRenderBuffer[l]=c})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const s=t.colorTexture.source;if(e.width=s.pixelWidth,e.height=s.pixelHeight,e._attachedMipLevel=0,e._attachedLayer=0,t.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(s.width,s.height,s._resolution)}),e.msaa){const i=this._renderer,n=i.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,h)=>{const l=a.source;i.texture.bindSource(l,0);const u=i.texture.getGlSource(l).internalFormat,d=e.msaaRenderBuffer[h];n.bindRenderbuffer(n.RENDERBUFFER,d),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,u,l.pixelWidth,l.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+h,n.RENDERBUFFER,d)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,s=e.createRenderbuffer();t.depthStencilRenderBuffer=s,e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&Lt.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Lt.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,s=t.colorTexture;s.context2D.drawImage(e,0,s.pixelHeight-e.height)}}_setDrawBuffers(t,e){const s=t.colorTextures.length,i=this._drawBuffersCache[s];if(this._renderer.context.webGLVersion===1){const n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(i):z("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(i)}}class Hl extends nn{constructor(t){super(t),this.adaptor=new ng,this.adaptor.init(t,this)}}Hl.extension={type:[b.WebGLSystem],name:"renderTarget"};class ln extends kt{constructor({buffer:t,offset:e,size:s}){super(),this.uid=et("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=et("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=et("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function og(r,t){const e=[],s=[`
747
+ var g = s.groups;
748
+ var sS = r.shader;
749
+ var p = s.glProgram;
750
+ var ugS = r.uniformGroup;
751
+ var resources;
752
+ `];let i=!1,n=0;const o=t._getProgramData(r.glProgram);for(const h in r.groups){const l=r.groups[h];e.push(`
753
+ resources = g[${h}].resources;
754
+ `);for(const c in l.resources){const u=l.resources[c];if(u instanceof Wt)if(u.ubo){const d=r._uniformBindMap[h][Number(c)];e.push(`
755
+ sS.bindUniformBlock(
756
+ resources[${c}],
757
+ '${d}',
758
+ ${r.glProgram._uniformBlockData[d].index}
759
+ );
760
+ `)}else e.push(`
761
+ ugS.updateUniformGroup(resources[${c}], p, sD);
762
+ `);else if(u instanceof ln){const d=r._uniformBindMap[h][Number(c)];e.push(`
763
+ sS.bindUniformBlock(
764
+ resources[${c}],
765
+ '${d}',
766
+ ${r.glProgram._uniformBlockData[d].index}
767
+ );
768
+ `)}else if(u instanceof ft){const d=r._uniformBindMap[h][c],f=o.uniformData[d];f&&(i||(i=!0,s.push(`
769
+ var tS = r.texture;
770
+ `)),t._gl.uniform1i(f.location,n),e.push(`
771
+ tS.bind(resources[${c}], ${n});
772
+ `),n++)}}}const a=[...s,...e].join(`
773
+ `);return new Function("r","s","sD",a)}class ag{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function Jo(r,t,e){const s=r.createShader(t);return r.shaderSource(s,e),r.compileShader(s),s}function Or(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Wl(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Or(2*t);case"bvec3":return Or(3*t);case"bvec4":return Or(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Ns=null;const ta={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},hg={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function zl(r,t){if(!Ns){const e=Object.keys(ta);Ns={};for(let s=0;s<e.length;++s){const i=e[s];Ns[r[i]]=ta[i]}}return Ns[t]}function lg(r,t){const e=zl(r,t);return hg[e]||"float32"}function cg(r,t,e=!1){const s={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let o=0;o<i;o++){const a=t.getActiveAttrib(r,o);if(a.name.startsWith("gl_"))continue;const h=lg(t,a.type);s[a.name]={location:0,format:h,stride:ps(h).stride,offset:0,instance:!1,start:0}}const n=Object.keys(s);if(e){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)s[n[o]].location=o,t.bindAttribLocation(r,o,n[o]);t.linkProgram(r)}else for(let o=0;o<n.length;o++)s[n[o]].location=t.getAttribLocation(r,n[o]);return s}function ug(r,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},s=t.getProgramParameter(r,t.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<s;i++){const n=t.getActiveUniformBlockName(r,i),o=t.getUniformBlockIndex(r,n),a=t.getActiveUniformBlockParameter(r,i,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:o,size:a}}return e}function dg(r,t){const e={},s=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let i=0;i<s;i++){const n=t.getActiveUniform(r,i),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),h=zl(t,n.type);e[o]={name:o,index:i,type:h,size:n.size,isArray:a,value:Wl(h,n.size)}}return e}function ea(r,t){const e=r.getShaderSource(t).split(`
774
+ `).map((l,c)=>`${c}: ${l}`),s=r.getShaderInfoLog(t),i=s.split(`
775
+ `),n={},o=i.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
776
+ `);a[0]=h,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function fg(r,t,e,s){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||ea(r,e),r.getShaderParameter(s,r.COMPILE_STATUS)||ea(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function pg(r,t){const e=Jo(r,r.VERTEX_SHADER,t.vertex),s=Jo(r,r.FRAGMENT_SHADER,t.fragment),i=r.createProgram();r.attachShader(i,e),r.attachShader(i,s);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"?z("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(i,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(i),r.getProgramParameter(i,r.LINK_STATUS)||fg(r,i,e,s),t._attributeData=cg(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=dg(i,r),t._uniformBlockData=ug(i,r),r.deleteShader(e),r.deleteShader(s);const o={};for(const h in t._uniformData){const l=t._uniformData[h];o[h]={location:r.getUniformLocation(i,h),value:Wl(l.type,l.size)}}return new ag(i,o)}const Hs={textureCount:0,blockIndex:0};class Vl{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;Hs.textureCount=0,Hs.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),s(this._renderer,t,Hs)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Hs)}bindUniformBlock(t,e,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);const a=t.buffer,h=i.updateBuffer(a),l=i.freeLocationForBufferBase(h);if(o){const{offset:u,size:d}=t;u===0&&d===a.data.byteLength?i.bindBufferBase(h,l):i.bindBufferRange(h,l,u)}else i.getLastBindBaseLocation(h)!==l&&i.bindBufferBase(h,l);const c=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==l&&(n.uniformBlockBindings[s]=l,this._renderer.gl.uniformBlockBinding(n.program,c,l))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=pg(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return og(t,e)}resetState(){this._activeProgram=null}}Vl.extension={type:[b.WebGLSystem],name:"shader"};const mg={f32:`if (cv !== v) {
777
+ cu.value = v;
778
+ gl.uniform1f(location, v);
779
+ }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
780
+ cv[0] = v[0];
781
+ cv[1] = v[1];
782
+ gl.uniform2f(location, v[0], v[1]);
783
+ }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
784
+ cv[0] = v[0];
785
+ cv[1] = v[1];
786
+ cv[2] = v[2];
787
+ gl.uniform3f(location, v[0], v[1], v[2]);
788
+ }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
789
+ cv[0] = v[0];
790
+ cv[1] = v[1];
791
+ cv[2] = v[2];
792
+ cv[3] = v[3];
793
+ gl.uniform4f(location, v[0], v[1], v[2], v[3]);
794
+ }`,i32:`if (cv !== v) {
795
+ cu.value = v;
796
+ gl.uniform1i(location, v);
797
+ }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
798
+ cv[0] = v[0];
799
+ cv[1] = v[1];
800
+ gl.uniform2i(location, v[0], v[1]);
801
+ }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
802
+ cv[0] = v[0];
803
+ cv[1] = v[1];
804
+ cv[2] = v[2];
805
+ gl.uniform3i(location, v[0], v[1], v[2]);
806
+ }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
807
+ cv[0] = v[0];
808
+ cv[1] = v[1];
809
+ cv[2] = v[2];
810
+ cv[3] = v[3];
811
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
812
+ }`,u32:`if (cv !== v) {
813
+ cu.value = v;
814
+ gl.uniform1ui(location, v);
815
+ }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
816
+ cv[0] = v[0];
817
+ cv[1] = v[1];
818
+ gl.uniform2ui(location, v[0], v[1]);
819
+ }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
820
+ cv[0] = v[0];
821
+ cv[1] = v[1];
822
+ cv[2] = v[2];
823
+ gl.uniform3ui(location, v[0], v[1], v[2]);
824
+ }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
825
+ cv[0] = v[0];
826
+ cv[1] = v[1];
827
+ cv[2] = v[2];
828
+ cv[3] = v[3];
829
+ gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
830
+ }`,bool:`if (cv !== v) {
831
+ cu.value = v;
832
+ gl.uniform1i(location, v);
833
+ }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
834
+ cv[0] = v[0];
835
+ cv[1] = v[1];
836
+ gl.uniform2i(location, v[0], v[1]);
837
+ }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
838
+ cv[0] = v[0];
839
+ cv[1] = v[1];
840
+ cv[2] = v[2];
841
+ gl.uniform3i(location, v[0], v[1], v[2]);
842
+ }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
843
+ cv[0] = v[0];
844
+ cv[1] = v[1];
845
+ cv[2] = v[2];
846
+ cv[3] = v[3];
847
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
848
+ }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},gg={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function _g(r,t){const e=[`
849
+ var v = null;
850
+ var cv = null;
851
+ var cu = null;
852
+ var t = 0;
853
+ var gl = renderer.gl;
854
+ var name = null;
855
+ `];for(const s in r.uniforms){if(!t[s]){r.uniforms[s]instanceof Wt?r.uniforms[s].ubo?e.push(`
856
+ renderer.shader.bindUniformBlock(uv.${s}, "${s}");
857
+ `):e.push(`
858
+ renderer.shader.updateUniformGroup(uv.${s});
859
+ `):r.uniforms[s]instanceof ln&&e.push(`
860
+ renderer.shader.bindBufferResource(uv.${s}, "${s}");
861
+ `);continue}const i=r.uniformStructures[s];let n=!1;for(let o=0;o<ge.length;o++){const a=ge[o];if(i.type===a.type&&a.test(i)){e.push(`name = "${s}";`,ge[o].uniform),n=!0;break}}if(!n){const a=(i.size===1?mg:gg)[i.type].replace("location",`ud["${s}"].location`);e.push(`
862
+ cu = ud["${s}"];
863
+ cv = cu.value;
864
+ v = uv["${s}"];
865
+ ${a};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
866
+ `))}class Xl{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,s){const i=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==i.uniformDirtyGroups[t.uid])&&(i.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(i.uniformData,t.uniforms,this._renderer,s))}_getUniformSyncFunction(t,e){var s;return((s=this._uniformGroupSyncHash[t._signature])==null?void 0:s[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const s=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),i=this._getSignature(t,e._uniformData,"u");return this._cache[i]||(this._cache[i]=this._generateUniformsSync(t,e._uniformData)),s[e._key]=this._cache[i],s[e._key]}_generateUniformsSync(t,e){return _g(t,e)}_getSignature(t,e,s){const i=t.uniforms,n=[`${s}-`];for(const o in i)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}Xl.extension={type:[b.WebGLSystem],name:"uniformGroup"};function xg(r){const t={};if(t.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t.add=[r.ONE,r.ONE],t.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof j.get().getWebGLRenderingContext()))t.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const s=r.getExtension("EXT_blend_minmax");s&&(t.min=[r.ONE,r.ONE,r.ONE,r.ONE,s.MIN_EXT,s.MIN_EXT],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,s.MAX_EXT,s.MAX_EXT])}return t}const yg=0,bg=1,vg=2,Tg=3,Sg=4,Cg=5,$l=class di{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[yg]=this.setBlend,this.map[bg]=this.setOffset,this.map[vg]=this.setCullFace,this.map[Tg]=this.setDepthTest,this.map[Sg]=this.setFrontFace,this.map[Cg]=this.setDepthMask,this.checks=[],this.defaultState=Qt.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=xg(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,s=0;for(;e;)e&1&&this.map[s].call(this,!!(t.data&1<<s)),e>>=1,s++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t||(t=this.defaultState);for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(di._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(di._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],s=this.gl;e.length===2?s.blendFunc(e[0],e[1]):s.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,s.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,s.blendEquationSeparate(s.FUNC_ADD,s.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const s=this.checks.indexOf(t);e&&s===-1?this.checks.push(t):!e&&s!==-1&&this.checks.splice(s,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};$l.extension={type:[b.WebGLSystem],name:"state"};let wg=$l;class Eg{constructor(t){this.target=an.TEXTURE_2D,this._layerInitMask=0,this.texture=t,this.width=-1,this.height=-1,this.type=K.UNSIGNED_BYTE,this.internalFormat=ui.RGBA,this.format=ui.RGBA,this.samplerType=0}destroy(){}}const Pg={id:"buffer",upload(r,t,e,s,i,n=!1){const o=i||t.target;!n&&t.width===r.width&&t.height===r.height?e.texSubImage2D(o,0,0,0,r.width,r.height,t.format,t.type,r.resource):e.texImage2D(o,0,t.internalFormat,r.width,r.height,0,t.format,t.type,r.resource),t.width=r.width,t.height=r.height}},Mg={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},Ag={id:"compressed",upload(r,t,e,s,i,n){const o=i??t.target;e.pixelStorei(e.UNPACK_ALIGNMENT,4);let a=r.pixelWidth,h=r.pixelHeight;const l=!!Mg[r.format];for(let c=0;c<r.resource.length;c++){const u=r.resource[c];l?e.compressedTexImage2D(o,c,t.internalFormat,a,h,0,u):e.texImage2D(o,c,t.internalFormat,a,h,0,t.format,t.type,u),a=Math.max(a>>1,1),h=Math.max(h>>1,1)}}},sa=["right","left","top","bottom","front","back"];function Rg(r){return{id:"cube",upload(t,e,s,i){const n=t.faces;for(let o=0;o<sa.length;o++){const a=sa[o],h=n[a];(r[h.uploadMethodId]||r.image).upload(h,e,s,i,an.TEXTURE_CUBE_MAP_POSITIVE_X+o,(e._layerInitMask&1<<o)===0),e._layerInitMask|=1<<o}e.width=t.pixelWidth,e.height=t.pixelHeight}}}const jl={id:"image",upload(r,t,e,s,i,n=!1){const o=i||t.target,a=r.pixelWidth,h=r.pixelHeight,l=r.resourceWidth,c=r.resourceHeight,u=s===2,d=n||t.width!==a||t.height!==h,f=l>=a&&c>=h,p=r.resource;(u?kg:Bg)(e,o,t,a,h,l,c,p,d,f),t.width=a,t.height=h}};function kg(r,t,e,s,i,n,o,a,h,l){if(!l){h&&r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,n,o,e.format,e.type,a);return}if(!h){r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,a)}function Bg(r,t,e,s,i,n,o,a,h,l){if(!l){h&&r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}if(!h){r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}r.texImage2D(t,0,e.internalFormat,e.format,e.type,a)}const Ig=sm(),Gg={id:"video",upload(r,t,e,s,i,n=Ig){if(!r.isValid){const o=i??t.target;e.texImage2D(o,0,t.internalFormat,1,1,0,t.format,t.type,null);return}jl.upload(r,t,e,s,i,n)}},ra={linear:9729,nearest:9728},Fg={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},Lr={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Dg={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function ia(r,t,e,s,i,n,o,a){const h=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const l=Lr[o?"clamp-to-edge":r.addressModeU],c=Lr[o?"clamp-to-edge":r.addressModeV],u=Lr[o?"clamp-to-edge":r.addressModeW];t[i](h,t.TEXTURE_WRAP_S,l),t[i](h,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R&&t[i](h,t.TEXTURE_WRAP_R,u)}if((!a||r.magFilter!=="linear")&&t[i](h,t.TEXTURE_MAG_FILTER,ra[r.magFilter]),e){if(!a||r.mipmapFilter!=="linear"){const l=Fg[r.minFilter][r.mipmapFilter];t[i](h,t.TEXTURE_MIN_FILTER,l)}}else t[i](h,t.TEXTURE_MIN_FILTER,ra[r.minFilter]);if(s&&r.maxAnisotropy>1){const l=Math.min(r.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](h,s.TEXTURE_MAX_ANISOTROPY_EXT,l)}r.compare&&t[i](h,t.TEXTURE_COMPARE_FUNC,Dg[r.compare])}function Ug(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}function Og(r,t){let e={},s=r.RGBA;return r instanceof j.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},s=r.RGBA8),{r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA,...e,rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:s,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function Lg(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function Ng(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":(r==null?void 0:r.TEXTURE_3D)||null,"2d-array":(r==null?void 0:r.TEXTURE_2D_ARRAY)||null,"cube-array":(r==null?void 0:r.TEXTURE_CUBE_MAP_ARRAY)||null}}const Hg=4;class Yl{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new zt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const e={image:jl,buffer:Pg,video:Gg,compressed:Ag};this._uploads={...e,cube:Rg(e)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Og(t,this._renderer.context.extensions),this._mapFormatToType=Lg(t),this._mapFormatToFormat=Ug(t),this._mapViewDimensionToGlTarget=Ng(t)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(L.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const s=t.source;t?(this.bindSource(s,e),this._useSeparateSamplers&&this._bindSampler(s.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const s=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=L.EMPTY.source);const i=this.getGlSource(t);s.bindTexture(i.target,i.texture)}}_bindSampler(t,e=0){const s=this._gl;if(!t){this._boundSamplers[e]=null,s.bindSampler(e,null);return}const i=this._getGlSampler(t);this._boundSamplers[e]!==i&&(this._boundSamplers[e]=i,s.bindSampler(e,i))}unbind(t){const e=t.source,s=this._boundTextures,i=this._gl;for(let n=0;n<s.length;n++)if(s[n]===e){this._activateLocation(n);const o=this.getGlSource(e);i.bindTexture(o.target,null),s[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,s=new Eg(e.createTexture());if(s.type=this._mapFormatToType[t.format],s.internalFormat=this._mapFormatToInternalFormat[t.format],s.format=this._mapFormatToFormat[t.format],s.target=this._mapViewDimensionToGlTarget[t.viewDimension],s.target===null)throw new Error(`Unsupported view dimension: ${t.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(t.uploadMethodId==="cube"&&(s.target=e.TEXTURE_CUBE_MAP),t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const n=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(n))+1}return t._gpuData[this._renderer.uid]=s,this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),this.updateStyle(t,!1),s}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const s=this._gl,i=this.getGlSource(t);s.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=t,ia(t.style,s,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];s&&(e||(this.unbind(t),this._gl.deleteTexture(s.texture)),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(t){const e=this._gl,s=this.getGlSource(t);e.bindTexture(s.target,s.texture),this._boundTextures[this._activeTextureLocation]=t;const i=t.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==i&&(this._premultiplyAlpha=i,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i)),this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,s,e,this._renderer.context.webGLVersion);else if(s.target===e.TEXTURE_2D)this._initEmptyTexture2D(s,t);else if(s.target===e.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(s,t);else if(s.target===e.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(s,t);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(s,t),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const s=this.getGlSource(t);this._gl.generateMipmap(s.target)}_initEmptyTexture2D(t,e){const s=this._gl;s.texImage2D(s.TEXTURE_2D,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let i=Math.max(e.pixelWidth>>1,1),n=Math.max(e.pixelHeight>>1,1);for(let o=1;o<e.mipLevelCount;o++)s.texImage2D(s.TEXTURE_2D,o,t.internalFormat,i,n,0,t.format,t.type,null),i=Math.max(i>>1,1),n=Math.max(n>>1,1)}_initEmptyTexture2DArray(t,e){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const s=this._gl,i=Math.max(e.arrayLayerCount|0,1);s.texImage3D(s.TEXTURE_2D_ARRAY,0,t.internalFormat,e.pixelWidth,e.pixelHeight,i,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a<e.mipLevelCount;a++)s.texImage3D(s.TEXTURE_2D_ARRAY,a,t.internalFormat,n,o,i,0,t.format,t.type,null),n=Math.max(n>>1,1),o=Math.max(o>>1,1)}_initEmptyTextureCube(t,e){const s=this._gl,i=6;for(let a=0;a<i;a++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a<e.mipLevelCount;a++){for(let h=0;h<i;h++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+h,a,t.internalFormat,n,o,0,t.format,t.type,null);n=Math.max(n>>1,1),o=Math.max(o>>1,1)}}_applyMipRange(t,e){if(this._renderer.context.webGLVersion!==2||e.mipLevelCount<=1)return;const s=this._gl,i=Math.max((e.mipLevelCount|0)-1,0);s.texParameteri(t.target,s.TEXTURE_BASE_LEVEL,0),s.texParameteri(t.target,s.TEXTURE_MAX_LEVEL,i)}_initSampler(t){const e=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,ia(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:s,height:i}=this.getPixels(t),n=j.get().createCanvas();n.width=s,n.height=i;const o=n.getContext("2d");if(o){const a=o.createImageData(s,i);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,s=t.frame,i=Math.max(Math.round(s.width*e),1),n=Math.max(Math.round(s.height*e),1),o=new Uint8Array(Hg*i*n),a=this._renderer,h=a.renderTarget.getRenderTarget(t),l=a.renderTarget.getGpuRenderTarget(h),c=a.gl;return c.bindFramebuffer(c.FRAMEBUFFER,l.resolveTargetFramebuffer),c.readPixels(Math.round(s.x*e),Math.round(s.y*e),i,n,c.RGBA,c.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:i,height:n}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(L.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Yl.extension={type:[b.WebGLSystem],name:"texture"};class ql{contextChange(t){const e=new Wt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),s=t.limits.maxBatchableTextures,i=Pi({name:"graphics",bits:[ph,gh(s),Lh,Ai]});this.shader=new Zt({glProgram:i,resources:{localUniforms:e,batchSamplers:_h(s)}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:h}=o.getContextRenderData(s);i.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(i),n.geometry.bind(a.geometry,i.glProgram);const l=h.instructions;for(let c=0;c<h.instructionSize;c++){const u=l[c];if(u.size){for(let d=0;d<u.textures.count;d++)n.texture.bind(u.textures.textures[d],d);n.geometry.draw(u.topology,u.size,u.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}ql.extension={type:[b.WebGLPipesAdaptor],name:"graphics"};class Kl{init(){const t=Pi({name:"mesh",bits:[Lh,nm,Ai]});this._shader=new Zt({glProgram:t,resources:{uTexture:L.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new G}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(i){if(!i.glProgram){z("Mesh shader has no glProgram",e.shader);return}}else{i=this._shader;const n=e.texture,o=n.source;i.resources.uTexture=o,i.resources.uSampler=o.style,i.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}i.groups[100]=s.globalUniforms.bindGroup,i.groups[101]=t.localUniformsBindGroup,s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Kl.extension={type:[b.WebGLPipesAdaptor],name:"mesh"};const Wg=[...rn,Nl,Jm,jm,Gl,Pl,Yl,Hl,Rl,Xl,Vl,Il,wg,Fl,Bl],zg=[...vl],Vg=[Kh,Kl,ql],Zl=[],Ql=[],Jl=[];W.handleByNamedList(b.WebGLSystem,Zl);W.handleByNamedList(b.WebGLPipes,Ql);W.handleByNamedList(b.WebGLPipesAdaptor,Jl);W.add(...Wg,...zg,...Vg);class Xg extends bs{constructor(){const t={name:"webgl",type:Nt.WEBGL,systems:Zl,renderPipes:Ql,renderPipeAdaptors:Jl};super(t)}}const $g=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:Xg},Symbol.toStringTag,{value:"Module"}));class tc{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,s){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,s)}_createBindGroup(t,e,s){const i=this._gpu.device,n=e.layout[s],o=[],a=this._renderer;for(const c in n){const u=t.resources[c]??t.resources[n[c]];let d;if(u._resourceType==="uniformGroup"){const f=u;a.ubo.updateUniformGroup(f);const p=f.buffer;d={buffer:a.buffer.getGPUBuffer(p),offset:0,size:p.descriptor.size}}else if(u._resourceType==="buffer"){const f=u;d={buffer:a.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(u._resourceType==="bufferResource"){const f=u;d={buffer:a.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(u._resourceType==="textureSampler"){const f=u;d=a.texture.getGpuSampler(f)}else if(u._resourceType==="textureSource"){const f=u;d=a.texture.getTextureView(f)}o.push({binding:n[c],resource:d})}const h=a.shader.getProgramData(e).bindGroups[s],l=i.createBindGroup({layout:h,entries:o});return this._hash[t._key]=l,l}destroy(){this._hash=null,this._renderer=null}}tc.extension={type:[b.WebGPUSystem],name:"bindGroup"};class jg{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class ec{constructor(t){this._renderer=t,this._managedBuffers=new zt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t}getGPUBuffer(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuBuffer)||this.createGPUBuffer(t)}updateBuffer(t){const e=this.getGPUBuffer(t),s=t.data;return t._updateID&&s&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,s.buffer,0,(t._updateSize||s.byteLength)+3&-4)),e}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this)}createGPUBuffer(t){const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t._resourceId=et("resource"),t.data&&(ti(t.data.buffer,e.getMappedRange(),t.data.byteOffset,t.data.byteLength),e.unmap()),t._gpuData[this._renderer.uid]=new jg(e),this._managedBuffers.add(t)&&(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this)),e}onBufferChange(t){this._managedBuffers.remove(t),t._updateID=0,this.createGPUBuffer(t)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}ec.extension={type:[b.WebGPUSystem],name:"buffer"};class Yg{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let s=e+t*4;if(s=Math.ceil(s/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,s>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=s,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let s=0;s<t.length;s++)this.data[e/4+s]=t[s];return e}destroy(){this.data=null}}class sc{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}sc.extension={type:[b.WebGPUSystem],name:"colorMask"};class cn{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await j.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),i=await e.requestDevice({requiredFeatures:s});return{adapter:e,device:i}}destroy(){this.gpu=null,this._renderer=null}}cn.extension={type:[b.WebGPUSystem],name:"device"};cn.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class rc{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,s,i){const n=this._renderer.pipeline.getPipeline(t,e,s,i);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,s){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.gc.now,this._renderer.tick);const i=this._renderer.bindGroup.getBindGroup(e,s,t);this.renderPassEncoder.setBindGroup(t,i)}setGeometry(t,e){const s=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const i in s)this._setVertexBuffer(parseInt(i,10),t.attributes[s[i]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const s in t.groups){const i=t.groups[s];e||this._syncBindGroup(i),this.setBindGroup(s,i,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const s=t.resources[e];s.isUniformGroup&&this._renderer.ubo.updateUniformGroup(s)}}draw(t){const{geometry:e,shader:s,state:i,topology:n,size:o,start:a,instanceCount:h,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,s.gpuProgram,i,n),this.setGeometry(e,s.gpuProgram),this._setShaderBindGroups(s,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,h??e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),h??e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,s={...this._boundVertexBuffer},i=this._boundIndexBuffer,n={...this._boundBindGroup};this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in s)this._setVertexBuffer(a,s[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(i)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}rc.extension={type:[b.WebGPUSystem],name:"encoder",priority:1};class ic{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}ic.extension={type:[b.WebGPUSystem],name:"limits"};class nc{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ut.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid];s.stencilMode=t,s.stencilReference=e;const i=this._renderer;i.pipeline.setStencilMode(t),i.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}nc.extension={type:[b.WebGPUSystem],name:"stencil"};const $s={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function qg(r){const t=r.map(s=>({data:s,offset:0,size:0}));let e=0;for(let s=0;s<t.length;s++){const i=t[s];let n=$s[i.data.type].size;const o=$s[i.data.type].align;if(!$s[i.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${i.data.type}`);i.data.size>1&&(n=Math.max(n,o)*i.data.size),e=Math.ceil(e/o)*o,i.size=n,i.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function Kg(r,t){const{size:e,align:s}=$s[r.data.type],i=(s-e)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
867
+ v = uv.${r.data.name};
868
+ ${t!==0?`offset += ${t};`:""}
869
+
870
+ arrayOffset = offset;
871
+
872
+ t = 0;
873
+
874
+ for(var i=0; i < ${r.data.size*(e/4)}; i++)
875
+ {
876
+ for(var j = 0; j < ${e/4}; j++)
877
+ {
878
+ ${n}[arrayOffset++] = v[t++];
879
+ }
880
+ ${i!==0?`arrayOffset += ${i};`:""}
881
+ }
882
+ `}function Zg(r){return Ol(r,"uboWgsl",Kg,sg)}class oc extends Dl{constructor(){super({createUboElements:qg,generateUboSync:Zg})}}oc.extension={type:[b.WebGPUSystem],name:"ubo"};const te=128;class ac{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new Yg({minUniformOffsetAlignment:te});const e=256/te;for(let s=0;s<e;s++){let i=it.UNIFORM|it.COPY_DST;s===0&&(i|=it.COPY_SRC),this._buffers.push(new ie({data:this._batchBuffer.data,usage:i}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const s=t.buffer.data,i=this._batchBuffer.addEmptyGroup(s.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,i/4),this._bindGroupHash[t.uid]=this._getBindGroup(i/te),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,s=this._batchBuffer.addGroup(e);return this._getBufferResource(s/te)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/te)}getArrayBufferResource(t){const s=this._batchBuffer.addGroup(t)/te;return this._getBufferResource(s)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new ln({buffer:e,offset:(t/2|0)*256,size:te})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new re({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const s=this._renderer.gpu.device.createCommandEncoder();for(let i=1;i<this._buffers.length;i++){const n=this._buffers[i];s.copyBufferToBuffer(t.getGPUBuffer(e),te,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([s.finish()])}destroy(){var t;for(let e=0;e<this._bindGroups.length;e++)(t=this._bindGroups[e])==null||t.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}}ac.extension={type:[b.WebGPUPipes],name:"uniformBatch"};const Qg={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function Jg(r,t,e,s,i){return r<<24|t<<16|e<<10|s<<5|i}function t_(r,t,e,s,i){return e<<8|r<<5|s<<3|i<<1|t}class hc{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(ut.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=t.colorTargetCount,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=ne[t],this._updatePipeHash())}setPipeline(t,e,s,i){const n=this.getPipeline(t,e,s);i.setPipeline(n)}getPipeline(t,e,s,i){t._layoutKey||(Al(t,e.attributeData),this._generateBufferKey(t)),i||(i=t.topology);const n=Jg(t._layoutKey,e._layoutKey,s.data,s._blendModeId,Qg[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,s,i),this._pipeCache[n])}_createPipeline(t,e,s,i){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(s,this._colorTargetCount),h=this._stencilMode===ut.RENDERING_MASK_ADD?0:this._colorMask;for(let d=0;d<a.length;d++)a[d].writeMask=h;const l=this._renderer.shader.getProgramData(e).pipeline,c={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:i,cullMode:s.cullMode},layout:l,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(c.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:s.depthTest,depthCompare:s.depthTest?"less":"always"}),n.createRenderPipeline(c)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let s=0;const i=Object.keys(t.attributes).sort();for(let o=0;o<i.length;o++){const a=t.attributes[i[o]];e[s++]=a.offset,e[s++]=a.format,e[s++]=a.stride,e[s++]=a.instance}const n=e.join("|");return t._layoutKey=fs(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let s=0;const i=Object.keys(t.attributeData).sort();for(let o=0;o<i.length;o++){const a=t.attributeData[i[o]];e[s++]=a.location}const n=e.join("|");return t._attributeLocationsKey=fs(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const s=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[s])return this._bindingNamesCache[s];const i=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<i.length;a++){const l=Object.values(i[a].attributes)[0].shaderLocation;for(const c in o)if(o[c].location===l){n[a]=c;break}}return this._bindingNamesCache[s]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const s=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[s])return this._bufferLayoutsCache[s];const i=[];return t.buffers.forEach(n=>{const o={arrayStride:0,stepMode:"vertex",attributes:[]},a=o.attributes;for(const h in e.attributeData){const l=t.attributes[h];(l.divisor??1)!==1&&z(`Attribute ${h} has an invalid divisor value of '${l.divisor}'. WebGPU only supports a divisor value of 1`),l.buffer===n&&(o.arrayStride=l.stride,o.stepMode=l.instance?"instance":"vertex",a.push({shaderLocation:e.attributeData[h].location,offset:l.offset,format:l.format}))}a.length&&i.push(o)}),this._bufferLayoutsCache[s]=i,i}_updatePipeHash(){const t=t_(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}hc.extension={type:[b.WebGPUSystem],name:"pipeline"};class e_{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class s_{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,s,i,n){const o=this._renderer,a=this._getGpuColorTexture(t),h=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:h,origin:n},i),e}startRenderPass(t,e=!0,s,i,n=0,o=0){var c,u;const h=this._renderTargetSystem.getGpuRenderTarget(t);if(o!==0&&((c=h.msaaTextures)!=null&&c.length))throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(n>0&&((u=h.msaaTextures)!=null&&u.length))throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const l=this.getDescriptor(t,e,s,n,o);h.descriptor=l,this._renderer.pipeline.setRenderTarget(h),this._renderer.encoder.beginRenderPass(h),this._renderer.encoder.setViewport(i)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,s,i=0,n=0){typeof e=="boolean"&&(e=e?wt.ALL:wt.NONE);const o=this._renderTargetSystem,a=o.getGpuRenderTarget(t),h=t.colorTextures.map((u,d)=>{const f=a.contexts[d];let p,g;if(f){if(n!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");p=f.getCurrentTexture().createView()}else p=this._renderer.texture.getGpuSource(u).createView({dimension:"2d",baseMipLevel:i,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1});a.msaaTextures[d]&&(g=p,p=this._renderer.texture.getTextureView(a.msaaTextures[d]));const m=e&wt.COLOR?"clear":"load";return s??(s=o.defaultClearColor),{view:p,resolveTarget:g,clearValue:s,storeOp:"store",loadOp:m}});let l;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=a.msaa?4:1),t.depthStencilTexture){const u=e&wt.STENCIL?"clear":"load",d=e&wt.DEPTH?"clear":"load";l={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:i,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1}),stencilStoreOp:"store",stencilLoadOp:u,depthClearValue:1,depthLoadOp:d,depthStoreOp:"store"}}return{colorAttachments:h,depthStencilAttachment:l}}clear(t,e=!0,s,i,n=0,o=0){if(!e)return;const{gpu:a,encoder:h}=this._renderer,l=a.device;if(h.commandEncoder===null){const u=l.createCommandEncoder(),d=this.getDescriptor(t,e,s,n,o),f=u.beginRenderPass(d);f.setViewport(i.x,i.y,i.width,i.height,0,1),f.end();const p=u.finish();l.queue.submit([p])}else this.startRenderPass(t,e,s,i,n,o)}initGpuRenderTarget(t){t.isRoot=!0;const e=new e_;return e.colorTargetCount=t.colorTextures.length,t.colorTextures.forEach((s,i)=>{if(s instanceof Lt){const n=s.resource.getContext("webgpu"),o=s.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[i]=n}if(e.msaa=s.source.antialias,s.source.antialias){const n=new ft({width:0,height:0,sampleCount:4,arrayLayerCount:s.source.arrayLayerCount});e.msaaTextures[i]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((s,i)=>{const n=e.msaaTextures[i];n==null||n.resize(s.source.width,s.source.height,s.source._resolution)})}}class lc extends nn{constructor(t){super(t),this.adaptor=new s_,this.adaptor.init(t,this)}}lc.extension={type:[b.WebGPUSystem],name:"renderTarget"};class cc{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,s=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),i={bindGroupLayouts:s};return this._gpuProgramData[t._layoutKey]={bindGroups:s,pipeline:e.createPipelineLayout(i)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}cc.extension={type:[b.WebGPUSystem],name:"shader"};const Tt={};Tt.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};Tt.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}};Tt.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}};Tt.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};Tt.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};Tt.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}};Tt["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}};Tt["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}};Tt["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}};Tt.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};Tt.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}};Tt.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class uc{constructor(){this.defaultState=new Qt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e){const s=Tt[t.blendMode]||Tt.normal,i=[],n={format:"bgra8unorm",writeMask:0,blend:s};for(let o=0;o<e;o++)i[o]=n;return i}destroy(){this.gpu=null}}uc.extension={type:[b.WebGPUSystem],name:"state"};const r_={type:"image",upload(r,t,e,s=0){const i=r.resource,n=(r.pixelWidth|0)*(r.pixelHeight|0),o=i.byteLength/n;e.device.queue.writeTexture({texture:t,origin:{x:0,y:0,z:s}},i,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelWidth*o},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},dc={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},i_={blockBytes:4,blockWidth:1,blockHeight:1},n_={type:"compressed",upload(r,t,e,s=0){let i=r.pixelWidth,n=r.pixelHeight;const o=dc[r.format]||i_;for(let a=0;a<r.resource.length;a++){const h=r.resource[a],l=Math.ceil(i/o.blockWidth)*o.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:s}},h,{offset:0,bytesPerRow:l},{width:Math.ceil(i/o.blockWidth)*o.blockWidth,height:Math.ceil(n/o.blockHeight)*o.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),n=Math.max(n>>1,1)}}},na=["right","left","top","bottom","front","back"];function o_(r){return{type:"cube",upload(t,e,s){const i=t.faces;for(let n=0;n<na.length;n++){const o=na[n],a=i[o];(r[a.uploadMethodId]||r.image).upload(a,e,s,n)}}}}const fc={type:"image",upload(r,t,e,s=0){const i=r.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const h=j.get().createCanvas(i.width,i.height);h.getContext("2d").drawImage(i,0,0,i.width,i.height),r.resource=h,z("ImageSource: Image element passed, converting to canvas and replacing resource.")}const n=Math.min(t.width,r.resourceWidth||r.pixelWidth),o=Math.min(t.height,r.resourceHeight||r.pixelHeight),a=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,origin:{x:0,y:0,z:s},premultipliedAlpha:a},{width:n,height:o})}},a_={type:"video",upload(r,t,e,s){fc.upload(r,t,e,s)}};class h_{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
883
+ var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
884
+ vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
885
+
886
+ struct VertexOutput {
887
+ @builtin(position) position : vec4<f32>,
888
+ @location(0) texCoord : vec2<f32>,
889
+ };
890
+
891
+ @vertex
892
+ fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
893
+ var output : VertexOutput;
894
+ output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
895
+ output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
896
+ return output;
897
+ }
898
+
899
+ @group(0) @binding(0) var imgSampler : sampler;
900
+ @group(0) @binding(1) var img : texture_2d<f32>;
901
+
902
+ @fragment
903
+ fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
904
+ return textureSample(img, imgSampler, texCoord);
905
+ }
906
+ `})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let s=t;const i=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const h={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};s=this.device.createTexture(h)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let h=0;h<i;++h){let l=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),c=n?1:0;for(let u=1;u<t.mipLevelCount;++u){const d=s.createView({baseMipLevel:c++,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),f=o.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),p=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:l}]});f.setPipeline(e),f.setBindGroup(0,p),f.draw(3,1,0,0),f.end(),l=d}}if(!n){const h={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i};for(let l=1;l<t.mipLevelCount;++l)o.copyTextureToTexture({texture:s,mipLevel:l-1},{texture:t,mipLevel:l},h),h.width=Math.ceil(h.width/2),h.height=Math.ceil(h.height/2)}return this.device.queue.submit([o.finish()]),n||s.destroy(),t}}class l_{constructor(t){this.textureView=null,this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class pc{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new zt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const e={image:fc,buffer:r_,video:a_,compressed:n_};this._uploads={...e,cube:o_(e)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t}initSource(t){var e;return((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const s=dc[t.format]||{blockWidth:1,blockHeight:1},i=Math.ceil(t.pixelWidth/s.blockWidth)*s.blockWidth,n=Math.ceil(t.pixelHeight/s.blockHeight)*s.blockHeight,o={label:t.label,size:{width:i,height:n,depthOrArrayLayers:t.arrayLayerCount},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpu.device.createTexture(o);return t._gpuData[this._renderer.uid]=new l_(a),this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),a}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new h_(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceUnload(t){t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(t){t._gcLastUsed=this._renderer.gc.now;const e=t._gpuData[this._renderer.uid],s=e==null?void 0:e.gpuTexture;s?(s.width!==t.pixelWidth||s.height!==t.pixelHeight)&&(e.destroy(),this._bindGroupHash[t.uid]=null,t._gpuData[this._renderer.uid]=null,this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]||this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new re({0:e,1:e.style,2:new Wt({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;e._gcLastUsed=this._renderer.gc.now;let s=e._gpuData[this._renderer.uid];return s||(this.initSource(e),s=e._gpuData[this._renderer.uid]),s.textureView||(s.textureView=s.gpuTexture.createView({dimension:e.viewDimension})),s.textureView}generateCanvas(t){const e=this._renderer,s=e.gpu.device.createCommandEncoder(),i=j.get().createCanvas();i.width=t.source.pixelWidth,i.height=t.source.pixelHeight;const n=i.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:j.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),s.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:i.width,height:i.height}),e.gpu.device.queue.submit([s.finish()]),i}getPixels(t){const e=this.generateCanvas(t),s=Ve.getOptimalCanvasAndContext(e.width,e.height),i=s.context;i.drawImage(e,0,0);const{width:n,height:o}=e,a=i.getImageData(0,0,n,o),h=new Uint8ClampedArray(a.data.buffer);return Ve.returnCanvasAndContext(s),{pixels:h,width:n,height:o}}destroy(){this._managedTextures.destroy();for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),s=this._bindGroupHash[e];s==null||s.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}pc.extension={type:[b.WebGPUSystem],name:"texture"};class mc{constructor(){this._maxTextures=0}contextChange(t){const e=new Wt({uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const s=Ei({name:"graphics",bits:[fh,mh(this._maxTextures),Ep,Mi]});this.shader=new Zt({gpuProgram:s,resources:{localUniforms:e}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:h}=o.getContextRenderData(s),l=n.encoder;l.setGeometry(a.geometry,i.gpuProgram);const c=n.globalUniforms.bindGroup;l.setBindGroup(0,c,i.gpuProgram);const u=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);l.setBindGroup(2,u,i.gpuProgram);const d=h.instructions;let f=null;for(let p=0;p<h.instructionSize;p++){const g=d[p];if(g.topology!==f&&(f=g.topology,l.setPipelineFromGeometryProgramAndState(a.geometry,i.gpuProgram,t.state,g.topology)),i.groups[1]=g.bindGroup,!g.gpuBindGroup){const m=g.textures;g.bindGroup=Ci(m.textures,m.count,this._maxTextures),g.gpuBindGroup=n.bindGroup.getBindGroup(g.bindGroup,i.gpuProgram,1)}l.setBindGroup(1,g.bindGroup,i.gpuProgram),l.renderPassEncoder.drawIndexed(g.size,1,g.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}mc.extension={type:[b.WebGPUPipesAdaptor],name:"graphics"};class gc{init(){const t=Ei({name:"mesh",bits:[Ws,im,Mi]});this._shader=new Zt({gpuProgram:t,resources:{uTexture:L.EMPTY._source,uSampler:L.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new G}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(!i)i=this._shader,i.groups[2]=s.texture.getTextureBindGroup(e.texture);else if(!i.gpuProgram){z("Mesh shader has no gpuProgram",e.shader);return}const n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=s.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;i.groups[1]=s.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}gc.extension={type:[b.WebGPUPipesAdaptor],name:"mesh"};const c_=[...rn,oc,rc,cn,ic,ec,pc,lc,cc,uc,hc,sc,nc,tc],u_=[...vl,ac],d_=[Zh,gc,mc],_c=[],xc=[],yc=[];W.handleByNamedList(b.WebGPUSystem,_c);W.handleByNamedList(b.WebGPUPipes,xc);W.handleByNamedList(b.WebGPUPipesAdaptor,yc);W.add(...c_,...u_,...d_);class f_ extends bs{constructor(){const t={name:"webgpu",type:Nt.WEBGPU,systems:_c,renderPipes:xc,renderPipeAdaptors:yc};super(t)}}const p_=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:f_},Symbol.toStringTag,{value:"Module"}));W.add(Cc,wc);W.add(Fu);W.mixin(vt,Du);W.add(Mh);W.add(Ah);W.mixin(vt,cp);W.add(Fh,Ih);W.add(Gh);const m_=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),g_=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Td as A,ee as C,er as G,st as P,tt as R,Ne as S,__ as T,ns as _,vt as a,rr as b,L as c};