screeps-client 0.4.1 → 0.5.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 (28) hide show
  1. package/dist/embedded/_client/{CodePanel-CQz186KT.js → CodePanel-GQOhmg-I.js} +1 -1
  2. package/dist/{standalone/_client/MapViewer-BlPsc-Ax.js → embedded/_client/MapViewer-qJGNT0CU.js} +1 -1
  3. package/dist/embedded/_client/index-DH5qlAud.js +24 -0
  4. package/dist/embedded/_client/vendor-pixi-D-Qjltr2.js +1215 -0
  5. package/dist/embedded/index.html +2 -2
  6. package/dist/embedded/themes/default/test.json +84 -0
  7. package/dist/embedded/themes/default/test.png +0 -0
  8. package/dist/standalone/_client/{CodePanel-U6dyPwU0.js → CodePanel-C-DMhyuw.js} +1 -1
  9. package/dist/{embedded/_client/MapViewer-CvJfxsK0.js → standalone/_client/MapViewer-CFzJVSsf.js} +1 -1
  10. package/dist/standalone/_client/index-RbsPr76e.js +24 -0
  11. package/dist/standalone/_client/vendor-pixi-CVMJwxeR.js +1215 -0
  12. package/dist/standalone/index.html +2 -2
  13. package/dist/standalone/themes/default/test.json +84 -0
  14. package/dist/standalone/themes/default/test.png +0 -0
  15. package/dist/xxscreeps-mod/_client/{CodePanel-DFEeWiMS.js → CodePanel-C4wZSlgU.js} +1 -1
  16. package/dist/xxscreeps-mod/_client/{MapViewer-B8jKtgs1.js → MapViewer-DdHdvydQ.js} +1 -1
  17. package/dist/xxscreeps-mod/_client/index-BlhT0eYc.js +24 -0
  18. package/dist/xxscreeps-mod/_client/vendor-pixi-DOKo__Ml.js +1215 -0
  19. package/dist/xxscreeps-mod/index.html +3 -3
  20. package/dist/xxscreeps-mod/themes/default/test.json +84 -0
  21. package/dist/xxscreeps-mod/themes/default/test.png +0 -0
  22. package/package.json +2 -2
  23. package/dist/embedded/_client/index-RlhG0JKu.js +0 -24
  24. package/dist/embedded/_client/vendor-pixi-Do7-_WYv.js +0 -1160
  25. package/dist/standalone/_client/index-BQrrXAc2.js +0 -24
  26. package/dist/standalone/_client/vendor-pixi-CXkRT4gi.js +0 -1160
  27. package/dist/xxscreeps-mod/_client/index-63TVlkxt.js +0 -24
  28. package/dist/xxscreeps-mod/_client/vendor-pixi-CXkRT4gi.js +0 -1160
@@ -0,0 +1,1215 @@
1
+ const du="modulepreload",fu=function(r){return"/client/"+r},zn={},zt=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){let o=function(h){return Promise.all(h.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]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(t.map(h=>{if(h=fu(h),h in zn)return;zn[h]=!0;const c=h.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":du,c||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),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 ${h}`)))})}))}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 e().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 ni=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},Gs=(r,e)=>ni(r).priority??e,V={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(ni).forEach(e=>{e.type.forEach(t=>{var s,i;return(i=(s=this._removeHandlers)[t])==null?void 0:i.call(s,e)})}),this},add(...r){return r.map(ni).forEach(e=>{e.type.forEach(t=>{var n,o;const s=this._addHandlers,i=this._queue;s[t]?(o=s[t])==null||o.call(s,e):(i[t]=i[t]||[],(n=i[t])==null||n.push(e))})}),this},handle(r,e,t){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]=e,i[r]=t;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>e(a)),delete n[r]),this},handleByMap(r,e){return this.handle(r,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(r,e,t=-1){return this.handle(r,s=>{e.findIndex(n=>n.name===s.name)>=0||(e.push({name:s.name,value:s.ref}),e.sort((n,o)=>Gs(o.value,t)-Gs(n.value,t)))},s=>{const i=e.findIndex(n=>n.name===s.name);i!==-1&&e.splice(i,1)})},handleByList(r,e,t=-1){return this.handle(r,s=>{e.includes(s.ref)||(e.push(s.ref),e.sort((i,n)=>Gs(n,t)-Gs(i,t)))},s=>{const i=e.indexOf(s.ref);i!==-1&&e.splice(i,1)})},mixin(r,...e){for(const t of e)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(t))}},pu={extension:{type:b.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await zt(()=>Promise.resolve().then(()=>cy),void 0)}},mu={extension:{type:b.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await zt(()=>Promise.resolve().then(()=>uy),void 0)}};class xe{constructor(e,t,s){this._x=t||0,this._y=s||0,this._observer=e}clone(e){return new xe(e??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.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(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}function Da(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tr={exports:{}},Vn;function gu(){return Vn||(Vn=1,(function(r){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function i(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new i(c,u||l,d),p=t?t+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new s:delete l._events[h]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)e.call(c,u)&&h.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=t?t+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=t?t+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var g=t?t+h:h;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,x,y;if(m.fn){switch(m.once&&this.removeListener(h,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 T=m.length,S;for(y=0;y<T;y++)switch(m[y].once&&this.removeListener(h,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(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=t?t+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var 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(h){var c;return h?(c=t?t+h:h,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=t,a.EventEmitter=a,r.exports=a})(Tr)),Tr.exports}var _u=gu();const Re=Da(_u),xu=Math.PI*2,yu=180/Math.PI,bu=Math.PI/180;class ie{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new ie(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Sr.x=0,Sr.y=0,Sr}}const Sr=new ie;class G{constructor(e=1,t=0,s=0,i=1,n=0,o=0){this.array=null,this.a=e,this.b=t,this.c=s,this.d=i,this.tx=n,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,s,i,n,o){return this.a=e,this.b=t,this.c=s,this.d=i,this.tx=n,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const s=t||this.array;return e?(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(e,t){t=t||new ie;const s=e.x,i=e.y;return t.x=this.a*s+this.c*i+this.tx,t.y=this.b*s+this.d*i+this.ty,t}applyInverse(e,t){t=t||new ie;const s=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(s*o+n*-i),c=e.x,u=e.y;return t.x=o*h*c+-n*h*u+(l*n-a*o)*h,t.y=s*h*u+-i*h*c+(-l*s+a*i)*h,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),s=Math.sin(e),i=this.a,n=this.c,o=this.tx;return this.a=i*t-this.b*s,this.b=i*s+this.b*t,this.c=n*t-this.d*s,this.d=n*s+this.d*t,this.tx=o*t-this.ty*s,this.ty=o*s+this.ty*t,this}append(e){const t=this.a,s=this.b,i=this.c,n=this.d;return this.a=e.a*t+e.b*i,this.b=e.a*s+e.b*n,this.c=e.c*t+e.d*i,this.d=e.c*s+e.d*n,this.tx=e.tx*t+e.ty*i+this.tx,this.ty=e.tx*s+e.ty*n+this.ty,this}appendFrom(e,t){const s=e.a,i=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=t.a,c=t.b,u=t.c,d=t.d;return this.a=s*h+i*u,this.b=s*c+i*d,this.c=n*h+o*u,this.d=n*c+o*d,this.tx=a*h+l*u+t.tx,this.ty=a*c+l*d+t.ty,this}setTransform(e,t,s,i,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(s*this.a+i*this.c),this.ty=t-(s*this.b+i*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const s=this.a,i=this.c;this.a=s*e.a+this.b*e.c,this.b=s*e.b+this.b*e.d,this.c=i*e.a+this.d*e.c,this.d=i*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,s=this.b,i=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-i,n),l=Math.atan2(s,t),h=Math.abs(a+l);return h<1e-5||Math.abs(xu-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=Math.sqrt(t*t+s*s),e.scale.y=Math.sqrt(i*i+n*n),e.position.x=this.tx+(o.x*t+o.y*i),e.position.y=this.ty+(o.x*s+o.y*n),e}invert(){const e=this.a,t=this.b,s=this.c,i=this.d,n=this.tx,o=e*i-t*s;return this.a=i/o,this.b=-t/o,this.c=-s/o,this.d=e/o,this.tx=(s*this.ty-i*n)/o,this.ty=-(e*this.ty-t*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 e=new G;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}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 Tu.identity()}static get shared(){return vu.identity()}}const vu=new G,Tu=new G,gt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],_t=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],xt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],yt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],oi=[],La=[],Us=Math.sign;function Su(){for(let r=0;r<16;r++){const e=[];oi.push(e);for(let t=0;t<16;t++){const s=Us(gt[r]*gt[t]+xt[r]*_t[t]),i=Us(_t[r]*gt[t]+yt[r]*_t[t]),n=Us(gt[r]*xt[t]+xt[r]*yt[t]),o=Us(_t[r]*xt[t]+yt[r]*yt[t]);for(let a=0;a<16;a++)if(gt[a]===s&&_t[a]===i&&xt[a]===n&&yt[a]===o){e.push(a);break}}}for(let r=0;r<16;r++){const e=new G;e.set(gt[r],_t[r],xt[r],yt[r],0,0),La.push(e)}}Su();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=>gt[r],uY:r=>_t[r],vX:r=>xt[r],vY:r=>yt[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>oi[r][e],sub:(r,e)=>oi[r][$.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?$.S:$.N:Math.abs(e)*2<=Math.abs(r)?r>0?$.E:$.W:e>0?r>0?$.SE:$.SW:r>0?$.NE:$.NW,matrixAppendRotationInv:(r,e,t=0,s=0,i=0,n=0)=>{const o=La[$.inv(e)],a=o.a,l=o.b,h=o.c,c=o.d,u=t-Math.min(0,a*i,h*n,a*i+h*n),d=s-Math.min(0,l*i,c*n,l*i+c*n),f=r.a,p=r.b,g=r.c,m=r.d;r.a=a*f+l*g,r.b=a*p+l*m,r.c=h*f+c*g,r.d=h*p+c*m,r.tx=u*f+d*g+r.tx,r.ty=u*p+d*m+r.ty},transformRectCoords:(r,e,t,s)=>{const{x:i,y:n,width:o,height:a}=r,{x:l,y:h,width:c,height:u}=e;return t===$.E?(s.set(i+l,n+h,o,a),s):t===$.S?s.set(c-n-a+l,i+h,a,o):t===$.W?s.set(c-i-o+l,u-n-a+h,o,a):t===$.N?s.set(n+l,u-i-o+h,a,o):s.set(i+l,n+h,o,a)}},Os=[new ie,new ie,new ie,new ie];class Q{constructor(e=0,t=0,s=0,i=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),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 Q(0,0,0,0)}clone(){return new Q(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,s,i=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,h=s*(1-i),c=s-h,u=a-h,d=a+n+h,f=l-h,p=l+o+h,g=a+c,m=a+n-c,_=l+c,x=l+o-c;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>g&&e<m&&t>_&&t<x)}intersects(e,t){if(!t){const A=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=A)return!1;const C=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>C}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=Os[0].set(e.left,e.top),l=Os[1].set(e.left,e.bottom),h=Os[2].set(e.right,e.top),c=Os[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(a,a),t.apply(l,l),t.apply(h,h),t.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=s||Math.min(a.x,l.x,h.x,c.x)>=i||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*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-h.y),y=u*(h.x-a.x),T=x*s+y*n,S=x*i+y*n,v=x*s+y*o,w=x*i+y*o;return!(Math.max(T,S,v,w)<=x*a.x+y*a.y||Math.min(T,S,v,w)>=x*c.x+y*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),s=Math.min(this.x+this.width,e.x+e.width),i=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(s-t,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(e=1,t=.001){const s=Math.ceil((this.x+this.width-t)*e)/e,i=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=s-this.x,this.height=i-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){const t=Math.min(this.x,e.x),s=Math.max(this.x+this.width,e.x+e.width),i=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=s-t,this.y=i,this.height=n-i,this}getBounds(e){return e||(e=new Q),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const t=e.x,s=e.y,i=e.x+e.width,n=e.y+e.height;return t>=this.x&&t<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(e,t,s,i){return this.x=e,this.y=t,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 wr={default:-1};function re(r="default"){return wr[r]===void 0&&(wr[r]=-1),++wr[r]}const Xn=new Set,Z="8.0.0",wu="8.3.4",Nt={quiet:!1,noColor:!1},F=((r,e,t=3)=>{if(Nt.quiet||Xn.has(e))return;let s=new Error().stack;const i=`${e}
2
+ Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!Nt.noColor;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",i):(s=s.split(`
3
+ `).splice(t).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))),Xn.add(e)});Object.defineProperties(F,{quiet:{get:()=>Nt.quiet,set:r=>{Nt.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Nt.noColor,set:r=>{Nt.noColor=r},enumerable:!0,configurable:!1}});const Na=()=>{};function Yt(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 $n(r){return!(r&r-1)&&!!r}function Wa(r){const e={};for(const t in r)r[t]!==void 0&&(e[t]=r[t]);return e}const jn=Object.create(null);function Cu(r){const e=jn[r];return e===void 0&&(jn[r]=re("resource")),e}const Ha=class za extends Re{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...za.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){F(Z,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,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 e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Cu(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ha.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let tt=Ha;const Va=class Xa extends Re{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=re("textureSource"),this._resourceType="textureSource",this._resourceId=re("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,e={...Xa.defaultOptions,...e},this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.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=e.format,this.dimension=e.dimensions,this.viewDimension=e.viewDimension??e.dimensions,this.arrayLayerCount=e.arrayLayerCount,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new tt(Wa(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){var t,s;this.style!==e&&((t=this._style)==null||t.off("change",this._onStyleChange,this),this._style=e,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))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 e,t;this._resourceId=re("resource"),this.emit("change",this),this.emit("unload",this);for(const s in this._gpuData)(t=(e=this._gpuData[s])==null?void 0:e.destroy)==null||t.call(e);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,s){s||(s=this._resolution),e||(e=this.width),t||(t=this.height);const i=Math.round(e*s),n=Math.round(t*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=re("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=$n(this.pixelWidth)&&$n(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};Va.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 me=Va;class Ii extends me{constructor(e){const t=e.resource||new Float32Array(e.width*e.height*4);let s=e.format;s||(t instanceof Float32Array?s="rgba32float":t instanceof Int32Array||t instanceof Uint32Array?s="rgba32uint":t instanceof Int16Array||t instanceof Uint16Array?s="rgba16uint":(t instanceof Int8Array,s="bgra8unorm")),super({...e,resource:t,format:s}),this.uploadMethodId="buffer"}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}Ii.extension=b.TextureSource;const Yn=new G;class $a{constructor(e,t){this.mapCoord=new G,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){var t;this._texture!==e&&((t=this._texture)==null||t.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this)),this.update()}multiplyUvs(e,t){t===void 0&&(t=e);const s=this.mapCoord;for(let i=0;i<e.length;i+=2){const n=e[i],o=e[i+1];t[i]=n*s.a+o*s.c+s.tx,t[i+1]=n*s.b+o*s.d+s.ty}return t}update(){const e=this._texture;this._updateID++;const t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);const s=e.orig,i=e.trim;i&&(Yn.set(s.width/i.width,0,0,s.height/i.height,-i.x/i.width,-i.y/i.height),this.mapCoord.append(Yn));const n=e.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(e.frame.x+a+l)/n.width,o[1]=(e.frame.y+a+l)/n.height,o[2]=(e.frame.x+e.frame.width-a+l)/n.width,o[3]=(e.frame.y+e.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=e.frame.width===n.width&&e.frame.height===n.height&&e.rotate===0,!0}}class O extends Re{constructor({source:e,label:t,frame:s,orig:i,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:h}={}){if(super(),this.uid=re("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Q,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=(e==null?void 0:e.source)??new me,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=l??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=h||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new $a(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:t}=this,{width:s,height:i}=this._source,n=t.x/s,o=t.y/i,a=t.width/s,l=t.height/i;let h=this.rotate;if(h){const c=a/2,u=l/2,d=n+c,f=o+u;h=$.add(h,$.NW),e.x0=d+c*$.uX(h),e.y0=f+u*$.uY(h),h=$.add(h,2),e.x1=d+c*$.uX(h),e.y1=f+u*$.uY(h),h=$.add(h,2),e.x2=d+c*$.uX(h),e.y2=f+u*$.uY(h),h=$.add(h,2),e.x3=d+c*$.uX(h),e.y3=f+u*$.uY(h)}else e.x0=n,e.y0=o,e.x1=n+a,e.y1=o,e.x2=n+a,e.y2=o+l,e.x3=n,e.y3=o+l}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(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 F(Z,"Texture.baseTexture is now Texture.source"),this._source}}O.EMPTY=new O({label:"EMPTY",source:new me({label:"EMPTY"})});O.EMPTY.destroy=Na;O.WHITE=new O({source:new Ii({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});O.WHITE.destroy=Na;function ja(r,e,t){const{width:s,height:i}=t.orig,n=t.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-e._x*s,r.maxX=r.minX+o,r.minY=n.y-e._y*i,r.maxY=r.minY+a}else r.minX=-e._x*s,r.maxX=r.minX+s,r.minY=-e._y*i,r.maxY=r.minY+i}const qn=new G;class ye{constructor(e=1/0,t=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=qn,this.minX=e,this.minY=t,this.maxX=s,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Q);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=qn,this}set(e,t,s,i){this.minX=e,this.minY=t,this.maxX=s,this.maxY=i}addFrame(e,t,s,i,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=o*e+l*t+c,_=a*e+h*t+u;m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*s+l*t+c,_=a*s+h*t+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*e+l*i+c,_=a*e+h*i+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*s+l*i+c,_=a*s+h*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(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const t=this.minX,s=this.minY,i=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:h,tx:c,ty:u}=e;let d=o*t+l*s+c,f=a*t+h*s+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=o*i+l*s+c,f=a*i+h*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*t+l*n+c,f=a*t+h*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+l*n+c,f=a*i+h*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(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,s,i){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<s&&(this.minY=s),this.maxY>i&&(this.maxY=i),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,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 ye(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}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(e,t,s,i){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;i||(i=this.matrix);const h=i.a,c=i.b,u=i.c,d=i.d,f=i.tx,p=i.ty;for(let g=t;g<s;g+=2){const m=e[g],_=e[g+1],x=h*m+u*_+f,y=c*m+d*_+p;n=x<n?x:n,o=y<o?y:o,a=x>a?x:a,l=y>l?y:l}this.minX=n,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var Au={grad:.9,turn:360,rad:360/(2*Math.PI)},Ye=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},ge=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},Ge=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},Ya=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Kn=function(r){return{r:Ge(r.r,0,255),g:Ge(r.g,0,255),b:Ge(r.b,0,255),a:Ge(r.a)}},Cr=function(r){return{r:ge(r.r),g:ge(r.g),b:ge(r.b),a:ge(r.a,3)}},Eu=/^#([0-9a-f]{3,8})$/i,Ds=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},qa=function(r){var e=r.r,t=r.g,s=r.b,i=r.a,n=Math.max(e,t,s),o=n-Math.min(e,t,s),a=o?n===e?(t-s)/o:n===t?2+(s-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},Ka=function(r){var e=r.h,t=r.s,s=r.v,i=r.a;e=e/360*6,t/=100,s/=100;var n=Math.floor(e),o=s*(1-t),a=s*(1-(e-n)*t),l=s*(1-(1-e+n)*t),h=n%6;return{r:255*[s,a,o,o,l,s][h],g:255*[l,s,s,a,o,o][h],b:255*[o,o,l,s,s,a][h],a:i}},Zn=function(r){return{h:Ya(r.h),s:Ge(r.s,0,100),l:Ge(r.l,0,100),a:Ge(r.a)}},Qn=function(r){return{h:ge(r.h),s:ge(r.s),l:ge(r.l),a:ge(r.a,3)}},Jn=function(r){return Ka((t=(e=r).s,{h:e.h,s:(t*=((s=e.l)<50?s:100-s)/100)>0?2*t/(s+t)*100:0,v:s+t,a:e.a}));var e,t,s},gs=function(r){return{h:(e=qa(r)).h,s:(i=(200-(t=e.s))*(s=e.v)/100)>0&&i<200?t*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,t,s,i},Pu=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Mu=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ru=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bu=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ai={string:[[function(r){var e=Eu.exec(r);return e?(r=e[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?ge(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?ge(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=Ru.exec(r)||Bu.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:Kn({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(r){var e=Pu.exec(r)||Mu.exec(r);if(!e)return null;var t,s,i=Zn({h:(t=e[1],s=e[2],s===void 0&&(s="deg"),Number(t)*(Au[s]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Jn(i)},"hsl"]],object:[[function(r){var e=r.r,t=r.g,s=r.b,i=r.a,n=i===void 0?1:i;return Ye(e)&&Ye(t)&&Ye(s)?Kn({r:Number(e),g:Number(t),b:Number(s),a:Number(n)}):null},"rgb"],[function(r){var e=r.h,t=r.s,s=r.l,i=r.a,n=i===void 0?1:i;if(!Ye(e)||!Ye(t)||!Ye(s))return null;var o=Zn({h:Number(e),s:Number(t),l:Number(s),a:Number(n)});return Jn(o)},"hsl"],[function(r){var e=r.h,t=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!Ye(e)||!Ye(t)||!Ye(s))return null;var o=(function(a){return{h:Ya(a.h),s:Ge(a.s,0,100),v:Ge(a.v,0,100),a:Ge(a.a)}})({h:Number(e),s:Number(t),v:Number(s),a:Number(n)});return Ka(o)},"hsv"]]},eo=function(r,e){for(var t=0;t<e.length;t++){var s=e[t][0](r);if(s)return[s,e[t][1]]}return[null,void 0]},ku=function(r){return typeof r=="string"?eo(r.trim(),ai.string):typeof r=="object"&&r!==null?eo(r,ai.object):[null,void 0]},Ar=function(r,e){var t=gs(r);return{h:t.h,s:Ge(t.s+100*e,0,100),l:t.l,a:t.a}},Er=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},to=function(r,e){var t=gs(r);return{h:t.h,s:t.s,l:Ge(t.l+100*e,0,100),a:t.a}},li=(function(){function r(e){this.parsed=ku(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return ge(Er(this.rgba),2)},r.prototype.isDark=function(){return Er(this.rgba)<.5},r.prototype.isLight=function(){return Er(this.rgba)>=.5},r.prototype.toHex=function(){return e=Cr(this.rgba),t=e.r,s=e.g,i=e.b,o=(n=e.a)<1?Ds(ge(255*n)):"","#"+Ds(t)+Ds(s)+Ds(i)+o;var e,t,s,i,n,o},r.prototype.toRgb=function(){return Cr(this.rgba)},r.prototype.toRgbString=function(){return e=Cr(this.rgba),t=e.r,s=e.g,i=e.b,(n=e.a)<1?"rgba("+t+", "+s+", "+i+", "+n+")":"rgb("+t+", "+s+", "+i+")";var e,t,s,i,n},r.prototype.toHsl=function(){return Qn(gs(this.rgba))},r.prototype.toHslString=function(){return e=Qn(gs(this.rgba)),t=e.h,s=e.s,i=e.l,(n=e.a)<1?"hsla("+t+", "+s+"%, "+i+"%, "+n+")":"hsl("+t+", "+s+"%, "+i+"%)";var e,t,s,i,n},r.prototype.toHsv=function(){return e=qa(this.rgba),{h:ge(e.h),s:ge(e.s),v:ge(e.v),a:ge(e.a,3)};var e},r.prototype.invert=function(){return ze({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},r.prototype.saturate=function(e){return e===void 0&&(e=.1),ze(Ar(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),ze(Ar(this.rgba,-e))},r.prototype.grayscale=function(){return ze(Ar(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),ze(to(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),ze(to(this.rgba,-e))},r.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},r.prototype.alpha=function(e){return typeof e=="number"?ze({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):ge(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=gs(this.rgba);return typeof e=="number"?ze({h:e,s:t.s,l:t.l,a:t.a}):ge(t.h)},r.prototype.isEqual=function(e){return this.toHex()===ze(e).toHex()},r})(),ze=function(r){return r instanceof li?r:new li(r)},so=[],Iu=function(r){r.forEach(function(e){so.indexOf(e)<0&&(e(li,ai),so.push(e))})};function Fu(r,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in t)s[t[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,l,h=s[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in t)n[f]=new r(t[f]).toRgb();for(var p in t){var g=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<u&&(u=g,d=p)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new r(l).toRgb():null},"name"])}Iu([Fu]);const qt=class fs{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(e){if(e instanceof fs)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,t){const s=typeof e;if(s!==typeof t)return!1;if(s==="number"||s==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((n,o)=>n===t[o]);if(e!==null&&t!==null){const n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?!1:n.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,s,i]=this._components;return{r:e,g:t,b:s,a:i}}toRgb(){const[e,t,s]=this._components;return{r:e,g:t,b:s}}toRgbaString(){const[e,t,s]=this.toUint8RgbArray();return`rgba(${e},${t},${s},${this.alpha})`}toUint8RgbArray(e){const[t,s,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(s*255),e[2]=Math.round(i*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[t,s,i,n]=this._components;return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[t,s,i]=this._components;return e[0]=t,e[1]=s,e[2]=i,e}toNumber(){return this._int}toBgrNumber(){const[e,t,s]=this.toUint8RgbArray();return(s<<16)+(t<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,s,i,n]=fs._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return t&&(s=s*e+.5|0,i=i*e+.5|0,n=n*e+.5|0),(e*255<<24)+(s<<16)+(i<<8)+n}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(e){let t,s,i,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,s,i,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,s,i,n=255]=e,t/=255,s/=255,i/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=fs.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=ze(e);o.isValid()&&({r:t,g:s,b:i,a:n}=o.rgba,t/=255,s/=255,i/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=s,this._components[2]=i,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[e,t,s]=this._components;this._int=(e*255<<16)+(t*255<<8)+(s*255|0)}_clamp(e,t=0,s=1){return typeof e=="number"?Math.min(Math.max(e,t),s):(e.forEach((i,n)=>{e[n]=Math.min(Math.max(i,t),s)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof fs||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};qt.shared=new qt;qt._temp=new qt;qt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ee=qt;const Gu={cullArea:null,cullable:!1,cullableChildren:!0};let Pr=0;const ro=500;function W(...r){Pr!==ro&&(Pr++,Pr===ro?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}const es={_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 Uu{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){var s;let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),(s=t.init)==null||s.call(t,e),t}return(e){var t;(t=e.reset)==null||t.call(e),this._pool[this._index++]=e}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 e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}class Ou{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Uu(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(t=>{const s=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[s]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}}const _e=new Ou;es.register(_e);const Du={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){F("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(r)}};function Za(r,e,t){const s=r.length;let i;if(e>=s||t===0)return;t=e+t>s?s-e:t;const n=s-t;for(i=e;i<n;++i)r[i]=r[i+t];r.length=n}const Lu={allowChildren:!0,removeChildren(r=0,e){var n;const t=e??this.children.length,s=t-r,i=[];if(s>0&&s<=t){for(let a=t-1;a>=r;a--){const l=this.children[a];l&&(i.push(l),l.parent=null)}Za(this.children,r,t);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(i);for(let a=0;a<i.length;++a){const l=i[a];(n=l.parentRenderLayer)==null||n.detach(l),this.emit("childRemoved",l,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 e=this.getChildAt(r);return this.removeChild(e)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,e)},getChildIndex(r){const e=this.children.indexOf(r);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(r,e){this.allowChildren||F(Z,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:t}=this;if(e<0||e>t.length)throw new Error(`${r}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);const s=r.parent===this;if(r.parent){const n=r.parent.children.indexOf(r);if(s){if(n===e)return r;r.parent.children.splice(n,1)}else r.removeFromParent()}e===t.length?t.push(r):t.splice(e,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,e),r.emit("added",this)),r},swapChildren(r,e){if(r===e)return;const t=this.getChildIndex(r),s=this.getChildIndex(e);this.children[t]=e,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(e=>this.reparentChildAt(e,this.children.length)),r[0])},reparentChildAt(r,e){if(r.parent===this)return this.setChildIndex(r,e),r;const t=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,e);const s=this.worldTransform.clone();return s.invert(),t.prepend(s),r.setFromMatrix(t),r},replaceChild(r,e){r.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(r)),e.setFromMatrix(r.localTransform),e.updateLocalTransform(),this.removeChild(r)}},Nu={collectRenderables(r,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,e,t))},collectRenderablesSimple(r,e,t){const s=this.children,i=s.length;for(let n=0;n<i;n++)s[n].collectRenderables(r,e,t)},collectRenderablesWithEffects(r,e,t){const{renderPipes:s}=e;for(let i=0;i<this.effects.length;i++){const n=this.effects[i];s[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,e,t);for(let i=this.effects.length-1;i>=0;i--){const n=this.effects[i];s[n.pipe].pop(n,this,r)}}};class ar{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}class Wu{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){const s=this._tests[t];if(s.test(e))return _e.get(s.maskClass,e)}return e}returnMaskEffect(e){_e.return(e)}}const hi=new Wu;V.handleByList(b.MaskEffect,hi._effectClasses);const Hu={_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((t,s)=>t.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const e=this.effects.indexOf(r);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const e=this._maskEffect;(e==null?void 0:e.mask)!==r&&(e&&(this.removeEffect(e),hi.returnMaskEffect(e),this._maskEffect=null),r!=null&&(this._maskEffect=hi.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 e=this._filterEffect||(this._filterEffect=new ar);r=r;const t=(r==null?void 0:r.length)>0,s=((n=e.filters)==null?void 0:n.length)>0,i=t!==s;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),i&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=r??null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new ar),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},zu={label:null,get name(){return F(Z,"Container.name property has been removed, use Container.label instead"),this.label},set name(r){F(Z,"Container.name property has been removed, use Container.label instead"),this.label=r},getChildByName(r,e=!1){return this.getChildByLabel(r,e)},getChildByLabel(r,e=!1){const t=this.children;for(let s=0;s<t.length;s++){const i=t[s];if(i.label===r||r instanceof RegExp&&r.test(i.label))return i}if(e)for(let s=0;s<t.length;s++){const n=t[s].getChildByLabel(r,!0);if(n)return n}return null},getChildrenByLabel(r,e=!1,t=[]){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))&&t.push(n)}if(e)for(let i=0;i<s.length;i++)s[i].getChildrenByLabel(r,!0,t);return t}},ve=_e.getPool(G),Je=_e.getPool(ye),Vu=new G,Xu={getFastGlobalBounds(r,e){e||(e=new ye),e.clear(),this._getGlobalBoundsRecursive(!!r,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(r,e,t){let s=e;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(s=Je.get().clear()),this.boundsArea)e.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,t)}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(Vu).invert()),e.addBounds(s),Je.return(s)}else this.renderGroup&&(e.addBounds(s,this.relativeGroupTransform),Je.return(s))}};function Fi(r,e,t){t.clear();let s,i;return r.parent?e?s=r.parent.worldTransform:(i=ve.get().identity(),s=Gi(r,i)):s=G.IDENTITY,Qa(r,t,s,e),i&&ve.return(i),t.isValid||t.set(0,0,0,0),t}function Qa(r,e,t,s){var a,l;if(!r.visible||!r.measurable)return;let i;s?i=r.worldTransform:(r.updateLocalTransform(),i=ve.get(),i.appendFrom(r.localTransform,t));const n=e,o=!!r.effects.length;if(o&&(e=Je.get().clear()),r.boundsArea)e.addRect(r.boundsArea,i);else{const h=r.bounds;h&&!h.isEmpty()&&(e.matrix=i,e.addBounds(h));for(let c=0;c<r.children.length;c++)Qa(r.children[c],e,i,s)}if(o){for(let h=0;h<r.effects.length;h++)(l=(a=r.effects[h]).addBounds)==null||l.call(a,e);n.addBounds(e,G.IDENTITY),Je.return(e)}s||ve.return(i)}function Gi(r,e){const t=r.parent;return t&&(Gi(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function Vt(r,e){if(r===16777215||!e)return e;if(e===16777215||!r)return r;const t=r>>16&255,s=r>>8&255,i=r&255,n=e>>16&255,o=e>>8&255,a=e&255,l=t*n/255|0,h=s*o/255|0,c=i*a/255|0;return(l<<16)+(h<<8)+c}const io=16777215;function lr(r,e){return r===io?e:e===io?r:Vt(r,e)}function Xt(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const $u={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,t=this.parent;for(;t;)e*=t.alpha,t=t.parent;return e},getGlobalTransform(r=new G,e){if(e)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const t=Gi(this,ve.get().identity());return r.appendFrom(this.localTransform,t),ve.return(t),r},getGlobalTint(r){if(r)return this.renderGroup?Xt(this.renderGroup.worldColor):this.parentRenderGroup?Xt(lr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=lr(e,t.localColor),t=t.parent;return Xt(e)}};function Ui(r,e,t){return e.clear(),t||(t=G.IDENTITY),Ja(r,e,t,r,!0),e.isValid||e.set(0,0,0,0),e}function Ja(r,e,t,s,i){var l,h;let n;if(i)n=ve.get(),n=t.copyTo(n);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;n=ve.get(),n.appendFrom(c,t)}const o=e,a=!!r.effects.length;if(a&&(e=Je.get().clear()),r.boundsArea)e.addRect(r.boundsArea,n);else{r.renderPipeId&&(e.matrix=n,e.addBounds(r.bounds));const c=r.children;for(let u=0;u<c.length;u++)Ja(c[u],e,n,s,!1)}if(a){for(let c=0;c<r.effects.length;c++)(h=(l=r.effects[c]).addLocalBounds)==null||h.call(l,e,s);o.addBounds(e,G.IDENTITY),Je.return(e)}ve.return(n)}function el(r,e){const t=r.children;for(let s=0;s<t.length;s++){const i=t[s],n=i.uid,o=(i._didViewChangeTick&65535)<<16|i._didContainerChangeTick&65535,a=e.index;(e.data[a]!==n||e.data[a+1]!==o)&&(e.data[e.index]=n,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,i.children.length&&el(i,e)}return e.didChange}const ju=new G,Yu={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,e){const t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=r/e*t:this.scale.x=t},_setHeight(r,e){const t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=r/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new ye});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),el(this,r),r.didChange&&Ui(this,r.localBounds,ju),r.localBounds},getBounds(r,e){return Fi(this,r,e||new ye)}},qu={_onRender:null,set onRender(r){const e=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(e==null||e.removeOnRender(this)),this._onRender=null;return}this._onRender||e==null||e.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},Ku={_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(Zu))}};function Zu(r,e){return r._zIndex-e._zIndex}const Qu={getGlobalPosition(r=new ie,e=!1){return this.parent?this.parent.toGlobal(this._position,r,e):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,e,t=!1){const s=this.getGlobalTransform(ve.get(),t);return e=s.apply(r,e),ve.return(s),e},toLocal(r,e,t,s){e&&(r=e.toGlobal(r,t,s));const i=this.getGlobalTransform(ve.get(),s);return t=i.applyInverse(r,t),ve.return(i),t}};class Oi{constructor(){this.uid=re("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(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let Ju=0;class ed{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new tt(this.textureOptions)}createTexture(e,t,s,i){const n=new me({...this.textureOptions,width:e,height:t,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:i});return new O({source:n,label:`texturePool_${Ju++}`})}getOptimalTexture(e,t,s=1,i,n=!1){let o=Math.ceil(e*s-1e-6),a=Math.ceil(t*s-1e-6);o=Yt(o),a=Yt(a);const l=i?1:0,h=n?1:0,c=(o<<17)+(a<<2)+(h<<1)+l;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=e,u.frame.height=t,u.updateUvs(),this._poolKeyHash[u.uid]=c,u}getSameSizeTexture(e,t=!1){const s=e.source;return this.getOptimalTexture(e.width,e.height,s._resolution,t)}returnTexture(e,t=!1){const s=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[s].push(e)}clear(e){if(e=e!==!1,e)for(const t in this._texturePool){const s=this._texturePool[t];if(s)for(let i=0;i<s.length;i++)s[i].destroy(!0)}this._texturePool={}}}const ue=new ed;es.register(ue);class ci{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 Oi,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const t=e.children;for(let s=0;s<t.length;s++){const i=t[s];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(ue.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const t=this.childrenToUpdate[e];t.list.fill(null),t.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(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){const t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const t=e.children;for(let s=0;s<t.length;s++)this.addChild(t[s])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const t=e.children;for(let s=0;s<t.length;s++)this.removeChild(t[s])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.push(e)}removeOnRender(e){this._onRenderContainers.splice(this._onRenderContainers.indexOf(e),1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}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(e=[]){const t=this.root.children;for(let s=0;s<t.length;s++)this._getChildren(t[s],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;const s=e.children;for(let i=0;i<s.length;i++)this._getChildren(s[i],t);return t}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 e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new G),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function td(r,e,t={}){for(const s in e)!t[s]&&e[s]!==void 0&&(r[s]=e[s])}const Mr=new xe(null),Ls=new xe(null),Rr=new xe(null,1,1),Ns=new xe(null),hr=1,Di=2,_s=4;class Te extends Re{constructor(e={}){var t,s;super(),this.uid=re("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 xe(this,0,0),this._scale=Rr,this._pivot=Ls,this._origin=Ns,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=[],td(this,e,{children:!0,parent:!0,effects:!0}),(t=e.children)==null||t.forEach(i=>this.addChild(i)),(s=e.parent)==null||s.addChild(this)}static mixin(e){F("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),V.mixin(Te,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||F(Z,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let i=0;i<e.length;i++)this.addChild(e[i]);return e[0]}const t=e[0],s=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),s&&(s.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,s&&s.addChild(t),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let i=0;i<e.length;i++)this.removeChild(e[i]);return e[0]}const t=e[0],s=this.children.indexOf(t);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit("childRemoved",t,this,s),t.emit("removed",this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=_e.get(ci,this),this.groupTransform=G.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),_e.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.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(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*yu}set angle(e){this.rotation=e*bu}get pivot(){return this._pivot===Ls&&(this._pivot=new xe(this,0,0)),this._pivot}set pivot(e){this._pivot===Ls&&(this._pivot=new xe(this,0,0),this._origin!==Ns&&W("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===Mr&&(this._skew=new xe(this,0,0)),this._skew}set skew(e){this._skew===Mr&&(this._skew=new xe(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===Rr&&(this._scale=new xe(this,1,1)),this._scale}set scale(e){this._scale===Rr&&(this._scale=new xe(this,0,0)),typeof e=="string"&&(e=parseFloat(e)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===Ns&&(this._origin=new xe(this,0,0)),this._origin}set origin(e){this._origin===Ns&&(this._origin=new xe(this,0,0),this._pivot!==Ls&&W("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){const t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||(e={});const t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){const s=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,s.width),t!==void 0&&this._setHeight(t,s.height)}_updateSkew(){const e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX||1:this.scale.x,typeof e.scaleY=="number"?e.scaleY||1:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX=="number"?e.originX:this.origin.x,typeof e.originY=="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const t=this.localTransform,s=this._scale,i=this._pivot,n=this._origin,o=this._position,a=s._x,l=s._y,h=i._x,c=i._y,u=-n._x,d=-n._y;t.a=this._cx*a,t.b=this._sx*a,t.c=this._cy*l,t.d=this._sy*l,t.tx=o._x-(h*t.a+c*t.c)+(u*t.a+d*t.c)-u,t.ty=o._y-(h*t.b+c*t.d)+(u*t.b+d*t.d)-d}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=hr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const s=ee.shared.setValue(e??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=hr,this._onUpdate())}get tint(){return Xt(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Di,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=_s,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=_s,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=_s,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){var i;if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=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 e=="boolean"?e:e==null?void 0:e.children)&&t)for(let n=0;n<t.length;++n)t[n].destroy(e);(i=this.renderGroup)==null||i.destroy(),this.renderGroup=null}}V.mixin(Te,Lu,Xu,Qu,qu,Yu,Hu,zu,Ku,Gu,Du,$u,Nu);class Li extends Te{constructor(e){super(e),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 ye(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const t=this.bounds,{x:s,y:i}=e;return s>=t.minX&&s<=t.maxX&&i>=t.minY&&i<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,s){const{renderPipes:i}=t;i.blendMode.pushBlendMode(this,this.groupBlendMode,e);const o=i[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,e),this.didViewUpdate=!1;const a=this.children,l=a.length;for(let h=0;h<l;h++)a[h].collectRenderables(e,t,s);i.blendMode.popBlendMode(e)}}class Kt extends Li{constructor(e=O.EMPTY){e instanceof O&&(e={texture:e});const{texture:t=O.EMPTY,anchor:s,roundPixels:i,width:n,height:o,...a}=e;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new xe({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=i??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(e,t=!1){return e instanceof O?new Kt(e):new Kt(O.from(e,t))}set texture(e){e||(e=O.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,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 ja(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return F("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,t=this._texture,s=this._bounds,{width:i,height:n}=t.orig;s.minX=-e._x*i,s.maxX=s.minX+i,s.minY=-e._y*n,s.maxY=s.minY+n}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const s=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(s)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}const sd=new ye;function tl(r,e,t){const s=sd;r.measurable=!0,Fi(r,t,s),e.addBoundsMask(s),r.measurable=!1}function sl(r,e,t){const s=Je.get();r.measurable=!0;const i=ve.get().identity(),n=rl(r,t,i);Ui(r,s,n),r.measurable=!1,e.addBoundsMask(s),ve.return(i),Je.return(s)}function rl(r,e,t){return r?(r!==e&&(rl(r.parent,e,t),r.updateLocalTransform(),t.append(r.localTransform)),t):(W("Mask bounds, renderable is not inside the root container"),t)}class il{constructor(e){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof Kt),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(e,t){this.inverse||tl(this.mask,e,t)}addLocalBounds(e,t){sl(this.mask,e,t)}containsPoint(e,t){const s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof Kt}}il.extension=b.MaskEffect;class nl{constructor(e){this.priority=0,this.pipe="colorMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}nl.extension=b.MaskEffect;class ol{constructor(e){this.priority=0,this.pipe="stencilMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,t){tl(this.mask,e,t)}addLocalBounds(e,t){sl(this.mask,e,t)}containsPoint(e,t){const s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof Te}}ol.extension=b.MaskEffect;const rd={createCanvas:(r,e)=>{const t=document.createElement("canvas");return t.width=r,t.height=e,t},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,e)=>fetch(r,e),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let no=rd;const z={get(){return no},set(r){no=r}};class Xe extends me{constructor(e){e.resource||(e.resource=z.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.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(e=this.width,t=this.height,s=this._resolution){const i=super.resize(e,t,s);return i&&this.resizeCanvas(),i}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Xe.extension=b.TextureSource;class Ct extends me{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}Ct.extension=b.TextureSource;var Zt=(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))(Zt||{});class Br{constructor(e,t=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=s,this._once=i}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));const t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const t=this.next;return this.next=e?null:t,this.previous=null,t}}const al=class Ce{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 Br(null,null,1/0),this.deltaMS=1/Ce.targetFPMS,this.elapsedMS=1/Ce.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,s=Zt.NORMAL){return this._addListener(new Br(e,t,s))}addOnce(e,t,s=Zt.NORMAL){return this._addListener(new Br(e,t,s,!0))}_addListener(e){let t=this._head.next,s=this._head;if(!t)e.connect(s);else{for(;t;){if(e.priority>t.priority){e.connect(s);break}s=t,t=t.next}e.previous||e.connect(s)}return this._startIfPossible(),this}remove(e,t){let s=this._head.next;for(;s;)s.match(e,t)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=e-n%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*Ce.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=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(Math.max(0,e)/1e3,Ce.targetFPMS);this._maxElapsedMS=1/t,this._minElapsedMS&&e>this.maxFPS&&(this.maxFPS=e)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!Ce._shared){const e=Ce._shared=new Ce;e.autoStart=!0,e._protected=!0}return Ce._shared}static get system(){if(!Ce._system){const e=Ce._system=new Ce;e.autoStart=!0,e._protected=!0}return Ce._system}};al.targetFPMS=.06;let Ue=al,kr;async function ll(){return kr??(kr=(async()=>{var o;const e=z.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const t=await new Promise(a=>{const l=document.createElement("video");l.onloadeddata=()=>a(l),l.onerror=()=>a(null),l.autoplay=!1,l.crossOrigin="anonymous",l.preload="auto",l.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",l.load()});if(!t)return"premultiply-alpha-on-upload";const s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s);const i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,s,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(i),e.deleteTexture(s),(o=e.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),kr}const _r=class hl extends me{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...hl.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.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),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=Ue.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!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 e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.isValid||e.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await ll(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.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 e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.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 e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("loadedmetadata",this._onLoadedMetadata),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ue.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||(Ue.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ue.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};_r.extension=b.TextureSource;_r.defaultOptions={...me.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};_r.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let xs=_r;const Ne=(r,e,t=!1)=>(Array.isArray(r)||(r=[r]),e?r.map(s=>typeof s=="string"||t?e(s):s):r);class id{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||W(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const s=Ne(e);let i;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.test(t)){i=h.getCacheableAssets(s,t);break}}const n=new Map(Object.entries(i||{}));i||s.forEach(l=>{n.set(l,t)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const h=i?i[l]:t;this._cache.has(l)&&this._cache.get(l)!==h&&W("[Cache] already has key:",l),this._cache.set(l,n.get(l))})}remove(e){if(!this._cacheMap.has(e)){W(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(i=>{this._cache.delete(i)}),t.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const se=new id,ui=[];V.handleByList(b.TextureSource,ui);function cl(r={}){const e=r&&r.resource,t=e?r.resource:r,s=e?r:{resource:r};for(let i=0;i<ui.length;i++){const n=ui[i];if(n.test(t))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function nd(r={},e=!1){const t=r&&r.resource,s=t?r.resource:r,i=t?r:{resource:r};if(!e&&se.has(s))return se.get(s);const n=new O({source:cl(i)});return n.on("destroy",()=>{se.has(s)&&se.remove(s)}),e||se.set(s,n),n}function od(r,e=!1){return typeof r=="string"?se.get(r):r instanceof me?new O({source:r}):nd(r,e)}O.from=od;me.from=cl;V.add(il,nl,ol,xs,Ct,Xe,Ii);var ut=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(ut||{});function De(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function os(r){return r.split("?")[0].split("#")[0]}function ad(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ld(r,e,t){return r.replace(new RegExp(ad(e),"g"),t)}function hd(r,e){let t="",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(t.length<2||s!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",s=0):(t=t.slice(0,l),s=t.length-1-t.lastIndexOf("/")),i=a,n=0;continue}}else if(t.length===2||t.length===1){t="",s=0,i=a,n=0;continue}}}else t.length>0?t+=`/${r.slice(i+1,a)}`:t=r.slice(i+1,a),s=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return t}const Pe={toPosix(r){return ld(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){De(r),r=this.toPosix(r);const e=/^file:\/\/\//.exec(r);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(De(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=os(this.toPosix(e??z.get().getBaseUrl())),i=os(this.toPosix(t??this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?Pe.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(De(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="";const t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));const s=r.endsWith("/");return r=hd(r),r.length>0&&s&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return De(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){const s=r[t];if(De(s),s.length>0)if(e===void 0)e=s;else{const i=r[t-1]??"";this.joinExtensions.includes(this.extname(i).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(De(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0);const t=e===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(e=r.charCodeAt(a),e===47){if(!i){s=a;break}}else i=!1;return s===-1?t?"/":this.isUrl(o)?n+r:n:t&&s===1?"//":n+r.slice(0,s)},rootname(r){De(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){const t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){De(r),e&&De(e),r=os(this.toPosix(r));let t=0,s=-1,i=!0,n;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let o=e.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!i){t=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return t===s?s=a:s===-1&&(s=r.length),r.slice(t,s)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!i){t=n+1;break}}else s===-1&&(i=!1,s=n+1);return s===-1?"":r.slice(t,s)},extname(r){De(r),r=os(this.toPosix(r));let e=-1,t=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){t=o+1;break}continue}s===-1&&(i=!1,s=o+1),a===46?e===-1?e=o:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||s===-1||n===0||n===1&&e===s-1&&e===t+1?"":r.slice(e,s)},parse(r){De(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=os(this.toPosix(r));let t=r.charCodeAt(0);const s=this.isAbsolute(r);let i;e.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=i;--h){if(t=r.charCodeAt(h),t===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),t===46?n===-1?n=h:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&s?e.base=e.name=r.slice(1,a):e.base=e.name=r.slice(o,a)):(o===0&&s?(e.name=r.slice(1,n),e.base=r.slice(1,a)):(e.name=r.slice(o,n),e.base=r.slice(o,a)),e.ext=r.slice(n,a)),e.dir=this.dirname(r),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function ul(r,e,t,s,i){const n=e[t];for(let o=0;o<n.length;o++){const a=n[o];t<e.length-1?ul(r.replace(s[t],a),e,t+1,s,i):i.push(r.replace(s[t],a))}}function cd(r){const e=/\{(.*?)\}/g,t=r.match(e),s=[];if(t){const i=[];t.forEach(n=>{const o=n.substring(1,n.length-1).split(",");i.push(o)}),ul(r,i,0,t,s)}else s.push(r);return s}const cr=r=>!Array.isArray(r);class ts{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(t[s])}`).join("&")}}getAlias(e){const{alias:t,src:s}=e;return Ne(t||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(e,t){this._assetMap[e]&&(t&&t!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&W("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const s=[];let i=t;Array.isArray(t)||(i=Object.entries(t).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 l;if(typeof a=="string"){const h=this._createBundleAssetId(e,a);s.push(h),l=[a,h]}else{const h=a.map(c=>this._createBundleAssetId(e,c));s.push(...h),l=[...a,...h]}this.add({...n,alias:l,src:o})}),this._bundles[e]=s}add(e){const t=[];Array.isArray(e)?t.push(...e):t.push(e);let s;s=n=>{this.hasKey(n)&&W(`[Resolver] already has key: ${n} overwriting`)},Ne(t).forEach(n=>{const{src:o}=n;let{data:a,format:l,loadParser:h,parser:c}=n;const u=Ne(o).map(g=>typeof g=="string"?cd(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,l=m.format??l,(m.loadParser||m.parser)&&(h=m.loadParser??h,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:l,loadParser:h,parser:c,progressSize:n.progressSize}),f.push(_)})}),d.forEach(g=>{this._assetMap[g]=f})})}resolveBundle(e){const t=cr(e);e=Ne(e);const s={};return e.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(i,l)]=h}s[i]=a}}),t?s[e[0]]:s}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const s={};for(const i in t)s[i]=t[i].src;return s}return t.src}resolve(e){const t=cr(e);e=Ne(e);const s={};return e.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(l=>{const h=n.filter(c=>c[a]?c[a]===l:!1);h.length&&(n=h)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),t?s[e[0]]:s}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const s=e[t],i=this._preferredOrder.find(n=>n.params.format.includes(s.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){const{aliases:s,data:i,loadParser:n,parser:o,format:a,progressSize:l}=t;return(this._basePath||this._rootPath)&&(e.src=Pe.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=s??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...i||{},...e.data},e.loadParser=n??e.loadParser,e.parser=o??e.parser,e.format=a??e.format??ud(e.src),l!==void 0&&(e.progressSize=l),e}}ts.RETINA_PREFIX=/@([0-9\.]+)x/;function ud(r){return r.split(".").pop().split("?").shift().split("#").shift()}const di=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r},dl=class ps{constructor(e,t){this.linkedSheets=[];let s=e;(e==null?void 0:e.source)instanceof me&&(s={texture:e,data:t});const{texture:i,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=i instanceof O?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(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=ps.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,t=!1){let s=e;const i=t?1/0:ps.BATCH_SIZE;for(;s-e<i&&s<this._frameKeys.length;){const n=this._frameKeys[s],o=this._frames[n],a=o.frame;if(a){let l=null,h=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,u=new Q(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?l=new Q(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):l=new Q(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&&(h=new Q(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 O({source:this.textureSource,frame:l,orig:u,trim:h,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}s++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let s=0;s<e[t].length;s++){const i=e[t][s];this.animations[t].push(this.textures[i])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*ps.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ps.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((t=this._texture)==null||t.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};dl.BATCH_SIZE=1e3;let oo=dl;const dd=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function fl(r,e,t){const s={};if(r.forEach(i=>{s[i]=e}),Object.keys(e.textures).forEach(i=>{s[`${e.cachePrefix}${i}`]=e.textures[i]}),!t){const i=Pe.dirname(r[0]);e.linkedSheets.forEach((n,o)=>{const a=fl([`${i}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const fd={extension:b.Asset,cache:{test:r=>r instanceof oo,getCacheableAssets:(r,e)=>fl(r,e,!1)},resolver:{extension:{type:b.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),s=t.pop(),i=t.pop();return s==="json"&&dd.includes(i)},parse:r=>{var t;const e=r.split(".");return{resolution:parseFloat(((t=ts.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:e[e.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:b.LoadParser,priority:ut.Normal,name:"spritesheetLoader"},async testParse(r,e){return Pe.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){var u,d;const{texture:s,imageFilename:i,textureOptions:n,cachePrefix:o}=(e==null?void 0:e.data)??{};let a=Pe.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(s instanceof O)l=s;else{const f=di(a+(i??r.meta.image),e.src);l=(await t.load([{src:f,data:n}]))[f]}const h=new oo({texture:l.source,data:r,cachePrefix:o});await h.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=e.data)!=null&&d.ignoreMultiPack||(m=di(m,e.src),f.push(t.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}const p=await Promise.all(f);h.linkedSheets=p,p.forEach(g=>{g.linkedSheets=[h].concat(h.linkedSheets.filter(m=>m!==g))})}return h},async unload(r,e,t){await t.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};V.add(fd);class pl{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),s=this._canvas.width,i=this._canvas.height,n=t.width/s*this._renderer.resolution,o=t.height/i*this._renderer.resolution,a=t.left,l=t.top,h=`translate(${a}px, ${l}px) scale(${n}, ${o})`;h!==this._lastTransform&&(this._domElement.style.transform=h,this._lastTransform=h)},this._domElement=e.domElement,this._renderer=e.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(e=>{for(const t of e){if(t.target!==this._canvas)continue;const s=this.canvas.width,i=this.canvas.height,n=t.contentRect.width/s*this._renderer.resolution,o=t.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||Ue.shared.add(this.updateTranslation,this,Zt.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Ue.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 Rs{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Rs.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ie,this.page=new ie,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,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 Ir=/iPhone/i,ao=/iPod/i,lo=/iPad/i,ho=/\biOS-universal(?:.+)Mac\b/i,Fr=/\bAndroid(?:.+)Mobile\b/i,co=/Android/i,kt=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ws=/Silk/i,qe=/Windows Phone/i,uo=/\bWindows(?:.+)ARM\b/i,fo=/BlackBerry/i,po=/BB10/i,mo=/Opera Mini/i,go=/\b(CriOS|Chrome)(?:.+)Mobile/i,_o=/Mobile(?:.+)Firefox\b/i,xo=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function pd(r){return function(e){return e.test(r)}}function yo(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,s=t.split("[FBAN");typeof s[1]<"u"&&(t=s[0]),s=t.split("Twitter"),typeof s[1]<"u"&&(t=s[0]);var i=pd(t),n={apple:{phone:i(Ir)&&!i(qe),ipod:i(ao),tablet:!i(Ir)&&(i(lo)||xo(e))&&!i(qe),universal:i(ho),device:(i(Ir)||i(ao)||i(lo)||i(ho)||xo(e))&&!i(qe)},amazon:{phone:i(kt),tablet:!i(kt)&&i(Ws),device:i(kt)||i(Ws)},android:{phone:!i(qe)&&i(kt)||!i(qe)&&i(Fr),tablet:!i(qe)&&!i(kt)&&!i(Fr)&&(i(Ws)||i(co)),device:!i(qe)&&(i(kt)||i(Ws)||i(Fr)||i(co))||i(/\bokhttp\b/i)},windows:{phone:i(qe),tablet:i(uo),device:i(qe)||i(uo)},other:{blackberry:i(fo),blackberry10:i(po),opera:i(mo),firefox:i(_o),chrome:i(go),device:i(fo)||i(po)||i(mo)||i(_o)||i(go)},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 md=yo.default??yo,gd=md(globalThis.navigator),_d=9,bo=100,xd=0,yd=0,vo=2,To=1,bd=-1e3,vd=-1e3,Td=2,Ni=class ml{constructor(e,t=gd){this._mobileInfo=t,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,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${To}px`,e.style.height=`${To}px`,e.style.position="absolute",e.style.top=`${bd}px`,e.style.left=`${vd}px`,e.style.zIndex=Td.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${xd}px`,this._div.style.left=`${yd}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=vo.toString(),this._canvasObserver=new pl({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var e,t;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)(e=s._accessibleDiv)!=null&&e.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];(t=this._div)!=null&&t.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let s=0;s<t.length;s++)this._updateAccessibleObjects(t[s])}init(e){const s={accessibilityOptions:{...ml.defaultOptions,...(e==null?void 0:e.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 e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const s of this._children)s._renderId===this._renderId&&t.add(this._children.indexOf(s))}for(let s=this._children.length-1;s>=0;s--){const i=this._children[s];t.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,Za(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(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:s}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>s&&(e.height=s-e.y)}_addChild(e){let s=this._getPool(e.accessibleType).pop();s?(s.innerHTML="",s.removeAttribute("title"),s.removeAttribute("aria-label"),s.tabIndex=0):(e.accessibleType==="button"?s=document.createElement("button"):(s=document.createElement(e.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
+ `,e.accessibleText&&(s.innerText=e.accessibleText)),s.style.width=`${bo}px`,s.style.height=`${bo}px`,s.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",s.style.position="absolute",s.style.zIndex=vo.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=e.accessiblePointerEvents,s.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?s.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(s.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&s.setAttribute("aria-label",e.accessibleHint),e.interactive?s.tabIndex=e.tabIndex:s.tabIndex=0,this.debug&&this._updateDebugHTML(s),e._accessibleActive=!0,e._accessibleDiv=s,s.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv)}_dispatchEvent(e,t){const{container:s}=e.target,i=this._renderer.events.rootBoundary,n=Object.assign(new Rs(i),{target:s});i.rootTarget=this._renderer.lastObjectRendered,t.forEach(o=>i.dispatchEvent(n,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode!==_d||!this._activateOnTab||this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){var e;this._deactivate(),this._destroyTouchHook(),(e=this._canvasObserver)==null||e.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(e){e?this._activate():this._deactivate()}_getPool(e){return this._pools[e]||(this._pools[e]=[]),this._pools[e]}};Ni.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"accessibility"};Ni.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Sd=Ni;const wd={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1},Gr=Object.create(null),So=Object.create(null);function Ss(r,e){let t=So[r];return t===void 0&&(Gr[e]===void 0&&(Gr[e]=1),So[r]=t=Gr[e]++),t}let It;function gl(){return(!It||It!=null&&It.isContextLost())&&(It=z.get().createCanvas().getContext("webgl",{})),It}let Hs;function Cd(){if(!Hs){Hs="mediump";const r=gl();r&&r.getShaderPrecisionFormat&&(Hs=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Hs}function Ad(r,e,t){return e?r:t?(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 Ed(r,e,t){const s=t?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let i=t?e.requestedFragmentPrecision:e.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 Pd(r,e){return e?`#version 300 es
34
+ ${r}`:r}const Md={},Rd={};function Bd(r,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";const s=t?Md:Rd;return s[e]?(s[e]++,e+=`-${s[e]}`):s[e]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${e}`}
35
+ ${r}`}function kd(r,e){return e?r.replace("#version 300 es",""):r}const Ur={stripVersion:kd,ensurePrecision:Ed,addProgramDefines:Ad,setProgramName:Bd,insertVersion:Pd},as=Object.create(null),_l=class fi{constructor(e){e={...fi.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Cd()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let i=e.fragment,n=e.vertex;Object.keys(Ur).forEach(o=>{const a=s[o];i=Ur[o](i,a,!0),n=Ur[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=Ss(`${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,as[this._cacheKey]=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return as[t]||(as[t]=new fi(e),as[t]._cacheKey=t),as[t]}};_l.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let dt=_l;const wo={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 ws(r){return wo[r]??wo.float32}const Id={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"},Co=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Ao(r,e){let t;for(;(t=Co.exec(r))!==null;){const s=Id[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:s,stride:ws(s).stride,offset:0,instance:!1,start:0}}Co.lastIndex=0}function Fd(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Gd({source:r,entryPoint:e}){const t={},s=Fd(r),i=s.indexOf(`fn ${e}(`);if(i===-1)return t;const n=s.indexOf("->",i);if(n===-1)return t;const o=s.substring(i,n);if(Ao(o,t),Object.keys(t).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const l=a[1],h=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),c=s.match(h);c&&Ao(c[1],t)}}return t}function Or(r){var u,d;const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,i=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,h=(u=r.match(e))==null?void 0:u.map(f=>({group:parseInt(f.match(t)[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(!h)return{groups:[],structs:[]};const c=((d=r.match(o))==null?void 0:d.map(f=>{const p=f.match(l)[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})=>h.some(p=>p.type===f||p.type.includes(`<${f}>`))))??[];return{groups:h,structs:c}}var bt=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(bt||{});function Ud({groups:r}){const e=[];for(let t=0;t<r.length;t++){const s=r[t];e[s.group]||(e[s.group]=[]),s.isUniform?e[s.group].push({binding:s.binding,visibility:bt.VERTEX|bt.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?e[s.group].push({binding:s.binding,visibility:bt.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?e[s.group].push({binding:s.binding,visibility:bt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):s.type==="texture_2d_array"||s.type.startsWith("texture_2d_array<")?e[s.group].push({binding:s.binding,visibility:bt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(s.type==="texture_cube"||s.type.startsWith("texture_cube<"))&&e[s.group].push({binding:s.binding,visibility:bt.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}function Od({groups:r}){const e=[];for(let t=0;t<r.length;t++){const s=r[t];e[s.group]||(e[s.group]={}),e[s.group][s.name]=s.binding}return e}function Dd(r,e){const t=new Set,s=new Set,i=[...r.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),n=[...r.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:i,groups:n}}const ls=Object.create(null);class st{constructor(e){var a,l;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:t,vertex:s,layout:i,gpuLayout:n,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=s,t.source===s.source){const h=Or(t.source);this.structsAndGroups=h}else{const h=Or(s.source),c=Or(t.source);this.structsAndGroups=Dd(h,c)}this.layout=i??Od(this.structsAndGroups),this.gpuLayout=n??Ud(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((l=this.layout[1])==null?void 0:l.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:e,fragment:t}=this,s=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=Ss(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Gd(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,ls[this._cacheKey]=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return ls[t]||(ls[t]=new st(e),ls[t]._cacheKey=t),ls[t]}}const xl=["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>"],Ld=xl.reduce((r,e)=>(r[e]=!0,r),{});function Nd(r,e){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);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 yl=class bl{constructor(e,t){this._touched=0,this.uid=re("uniform"),this._resourceType="uniformGroup",this._resourceId=re("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...bl.defaultOptions,...t},this.uniformStructures=e;const s={};for(const i in e){const n=e[i];if(n.name=i,n.size=n.size??1,!Ld[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,l]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${l} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${xl.join(", ")}`)}n.value??(n.value=Nd(n.type,n.size)),s[i]=n.value}this.uniforms=s,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=Ss(Object.keys(s).map(i=>`${i}-${e[i].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};yl.defaultOptions={ubo:!1,isStatic:!1};let We=yl;class lt{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(const s in e){const i=e[s];this.setResource(i,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const e=[];let t=0;for(const s in this.resources)e[t++]=this.resources[s]._resourceId;this._key=e.join("|")}setResource(e,t){var i,n;const s=this.resources[t];e!==s&&((i=s==null?void 0:s.off)==null||i.call(s,"change",this.onResourceChange,this),(n=e.on)==null||n.call(e,"change",this.onResourceChange,this),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e,t){const s=this.resources;for(const i in s)s[i]._gcLastUsed=e,s[i]._touched=t}destroy(){var t;const e=this.resources;for(const s in e){const i=e[s];(t=i==null?void 0:i.off)==null||t.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(e){this._dirty=!0,e.destroyed?this.destroy():this._updateKey()}}var Me=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Me||{});class rt extends Re{constructor(e){super(),this.uid=re("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=e;this.gpuProgram=t,this.glProgram=s,o===void 0&&(o=0,t&&(o|=Me.WEBGPU),s&&(o|=Me.WEBGL)),this.compatibleRenderers=o;const l={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!t&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!t&&i&&a)for(const h in a)for(const c in a[h]){const u=a[h][c];l[u]={group:h,binding:c,name:u}}else if(t&&i&&!a){const h=t.structsAndGroups.groups;a={},h.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,l[c.name]=c})}else if(n){i={},a={},t&&t.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,l[u.name]=u});let h=0;for(const c in n)l[c]||(i[99]||(i[99]=new lt,this._ownedBindGroups.push(i[99])),l[c]={group:99,binding:h,name:c},a[99]=a[99]||{},a[99][h]=c,h++);for(const c in n){const u=c;let d=n[c];!d.source&&!d._resourceType&&(d=new We(d));const f=l[u];f&&(i[f.group]||(i[f.group]=new lt,this._ownedBindGroups.push(i[f.group])),i[f.group].setResource(d,f.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,l)}addResource(e,t,s){var i,n;(i=this._uniformBindMap)[t]||(i[t]={}),(n=this._uniformBindMap[t])[s]||(n[s]=e),this.groups[t]||(this.groups[t]=new lt,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){const s={};for(const i in t){const n=t[i];Object.defineProperty(s,n.name,{get(){return e[n.group].getResource(n.binding)},set(o){e[n.group].setResource(o,n.binding)}})}return s}destroy(e=!1){var t,s;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&((t=this.gpuProgram)==null||t.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(e){const{gpu:t,gl:s,...i}=e;let n,o;return t&&(n=st.from(t)),s&&(o=dt.from(s)),new rt({gpuProgram:n,glProgram:o,...i})}}const Wd={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},Dr=0,Lr=1,Nr=2,Wr=3,Hr=4,zr=5,pi=class vl{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Dr)}set blend(e){!!(this.data&1<<Dr)!==e&&(this.data^=1<<Dr)}get offsets(){return!!(this.data&1<<Lr)}set offsets(e){!!(this.data&1<<Lr)!==e&&(this.data^=1<<Lr)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<Nr)}set culling(e){!!(this.data&1<<Nr)!==e&&(this.data^=1<<Nr)}get depthTest(){return!!(this.data&1<<Wr)}set depthTest(e){!!(this.data&1<<Wr)!==e&&(this.data^=1<<Wr)}get depthMask(){return!!(this.data&1<<zr)}set depthMask(e){!!(this.data&1<<zr)!==e&&(this.data^=1<<zr)}get clockwiseFrontFace(){return!!(this.data&1<<Hr)}set clockwiseFrontFace(e){!!(this.data&1<<Hr)!==e&&(this.data^=1<<Hr)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=Wd[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new vl;return e.depthTest=!1,e.blend=!0,e}};pi.default2d=pi.for2d();let it=pi;const Tl=class mi extends rt{constructor(e){e={...mi.defaultOptions,...e},super(e),this.enabled=!0,this._state=it.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,s,i){e.applyFilter(this,t,s,i)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:s,...i}=e;let n,o;return t&&(n=st.from(t)),s&&(o=dt.from(s)),new mi({gpuProgram:n,glProgram:o,...i})}};Tl.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Bs=Tl;const gi=[];V.handleByNamedList(b.Environment,gi);async function Hd(r){if(!r)for(let e=0;e<gi.length;e++){const t=gi[e];if(t.value.test()){await t.value.load();return}}}let hs;function Sl(){if(typeof hs=="boolean")return hs;try{hs=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{hs=!1}return hs}function Eo(r,e,t=2){const s=e&&e.length,i=s?e[0]*t:r.length;let n=wl(r,0,i,t,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,h;if(s&&(n=jd(r,e,n,t)),r.length>80*t){a=r[0],l=r[1];let c=a,u=l;for(let d=t;d<i;d+=t){const f=r[d],p=r[d+1];f<a&&(a=f),p<l&&(l=p),f>c&&(c=f),p>u&&(u=p)}h=Math.max(c-a,u-l),h=h!==0?32767/h:0}return Cs(n,o,t,a,l,h,0),o}function wl(r,e,t,s,i){let n;if(i===nf(r,e,t,s)>0)for(let o=e;o<t;o+=s)n=Po(o/s|0,r[o],r[o+1],n);else for(let o=t-s;o>=e;o-=s)n=Po(o/s|0,r[o],r[o+1],n);return n&&Qt(n,n.next)&&(Es(n),n=n.next),n}function At(r,e){if(!r)return r;e||(e=r);let t=r,s;do if(s=!1,!t.steiner&&(Qt(t,t.next)||le(t.prev,t,t.next)===0)){if(Es(t),t=e=t.prev,t===t.next)break;s=!0}else t=t.next;while(s||t!==e);return e}function Cs(r,e,t,s,i,n,o){if(!r)return;!o&&n&&Qd(r,s,i,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,h=r.next;if(n?Vd(r,s,i,n):zd(r)){e.push(l.i,r.i,h.i),Es(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Xd(At(r),e),Cs(r,e,t,s,i,n,2)):o===2&&$d(r,e,t,s,i,n):Cs(At(r),e,t,s,i,n,1);break}}}function zd(r){const e=r.prev,t=r,s=r.next;if(le(e,t,s)>=0)return!1;const i=e.x,n=t.x,o=s.x,a=e.y,l=t.y,h=s.y,c=Math.min(i,n,o),u=Math.min(a,l,h),d=Math.max(i,n,o),f=Math.max(a,l,h);let p=s.next;for(;p!==e;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&ms(i,a,n,l,o,h,p.x,p.y)&&le(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Vd(r,e,t,s){const i=r.prev,n=r,o=r.next;if(le(i,n,o)>=0)return!1;const a=i.x,l=n.x,h=o.x,c=i.y,u=n.y,d=o.y,f=Math.min(a,l,h),p=Math.min(c,u,d),g=Math.max(a,l,h),m=Math.max(c,u,d),_=_i(f,p,e,t,s),x=_i(g,m,e,t,s);let y=r.prevZ,T=r.nextZ;for(;y&&y.z>=_&&T&&T.z<=x;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==i&&y!==o&&ms(a,c,l,u,h,d,y.x,y.y)&&le(y.prev,y,y.next)>=0||(y=y.prevZ,T.x>=f&&T.x<=g&&T.y>=p&&T.y<=m&&T!==i&&T!==o&&ms(a,c,l,u,h,d,T.x,T.y)&&le(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;y&&y.z>=_;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==i&&y!==o&&ms(a,c,l,u,h,d,y.x,y.y)&&le(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;T&&T.z<=x;){if(T.x>=f&&T.x<=g&&T.y>=p&&T.y<=m&&T!==i&&T!==o&&ms(a,c,l,u,h,d,T.x,T.y)&&le(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function Xd(r,e){let t=r;do{const s=t.prev,i=t.next.next;!Qt(s,i)&&Al(s,t,t.next,i)&&As(s,i)&&As(i,s)&&(e.push(s.i,t.i,i.i),Es(t),Es(t.next),t=r=i),t=t.next}while(t!==r);return At(t)}function $d(r,e,t,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&tf(o,a)){let l=El(o,a);o=At(o,o.next),l=At(l,l.next),Cs(o,e,t,s,i,n,0),Cs(l,e,t,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function jd(r,e,t,s){const i=[];for(let n=0,o=e.length;n<o;n++){const a=e[n]*s,l=n<o-1?e[n+1]*s:r.length,h=wl(r,a,l,s,!1);h===h.next&&(h.steiner=!0),i.push(ef(h))}i.sort(Yd);for(let n=0;n<i.length;n++)t=qd(i[n],t);return t}function Yd(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){const s=(r.next.y-r.y)/(r.next.x-r.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=s-i}return t}function qd(r,e){const t=Kd(r,e);if(!t)return e;const s=El(t,r);return At(s,s.next),At(t,t.next)}function Kd(r,e){let t=e;const s=r.x,i=r.y;let n=-1/0,o;if(Qt(r,t))return t;do{if(Qt(r,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const u=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(u<=s&&u>n&&(n=u,o=t.x<t.next.x?t:t.next,u===s))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,l=o.x,h=o.y;let c=1/0;t=o;do{if(s>=t.x&&t.x>=l&&s!==t.x&&Cl(i<h?s:n,i,l,h,i<h?n:s,i,t.x,t.y)){const u=Math.abs(i-t.y)/(s-t.x);As(t,r)&&(u<c||u===c&&(t.x>o.x||t.x===o.x&&Zd(o,t)))&&(o=t,c=u)}t=t.next}while(t!==a);return o}function Zd(r,e){return le(r.prev,r,e.prev)<0&&le(e.next,r,r.next)<0}function Qd(r,e,t,s){let i=r;do i.z===0&&(i.z=_i(i.x,i.y,e,t,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Jd(i)}function Jd(r){let e,t=1;do{let s=r,i;r=null;let n=null;for(e=0;s;){e++;let o=s,a=0;for(let h=0;h<t&&(a++,o=o.nextZ,!!o);h++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||s.z<=o.z)?(i=s,s=s.nextZ,a--):(i=o,o=o.nextZ,l--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;s=o}n.nextZ=null,t*=2}while(e>1);return r}function _i(r,e,t,s,i){return r=(r-t)*i|0,e=(e-s)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function ef(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Cl(r,e,t,s,i,n,o,a){return(i-o)*(e-a)>=(r-o)*(n-a)&&(r-o)*(s-a)>=(t-o)*(e-a)&&(t-o)*(n-a)>=(i-o)*(s-a)}function ms(r,e,t,s,i,n,o,a){return!(r===o&&e===a)&&Cl(r,e,t,s,i,n,o,a)}function tf(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!sf(r,e)&&(As(r,e)&&As(e,r)&&rf(r,e)&&(le(r.prev,r,e.prev)||le(r,e.prev,e))||Qt(r,e)&&le(r.prev,r,r.next)>0&&le(e.prev,e,e.next)>0)}function le(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Qt(r,e){return r.x===e.x&&r.y===e.y}function Al(r,e,t,s){const i=Vs(le(r,e,t)),n=Vs(le(r,e,s)),o=Vs(le(t,s,r)),a=Vs(le(t,s,e));return!!(i!==n&&o!==a||i===0&&zs(r,t,e)||n===0&&zs(r,s,e)||o===0&&zs(t,r,s)||a===0&&zs(t,e,s))}function zs(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Vs(r){return r>0?1:r<0?-1:0}function sf(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Al(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function As(r,e){return le(r.prev,r,r.next)<0?le(r,e,r.next)>=0&&le(r,r.prev,e)>=0:le(r,e,r.prev)<0||le(r,r.next,e)<0}function rf(r,e){let t=r,s=!1;const i=(r.x+e.x)/2,n=(r.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&i<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(s=!s),t=t.next;while(t!==r);return s}function El(r,e){const t=xi(r.i,r.x,r.y),s=xi(e.i,e.x,e.y),i=r.next,n=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,s.next=t,t.prev=s,n.next=s,s.prev=n,s}function Po(r,e,t,s){const i=xi(r,e,t);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Es(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 xi(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function nf(r,e,t,s){let i=0;for(let n=e,o=t-s;n<t;n+=s)i+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return i}const of=Eo.default||Eo;var Ae=(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))(Ae||{});class Pl{constructor(e){this.items=[],this._name=e}emit(e,t,s,i,n,o,a,l){const{name:h,items:c}=this;for(let u=0,d=c.length;u<d;u++)c[u][h](e,t,s,i,n,o,a,l);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-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 af=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Ml=class Rl extends Re{constructor(e){super(),this.tick=0,this.uid=re("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;const t=[...af,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){const t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await Hd(t),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash)e={...this._systemsHash[s].constructor.defaultOptions,...e};e={...Rl.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(e);this._initOptions=e}render(e,t){this.tick++;let s=e;if(s instanceof Te&&(s={container:s},t&&(F(Z,"passing a second argument is deprecated, please use render options instead"),s.target=t.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:ee.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(e,t,s){const i=this.view.resolution;this.view.resize(e,t,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(e={}){const t=this;e.target||(e.target=t.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=Ae.ALL);const{clear:s,clearColor:i,target:n,mipLevel:o,layer:a}=e;ee.shared.setValue(i??this.background.colorRgba),t.renderTarget.clear(n,s,ee.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}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(...e){e.forEach(t=>{this.runners[t]=new Pl(t)})}_addSystems(e){let t;for(t in e){const s=e[t];this._addSystem(s.value,s.name)}}_addSystem(e,t){const s=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=s,this._systemsHash[t]=s;for(const i in this.runners)this.runners[i].add(s);return this}_addPipes(e,t){const s=t.reduce((i,n)=>(i[n.name]=n.value,i),{});e.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(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e=="object"&&e.releaseGlobalResources)&&es.release(),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Sl())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()}};Ml.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let ks=Ml,Xs;function lf(r){return Xs!==void 0||(Xs=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r??ks.defaultOptions.failIfMajorPerformanceCaveat};try{if(!z.get().getWebGLRenderingContext())return!1;let i=z.get().createCanvas().getContext("webgl",e);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const o=i.getExtension("WEBGL_lose_context");o&&o.loseContext()}return i=null,n}catch{return!1}})()),Xs}let $s;async function hf(r={}){return $s!==void 0||($s=await(async()=>{const e=z.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),$s}const Mo=["webgl","webgpu","canvas"];async function cf(r){let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),Mo.forEach(n=>{n!==r.preference&&e.push(n)})):e=Mo.slice();let t,s={};for(let n=0;n<e.length;n++){const o=e[n];if(o==="webgpu"&&await hf()){const{WebGPURenderer:a}=await zt(async()=>{const{WebGPURenderer:l}=await Promise.resolve().then(()=>ay);return{WebGPURenderer:l}},void 0);t=a,s={...r,...r.webgpu};break}else if(o==="webgl"&&lf(r.failIfMajorPerformanceCaveat??ks.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await zt(async()=>{const{WebGLRenderer:l}=await Promise.resolve().then(()=>Lx);return{WebGLRenderer:l}},void 0);t=a,s={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await zt(async()=>{const{CanvasRenderer:l}=await Promise.resolve().then(()=>D_);return{CanvasRenderer:l}},void 0);t=a,s={...r,...r.canvasOptions};break}}if(delete s.webgpu,delete s.webgl,delete s.canvasOptions,!t)throw new Error("No available renderer for the current environment");const i=new t;return await i.init(s),i}const ur="8.18.1";class Bl{static init(){var e;(e=globalThis.__PIXI_APP_INIT__)==null||e.call(globalThis,this,ur)}static destroy(){}}Bl.extension=b.Application;class kl{constructor(e){this._renderer=e}init(){var e;(e=globalThis.__PIXI_RENDERER_INIT__)==null||e.call(globalThis,this._renderer,ur)}destroy(){this._renderer=null}}kl.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"initHook",priority:-10};class Il{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let t,s;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;t=i,s=n}this.renderer.resize(t,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Il.extension=b.Application;class Fl{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{configurable:!0,set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Zt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Ue.shared:new Ue,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}Fl.extension=b.Application;V.add(Il);V.add(Fl);const Gl=class yi{constructor(...e){this.stage=new Te,e[0]!==void 0&&F(Z,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new Te),this.renderer=await cf(e),yi._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return F(Z,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var e;return(e=this.renderer.renderPipes.dom)==null?void 0:e._domElement}destroy(e=!1,t=!1){const s=yi._plugins.slice(0);s.reverse(),s.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};Gl._plugins=[];let uf=Gl;V.handleByList(b.Application,uf._plugins);V.add(Bl);const Vr={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){const e=r.match(/^[a-z]+\s+.+$/gm),t={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in e){const d=e[u].match(/^[a-z]+/gm)[0],f=e[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const g in f){const m=f[g].split("="),_=m[0],x=m[1].replace(/"/gm,""),y=parseFloat(x),T=isNaN(y)?x:y;p[_]=T}t[d].push(p)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[i]=t.info,[n]=t.common,[o]=t.distanceField??[];o&&(s.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),s.fontSize=parseInt(i.size,10),s.fontFamily=i.face,s.lineHeight=parseInt(n.lineHeight,10);const a=t.page;for(let u=0;u<a.length;u++)s.pages.push({id:parseInt(a[u].id,10)||0,file:a[u].file});const l={};s.baseLineOffset=s.lineHeight-parseInt(n.base,10);const h=t.char;for(let u=0;u<h.length;u++){const d=h[u],f=parseInt(d.id,10);let p=d.letter??d.char??String.fromCharCode(f);p==="space"&&(p=" "),l[f]=p,s.chars[p]={id:f,page:parseInt(d.page,10)||0,x:parseInt(d.x,10),y:parseInt(d.y,10),width:parseInt(d.width,10),height:parseInt(d.height,10),xOffset:parseInt(d.xoffset,10),yOffset:parseInt(d.yoffset,10),xAdvance:parseInt(d.xadvance,10),kerning:{}}}const c=t.kerning||[];for(let u=0;u<c.length;u++){const d=parseInt(c[u].first,10),f=parseInt(c[u].second,10),p=parseInt(c[u].amount,10);s.chars[l[f]]&&(s.chars[l[f]].kerning[l[d]]=p)}return s}},Ro={test(r){const e=r;return typeof e!="string"&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},t=r.getElementsByTagName("info")[0],s=r.getElementsByTagName("common")[0],i=r.getElementsByTagName("distanceField")[0];i&&(e.distanceField={type:i.getAttribute("fieldType"),range:parseInt(i.getAttribute("distanceRange"),10)});const n=r.getElementsByTagName("page"),o=r.getElementsByTagName("char"),a=r.getElementsByTagName("kerning");e.fontSize=parseInt(t.getAttribute("size"),10),e.fontFamily=t.getAttribute("face"),e.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let h=0;h<n.length;h++)e.pages.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});const l={};e.baseLineOffset=e.lineHeight-parseInt(s.getAttribute("base"),10);for(let h=0;h<o.length;h++){const c=o[h],u=parseInt(c.getAttribute("id"),10);let d=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(u);d==="space"&&(d=" "),l[u]=d,e.chars[d]={id:u,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let h=0;h<a.length;h++){const c=parseInt(a[h].getAttribute("first"),10),u=parseInt(a[h].getAttribute("second"),10),d=parseInt(a[h].getAttribute("amount"),10);e.chars[l[u]]&&(e.chars[l[u]].kerning[l[c]]=d)}return e}},Bo={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?Ro.test(z.get().parseXML(r)):!1},parse(r){return Ro.parse(z.get().parseXML(r))}},df=[".xml",".fnt"],ff={extension:{type:b.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string"&&r.fontFamily!=="",getCacheableAssets(r,e){const t={};return r.forEach(s=>{t[s]=e,t[`${s}-bitmap`]=e}),t[`${e.fontFamily}-bitmap`]=e,t}},pf={extension:{type:b.LoadParser,priority:ut.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return df.includes(Pe.extname(r).toLowerCase())},async testParse(r){return Vr.test(r)||Bo.test(r)},async parse(r,e,t){const s=Vr.test(r)?Vr.parse(r):Bo.parse(r),{src:i}=e,{pages:n}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;d<n.length;++d){const f=n[d].file;let p=Pe.join(Pe.dirname(i),f);p=di(p,i),o.push({src:p,data:a})}const[l,{BitmapFont:h}]=await Promise.all([t.load(o),zt(()=>Promise.resolve().then(()=>hy),void 0)]),c=o.map(d=>l[d.src]);return new h({data:s,textures:c},i)},async load(r,e){return await(await z.get().fetch(r)).text()},async unload(r,e,t){await Promise.all(r.pages.map(s=>t.unload(s.texture.source._sourceOrigin))),r.destroy()}};class mf{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;s<t;s++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}const gf={extension:{type:b.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(e=>e instanceof O),getCacheableAssets:(r,e)=>{const t={};return r.forEach(s=>{e.forEach((i,n)=>{t[s+(n===0?"":n+1)]=i})}),t}};async function Ul(r){if("Image"in globalThis)return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(r)).blob();await createImageBitmap(e)}catch{return!1}return!0}return!1}const _f={extension:{type:b.DetectionParser,priority:1},test:async()=>Ul("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(e=>e!=="avif")},ko=["png","jpg","jpeg"],xf={extension:{type:b.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...ko],remove:async r=>r.filter(e=>!ko.includes(e))},yf="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function xr(r){return yf?!1:document.createElement("video").canPlayType(r)!==""}const bf={extension:{type:b.DetectionParser,priority:0},test:async()=>xr("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(e=>e!=="mp4"&&e!=="m4v")},vf={extension:{type:b.DetectionParser,priority:0},test:async()=>xr("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(e=>e!=="ogv")},Tf={extension:{type:b.DetectionParser,priority:0},test:async()=>xr("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(e=>e!=="webm")},Sf={extension:{type:b.DetectionParser,priority:0},test:async()=>Ul("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(e=>e!=="webp")},Ol=class tr{constructor(){this.loadOptions={...tr.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,s)=>(this._parsersValidated=!1,e[t]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const s={promise:null,parser:null};return s.promise=(async()=>{var o,a;let i=null,n=null;if((t.parser||t.loadParser)&&(n=this._parserHash[t.parser||t.loadParser],t.loadParser&&W(`[Assets] "loadParser" is deprecated, use "parser" instead for ${e}`),n||W(`[Assets] specified load parser "${t.parser||t.loadParser}" not found while loading ${e}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,e,t,this))){n=h;break}}if(!n)return W(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}i=await n.load(e,t,this),s.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,i,t,this))&&(i=await h.parse(i,t,this)||i,s.parser=h)}return i})(),s}async load(e,t){this._parsersValidated||this._validateParsers();const s=typeof t=="function"?{...tr.defaultOptions,...this.loadOptions,onProgress:t}:{...tr.defaultOptions,...this.loadOptions,...t||{}},{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l}=s;let h=0;const c={},u=cr(e),d=Ne(e,g=>({alias:[g],src:g,data:{}})),f=d.reduce((g,m)=>g+(m.progressSize||1),0),p=d.map(async g=>{const m=Pe.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(m,g,{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l},c),h+=g.progressSize||1,i&&i(h/f))});return await Promise.all(p),u?c[d[0].src]:c}async unload(e){const s=Ne(e,i=>({alias:[i],src:i})).map(async i=>{var a,l;const n=Pe.toAbsolute(i.src),o=this.promiseCache[n];if(o){const h=await o.promise;delete this.promiseCache[n],await((l=(a=o.parser)==null?void 0:a.unload)==null?void 0:l.call(a,h,i,this))}});await Promise.all(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name||e.id).reduce((e,t)=>(!t.name&&!t.id?W("[Assets] parser should have an id"):(e[t.name]||e[t.id])&&W(`[Assets] parser id conflict "${t.id}"`),e[t.name]=t,t.id&&(e[t.id]=t),e),{})}async _loadAssetWithRetry(e,t,s,i){let n=0;const{onError:o,strategy:a,retryCount:l,retryDelay:h}=s,c=u=>new Promise(d=>setTimeout(d,u));for(;;)try{this.promiseCache[e]||(this.promiseCache[e]=this._getLoadPromiseAndParser(e,t)),i[t.src]=await this.promiseCache[e].promise;return}catch(u){delete this.promiseCache[e],delete i[t.src],n++;const d=a!=="retry"||n>l;if(a==="retry"&&!d){o&&o(u,t),await c(h);continue}if(a==="skip"){o&&o(u,t);return}o&&o(u,t);const f=new Error(`[Loader.load] Failed to load ${e}.
36
+ ${u}`);throw u instanceof Error&&u.stack&&(f.stack=u.stack),f}}};Ol.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let wf=Ol;function ss(r,e){if(Array.isArray(e)){for(const t of e)if(r.startsWith(`data:${t}`))return!0;return!1}return r.startsWith(`data:${e}`)}function rs(r,e){const t=r.split("?")[0],s=Pe.extname(t).toLowerCase();return Array.isArray(e)?e.includes(s):s===e}const Cf=".json",Af="application/json",Ef={extension:{type:b.LoadParser,priority:ut.Low},name:"loadJson",id:"json",test(r){return ss(r,Af)||rs(r,Cf)},async load(r){return await(await z.get().fetch(r)).json()}},Pf=".txt",Mf="text/plain",Rf={name:"loadTxt",id:"text",extension:{type:b.LoadParser,priority:ut.Low,name:"loadTxt"},test(r){return ss(r,Mf)||rs(r,Pf)},async load(r){return await(await z.get().fetch(r)).text()}},Bf=["normal","bold","100","200","300","400","500","600","700","800","900"],kf=[".ttf",".otf",".woff",".woff2"],If=["font/ttf","font/otf","font/woff","font/woff2"],Ff=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Gf(r){const e=Pe.extname(r),i=Pe.basename(r,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let n=i.length>0;for(const a of i)if(!a.match(Ff)){n=!1;break}let o=i.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const Uf=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Of(r){return Uf.test(r)?r:encodeURI(r)}const Df={extension:{type:b.LoadParser,priority:ut.Low},name:"loadWebFont",id:"web-font",test(r){return ss(r,If)||rs(r,kf)},async load(r,e){var s,i,n;const t=z.get().getFontFaceSet();if(t){const o=[],a=((s=e.data)==null?void 0:s.family)??Gf(r),l=((n=(i=e.data)==null?void 0:i.weights)==null?void 0:n.filter(c=>Bf.includes(c)))??["normal"],h=e.data??{};for(let c=0;c<l.length;c++){const u=l[c],d=new FontFace(a,`url('${Of(r)}')`,{...h,weight:u});await d.load(),t.add(d),o.push(d)}return se.has(`${a}-and-url`)?se.get(`${a}-and-url`).entries.push({url:r,faces:o}):se.set(`${a}-and-url`,{entries:[{url:r,faces:o}]}),o.length===1?o[0]:o}return W("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){const e=Array.isArray(r)?r:[r],t=e[0].family,s=se.get(`${t}-and-url`),i=s.entries.find(n=>n.faces.some(o=>e.indexOf(o)!==-1));i.faces=i.faces.filter(n=>e.indexOf(n)===-1),i.faces.length===0&&(s.entries=s.entries.filter(n=>n!==i)),e.forEach(n=>{z.get().getFontFaceSet().delete(n)}),s.entries.length===0&&se.remove(`${t}-and-url`)}};var Xr,Io;function Lf(){if(Io)return Xr;Io=1,Xr=t;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function t(n){var o=[];return n.replace(e,function(a,l,h){var c=l.toLowerCase();for(h=i(h),c=="m"&&h.length>2&&(o.push([l].concat(h.splice(0,2))),c="l",l=l=="m"?"l":"L");;){if(h.length==r[c])return h.unshift(l),o.push(h);if(h.length<r[c])throw new Error("malformed path data");o.push([l].concat(h.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 Xr}var Nf=Lf();const Wf=Da(Nf);function Hf(r,e){const t=Wf(r),s=[];let i=null,n=0,o=0;for(let a=0;a<t.length;a++){const l=t[a],h=l[0],c=l;switch(h){case"M":n=c[1],o=c[2],e.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],e.moveTo(n,o);break;case"H":n=c[1],e.lineTo(n,o);break;case"h":n+=c[1],e.lineTo(n,o);break;case"V":o=c[1],e.lineTo(n,o);break;case"v":o+=c[1],e.lineTo(n,o);break;case"L":n=c[1],o=c[2],e.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],e.lineTo(n,o);break;case"C":n=c[5],o=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":e.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],e.bezierCurveToShort(c[1],c[2],n,o);break;case"s":e.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],e.quadraticCurveTo(c[1],c[2],n,o);break;case"q":e.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],e.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],e.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":e.closePath(),s.length>0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:W(`Unknown SVG path command: ${h}`)}h!=="Z"&&h!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return e}class Wi{constructor(e=0,t=0,s=0){this.type="circle",this.x=e,this.y=t,this.radius=s}clone(){return new Wi(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-e,n=this.y-t;return i*=i,n*=n,i+n<=s}strokeContains(e,t,s,i=.5){if(this.radius===0)return!1;const n=this.x-e,o=this.y-t,a=this.radius,l=(1-i)*s,h=Math.sqrt(n*n+o*o);return h<=a+l&&h>a-(s-l)}getBounds(e){return e||(e=new Q),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Hi{constructor(e=0,t=0,s=0,i=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=s,this.halfHeight=i}clone(){return new Hi(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(e-this.x)/this.halfWidth,i=(t-this.y)/this.halfHeight;return s*=s,i*=i,s+i<=1}strokeContains(e,t,s,i=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=s*(1-i),l=s-a,h=n-l,c=o-l,u=n+a,d=o+a,f=e-this.x,p=t-this.y,g=f*f/(h*h)+p*p/(c*c),m=f*f/(u*u)+p*p/(d*d);return g>1&&m<=1}getBounds(e){return e||(e=new Q),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function zf(r,e,t,s,i,n){const o=r-t,a=e-s,l=i-t,h=n-s,c=o*l+a*h,u=l*l+h*h;let d=-1;u!==0&&(d=c/u);let f,p;d<0?(f=t,p=s):d>1?(f=i,p=n):(f=t+d*l,p=s+d*h);const g=r-f,m=e-p;return g*g+m*m}let Vf,Xf;class ys{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const s=[];for(let i=0,n=t.length;i<n;i++)s.push(t[i].x,t[i].y);t=s}this.points=t,this.closePath=!0}isClockwise(){let e=0;const t=this.points,s=t.length;for(let i=0;i<s;i+=2){const n=t[i],o=t[i+1],a=t[(i+2)%s],l=t[(i+3)%s];e+=(a-n)*(l+o)}return e<0}containsPolygon(e){const t=this.getBounds(Vf),s=e.getBounds(Xf);if(!t.containsRect(s))return!1;const i=e.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 e=this.points.slice(),t=new ys(e);return t.closePath=this.closePath,t}contains(e,t){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],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>t!=c>t&&e<(h-a)*((t-l)/(c-l))+a&&(s=!s)}return s}strokeContains(e,t,s,i=.5){const n=s*s,o=n*(1-i),a=n-o,{points:l}=this,h=l.length-(this.closePath?0:2);for(let c=0;c<h;c+=2){const u=l[c],d=l[c+1],f=l[(c+2)%l.length],p=l[(c+3)%l.length],g=zf(e,t,u,d,f,p),m=Math.sign((f-u)*(t-d)-(p-d)*(e-u));if(g<=(m<0?a:o))return!0}return!1}getBounds(e){e||(e=new Q);const t=this.points;let s=1/0,i=-1/0,n=1/0,o=-1/0;for(let a=0,l=t.length;a<l;a+=2){const h=t[a],c=t[a+1];s=h<s?h:s,i=h>i?h:i,n=c<n?c:n,o=c>o?c:o}return e.x=s,e.width=i-s,e.y=n,e.height=o-n,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return F("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return F("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 js=(r,e,t,s,i,n,o)=>{const a=r-t,l=e-s,h=Math.sqrt(a*a+l*l);return h>=i-n&&h<=i+o};class zi{constructor(e=0,t=0,s=0,i=0,n=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=s,this.height=i,this.radius=n}getBounds(e){return e||(e=new Q),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new zi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+s&&t<=this.y+this.height-s||e>=this.x+s&&e<=this.x+this.width-s)return!0;let i=e-(this.x+s),n=t-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=e-(this.x+this.width-s),i*i+n*n<=o)||(n=t-(this.y+this.height-s),i*i+n*n<=o)||(i=e-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(e,t,s,i=.5){const{x:n,y:o,width:a,height:l,radius:h}=this,c=s*(1-i),u=s-c,d=n+h,f=o+h,p=a-h*2,g=l-h*2,m=n+a,_=o+l;return(e>=n-c&&e<=n+u||e>=m-u&&e<=m+c)&&t>=f&&t<=f+g||(t>=o-c&&t<=o+u||t>=_-u&&t<=_+c)&&e>=d&&e<=d+p?!0:e<d&&t<f&&js(e,t,d,f,h,u,c)||e>m-h&&t<f&&js(e,t,m-h,f,h,u,c)||e>m-h&&t>_-h&&js(e,t,m-h,_-h,h,u,c)||e<d&&t>_-h&&js(e,t,d,_-h,h,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Dl={};function Vi(r,e,t){let s=2166136261;for(let i=0;i<e;i++)s^=r[i].uid,s=Math.imul(s,16777619),s>>>=0;return Dl[s]||$f(r,e,s,t)}function $f(r,e,t,s){const i={};let n=0;for(let a=0;a<s;a++){const l=a<e?r[a]:O.EMPTY.source;i[n++]=l.source,i[n++]=l.style}const o=new lt(i);return Dl[t]=o,o}class Fo{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),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(e){return this[`${e}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(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}function bi(r,e,t,s){if(t??(t=0),s??(s=Math.min(r.byteLength-t,e.byteLength)),!(t&7)&&!(s&7)){const i=s/8;new Float64Array(e,0,i).set(new Float64Array(r,t,i))}else if(!(t&3)&&!(s&3)){const i=s/4;new Float32Array(e,0,i).set(new Float32Array(r,t,i))}else new Uint8Array(e).set(new Uint8Array(r,t,s))}const jf={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var fe=(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))(fe||{});function Go(r,e){return e.alphaMode==="no-premultiply-alpha"&&jf[r]||r}const Yf=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
37
+ `);function qf(r){let e="";for(let t=0;t<r;++t)t>0&&(e+=`
38
+ else `),t<r-1&&(e+=`if(test == ${t}.0){}`);return e}function Ll(r,e){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const s=Yf.replace(/%forloop%/gi,qf(r));if(e.shaderSource(t,s),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))r=r/2|0;else break}}finally{e.deleteShader(t)}return r}let Ft=null;function Kf(){var e;if(Ft)return Ft;const r=gl();return Ft=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),Ft=Ll(Ft,r),(e=r.getExtension("WEBGL_lose_context"))==null||e.loseContext(),Ft}class Zf{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){const t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}class Qf{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Zf,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 bs=[];let dr=0;es.register({clear:()=>{if(bs.length>0)for(const r of bs)r&&r.destroy();bs.length=0,dr=0}});function Uo(){return dr>0?bs[--dr]:new Qf}function Oo(r){r.elements=null,bs[dr++]=r}let cs=0;const Nl=class Wl{constructor(e){this.uid=re("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...Wl.defaultOptions,...e},e.maxTextures||(F("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=Kf());const{maxTextures:t,attributesInitialSize:s,indicesInitialSize:i}=e;this.attributeBuffer=new Fo(s*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=t}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)Oo(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,t){const s=e._batch.textures.ids[t._source.uid];return!s&&s!==0?!1:(e._textureId=s,e.texture=t,!0)}updateElement(e){this.dirty=!0;const t=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId)}break(e){const t=this._elements;if(!t[this.elementStart])return;let s=Uo(),i=s.textures;i.clear();const n=t[this.elementStart];let o=Go(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 l=this.attributeBuffer.float32View,h=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 _=t[m];t[m]=null;const y=_.texture._source,T=Go(_.blendMode,y),S=o!==T||a!==_.topology;if(y._batchTick===cs&&!S){_._textureId=y._textureBindLocation,u+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,l,h,_._attributeStart,_._textureId),this.packQuadIndex(c,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,l,h,_._attributeStart,_._textureId),this.packIndex(_,c,_._indexStart,_._attributeStart/this.vertexSize)),_._batch=s,p.push(_);continue}y._batchTick=cs,(i.count>=g||S)&&(this._finishBatch(s,d,u-d,i,o,a,e,f,p),f="renderBatch",d=u,o=T,a=_.topology,s=Uo(),i=s.textures,i.clear(),p=[],++cs),_._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(_,l,h,_._attributeStart,_._textureId),this.packQuadIndex(c,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,l,h,_._attributeStart,_._textureId),this.packIndex(_,c,_._indexStart,_._attributeStart/this.vertexSize))}i.count>0&&(this._finishBatch(s,d,u-d,i,o,a,e,f,p),d=u,++cs),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(e,t,s,i,n,o,a,l,h){e.gpuBindGroup=null,e.bindGroup=null,e.action=l,e.batcher=this,e.textures=i,e.blendMode=n,e.topology=o,e.start=t,e.size=s,e.elements=h,++cs,this.batches[this.batchIndex++]=e,a.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){const t=Math.max(e,this.attributeBuffer.size*2),s=new Fo(t);bi(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(e){const t=this.indexBuffer;let s=Math.max(e,t.length*1.5);s+=s%2;const i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let n=0;n<t.length;n++)i[n]=t[n];else bi(t.buffer,i.buffer);this.indexBuffer=i}packQuadIndex(e,t,s){e[t]=s+0,e[t+1]=s+1,e[t+2]=s+2,e[t+3]=s+0,e[t+4]=s+2,e[t+5]=s+3}packIndex(e,t,s,i){const n=e.indices,o=e.indexSize,a=e.indexOffset,l=e.attributeOffset;for(let h=0;h<o;h++)t[s++]=i+n[h+a]-l}destroy(e={}){var t;if(this.batches!==null){for(let s=0;s<this.batchIndex;s++)Oo(this.batches[s]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&((t=this.shader)==null||t.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}}};Nl.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Jf=Nl;var oe=(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))(oe||{});class ht extends Re{constructor(e){let{data:t,size:s}=e;const{usage:i,label:n,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=re("buffer"),this._resourceType="buffer",this._resourceId=re("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array&&(t=new Float32Array(t)),this._data=t,s??(s=t==null?void 0:t.byteLength);const a=!!t;this.descriptor={size:s,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&oe.STATIC)}set static(e){e?this.descriptor.usage|=oe.STATIC:this.descriptor.usage&=~oe.STATIC}setDataWithSize(e,t,s){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){s&&this.emit("update",this);return}const i=this._data;if(this._data=e,this._dataInt32=null,!i||i.length!==e.length){!this.shrinkToFit&&i&&e.byteLength<i.byteLength?s&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=re("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(e){this._updateSize=e??this._updateSize,this._updateID++,this.emit("update",this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.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 Hl(r,e){if(!(r instanceof ht)){let t=e?oe.INDEX:oe.VERTEX;r instanceof Array&&(e?(r=new Uint32Array(r),t=oe.INDEX|oe.COPY_DST):(r=new Float32Array(r),t=oe.VERTEX|oe.COPY_DST)),r=new ht({data:r,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return r}function ep(r,e,t){const s=r.getAttribute(e);if(!s)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;const i=s.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const h=i.BYTES_PER_ELEMENT,c=(s.offset||0)/h,u=(s.stride||8)/h;for(let d=c;d<i.length;d+=u){const f=i[d],p=i[d+1];f>a&&(a=f),p>l&&(l=p),f<n&&(n=f),p<o&&(o=p)}return t.minX=n,t.minY=o,t.maxX=a,t.maxY=l,t}function tp(r){return(r instanceof ht||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=Hl(r.buffer,!1),r}class Xi extends Re{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=re("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new ye,this._boundsDirty=!0;const{attributes:t,indexBuffer:s,topology:i}=e;if(this.buffers=[],this.attributes={},t)for(const n in t)this.addAttribute(n,t[n]);this.instanceCount=e.instanceCount??1,s&&this.addIndex(s),this.topology=i||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}getSize(){for(const e in this.attributes){const t=this.attributes[e];return t.buffer.data.length/(t.stride/4||t.size)}return 0}addAttribute(e,t){const s=tp(t);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[e]=s}addIndex(e){this.indexBuffer=Hl(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,ep(this,"aPosition",this._bounds)):this._bounds}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!1){var t;this.emit("destroy",this),this.removeAllListeners(),e&&this.buffers.forEach(s=>s.destroy()),this.unload(),(t=this.indexBuffer)==null||t.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const sp=new Float32Array(1),rp=new Uint32Array(1);class ip extends Xi{constructor(){const t=new ht({data:sp,label:"attribute-batch-buffer",usage:oe.VERTEX|oe.COPY_DST,shrinkToFit:!1}),s=new ht({data:rp,label:"index-batch-buffer",usage:oe.INDEX|oe.COPY_DST,shrinkToFit:!1}),i=24;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:i,offset:0},aUV:{buffer:t,format:"float32x2",stride:i,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:i,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:i,offset:20}},indexBuffer:s})}}function Do(r,e,t){if(r)for(const s in r){const i=s.toLocaleLowerCase(),n=e[i];if(n){let o=r[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),t&&n.push(`//----${t}----//`),n.push(o)}else W(`${s} placement hook does not exist in shader`)}}const np=/\{\{(.*?)\}\}/g;function Lo(r){var s;const e={};return(((s=r.match(np))==null?void 0:s.map(i=>i.replace(/[{()}]/g,"")))??[]).forEach(i=>{e[i]=[]}),e}function No(r,e){let t;const s=/@in\s+([^;]+);/g;for(;(t=s.exec(r))!==null;)e.push(t[1])}function Wo(r,e,t=!1){const s=[];No(e,s),r.forEach(a=>{a.header&&No(a.header,s)});const i=s;t&&i.sort();const n=i.map((a,l)=>` @location(${l}) ${a},`).join(`
39
+ `);let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
40
+ ${n}
41
+ `),o}function Ho(r,e){let t;const s=/@out\s+([^;]+);/g;for(;(t=s.exec(r))!==null;)e.push(t[1])}function op(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function ap(r){const e=/@.*?\s+/g;return r.replace(e,"")}function lp(r,e){const t=[];Ho(e,t),r.forEach(l=>{l.header&&Ho(l.header,t)});let s=0;const i=t.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${s++}) ${l}`).join(`,
42
+ `),n=t.sort().map(l=>` var ${ap(l)};`).join(`
43
+ `),o=`return VSOutput(
44
+ ${t.sort().map(l=>` ${op(l)}`).join(`,
45
+ `)});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
46
+ ${i}
47
+ `),a=a.replace("{{start}}",`
48
+ ${n}
49
+ `),a=a.replace("{{return}}",`
50
+ ${o}
51
+ `),a}function zo(r,e){let t=r;for(const s in e){const i=e[s];i.join(`
52
+ `).length?t=t.replace(`{{${s}}}`,`//-----${s} START-----//
53
+ ${i.join(`
54
+ `)}
55
+ //----${s} FINISH----//`):t=t.replace(`{{${s}}}`,"")}return t}const at=Object.create(null),$r=new Map;let hp=0;function cp({template:r,bits:e}){const t=zl(r,e);if(at[t])return at[t];const{vertex:s,fragment:i}=dp(r,e);return at[t]=Vl(s,i,e),at[t]}function up({template:r,bits:e}){const t=zl(r,e);return at[t]||(at[t]=Vl(r.vertex,r.fragment,e)),at[t]}function dp(r,e){const t=e.map(o=>o.vertex).filter(o=>!!o),s=e.map(o=>o.fragment).filter(o=>!!o);let i=Wo(t,r.vertex,!0);i=lp(t,i);const n=Wo(s,r.fragment,!0);return{vertex:i,fragment:n}}function zl(r,e){return e.map(t=>($r.has(t)||$r.set(t,hp++),$r.get(t))).sort((t,s)=>t-s).join("-")+r.vertex+r.fragment}function Vl(r,e,t){const s=Lo(r),i=Lo(e);return t.forEach(n=>{Do(n.vertex,s,n.name),Do(n.fragment,i,n.name)}),{vertex:zo(r,s),fragment:zo(e,i)}}const fp=`
56
+ @in aPosition: vec2<f32>;
57
+ @in aUV: vec2<f32>;
58
+
59
+ @out @builtin(position) vPosition: vec4<f32>;
60
+ @out vUV : vec2<f32>;
61
+ @out vColor : vec4<f32>;
62
+
63
+ {{header}}
64
+
65
+ struct VSOutput {
66
+ {{struct}}
67
+ };
68
+
69
+ @vertex
70
+ fn main( {{in}} ) -> VSOutput {
71
+
72
+ var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
73
+ var modelMatrix = mat3x3<f32>(
74
+ 1.0, 0.0, 0.0,
75
+ 0.0, 1.0, 0.0,
76
+ 0.0, 0.0, 1.0
77
+ );
78
+ var position = aPosition;
79
+ var uv = aUV;
80
+
81
+ {{start}}
82
+
83
+ vColor = vec4<f32>(1., 1., 1., 1.);
84
+
85
+ {{main}}
86
+
87
+ vUV = uv;
88
+
89
+ var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
90
+
91
+ vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
92
+
93
+ vColor *= globalUniforms.uWorldColorAlpha;
94
+
95
+ {{end}}
96
+
97
+ {{return}}
98
+ };
99
+ `,pp=`
100
+ @in vUV : vec2<f32>;
101
+ @in vColor : vec4<f32>;
102
+
103
+ {{header}}
104
+
105
+ @fragment
106
+ fn main(
107
+ {{in}}
108
+ ) -> @location(0) vec4<f32> {
109
+
110
+ {{start}}
111
+
112
+ var outColor:vec4<f32>;
113
+
114
+ {{main}}
115
+
116
+ var finalColor:vec4<f32> = outColor * vColor;
117
+
118
+ {{end}}
119
+
120
+ return finalColor;
121
+ };
122
+ `,mp=`
123
+ in vec2 aPosition;
124
+ in vec2 aUV;
125
+
126
+ out vec4 vColor;
127
+ out vec2 vUV;
128
+
129
+ {{header}}
130
+
131
+ void main(void){
132
+
133
+ mat3 worldTransformMatrix = uWorldTransformMatrix;
134
+ mat3 modelMatrix = mat3(
135
+ 1.0, 0.0, 0.0,
136
+ 0.0, 1.0, 0.0,
137
+ 0.0, 0.0, 1.0
138
+ );
139
+ vec2 position = aPosition;
140
+ vec2 uv = aUV;
141
+
142
+ {{start}}
143
+
144
+ vColor = vec4(1.);
145
+
146
+ {{main}}
147
+
148
+ vUV = uv;
149
+
150
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
151
+
152
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
153
+
154
+ vColor *= uWorldColorAlpha;
155
+
156
+ {{end}}
157
+ }
158
+ `,gp=`
159
+
160
+ in vec4 vColor;
161
+ in vec2 vUV;
162
+
163
+ out vec4 finalColor;
164
+
165
+ {{header}}
166
+
167
+ void main(void) {
168
+
169
+ {{start}}
170
+
171
+ vec4 outColor;
172
+
173
+ {{main}}
174
+
175
+ finalColor = outColor * vColor;
176
+
177
+ {{end}}
178
+ }
179
+ `,_p={name:"global-uniforms-bit",vertex:{header:`
180
+ struct GlobalUniforms {
181
+ uProjectionMatrix:mat3x3<f32>,
182
+ uWorldTransformMatrix:mat3x3<f32>,
183
+ uWorldColorAlpha: vec4<f32>,
184
+ uResolution: vec2<f32>,
185
+ }
186
+
187
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
188
+ `}},xp={name:"global-uniforms-bit",vertex:{header:`
189
+ uniform mat3 uProjectionMatrix;
190
+ uniform mat3 uWorldTransformMatrix;
191
+ uniform vec4 uWorldColorAlpha;
192
+ uniform vec2 uResolution;
193
+ `}};function $i({bits:r,name:e}){const t=cp({template:{fragment:pp,vertex:fp},bits:[_p,...r]});return st.from({name:e,vertex:{source:t.vertex,entryPoint:"main"},fragment:{source:t.fragment,entryPoint:"main"}})}function ji({bits:r,name:e}){return new dt({name:e,...up({template:{vertex:mp,fragment:gp},bits:[xp,...r]})})}const Xl={name:"color-bit",vertex:{header:`
194
+ @in aColor: vec4<f32>;
195
+ `,main:`
196
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
197
+ `}},$l={name:"color-bit",vertex:{header:`
198
+ in vec4 aColor;
199
+ `,main:`
200
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
201
+ `}},jr={};function yp(r){const e=[];if(r===1)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let t=0;for(let s=0;s<r;s++)e.push(`@group(1) @binding(${t++}) var textureSource${s+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${t++}) var textureSampler${s+1}: sampler;`)}return e.join(`
202
+ `)}function bp(r){const e=[];if(r===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let t=0;t<r;t++)t===r-1?e.push(" default:{"):e.push(` case ${t}:{`),e.push(` outColor = textureSampleGrad(textureSource${t+1}, textureSampler${t+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join(`
203
+ `)}function jl(r){return jr[r]||(jr[r]={name:"texture-batch-bit",vertex:{header:`
204
+ @in aTextureIdAndRound: vec2<u32>;
205
+ @out @interpolate(flat) vTextureId : u32;
206
+ `,main:`
207
+ vTextureId = aTextureIdAndRound.y;
208
+ `,end:`
209
+ if(aTextureIdAndRound.x == 1)
210
+ {
211
+ vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
212
+ }
213
+ `},fragment:{header:`
214
+ @in @interpolate(flat) vTextureId: u32;
215
+
216
+ ${yp(r)}
217
+ `,main:`
218
+ var uvDx = dpdx(vUV);
219
+ var uvDy = dpdy(vUV);
220
+
221
+ ${bp(r)}
222
+ `}}),jr[r]}const Yr={};function vp(r){const e=[];for(let t=0;t<r;t++)t>0&&e.push("else"),t<r-1&&e.push(`if(vTextureId < ${t}.5)`),e.push("{"),e.push(` outColor = texture(uTextures[${t}], vUV);`),e.push("}");return e.join(`
223
+ `)}function Yl(r){return Yr[r]||(Yr[r]={name:"texture-batch-bit",vertex:{header:`
224
+ in vec2 aTextureIdAndRound;
225
+ out float vTextureId;
226
+
227
+ `,main:`
228
+ vTextureId = aTextureIdAndRound.y;
229
+ `,end:`
230
+ if(aTextureIdAndRound.x == 1.)
231
+ {
232
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
233
+ }
234
+ `},fragment:{header:`
235
+ in float vTextureId;
236
+
237
+ uniform sampler2D uTextures[${r}];
238
+
239
+ `,main:`
240
+
241
+ ${vp(r)}
242
+ `}}),Yr[r]}const Yi={name:"round-pixels-bit",vertex:{header:`
243
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
244
+ {
245
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
246
+ }
247
+ `}},qi={name:"round-pixels-bit",vertex:{header:`
248
+ vec2 roundPixels(vec2 position, vec2 targetSize)
249
+ {
250
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
251
+ }
252
+ `}},Vo={};function ql(r){let e=Vo[r];if(e)return e;const t=new Int32Array(r);for(let s=0;s<r;s++)t[s]=s;return e=Vo[r]=new We({uTextures:{value:t,type:"i32",size:r}},{isStatic:!0}),e}class Xo extends rt{constructor(e){const t=ji({name:"batch",bits:[$l,Yl(e),qi]}),s=$i({name:"batch",bits:[Xl,jl(e),Yi]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:ql(e)}}),this.maxTextures=e}}let us=null;const Kl=class Zl extends Jf{constructor(e){super(e),this.geometry=new ip,this.name=Zl.extension.name,this.vertexSize=6,us??(us=new Xo(e.maxTextures)),this.shader=us}packAttributes(e,t,s,i,n){const o=n<<16|e.roundPixels&65535,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,{positions:p,uvs:g}=e,m=e.color,_=e.attributeOffset,x=_+e.attributeSize;for(let y=_;y<x;y++){const T=y*2,S=p[T],v=p[T+1];t[i++]=l*S+c*v+d,t[i++]=u*v+h*S+f,t[i++]=g[T],t[i++]=g[T+1],s[i++]=m,s[i++]=o}}packQuadAttributes(e,t,s,i,n){const o=e.texture,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,p=e.bounds,g=p.maxX,m=p.minX,_=p.maxY,x=p.minY,y=o.uvs,T=e.color,S=n<<16|e.roundPixels&65535;t[i+0]=l*m+c*x+d,t[i+1]=u*x+h*m+f,t[i+2]=y.x0,t[i+3]=y.y0,s[i+4]=T,s[i+5]=S,t[i+6]=l*g+c*x+d,t[i+7]=u*x+h*g+f,t[i+8]=y.x1,t[i+9]=y.y1,s[i+10]=T,s[i+11]=S,t[i+12]=l*g+c*_+d,t[i+13]=u*_+h*g+f,t[i+14]=y.x2,t[i+15]=y.y2,s[i+16]=T,s[i+17]=S,t[i+18]=l*m+c*_+d,t[i+19]=u*_+h*m+f,t[i+20]=y.x3,t[i+21]=y.y3,s[i+22]=T,s[i+23]=S}_updateMaxTextures(e){this.shader.maxTextures!==e&&(us=new Xo(e),this.shader=us)}destroy(){this.shader=null,super.destroy()}};Kl.extension={type:[b.Batcher],name:"default"};let Ki=Kl;class je{constructor(e){this.items=Object.create(null);const{renderer:t,type:s,onUnload:i,priority:n,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",s,n??0),this._onUnload=i,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){var i;if(!this.items[e.uid])return;const s=e._gpuData[this._renderer.uid];s&&((i=this._onUnload)==null||i.call(this,e,...t),s.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function Tp(r,e,t,s,i,n,o,a=null){let l=0;t*=e,i*=n;const h=a.a,c=a.b,u=a.c,d=a.d,f=a.tx,p=a.ty;for(;l<o;){const g=r[t],m=r[t+1];s[i]=h*g+u*m+f,s[i+1]=c*g+d*m+p,i+=n,t+=e,l++}}function Sp(r,e,t,s){let i=0;for(e*=t;i<s;)r[e]=0,r[e+1]=0,e+=t,i++}function Ql(r,e,t,s,i){const n=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;t||(t=0),s||(s=2),i||(i=r.length/s-t);let u=t*s;for(let d=0;d<i;d++){const f=r[u],p=r[u+1];r[u]=n*f+a*p+h,r[u+1]=o*f+l*p+c,u+=s}}const wp=new G;class Zi{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 e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,s=this.renderable;return s?Vt(t,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){var e;return((e=this.renderable)==null?void 0:e.groupTransform)||wp}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.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 Ps={extension:{type:b.ShapeBuilder,name:"circle"},build(r,e){let t,s,i,n,o,a;if(r.type==="circle"){const T=r;if(o=a=T.radius,o<=0)return!1;t=T.x,s=T.y,i=n=0}else if(r.type==="ellipse"){const T=r;if(o=T.halfWidth,a=T.halfHeight,o<=0||a<=0)return!1;t=T.x,s=T.y,i=n=0}else{const T=r,S=T.width/2,v=T.height/2;t=T.x+S,s=T.y+v,o=a=Math.max(0,Math.min(T.radius,Math.min(S,v))),i=S-o,n=v-a}if(i<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(i?4:0)+(n?4:0);if(h===0)return!1;if(l===0)return e[0]=e[6]=t+i,e[1]=e[3]=s+n,e[2]=e[4]=t-i,e[5]=e[7]=s-n,!0;let c=0,u=l*4+(i?2:0)+2,d=u,f=h,p=i+o,g=n,m=t+p,_=t-p,x=s+g;if(e[c++]=m,e[c++]=x,e[--u]=x,e[--u]=_,n){const T=s-g;e[d++]=_,e[d++]=T,e[--f]=T,e[--f]=m}for(let T=1;T<l;T++){const S=Math.PI/2*(T/l),v=i+Math.cos(S)*o,w=n+Math.sin(S)*a,A=t+v,R=t-v,C=s+w,E=s-w;e[c++]=A,e[c++]=C,e[--u]=C,e[--u]=R,e[d++]=R,e[d++]=E,e[--f]=E,e[--f]=A}p=i,g=n+a,m=t+p,_=t-p,x=s+g;const y=s-g;return e[c++]=m,e[c++]=x,e[--f]=y,e[--f]=m,i&&(e[c++]=_,e[c++]=x,e[--f]=y,e[--f]=_),!0},triangulate(r,e,t,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 l=s;e[l*t]=o,e[l*t+1]=a;const h=l++;for(let c=0;c<r.length;c+=2)e[l*t]=r[c],e[l*t+1]=r[c+1],c>0&&(i[n++]=l,i[n++]=h,i[n++]=l-1),l++;i[n++]=h+1,i[n++]=h,i[n++]=l-1}},Cp={...Ps,extension:{...Ps.extension,name:"ellipse"}},Ap={...Ps,extension:{...Ps.extension,name:"roundedRectangle"}},Jl=1e-4,$o=1e-4;function Ep(r){const e=r.length;if(e<6)return 1;let t=0;for(let s=0,i=r[e-2],n=r[e-1];s<e;s+=2){const o=r[s],a=r[s+1];t+=(o-i)*(a+n),i=o,n=a}return t<0?-1:1}function jo(r,e,t,s,i,n,o,a){const l=r-t*i,h=e-s*i,c=r+t*n,u=e+s*n;let d,f;o?(d=s,f=-t):(d=-s,f=t);const p=l+d,g=h+f,m=c+d,_=u+f;return a.push(p,g),a.push(m,_),2}function pt(r,e,t,s,i,n,o,a){const l=t-r,h=s-e;let c=Math.atan2(l,h),u=Math.atan2(i-r,n-e);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(l*l+h*h),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/m;if(d+=_,a){o.push(r,e),o.push(t,s);for(let x=1,y=d;x<m;x++,y+=_)o.push(r,e),o.push(r+Math.sin(y)*g,e+Math.cos(y)*g);o.push(r,e),o.push(i,n)}else{o.push(t,s),o.push(r,e);for(let x=1,y=d;x<m;x++,y+=_)o.push(r+Math.sin(y)*g,e+Math.cos(y)*g),o.push(r,e);o.push(i,n),o.push(r,e)}return m*2}function Qi(r,e,t,s,i,n){const o=Jl;if(r.length===0)return;const a=e;let l=a.alignment;if(e.alignment!==.5){let B=Ep(r);l=(l-.5)*B+.5}const h=new ie(r[0],r[1]),c=new ie(r[r.length-2],r[r.length-1]),u=s,d=Math.abs(h.x-c.x)<o&&Math.abs(h.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 B=(h.x+c.x)*.5,N=(c.y+h.y)*.5;r.unshift(B,N),r.push(B,N)}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 T=r[0],S=r[1],v=r[2],w=r[3],A=0,R=0,C=-(S-w),E=T-v,P=0,k=0,U=Math.sqrt(C*C+E*E);C/=U,E/=U,C*=_,E*=_;const he=l,M=(1-he)*2,I=he*2;u||(a.cap==="round"?g+=pt(T-C*(M-I)*.5,S-E*(M-I)*.5,T-C*M,S-E*M,T+C*I,S+E*I,f,!0)+2:a.cap==="square"&&(g+=jo(T,S,C,E,M,I,!0,f))),f.push(T-C*M,S-E*M),f.push(T+C*I,S+E*I);for(let B=1;B<p-1;++B){T=r[(B-1)*2],S=r[(B-1)*2+1],v=r[B*2],w=r[B*2+1],A=r[(B+1)*2],R=r[(B+1)*2+1],C=-(S-w),E=T-v,U=Math.sqrt(C*C+E*E),C/=U,E/=U,C*=_,E*=_,P=-(w-R),k=v-A,U=Math.sqrt(P*P+k*k),P/=U,k/=U,P*=_,k*=_;const N=v-T,Y=S-w,D=v-A,q=R-w,ne=N*D+Y*q,ae=Y*D-q*N,J=ae<0;if(Math.abs(ae)<.001*Math.abs(ne)){f.push(v-C*M,w-E*M),f.push(v+C*I,w+E*I),ne>=0&&(a.join==="round"?g+=pt(v,w,v-C*M,w-E*M,v-P*M,w-k*M,f,!1)+4:g+=2,f.push(v-P*I,w-k*I),f.push(v+P*M,w+k*M));continue}const pe=(-C+T)*(-E+w)-(-C+v)*(-E+S),be=(-P+A)*(-k+w)-(-P+v)*(-k+R),X=(N*be-D*pe)/ae,we=(q*pe-Y*be)/ae,Be=(X-v)*(X-v)+(we-w)*(we-w),de=v+(X-v)*M,He=w+(we-w)*M,Oe=v-(X-v)*I,ke=w-(we-w)*I,Pt=Math.min(N*N+Y*Y,D*D+q*q),Mt=J?M:I,ns=Pt+Mt*Mt*x;Be<=ns?a.join==="bevel"||Be/x>y?(J?(f.push(de,He),f.push(v+C*I,w+E*I),f.push(de,He),f.push(v+P*I,w+k*I)):(f.push(v-C*M,w-E*M),f.push(Oe,ke),f.push(v-P*M,w-k*M),f.push(Oe,ke)),g+=2):a.join==="round"?J?(f.push(de,He),f.push(v+C*I,w+E*I),g+=pt(v,w,v+C*I,w+E*I,v+P*I,w+k*I,f,!0)+4,f.push(de,He),f.push(v+P*I,w+k*I)):(f.push(v-C*M,w-E*M),f.push(Oe,ke),g+=pt(v,w,v-C*M,w-E*M,v-P*M,w-k*M,f,!1)+4,f.push(v-P*M,w-k*M),f.push(Oe,ke)):(f.push(de,He),f.push(Oe,ke)):(f.push(v-C*M,w-E*M),f.push(v+C*I,w+E*I),a.join==="round"?J?g+=pt(v,w,v+C*I,w+E*I,v+P*I,w+k*I,f,!0)+2:g+=pt(v,w,v-C*M,w-E*M,v-P*M,w-k*M,f,!1)+2:a.join==="miter"&&Be/x<=y&&(J?(f.push(Oe,ke),f.push(Oe,ke)):(f.push(de,He),f.push(de,He)),g+=2),f.push(v-P*M,w-k*M),f.push(v+P*I,w+k*I),g+=2)}T=r[(p-2)*2],S=r[(p-2)*2+1],v=r[(p-1)*2],w=r[(p-1)*2+1],C=-(S-w),E=T-v,U=Math.sqrt(C*C+E*E),C/=U,E/=U,C*=_,E*=_,f.push(v-C*M,w-E*M),f.push(v+C*I,w+E*I),u||(a.cap==="round"?g+=pt(v-C*(M-I)*.5,w-E*(M-I)*.5,v-C*M,w-E*M,v+C*I,w+E*I,f,!1)+2:a.cap==="square"&&(g+=jo(v,w,C,E,M,I,!1,f)));const L=$o*$o;for(let B=m;B<g+m-2;++B)T=f[B*2],S=f[B*2+1],v=f[(B+1)*2],w=f[(B+1)*2+1],A=f[(B+2)*2],R=f[(B+2)*2+1],!(Math.abs(T*(w-R)+v*(R-S)+A*(S-w))<L)&&n.push(B,B+1,B+2)}function Pp(r,e,t,s){const i=Jl;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],l=r[r.length-1],h=e||Math.abs(n-a)<i&&Math.abs(o-l)<i,c=t,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);h&&s.push(d+u-1,d)}function eh(r,e,t,s,i,n,o){const a=of(r,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)n[o++]=a[h]+i,n[o++]=a[h+1]+i,n[o++]=a[h+2]+i;let l=i*s;for(let h=0;h<r.length;h+=2)t[l]=r[h],t[l+1]=r[h+1],l+=s}const Mp=[],Rp={extension:{type:b.ShapeBuilder,name:"polygon"},build(r,e){for(let t=0;t<r.points.length;t++)e[t]=r.points[t];return!0},triangulate(r,e,t,s,i,n){eh(r,Mp,e,t,s,i,n)}},Bp={extension:{type:b.ShapeBuilder,name:"rectangle"},build(r,e){const t=r,s=t.x,i=t.y,n=t.width,o=t.height;return n>0&&o>0?(e[0]=s,e[1]=i,e[2]=s+n,e[3]=i,e[4]=s+n,e[5]=i+o,e[6]=s,e[7]=i+o,!0):!1},triangulate(r,e,t,s,i,n){let o=0;s*=t,e[s+o]=r[0],e[s+o+1]=r[1],o+=t,e[s+o]=r[2],e[s+o+1]=r[3],o+=t,e[s+o]=r[6],e[s+o+1]=r[7],o+=t,e[s+o]=r[4],e[s+o+1]=r[5],o+=t;const a=s/t;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},kp={extension:{type:b.ShapeBuilder,name:"triangle"},build(r,e){return e[0]=r.x,e[1]=r.y,e[2]=r.x2,e[3]=r.y2,e[4]=r.x3,e[5]=r.y3,!0},triangulate(r,e,t,s,i,n){let o=0;s*=t,e[s+o]=r[0],e[s+o+1]=r[1],o+=t,e[s+o]=r[2],e[s+o+1]=r[3],o+=t,e[s+o]=r[4],e[s+o+1]=r[5];const a=s/t;i[n++]=a,i[n++]=a+1,i[n++]=a+2}},Yo=[{offset:0,color:"white"},{offset:1,color:"black"}],Ji=class vi{constructor(...e){this.uid=re("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=Ip(e);t={...t.type==="radial"?vi.defaultRadialOptions:vi.defaultLinearOptions,...Wa(t)},this._textureSize=t.textureSize,this._wrapMode=t.wrapMode,t.type==="radial"?(this.center=t.center,this.outerCenter=t.outerCenter??this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(i=>{this.addColorStop(i.offset,i.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:ee.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:s,y:i}=this.end,n=s-e,o=i-t;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=e;e=s,s=m,n*=-1}if(o<0){const m=t;t=i,i=m,o*=-1}}const l=this.colorStops.length?this.colorStops:Yo,h=this._textureSize,{canvas:c,context:u}=Ko(h,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);qo(d,l),u.fillStyle=d,u.fillRect(0,0,h,1),this.texture=new O({source:new Ct({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),g=new G;g.scale(f/h,1),g.rotate(p),g.translate(e,t),this.textureSpace==="local"&&g.scale(h,h),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:Yo,t=this._textureSize,{canvas:s,context:i}=Ko(t,t),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,h=this.innerRadius,c=this.outerRadius,u=a-c,d=l-c,f=t/(c*2),p=(n-u)*f,g=(o-d)*f,m=i.createRadialGradient(p,g,h*f,(a-u)*f,(l-d)*f,c*f);qo(m,e),i.fillStyle=e[e.length-1].color,i.fillRect(0,0,t,t),i.fillStyle=m,i.translate(p,g),i.rotate(this.rotation),i.scale(1,this.scale),i.translate(-p,-g),i.fillRect(0,0,t,t),this.texture=new O({source:new Ct({resource:s,addressMode:this._wrapMode})});const _=new G;_.scale(1/f,1/f),_.translate(u,d),this.textureSpace==="local"&&_.scale(t,t),this.transform=_}destroy(){var e;(e=this.texture)==null||e.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}`}};Ji.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Ji.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let $e=Ji;function qo(r,e){for(let t=0;t<e.length;t++){const s=e[t];r.addColorStop(s.offset,s.color)}}function Ko(r,e){const t=z.get().createCanvas(r,e),s=t.getContext("2d");return{canvas:t,context:s}}function Ip(r){let e=r[0]??{};return(typeof e=="number"||r[1])&&(F("8.5.2","use options object instead"),e={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:r[5]??$e.defaultLinearOptions.textureSize}),e}const Fp=new G,Gp=new Q;function th(r,e,t,s){const i=e.matrix?r.copyFrom(e.matrix).invert():r.identity();if(e.textureSpace==="local"){const o=t.getBounds(Gp);e.width&&o.pad(e.width);const{x:a,y:l}=o,h=1/o.width,c=1/o.height,u=-a*h,d=-l*c,f=i.a,p=i.b,g=i.c,m=i.d;i.a*=h,i.b*=h,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(e.texture.frame.x,e.texture.frame.y),i.scale(1/e.texture.source.width,1/e.texture.source.height);const n=e.texture.source.style;return!(e.fill instanceof $e)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),s&&i.append(Fp.copyFrom(s).invert()),i}const is={};V.handleByMap(b.ShapeBuilder,is);V.add(Bp,Rp,kp,Ps,Cp,Ap);const Up=new Q,Op=new G;function Dp(r,e){const{geometryData:t,batches:s}=e;s.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let i=0;i<r.instructions.length;i++){const n=r.instructions[i];if(n.action==="texture")Lp(n.data,s,t);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,h=n.data.hole;o&&h&&Zo(h.shapePath,l,!0,s,t),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),Zo(a,l,o,s,t)}}}function Lp(r,e,t){const s=[],i=is.rectangle,n=Up;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:l,indices:h}=t,c=h.length,u=a.length/2;o&&Ql(s,o),i.triangulate(s,a,2,u,h,c);const d=r.image,f=d.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=_e.get(Zi);p.indexOffset=c,p.indexSize=h.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=r.style,p.alpha=r.alpha,p.texture=d,p.geometryData=t,e.push(p)}function Zo(r,e,t,s,i){const{vertices:n,uvs:o,indices:a}=i;r.shapePrimitives.forEach(({shape:l,transform:h,holes:c})=>{const u=[],d=is[l.type];if(!d.build(l,u))return;const f=a.length,p=n.length/2;let g="triangle-list";if(h&&Ql(u,h),t){const y=l.closePath??!0,T=e;T.pixelLine?(Pp(u,y,n,a),g="line-list"):Qi(u,T,!1,y,n,a)}else if(c){const y=[],T=u.slice();Np(c).forEach(v=>{y.push(T.length/2),T.push(...v)}),eh(T,y,n,2,p,a,f)}else d.triangulate(u,n,2,p,a,f);const m=o.length/2,_=e.texture;if(_!==O.WHITE){const y=th(Op,e,l,h);Tp(n,2,p,o,m,2,n.length/2-p,y)}else Sp(o,m,2,n.length/2-p);const x=_e.get(Zi);x.indexOffset=f,x.indexSize=a.length-f,x.attributeOffset=p,x.attributeSize=n.length/2-p,x.baseColor=e.color,x.alpha=e.alpha,x.texture=_,x.geometryData=i,x.topology=g,s.push(x)})}function Np(r){const e=[];for(let t=0;t<r.length;t++){const s=r[t].shape,i=[];is[s.type].build(s,i)&&e.push(i)}return e}class Wp{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{_e.return(e)}),this.graphicsData&&_e.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 Hp{constructor(){this.instructions=new Oi}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new Ki({maxTextures:t}),this.instructions.reset()}get geometry(){return F(wu,"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 en=class Ti{constructor(e){this._renderer=e,this._managedContexts=new je({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Ti.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Ti.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=!!e._gpuData[this._renderer.uid],s=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&s.reset(),Dp(e,s);const i=e.batchMode;e.customShader||i==="no-batch"?s.isBatchable=!1:i==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,e.dirty=!1}return s}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=_e.get(Hp,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=e._gpuData[this._renderer.uid],{batches:i,geometryData:n}=s;s.graphicsData=t;const o=n.vertices.length,a=n.indices.length;for(let u=0;u<i.length;u++)i[u].applyTransform=!1;const l=t.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let u=0;u<i.length;u++){const d=i[u];l.add(d)}l.finish(t.instructions);const h=l.geometry;h.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),h.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);const c=l.batches;for(let u=0;u<c.length;u++){const d=c[u];d.bindGroup=Vi(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new Wp;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};en.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"graphicsContext"};en.defaultOptions={bezierSmoothness:.5};let tn=en;const zp=8,Ys=11920929e-14,Vp=1;function sh(r,e,t,s,i,n,o,a,l,h){const u=Math.min(.99,Math.max(0,h??tn.defaultOptions.bezierSmoothness));let d=(Vp-u)/1;return d*=d,Xp(e,t,s,i,n,o,a,l,r,d),r}function Xp(r,e,t,s,i,n,o,a,l,h){Si(r,e,t,s,i,n,o,a,l,h,0),l.push(o,a)}function Si(r,e,t,s,i,n,o,a,l,h,c){if(c>zp)return;const u=(r+t)/2,d=(e+s)/2,f=(t+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,T=(p+m)/2,S=(_+y)/2,v=(x+T)/2;if(c>0){let w=o-r,A=a-e;const R=Math.abs((t-o)*A-(s-a)*w),C=Math.abs((i-o)*A-(n-a)*w);if(R>Ys&&C>Ys){if((R+C)*(R+C)<=h*(w*w+A*A)){l.push(S,v);return}}else if(R>Ys){if(R*R<=h*(w*w+A*A)){l.push(S,v);return}}else if(C>Ys){if(C*C<=h*(w*w+A*A)){l.push(S,v);return}}else if(w=S-(r+o)/2,A=v-(e+a)/2,w*w+A*A<=h){l.push(S,v);return}}Si(r,e,u,d,_,x,S,v,l,h,c+1),Si(S,v,y,T,g,m,o,a,l,h,c+1)}const $p=8,jp=11920929e-14,Yp=1;function qp(r,e,t,s,i,n,o,a){const h=Math.min(.99,Math.max(0,a??tn.defaultOptions.bezierSmoothness));let c=(Yp-h)/1;return c*=c,Kp(e,t,s,i,n,o,r,c),r}function Kp(r,e,t,s,i,n,o,a){wi(o,r,e,t,s,i,n,a,0),o.push(i,n)}function wi(r,e,t,s,i,n,o,a,l){if(l>$p)return;const h=(e+s)/2,c=(t+i)/2,u=(s+n)/2,d=(i+o)/2,f=(h+u)/2,p=(c+d)/2;let g=n-e,m=o-t;const _=Math.abs((s-n)*m-(i-o)*g);if(_>jp){if(_*_<=a*(g*g+m*m)){r.push(f,p);return}}else if(g=f-(e+n)/2,m=p-(t+o)/2,g*g+m*m<=a){r.push(f,p);return}wi(r,e,t,h,c,f,p,a,l+1),wi(r,f,p,u,d,n,o,a,l+1)}function rh(r,e,t,s,i,n,o,a){let l=Math.abs(i-n);(!o&&i>n||o&&n>i)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(l/Math.PI)))),a=Math.max(a,3);let h=l/a,c=i;h*=o?-1:1;for(let u=0;u<a+1;u++){const d=Math.cos(c),f=Math.sin(c),p=e+d*s,g=t+f*s;r.push(p,g),c+=h}}function Zp(r,e,t,s,i,n){const o=r[r.length-2],l=r[r.length-1]-t,h=o-e,c=i-t,u=s-e,d=Math.abs(l*u-h*c);if(d<1e-8||n===0){(r[r.length-2]!==e||r[r.length-1]!==t)&&r.push(e,t);return}const f=l*l+h*h,p=c*c+u*u,g=l*c+h*u,m=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,x=m*g/f,y=_*g/p,T=m*u+_*h,S=m*c+_*l,v=h*(_+x),w=l*(_+x),A=u*(m+y),R=c*(m+y),C=Math.atan2(w-S,v-T),E=Math.atan2(R-S,A-T);rh(r,T+e,S+t,n,C,E,h*c>u*l)}const vs=Math.PI*2,qr={centerX:0,centerY:0,ang1:0,ang2:0},Kr=({x:r,y:e},t,s,i,n,o,a,l)=>{r*=t,e*=s;const h=i*r-n*e,c=n*r+i*e;return l.x=h+o,l.y=c+a,l};function Qp(r,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),s=e===1.5707963267948966?.551915024494:t,i=Math.cos(r),n=Math.sin(r),o=Math.cos(r+e),a=Math.sin(r+e);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Qo=(r,e,t,s)=>{const i=r*s-e*t<0?-1:1;let n=r*t+e*s;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},Jp=(r,e,t,s,i,n,o,a,l,h,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,T=h*x-l*y+(r+t)/2,S=l*x+h*y+(e+s)/2,v=(c-x)/i,w=(u-y)/n,A=(-c-x)/i,R=(-u-y)/n,C=Qo(1,0,v,w);let E=Qo(v,w,A,R);a===0&&E>0&&(E-=vs),a===1&&E<0&&(E+=vs),d.centerX=T,d.centerY=S,d.ang1=C,d.ang2=E};function em(r,e,t,s,i,n,o,a=0,l=0,h=0){if(n===0||o===0)return;const c=Math.sin(a*vs/360),u=Math.cos(a*vs/360),d=u*(e-s)/2+c*(t-i)/2,f=-c*(e-s)/2+u*(t-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)),Jp(e,t,s,i,n,o,l,h,c,u,d,f,qr);let{ang1:g,ang2:m}=qr;const{centerX:_,centerY:x}=qr;let y=Math.abs(m)/(vs/4);Math.abs(1-y)<1e-7&&(y=1);const T=Math.max(Math.ceil(y),1);m/=T;let S=r[r.length-2],v=r[r.length-1];const w={x:0,y:0};for(let A=0;A<T;A++){const R=Qp(g,m),{x:C,y:E}=Kr(R[0],n,o,u,c,_,x,w),{x:P,y:k}=Kr(R[1],n,o,u,c,_,x,w),{x:U,y:he}=Kr(R[2],n,o,u,c,_,x,w);sh(r,S,v,C,E,P,k,U,he),S=U,v=he,g+=m}}function tm(r,e,t){const s=(o,a)=>{const l=a.x-o.x,h=a.y-o.y,c=Math.sqrt(l*l+h*h),u=l/c,d=h/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=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],l=a.radius??t;if(l<=0){i(o,a),n=a;continue}const h=e[(o+1)%e.length],c=s(a,n),u=s(a,h);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)*l/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=l;const x=a.x+u.nx*_+-u.ny*m*f,y=a.y+u.ny*_+u.nx*m*f,T=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(T)*m,y+Math.sin(T)*m),r.arc(x,y,m,T,S,p),n=a}}function sm(r,e,t,s){const i=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),n=(a,l,h)=>({x:a.x+(l.x-a.x)*h,y:a.y+(l.y-a.y)*h}),o=e.length;for(let a=0;a<o;a++){const l=e[(a+1)%o],h=l.radius??t;if(h<=0){a===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y);continue}const c=e[a],u=e[(a+2)%o],d=i(c,l);let f;if(d<1e-4)f=l;else{const m=Math.min(d/2,h);f=n(l,c,m/d)}const p=i(u,l);let g;if(p<1e-4)g=l;else{const m=Math.min(p/2,h);g=n(l,u,m/p)}a===0?r.moveTo(f.x,f.y):r.lineTo(f.x,f.y),r.quadraticCurveTo(l.x,l.y,g.x,g.y,s)}}const rm=new Q;class im{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new ye,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const s=this._currentPoly.points,i=s[s.length-2],n=s[s.length-1];return(i!==e||n!==t)&&s.push(e,t),this}arc(e,t,s,i,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return rh(a,e,t,s,i,n,o),this}arcTo(e,t,s,i,n){this._ensurePoly();const o=this._currentPoly.points;return Zp(o,e,t,s,i,n),this}arcToSvg(e,t,s,i,n,o,a){const l=this._currentPoly.points;return em(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,s,i,n),this}bezierCurveTo(e,t,s,i,n,o,a){this._ensurePoly();const l=this._currentPoly;return sh(this._currentPoly.points,l.lastX,l.lastY,e,t,s,i,n,o,a),this}quadraticCurveTo(e,t,s,i,n){this._ensurePoly();const o=this._currentPoly;return qp(this._currentPoly.points,o.lastX,o.lastY,e,t,s,i,n),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));const s=this.shapePrimitives,i=s.length;for(let n=0;n<e.instructions.length;n++){const o=e.instructions[n];this[o.action](...o.data)}if(e.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 l=a.shape,h=n==null?void 0:n.shape;h&&h.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),s.copyWithin(o,o+1),s.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,s,i,n){return this.drawShape(new Q(e,t,s,i),n),this}circle(e,t,s,i){return this.drawShape(new Wi(e,t,s),i),this}poly(e,t,s){const i=new ys(e);return i.closePath=t,this.drawShape(i,s),this}regularPoly(e,t,s,i,n=0,o){i=Math.max(i|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/i,h=[];for(let c=0;c<i;c++){const u=a-c*l;h.push(e+s*Math.cos(u),t+s*Math.sin(u))}return this.poly(h,!0,o),this}roundPoly(e,t,s,i,n,o=0,a){if(i=Math.max(i|0,3),n<=0)return this.regularPoly(e,t,s,i,o);const l=s*Math.sin(Math.PI/i)-.001;n=Math.min(n,l);const h=-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+h,p=e+s*Math.cos(f),g=t+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),T=p+n*Math.cos(_),S=g+n*Math.sin(_);d===0?this.moveTo(x,y):this.lineTo(x,y),this.quadraticCurveTo(p,g,T,S,a)}return this.closePath()}roundShape(e,t,s=!1,i){return e.length<3?this:(s?sm(this,e,t,i):tm(this,e,t),this.closePath())}filletRect(e,t,s,i,n){if(n===0)return this.rect(e,t,s,i);const o=Math.min(s,i)/2,a=Math.min(o,Math.max(-o,n)),l=e+s,h=t+i,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(e,t+u).arcTo(e+c,t+c,e+u,t,u).lineTo(l-u,t).arcTo(l-c,t+c,l,t+u,u).lineTo(l,h-u).arcTo(l-c,h-c,e+s-u,h,u).lineTo(e+u,h).arcTo(e+c,h-c,e,h-u,u).closePath()}chamferRect(e,t,s,i,n,o){if(n<=0)return this.rect(e,t,s,i);const a=Math.min(n,Math.min(s,i)/2),l=e+s,h=t+i,c=[e+a,t,l-a,t,l,t+a,l,h-a,l-a,h,e+a,h,e,h-a,e,t+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(e,t,s,i,n){return this.drawShape(new Hi(e,t,s,i),n),this}roundRect(e,t,s,i,n,o){return this.drawShape(new zi(e,t,s,i,n),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let s=this._currentPoly;return s&&this.endPoly(),s=new ys,s.points.push(e,t),this._currentPoly=s,this}endPoly(e=!1){const t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new ys,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let s=t.shape.x,i=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.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 e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){const s=e.instructions[t];this[s.action](...s.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let s=0;s<t.length;s++){const i=t[s],n=i.shape.getBounds(rm);i.transform?e.addRect(n,i.transform):e.addRect(n)}return e}}class et{constructor(e,t=!1){this.instructions=[],this.uid=re("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?Hf(e,this):this.instructions=(e==null?void 0:e.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new im(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,s,i,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(ie.shared);let l=0,h=0;if(!o||o.action!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.data[2],h=o.data[3];const c=a.x,u=a.y;l=c+(c-l),h=u+(u-h)}return this.instructions.push({action:"bezierCurveTo",data:[l,h,e,t,s,i,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,s){const i=this.instructions[this.instructions.length-1],n=this.getLastPoint(ie.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 l=n.x,h=n.y;o=l+(l-o),a=h+(h-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,s]}),this._dirty=!0,this}rect(e,t,s,i,n){return this.instructions.push({action:"rect",data:[e,t,s,i,n]}),this._dirty=!0,this}circle(e,t,s,i){return this.instructions.push({action:"circle",data:[e,t,s,i]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,s,i,n,o,a){n||(n=i/2);const l=-1*Math.PI/2+o,h=s*2,c=Math.PI*2/h,u=[];for(let d=0;d<h;d++){const f=d%2?n:i,p=d*c+l;u.push(e+f*Math.cos(p),t+f*Math.sin(p))}return this.poly(u,!0,a),this}clone(e=!1){const t=new et;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const i=this.instructions[s];t.instructions.push({action:i.action,data:i.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const t=e.a,s=e.b,i=e.c,n=e.d,o=e.tx,a=e.ty;let l=0,h=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":l=x[0],h=x[1],x[0]=t*l+i*h+o,x[1]=s*l+n*h+a;break;case"bezierCurveTo":c=x[0],u=x[1],d=x[2],f=x[3],l=x[4],h=x[5],x[0]=t*c+i*u+o,x[1]=s*c+n*u+a,x[2]=t*d+i*f+o,x[3]=s*d+n*f+a,x[4]=t*l+i*h+o,x[5]=s*l+n*h+a;break;case"quadraticCurveTo":c=x[0],u=x[1],l=x[2],h=x[3],x[0]=t*c+i*u+o,x[1]=s*c+n*u+a,x[2]=t*l+i*h+o,x[3]=s*l+n*h+a;break;case"arcToSvg":l=x[5],h=x[6],p=x[0],g=x[1],x[0]=t*p+i*g,x[1]=s*p+n*g,x[5]=t*l+i*h+o,x[6]=s*l+n*h+a;break;case"circle":x[4]=Gt(x[3],e);break;case"rect":x[4]=Gt(x[4],e);break;case"ellipse":x[8]=Gt(x[8],e);break;case"roundRect":x[5]=Gt(x[5],e);break;case"addPath":x[0].transform(e);break;case"poly":x[2]=Gt(x[2],e);break;case"regularPoly":case"chamferRect":x[5]=Gt(x[5],e);break;case"closePath":break;default:W("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,s=this.instructions[t];if(!s)return e.x=0,e.y=0,e;for(;s.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;s=this.instructions[t]}switch(s.action){case"moveTo":case"lineTo":e.x=s.data[0],e.y=s.data[1];break;case"quadraticCurveTo":e.x=s.data[2],e.y=s.data[3];break;case"bezierCurveTo":e.x=s.data[4],e.y=s.data[5];break;case"arc":case"arcToSvg":e.x=s.data[5],e.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(e);break}return e}}function Gt(r,e){return r?r.prepend(e):e.clone()}function ce(r,e,t){const s=r.getAttribute(e);return s?Number(s):t}function nm(r,e){const t=r.querySelectorAll("defs");for(let s=0;s<t.length;s++){const i=t[s];for(let n=0;n<i.children.length;n++){const o=i.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=om(o);break;case"radialgradient":e.defs[o.id]=am();break}}}}function om(r){const e=ce(r,"x1",0),t=ce(r,"y1",0),s=ce(r,"x2",1),i=ce(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new $e(e,t,s,i,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const l=r.children[a],h=ce(l,"offset",0),c=ee.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(h,c)}return o}function am(r){return W("[SVG Parser] Radial gradients are not yet supported"),new $e(0,0,1,0)}function Jo(r){const e=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const ea={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 ih(r,e){const t=r.getAttribute("style"),s={},i={},n={strokeStyle:s,fillStyle:i,useFill:!1,useStroke:!1};for(const o in ea){const a=r.getAttribute(o);a&&ta(e,n,o,a.trim())}if(t){const o=t.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[h,c]=l.split(":");ea[h]&&ta(e,n,h,c.trim())}}return{strokeStyle:n.useStroke?s:null,fillStyle:n.useFill?i:null,useFill:n.useFill,useStroke:n.useStroke}}function ta(r,e,t,s){switch(t){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const i=Jo(s);e.strokeStyle.fill=r.defs[i]}else e.strokeStyle.color=ee.shared.setValue(s).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(s);break;case"fill":if(s!=="none"){if(s.startsWith("url(")){const i=Jo(s);e.fillStyle.fill=r.defs[i]}else e.fillStyle.color=ee.shared.setValue(s).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(s);break;case"stroke-opacity":e.strokeStyle.alpha=Number(s);break;case"opacity":e.fillStyle.alpha=Number(s),e.strokeStyle.alpha=Number(s);break}}function lm(r){if(r.length<=2)return!0;const e=r.map(a=>a.area).sort((a,l)=>l-a),[t,s]=e,i=e[e.length-1],n=t/s,o=s/i;return!(n>3&&o<2)}function hm(r){return r.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function cm(r){const e=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const t=e.map(Number),s=[],i=[];for(let c=0;c<t.length;c+=2)c+1<t.length&&(s.push(t[c]),i.push(t[c+1]));if(s.length===0||i.length===0)return 0;const n=Math.min(...s),o=Math.max(...s),a=Math.min(...i),l=Math.max(...i);return(o-n)*(l-a)}function sa(r,e){const t=new et(r,!1);for(const s of t.instructions)e.instructions.push(s)}function um(r,e){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const t={context:e,defs:{},path:new et};nm(r,t);const s=r.children,{fillStyle:i,strokeStyle:n}=ih(r,t);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&nh(a,t,i,n)}return e}function nh(r,e,t,s){const i=r.children,{fillStyle:n,strokeStyle:o}=ih(r,e);n&&t?t={...t,...n}:n&&(t=n),o&&s?s={...s,...o}:o&&(s=o);const a=!t&&!s;a&&(t={color:0});let l,h,c,u,d,f,p,g,m,_,x,y,T,S,v,w,A;switch(r.nodeName.toLowerCase()){case"path":{S=r.getAttribute("d");const R=r.getAttribute("fill-rule"),C=hm(S),E=R==="evenodd",P=C.length>1;if(E&&P){const U=C.map(M=>({path:M,area:cm(M)}));if(U.sort((M,I)=>I.area-M.area),C.length>3||!lm(U))for(let M=0;M<U.length;M++){const I=U[M],L=M===0;e.context.beginPath();const B=new et(void 0,!0);sa(I.path,B),e.context.path(B),L?(t&&e.context.fill(t),s&&e.context.stroke(s)):e.context.cut()}else for(let M=0;M<U.length;M++){const I=U[M],L=M%2===1;e.context.beginPath();const B=new et(void 0,!0);sa(I.path,B),e.context.path(B),L?e.context.cut():(t&&e.context.fill(t),s&&e.context.stroke(s))}}else{const U=R?R==="evenodd":!0;v=new et(S,U),e.context.path(v),t&&e.context.fill(t),s&&e.context.stroke(s)}break}case"circle":p=ce(r,"cx",0),g=ce(r,"cy",0),m=ce(r,"r",0),e.context.ellipse(p,g,m,m),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"rect":l=ce(r,"x",0),h=ce(r,"y",0),w=ce(r,"width",0),A=ce(r,"height",0),_=ce(r,"rx",0),x=ce(r,"ry",0),_||x?e.context.roundRect(l,h,w,A,_||x):e.context.rect(l,h,w,A),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"ellipse":p=ce(r,"cx",0),g=ce(r,"cy",0),_=ce(r,"rx",0),x=ce(r,"ry",0),e.context.beginPath(),e.context.ellipse(p,g,_,x),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"line":c=ce(r,"x1",0),u=ce(r,"y1",0),d=ce(r,"x2",0),f=ce(r,"y2",0),e.context.beginPath(),e.context.moveTo(c,u),e.context.lineTo(d,f),s&&e.context.stroke(s);break;case"polygon":T=r.getAttribute("points"),y=T.match(/-?\d+/g).map(R=>parseInt(R,10)),e.context.poly(y,!0),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"polyline":T=r.getAttribute("points"),y=T.match(/-?\d+/g).map(R=>parseInt(R,10)),e.context.poly(y,!1),s&&e.context.stroke(s);break;case"g":case"svg":break;default:{W(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(t=null);for(let R=0;R<i.length;R++)nh(i[R],e,t,s)}const ra={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 Is{constructor(e,t){this.uid=re("fillPattern"),this._tick=0,this.transform=new G,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=ra[t].addressModeU,e.source.style.addressModeV=ra[t].addressModeV)}setTransform(e){const t=this.texture;this.transform.copyFrom(e),this.transform.invert(),this.transform.scale(1/t.frame.width,1/t.frame.height),this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function dm(r){return ee.isColorLike(r)}function ia(r){return r instanceof Is}function na(r){return r instanceof $e}function fm(r){return r instanceof O}function pm(r,e,t){const s=ee.shared.setValue(e??0);return r.color=s.toNumber(),r.alpha=s.alpha===1?t.alpha:s.alpha,r.texture=O.WHITE,{...t,...r}}function mm(r,e,t){return r.texture=e,{...t,...r}}function oa(r,e,t){return r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,{...t,...r}}function aa(r,e,t){return e.buildGradient(),r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,r.textureSpace=e.textureSpace,{...t,...r}}function gm(r,e){const t={...e,...r},s=ee.shared.setValue(t.color);return t.alpha*=s.alpha,t.color=s.toNumber(),t}function St(r,e){if(r==null)return null;const t={},s=r;return dm(r)?pm(t,r,e):fm(r)?mm(t,r,e):ia(r)?oa(t,r,e):na(r)?aa(t,r,e):s.fill&&ia(s.fill)?oa(s,s.fill,e):s.fill&&na(s.fill)?aa(s,s.fill,e):gm(s,e)}function fr(r,e){const{width:t,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...l}=e,h=St(r,l);return h?{width:t,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...h}:null}function _m(r,e){let t=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 l=n.closePath;for(let h=0;h<a;h+=2){if(!l&&(h===0||h===a-2))continue;const c=(h-2+a)%a,u=(h+2)%a,d=o[c],f=o[c+1],p=o[h],g=o[h+1],m=o[u],_=o[u+1],x=d-p,y=f-g,T=m-p,S=_-g,v=x*x+y*y,w=T*T+S*S;if(v<1e-12||w<1e-12)continue;let C=(x*T+y*S)/Math.sqrt(v*w);C<-1?C=-1:C>1&&(C=1);const E=Math.sqrt((1-C)*.5);if(E<1e-6)continue;const P=Math.min(1/E,e);P>t&&(t=P)}}return t}const xm=new ie,la=new G,sn=class Ve extends Re{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=re("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new et,this._transform=new G,this._fillStyle={...Ve.defaultFillStyle},this._strokeStyle={...Ve.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new ye,this._boundsDirty=!0}clone(){const e=new Ve;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=St(e,Ve.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=fr(e,Ve.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=St(e,Ve.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=St(e,Ve.defaultStrokeStyle),this}texture(e,t,s,i,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:s||0,dy:i||0,dw:n||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?ee.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new et,this}fill(e,t){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?(e!=null&&(t!==void 0&&typeof e=="number"&&(F(Z,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=St(e,Ve.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(ie.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="fill"?t=s.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=fr(e,Ve.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const t=this.instructions[this.instructions.length-1-e],s=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(s);else{t.data.hole=s;break}}return this._initNextPathLocation(),this}arc(e,t,s,i,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,s,i,n,o),this}arcTo(e,t,s,i,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}arcToSvg(e,t,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(e,t,s,i,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(e,t,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*e+l.c*t+l.tx,l.b*e+l.d*t+l.ty,l.a*s+l.c*i+l.tx,l.b*s+l.d*i+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){var e;return this._tick++,(e=this._activePath)==null||e.closePath(),this}ellipse(e,t,s,i){return this._tick++,this._activePath.ellipse(e,t,s,i,this._transform.clone()),this}circle(e,t,s){return this._tick++,this._activePath.circle(e,t,s,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*e+s.c*t+s.tx,s.b*e+s.d*t+s.ty),this}moveTo(e,t){this._tick++;const s=this._transform,i=this._activePath.instructions,n=s.a*e+s.c*t+s.tx,o=s.b*e+s.d*t+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(e,t,s,i,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}rect(e,t,s,i){return this._tick++,this._activePath.rect(e,t,s,i,this._transform.clone()),this}roundRect(e,t,s,i,n){return this._tick++,this._activePath.roundRect(e,t,s,i,n,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,s,i,n=0,o){return this._tick++,this._activePath.regularPoly(e,t,s,i,n,o),this}roundPoly(e,t,s,i,n,o){return this._tick++,this._activePath.roundPoly(e,t,s,i,n,o),this}roundShape(e,t,s,i){return this._tick++,this._activePath.roundShape(e,t,s,i),this}filletRect(e,t,s,i,n){return this._tick++,this._activePath.filletRect(e,t,s,i,n),this}chamferRect(e,t,s,i,n,o){return this._tick++,this._activePath.chamferRect(e,t,s,i,n,o),this}star(e,t,s,i,n=0,o=0){return this._tick++,this._activePath.star(e,t,s,i,n,o,this._transform.clone()),this}svg(e){return this._tick++,um(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.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(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,s,i,n,o){return e instanceof G?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,s,i,n,o),this)}transform(e,t,s,i,n,o){return e instanceof G?(this._transform.append(e),this):(la.set(e,t,s,i,n,o),this._transform.append(la),this)}translate(e,t=e){return this._transform.translate(e,t),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 e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){const s=this.instructions[t],i=s.action;if(i==="fill"){const n=s.data;e.addBounds(n.path.bounds)}else if(i==="texture"){const n=s.data;e.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*=_m(n.path,n.style.miterLimit));const l=n.path.bounds;e.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){var i;if(!this.bounds.containsPoint(e.x,e.y))return!1;const t=this.instructions;let s=!1;for(let n=0;n<t.length;n++){const o=t[n],a=o.data,l=a.path;if(!o.action||!l)continue;const h=a.style,c=l.shapePath.shapePrimitives;for(let u=0;u<c.length;u++){const d=c[u].shape;if(!h||!d)continue;const f=c[u].transform,p=f?f.applyInverse(e,xm):e;if(o.action==="fill")s=d.contains(p.x,p.y);else{const m=h;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 e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!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 e=="boolean"?e:e==null?void 0:e.texture){const s=typeof e=="boolean"?e:e==null?void 0:e.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}};sn.defaultFillStyle={color:16777215,alpha:1,texture:O.WHITE,matrix:null,fill:null,textureSpace:"local"};sn.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:O.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Fe=sn;function rn(r,e=1){var s;const t=(s=ts.RETINA_PREFIX)==null?void 0:s.exec(r);return t?parseFloat(t[1]):e}function nn(r,e,t){r.label=t,r._sourceOrigin=t;const s=new O({source:r,label:t}),i=()=>{delete e.promiseCache[t],se.has(t)&&se.remove(t)};return s.source.once("destroy",()=>{e.promiseCache[t]&&(W("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),i())}),s.once("destroy",()=>{r.destroyed||(W("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),i())}),s}const ym=".svg",bm="image/svg+xml",vm={extension:{type:b.LoadParser,priority:ut.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return ss(r,bm)||rs(r,ym)},async load(r,e,t){var s;return((s=e.data)==null?void 0:s.parseAsGraphicsContext)??this.config.parseAsGraphicsContext?Sm(r):Tm(r,e,t,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function Tm(r,e,t,s){var m,_,x;const i=await z.get().fetch(r),n=z.get().createImage();n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await i.text())}`,n.crossOrigin=s,await n.decode();const o=((m=e.data)==null?void 0:m.width)??n.width,a=((_=e.data)==null?void 0:_.height)??n.height,l=((x=e.data)==null?void 0:x.resolution)||rn(r),h=Math.ceil(o*l),c=Math.ceil(a*l),u=z.get().createCanvas(h,c),d=u.getContext("2d");d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(n,0,0,o*l,a*l);const{parseAsGraphicsContext:f,...p}=e.data??{},g=new Ct({resource:u,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return nn(g,t,r)}async function Sm(r){const t=await(await z.get().fetch(r)).text(),s=new Fe;return s.svg(t),s}const wm=`(function () {
253
+ 'use strict';
254
+
255
+ const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
256
+ async function checkImageBitmap() {
257
+ try {
258
+ if (typeof createImageBitmap !== "function") return false;
259
+ const response = await fetch(WHITE_PNG);
260
+ const imageBlob = await response.blob();
261
+ const imageBitmap = await createImageBitmap(imageBlob);
262
+ return imageBitmap.width === 1 && imageBitmap.height === 1;
263
+ } catch (_e) {
264
+ return false;
265
+ }
266
+ }
267
+ void checkImageBitmap().then((result) => {
268
+ self.postMessage(result);
269
+ });
270
+
271
+ })();
272
+ `;let $t=null,Ci=class{constructor(){$t||($t=URL.createObjectURL(new Blob([wm],{type:"application/javascript"}))),this.worker=new Worker($t)}};Ci.revokeObjectURL=function(){$t&&(URL.revokeObjectURL($t),$t=null)};const Cm=`(function () {
273
+ 'use strict';
274
+
275
+ async function loadImageBitmap(url, alphaMode) {
276
+ const response = await fetch(url);
277
+ if (!response.ok) {
278
+ throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
279
+ }
280
+ const imageBlob = await response.blob();
281
+ return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
282
+ }
283
+ self.onmessage = async (event) => {
284
+ try {
285
+ const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
286
+ self.postMessage({
287
+ data: imageBitmap,
288
+ uuid: event.data.uuid,
289
+ id: event.data.id
290
+ }, [imageBitmap]);
291
+ } catch (e) {
292
+ self.postMessage({
293
+ error: e,
294
+ uuid: event.data.uuid,
295
+ id: event.data.id
296
+ });
297
+ }
298
+ };
299
+
300
+ })();
301
+ `;let jt=null;class oh{constructor(){jt||(jt=URL.createObjectURL(new Blob([Cm],{type:"application/javascript"}))),this.worker=new Worker(jt)}}oh.revokeObjectURL=function(){jt&&(URL.revokeObjectURL(jt),jt=null)};let ha=0,Zr;class Am{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(e=>{const{worker:t}=new Ci;t.addEventListener("message",s=>{t.terminate(),Ci.revokeObjectURL(),e(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e,t){var s;return this._run("loadImageBitmap",[e,(s=t==null?void 0:t.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Zr===void 0&&(Zr=navigator.hardwareConcurrency||4);let e=this._workerPool.pop();return!e&&this._createdWorkers<Zr&&(this._createdWorkers++,e=new oh().worker,e.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),e}_returnWorker(e){this._workerPool.push(e)}_complete(e){this._resolveHash[e.uuid]&&(e.error!==void 0?this._resolveHash[e.uuid].reject(e.error):this._resolveHash[e.uuid].resolve(e.data),delete this._resolveHash[e.uuid])}async _run(e,t){await this._initWorkers();const s=new Promise((i,n)=>{this._queue.push({id:e,arguments:t,resolve:i,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const e=this._getWorker();if(!e)return;const t=this._queue.pop(),s=t.id;this._resolveHash[ha]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:ha++,id:s})}reset(){this._workerPool.forEach(e=>e.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:e})=>{e==null||e(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}}const ca=new Am,Em=[".jpeg",".jpg",".png",".webp",".avif"],Pm=["image/jpeg","image/png","image/webp","image/avif"];async function Mm(r,e){var i;const t=await z.get().fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const s=await t.blob();return((i=e==null?void 0:e.data)==null?void 0:i.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const ah={name:"loadTextures",id:"texture",extension:{type:b.LoadParser,priority:ut.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return ss(r,Pm)||rs(r,Em)},async load(r,e,t){var n;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ca.isImageBitmapSupported()?s=await ca.loadImageBitmap(r,e):s=await Mm(r,e):s=await new Promise((o,a)=>{s=z.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=r,s.complete?o(s):(s.onload=()=>{o(s)},s.onerror=a)});const i=new Ct({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((n=e.data)==null?void 0:n.resolution)||rn(r),...e.data});return nn(i,t,r)},unload(r){r.destroy(!0)}},Rm=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let Qr,Jr;function Bm(r,e,t){t===void 0&&!e.startsWith("data:")?r.crossOrigin=Im(e):t!==!1&&(r.crossOrigin=typeof t=="string"?t:"anonymous")}function km(r){return new Promise((e,t)=>{r.addEventListener("canplaythrough",s),r.addEventListener("error",i),r.load();function s(){n(),e()}function i(o){n(),t(o)}function n(){r.removeEventListener("canplaythrough",s),r.removeEventListener("error",i)}})}function Im(r,e=globalThis.location){if(r.startsWith("data:"))return"";e||(e=globalThis.location);const t=new URL(r,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function Fm(){const r=[],e=[];for(const t of Rm){const s=xs.MIME_TYPES[t.substring(1)]||`video/${t.substring(1)}`;xr(s)&&(r.push(t),e.includes(s)||e.push(s))}return{validVideoExtensions:r,validVideoMime:e}}const Gm={name:"loadVideo",id:"video",extension:{type:b.LoadParser,name:"loadVideo"},test(r){if(!Qr||!Jr){const{validVideoExtensions:s,validVideoMime:i}=Fm();Qr=s,Jr=i}const e=ss(r,Jr),t=rs(r,Qr);return e||t},async load(r,e,t){var l,h;const s={...xs.defaultOptions,resolution:((l=e.data)==null?void 0:l.resolution)||rn(r),alphaMode:((h=e.data)==null?void 0:h.alphaMode)||await ll(),...e.data},i=document.createElement("video"),n={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(n).forEach(c=>{const u=n[c];u!==void 0&&i.setAttribute(c,u)}),s.muted===!0&&(i.muted=!0),Bm(i,r,s.crossorigin);const o=document.createElement("source");let a;if(s.mime)a=s.mime;else if(r.startsWith("data:"))a=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();a=xs.MIME_TYPES[c]||`video/${c}`}return o.src=r,a&&(o.type=a),new Promise((c,u)=>{s.preload&&!s.autoPlay&&i.load(),i.addEventListener("canplay",d),i.addEventListener("error",f),o.addEventListener("error",f),i.appendChild(o);async function d(){const g=new xs({...s,resource:i});p(),e.data.preload&&await km(i),c(nn(g,t,r))}function f(g){p(),u(g)}function p(){i.removeEventListener("canplay",d),i.removeEventListener("error",f),o.removeEventListener("error",f)}})},unload(r){r.destroy(!0)}},lh={extension:{type:b.ResolveParser,name:"resolveTexture"},test:ah.test,parse:r=>{var e;return{resolution:parseFloat(((e=ts.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:r.split(".").pop(),src:r}}},Um={extension:{type:b.ResolveParser,priority:-2,name:"resolveJson"},test:r=>ts.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:lh.parse};class Om{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ts,this.loader=new wf,this.cache=se,this._backgroundLoader=new mf(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){var n,o;if(this._initialized){W("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let a=e.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const t=((n=e.texturePreference)==null?void 0:n.resolution)??1,s=typeof t=="number"?[t]:t,i=await this._detectFormats({preferredFormats:(o=e.texturePreference)==null?void 0:o.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:i,resolution:s}}),e.preferences&&this.setPreferences(e.preferences),e.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...e.loadOptions})}add(e){this.resolver.add(e)}async load(e,t){this._initialized||await this.init();const s=cr(e),i=Ne(e).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(i),o=await this._mapLoadToResolve(n,t);return s?o[i[0]]:o}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let s=!1;typeof e=="string"&&(s=!0,e=[e]);const i=this.resolver.resolveBundle(e),n={},o=Object.keys(i);let a=0;const l=[],h=()=>{t==null||t(l.reduce((u,d)=>u+d,0)/a)},c=o.map((u,d)=>{const f=i[u],p=Object.values(f),m=[...new Set(p.flat())].reduce((_,x)=>_+(x.progressSize||1),0);return l.push(0),a+=m,this._mapLoadToResolve(f,_=>{l[d]=_*m,h()}).then(_=>{n[u]=_})});return await Promise.all(c),s?n[e[0]]:n}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return se.get(e);const t={};for(let s=0;s<e.length;s++)t[s]=se.get(e[s]);return t}async _mapLoadToResolve(e,t){const s=[...new Set(Object.values(e))];this._backgroundLoader.active=!1;const i=await this.loader.load(s,t);this._backgroundLoader.active=!0;const n={};return s.forEach(o=>{const a=i[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(h=>{n[h]=a}),se.set(l,a)}),n}async unload(e){this._initialized||await this.init();const t=Ne(e).map(i=>typeof i!="string"?i.src:i),s=this.resolver.resolve(t);await this._unloadFromResolved(s)}async unloadBundle(e){this._initialized||await this.init(),e=Ne(e);const t=this.resolver.resolveBundle(e),s=Object.keys(t).map(i=>this._unloadFromResolved(t[i]));await Promise.all(s)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(s=>{se.remove(s.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const s of e.detections)e.skipDetections||await s.test()?t=await s.add(t):e.skipDetections||(t=await s.remove(t));return t=t.filter((s,i)=>t.indexOf(s)===i),t}get detections(){return this._detections}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(s=>s in e).forEach(s=>{t.config[s]=e[s]})})}}const qs=new Om;V.handleByList(b.LoadParser,qs.loader.parsers).handleByList(b.ResolveParser,qs.resolver.parsers).handleByList(b.CacheParser,qs.cache.parsers).handleByList(b.DetectionParser,qs.detections);V.add(gf,xf,_f,Sf,bf,vf,Tf,Ef,Rf,Df,vm,ah,Gm,pf,ff,lh,Um);const ua={loader:b.LoadParser,resolver:b.ResolveParser,cache:b.CacheParser,detection:b.DetectionParser};V.handle(b.Asset,r=>{const e=r.ref;Object.entries(ua).filter(([t])=>!!e[t]).forEach(([t,s])=>V.add(Object.assign(e[t],{extension:e[t].extension??s})))},r=>{const e=r.ref;Object.keys(ua).filter(t=>!!e[t]).forEach(t=>V.remove(e[t]))});class hh{constructor(e){this._attachedDomElements=[],this._renderer=e,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 pl({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){const e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){const s=e[t],i=s.element;if(!s.parent||s.globalDisplayStatus<7)i==null||i.remove(),e.splice(t,1),t--;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,l=s.height*o.y;i.style.transformOrigin=`${a}px ${l}px`,i.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,i.style.opacity=s.groupAlpha.toString()}}}destroy(){var e;this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++)(e=this._attachedDomElements[t].element)==null||e.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}hh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"dom"};class Dm{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this._tickerAdded||!this.domElement||(Ue.system.add(this._tickerUpdate,this,Zt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Ue.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){this._deltaTime+=e.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 Ze=new Dm;class pr extends Rs{constructor(){super(...arguments),this.client=new ie,this.movement=new ie,this.offset=new ie,this.global=new ie,this.screen=new ie}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,s){return e.worldTransform.applyInverse(s||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,s,i,n,o,a,l,h,c,u,d,f,p,g){throw new Error("Method not implemented.")}}class Le extends pr{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 Jt extends pr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Jt.DOM_DELTA_PIXEL=0;Jt.DOM_DELTA_LINE=1;Jt.DOM_DELTA_PAGE=2;const Lm=2048,Nm=new ie,ds=new ie;class Wm{constructor(e){this.dispatch=new Re,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((s,i)=>s.priority-i.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let s=0,i=t.length;s<i;s++)t[s].fn(e);else W(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Ze.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,Nm.set(e,t),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(e,t){if(!e.target)return;const s=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let i=0,n=s.length-1;i<n;i++)if(e.currentTarget=s[i],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let i=s.length-2;i>=0;i--)if(e.currentTarget=s[i],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,s=this._allInteractiveElements){if(s.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const i=Array.isArray(t)?t:[t];for(let n=s.length-1;n>=0;n--)i.forEach(o=>{e.currentTarget=s[n],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let s=0;s<Lm&&e!==this.rootTarget&&e.parent;s++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,s,i,n,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Ze.pauseUpdate=!1),e.interactiveChildren&&e.children){const c=e.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,s,i,n,o||n(e,s));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=e.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(e),f.push(e)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(t),h=e.isInteractive();return h&&h&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(e,s)&&i(e,s)?h?[e]:[]:null}hitTestRecursive(e,t,s,i,n){if(this._interactivePrune(e)||n(e,s))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Ze.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children,h=s;for(let c=l.length-1;c>=0;c--){const u=l[c],d=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,h,i,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const f=e.isInteractive();return(d.length>0||f)&&d.push(e),d}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&i(e,s)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.measurable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,ds),!e.hitArea.contains(ds.x,ds.y)))return!0;if(e.effects&&e.effects.length)for(let s=0;s<e.effects.length;s++){const i=e.effects[s];if(i.containsPoint&&!i.containsPoint(t,this.hitTestFn))return!0}return!1}hitTestFn(e,t){return e.hitArea?!0:e!=null&&e.containsPoint?(e.worldTransform.applyInverse(t,ds),e.containsPoint(ds)):!1}notifyTarget(e,t){var n,o;if(!e.currentTarget.isInteractive())return;t??(t=e.type);const s=`on${t}`;(o=(n=e.currentTarget)[s])==null||o.call(n,e);const i=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this._notifyListeners(e,i),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof Le)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const i=t.button===2;this.dispatchEvent(t,i?"rightdown":"mousedown")}const s=this.trackingData(e.pointerId);s.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){var l,h;if(!(e instanceof Le)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const s=t.pointerType==="mouse"||t.pointerType==="pen",i=this.trackingData(e.pointerId),n=this.findMountedTarget(i.overTargets);if(((l=i.overTargets)==null?void 0:l.length)>0&&n!==t.target){const c=e.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(e,c,n);if(this.dispatchEvent(u,"pointerout"),s&&this.dispatchEvent(u,"mouseout"),!t.composedPath().includes(n)){const d=this.createPointerEvent(e,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!t.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!==t.target){const c=e.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(t,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!==t.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(t,"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(t,"pointermove"),a&&o.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),a&&o.push("globaltouchmove")),s&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=t.target)==null?void 0:h.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,i.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){var o;if(!(e instanceof Le)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),s=this.createPointerEvent(e),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;t.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof Le)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const s=e.pointerType==="mouse"||e.pointerType==="pen",i=this.findMountedTarget(t.overTargets),n=this.createPointerEvent(e,"pointerout",i);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(e,"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;t.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof Le)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),s=this.createPointerEvent(e);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(e.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[e.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 l=s.button===2;this.notifyTarget(s,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete i.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,i.clicksByButton[e.button]||(i.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const l=i.clicksByButton[e.button];if(l.target===a.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=t,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(e){if(!(e instanceof Le)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),s=this.findMountedTarget(t.pressTargetsByButton[e.button]),i=this.createPointerEvent(e);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 t.pressTargetsByButton[e.button]}this.freeEvent(i)}mapWheel(e){if(!(e instanceof Jt)){W("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let s=1;s<e.length&&e[s].parent===t;s++)t=e[s];return t}createPointerEvent(e,t,s){const i=this.allocateEvent(Le);return this.copyPointerData(e,i),this.copyMouseData(e,i),this.copyData(e,i),i.nativeEvent=e.nativeEvent,i.originalEvent=e,i.target=s??this.hitTest(i.global.x,i.global.y)??this._hitElements[0],typeof t=="string"&&(i.type=t),i}createWheelEvent(e){const t=this.allocateEvent(Jt);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const s=this.allocateEvent(Le);return s.nativeEvent=e.nativeEvent,s.originalEvent=e.originalEvent,this.copyPointerData(e,s),this.copyMouseData(e,s),this.copyData(e,s),s.target=e.target,s.path=e.composedPath().slice(),s.type=t??s.type,s}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof Le&&t instanceof Le&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist)}copyMouseData(e,t){e instanceof pr&&t instanceof pr&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.defaultPrevented=!1,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){const s=e.currentTarget._events[t];if(s)if("fn"in s)s.once&&e.currentTarget.removeListener(t,s.fn,void 0,!0),s.fn.call(s.context,e);else for(let i=0,n=s.length;i<n&&!e.propagationImmediatelyStopped;i++)s[i].once&&e.currentTarget.removeListener(t,s[i].fn,void 0,!0),s[i].fn.call(s[i].context,e)}}const Hm=1,zm={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},on=class Ai{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new Wm(null),Ze.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Le(null),this._rootWheelEvent=new Jt(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ai.defaultEventFeatures},{set:(t,s,i)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),t[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(e){const{canvas:t,resolution:s}=this.renderer;this.setTargetElement(t),this.resolution=s,Ai._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){Ze.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||(e="default");let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;const s=this.cursorStyles[e];if(s)switch(typeof s){case"string":t&&(this.domElement.style.cursor=s);break;case"function":s(e);break;case"object":t&&Object.assign(this.domElement.style,s);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let s=0,i=t.length;s<i;s++){const n=t[s],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Ze.pointerMoved();const t=this._normalizeToPointerData(e);for(let s=0,i=t.length;s<i;s++){const n=this._bootstrapEvent(this._rootPointerEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const s=t!==this.domElement?"outside":"",i=this._normalizeToPointerData(e);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(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);for(let s=0,i=t.length;s<i;s++){const n=this._bootstrapEvent(this._rootPointerEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,Ze.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Ze.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;Ze.removeTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(e,t,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;e.x=(t-i.left)*(this.domElement.width/i.width)*n,e.y=(s-i.top)*(this.domElement.height/i.height)*n}_normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let s=0,i=e.changedTouches.length;s<i;s++){const n=e.changedTouches[s];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.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=e.type,n.altKey??(n.altKey=e.altKey),n.ctrlKey??(n.ctrlKey=e.ctrlKey),n.metaKey??(n.metaKey=e.metaKey),n.shiftKey??(n.shiftKey=e.shiftKey),t.push(n)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const s=e;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=Hm),typeof s.pressure>"u"&&(s.pressure=.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),s.isNormalized=!0,t.push(s)}else t.push(e);return t}normalizeWheelEvent(e){const t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=zm[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};on.extension={name:"events",type:[b.WebGLSystem,b.CanvasSystem,b.WebGPUSystem],priority:-1};on.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ch=on;const Vm={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??ch.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,e,t){const s=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,i=typeof t=="object"?t.signal:void 0,n=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;r=s?`${r}capture`:r;const a=typeof e=="function"?e:e.handleEvent,l=this;i&&i.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,e,t){const s=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,i=typeof e=="function"?void 0:e;r=s?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.off(r,e,i)},dispatchEvent(r){if(!(r instanceof Rs))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 Ut;function da(r){const e=z.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=r,t.fillRect(0,0,6,1),e}function uh(){if(Ut!==void 0)return Ut;try{const r=da("#ff00ff"),e=da("#ffff00"),s=z.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(r,0,0),s.drawImage(e,2,0);const i=s.getImageData(2,0,1,1);if(!i)Ut=!1;else{const n=i.data;Ut=n[0]===255&&n[1]===0&&n[2]===0}}catch{Ut=!1}return Ut}const j={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:uh(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{const e=r.source,t=e==null?void 0:e.resource;if(!t)return null;const s=e.alphaMode==="premultiplied-alpha",i=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=i!==e.pixelWidth||n!==e.pixelHeight;if(s){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=j._unpremultipliedCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const a=j._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=z.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d"),c=h.createImageData(e.pixelWidth,e.pixelHeight),u=c.data,d=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.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 h.putImageData(c,0,0),j._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}if(s){const a=z.get().createCanvas(e.pixelWidth,e.pixelHeight),l=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,l.drawImage(t,0,0);const h=l.getImageData(0,0,a.width,a.height),c=h.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 l.putImageData(h,0,0),j._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=j._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=z.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d");return l.width=e.pixelWidth,l.height=e.pixelHeight,h.drawImage(t,0,0),j._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}return t},getTintedCanvas:(r,e)=>{const t=r.texture,s=ee.shared.setValue(e).toHex(),i=t.tintCache||(t.tintCache={}),n=i[s],o=t.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:z.get().createCanvas();return j.tintMethod(t,e,a),a.tintId=o,i[s]=a,i[s]},getTintedPattern:(r,e)=>{const t=ee.shared.setValue(e).toHex(),s=r.patternCache||(r.patternCache={}),i=r.source._resourceId;let n=s[t];return(n==null?void 0:n.tintId)===i||(j.canvas||(j.canvas=z.get().createCanvas()),j.tintMethod(r,e,j.canvas),n=j.canvas.getContext("2d").createPattern(j.canvas,"repeat"),n.tintId=i,s[t]=n),n},applyPatternTransform:(r,e,t=!0)=>{if(!e)return;const s=r;if(!s.setTransform)return;const i=globalThis.DOMMatrix;if(!i)return;const n=new i([e.a,e.b,e.c,e.d,e.tx,e.ty]);s.setTransform(t?n.inverse():n)},tintWithMultiply:(r,e,t)=>{const s=t.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),l=a?i.height:i.width,h=a?i.width:i.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),s.fillStyle=ee.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="multiply";const c=j.getCanvasSource(r);if(!c){s.restore();return}o&&j._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,e,t)=>{const s=t.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),l=a?i.height:i.width,h=a?i.width:i.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy",s.fillStyle=ee.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="destination-atop";const c=j.getCanvasSource(r);if(!c){s.restore();return}o&&j._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,e,t)=>{const s=t.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),l=a?i.height:i.width,h=a?i.width:i.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy";const c=j.getCanvasSource(r);if(!c){s.restore();return}o&&j._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=e>>16&255,d=e>>8&255,f=e&255,p=s.getImageData(0,0,l,h),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,e,t,s)=>{const i=$.inv(e),n=$.uX(i),o=$.uY(i),a=$.vX(i),l=$.vY(i),h=-Math.min(0,n*t,a*s,n*t+a*s),c=-Math.min(0,o*t,l*s,o*t+l*s);r.transform(n,o,a,l,h,c)}};j.tintMethod=j.canUseMultiply?j.tintWithMultiply:j.tintWithPerPixel;class Xm{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const s=z.get().createCanvas();s.width=e,s.height=t;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(e,t,s=1){e=Math.ceil(e*s-1e-6),t=Math.ceil(t*s-1e-6),e=Yt(e),t=Yt(t);const i=(e<<17)+(t<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(e,t)),n}returnCanvasAndContext(e){const t=e.canvas,{width:s,height:i}=t,n=(s<<17)+(i<<1);e.context.resetTransform(),e.context.clearRect(0,0,s,i),this._canvasPool[n].push(e)}clear(){this._canvasPool={}}}const ct=new Xm;es.register(ct);const fa=new G;function dh(r,e){e.clear();const t=e.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?e.matrix=fa.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n!=null&&n._parentCacheAsTextureRenderGroup?e.matrix=fa.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):e.matrix=i.worldTransform,e.addBounds(i.bounds)}return e.matrix=t,e}const $m=new ye;function fh(r,e,t,s,i=!1){const n=$m;n.minX=0,n.minY=0,n.maxX=r.width/s|0,n.maxY=r.height/s|0;const o=ue.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=e/s,o.frame.height=t/s,o.source.emit("update",o.source),o.updateUvs(),o}function pa(r){return typeof r.getCanvasFilterString=="function"}class jm{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new ye,this.cssFilterString=""}}class ph{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){const t=this._pushFilterFrame(),s=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=s,t.container=e.container,t.cssFilterString="",s.every(l=>!l.enabled)){t.skip=!0;return}const i=[],n=1;for(const l of s){if(!l.enabled)continue;if(!pa(l)){this._warnUnsupportedFilter(l);continue}const h=l.getCanvasFilterString();if(h===null){this._warnUnsupportedFilter(l);continue}h&&i.push(h)}if(i.length===0&&n===1){t.skip=!0;return}t.cssFilterString=i.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(t.bounds.x*l,t.bounds.y*l,t.bounds.width*l,t.bounds.height*l),o.clip()}else t.useClip=!1;t.cssFilterString&&(o.filter=a!=="none"?`${a} ${t.cssFilterString}`:t.cssFilterString)}pop(){const e=this._popFilterFrame();if(e.skip)return;const t=this._savedStates.pop();if(!t)return;const s=this.renderer.canvasContext.activeContext;e.useClip?s.restore():s.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!(t!=null&&t.length)||t.every(_=>!_.enabled))return e;const s=[],i=1;for(const _ of t){if(!_.enabled)continue;if(!pa(_)){this._warnUnsupportedFilter(_);continue}const x=_.getCanvasFilterString();if(x===null){this._warnUnsupportedFilter(_);continue}x&&s.push(x)}if(s.length===0&&i===1)return e;const n=j.getCanvasSource(e);if(!n)return e;const o=e.frame,a=e.source._resolution??e.source.resolution??1,l=o.width,h=o.height,c=ct.getOptimalCanvasAndContext(l,h,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=l*a,m=h*a;return d.drawImage(n,f,p,g,m,0,0,g,m),d.filter="none",d.globalAlpha=1,fh(u,l,h,a)}_calculateFilterArea(e,t){if(e.renderables?dh(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const s=e.container.renderGroup||e.container.parentRenderGroup,i=s==null?void 0:s.cacheToLocalTransform;i&&t.applyMatrix(i)}}_warnUnsupportedFilter(e){var s;const t=((s=e==null?void 0:e.constructor)==null?void 0:s.name)||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new jm),this._filterStackIndex++,e}_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}}ph.extension={type:[b.CanvasSystem],name:"filter"};var mh=`in vec2 aPosition;
302
+ out vec2 vTextureCoord;
303
+
304
+ uniform vec4 uInputSize;
305
+ uniform vec4 uOutputFrame;
306
+ uniform vec4 uOutputTexture;
307
+
308
+ vec4 filterVertexPosition( void )
309
+ {
310
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
311
+
312
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
313
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
314
+
315
+ return vec4(position, 0.0, 1.0);
316
+ }
317
+
318
+ vec2 filterTextureCoord( void )
319
+ {
320
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
321
+ }
322
+
323
+ void main(void)
324
+ {
325
+ gl_Position = filterVertexPosition();
326
+ vTextureCoord = filterTextureCoord();
327
+ }
328
+ `;const gh={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},Ym=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(`
329
+ `);function qm(r){const e=gh[r],t=e.length;let s="";const i="finalColor = ",n=" + ",o="texture(uTexture, vBlurTexCoords[%index%]) * %value%";for(let a=0;a<r;a++){const l=a===0?i:n,h=a<t?a:r-a-1,c=o.replace("%index%",a.toString()).replace("%value%",e[h].toString());s+=`${l}${c}
330
+ `}return Ym.replace("%blur%",`${s};`).replace("%size%",r.toString())}const Km=`
331
+ in vec2 aPosition;
332
+
333
+ uniform float uStrength;
334
+
335
+ out vec2 vBlurTexCoords[%size%];
336
+
337
+ uniform vec4 uInputSize;
338
+ uniform vec4 uOutputFrame;
339
+ uniform vec4 uOutputTexture;
340
+
341
+ vec4 filterVertexPosition( void )
342
+ {
343
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
344
+
345
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
346
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
347
+
348
+ return vec4(position, 0.0, 1.0);
349
+ }
350
+
351
+ vec2 filterTextureCoord( void )
352
+ {
353
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
354
+ }
355
+
356
+ void main(void)
357
+ {
358
+ gl_Position = filterVertexPosition();
359
+
360
+ float pixelStrength = uInputSize.%dimension% * uStrength;
361
+
362
+ vec2 textureCoord = filterTextureCoord();
363
+ %blur%
364
+ }`;function Zm(r,e){const t=Math.ceil(r/2);let s=Km,i="",n;e?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(t-1)}.0`),i+=a,i+=`
365
+ `}return s=s.replace("%blur%",i),s=s.replace("%size%",r.toString()),s=s.replace("%dimension%",e?"z":"w"),s}function Qm(r,e){const t=Zm(e,r),s=qm(e);return dt.from({vertex:t,fragment:s,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var Jm=`
366
+
367
+ struct GlobalFilterUniforms {
368
+ uInputSize:vec4<f32>,
369
+ uInputPixel:vec4<f32>,
370
+ uInputClamp:vec4<f32>,
371
+ uOutputFrame:vec4<f32>,
372
+ uGlobalFrame:vec4<f32>,
373
+ uOutputTexture:vec4<f32>,
374
+ };
375
+
376
+ struct BlurUniforms {
377
+ uStrength:f32,
378
+ };
379
+
380
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
381
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
382
+ @group(0) @binding(2) var uSampler : sampler;
383
+
384
+ @group(1) @binding(0) var<uniform> blurUniforms : BlurUniforms;
385
+
386
+
387
+ struct VSOutput {
388
+ @builtin(position) position: vec4<f32>,
389
+ %blur-struct%
390
+ };
391
+
392
+ fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
393
+ {
394
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
395
+
396
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
397
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
398
+
399
+ return vec4(position, 0.0, 1.0);
400
+ }
401
+
402
+ fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
403
+ {
404
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
405
+ }
406
+
407
+ fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
408
+ {
409
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
410
+ }
411
+
412
+ fn getSize() -> vec2<f32>
413
+ {
414
+ return gfu.uGlobalFrame.zw;
415
+ }
416
+
417
+
418
+ @vertex
419
+ fn mainVertex(
420
+ @location(0) aPosition : vec2<f32>,
421
+ ) -> VSOutput {
422
+
423
+ let filteredCord = filterTextureCoord(aPosition);
424
+
425
+ let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength;
426
+
427
+ return VSOutput(
428
+ filterVertexPosition(aPosition),
429
+ %blur-vertex-out%
430
+ );
431
+ }
432
+
433
+ @fragment
434
+ fn mainFragment(
435
+ @builtin(position) position: vec4<f32>,
436
+ %blur-fragment-in%
437
+ ) -> @location(0) vec4<f32> {
438
+
439
+ var finalColor = vec4(0.0);
440
+
441
+ %blur-sampling%
442
+
443
+ return finalColor;
444
+ }
445
+ `;function eg(r,e){const t=gh[e],s=t.length,i=[],n=[],o=[];for(let u=0;u<e;u++){i[u]=`@location(${u}) offset${u}: vec2<f32>,`,r?n[u]=`filteredCord + vec2(${u-s+1} * pixelStrength, 0.0),`:n[u]=`filteredCord + vec2(0.0, ${u-s+1} * pixelStrength),`;const d=u<s?u:e-u-1,f=t[d].toString();o[u]=`finalColor += textureSample(uTexture, uSampler, offset${u}) * ${f};`}const a=i.join(`
446
+ `),l=n.join(`
447
+ `),h=o.join(`
448
+ `),c=Jm.replace("%blur-struct%",a).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",a).replace("%blur-sampling%",h).replace("%dimension%",r?"z":"w");return st.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}const _h=class xh extends Bs{constructor(e){e={...xh.defaultOptions,...e};const t=Qm(e.horizontal,e.kernelSize),s=eg(e.horizontal,e.kernelSize);super({glProgram:t,gpuProgram:s,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}},...e}),this.horizontal=e.horizontal,this.legacy=e.legacy??!1,this._quality=0,this.quality=e.quality,this.blur=e.strength,this._blurUniforms=this.resources.blurUniforms,this._uniforms=this._blurUniforms.uniforms}apply(e,t,s,i){this.legacy?this._applyLegacy(e,t,s,i):this._applyOptimized(e,t,s,i)}_applyLegacy(e,t,s,i){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)e.applyFilter(this,t,s,i);else{const n=ue.getSameSizeTexture(t);let o=t,a=n;this._state.blend=!1;const l=e.renderer.type===Me.WEBGPU;for(let h=0;h<this.passes-1;h++){e.applyFilter(this,o,a,h===0?!0:l);const c=a;a=o,o=c}this._state.blend=!0,e.applyFilter(this,o,s,i),ue.returnTexture(n)}}_applyOptimized(e,t,s,i){if(this._uniforms.uStrength=this._calculateInitialStrength(),this.passes===1)e.applyFilter(this,t,s,i);else{const n=ue.getSameSizeTexture(t);let o=t,a=n;this._state.blend=!1;const l=e.renderer,h=l.type===Me.WEBGPU,c=h?l.renderPipes.uniformBatch:null;for(let u=0;u<this.passes-1;u++){c&&this.groups[1].setResource(c.getUboResource(this._blurUniforms),0),e.applyFilter(this,o,a,h);const d=a;a=o,o=d,this._uniforms.uStrength*=.5}c&&this.groups[1].setResource(c.getUboResource(this._blurUniforms),0),this._state.blend=!0,e.applyFilter(this,o,s,i),ue.returnTexture(n)}}_calculateInitialStrength(){let e=1,t=.5;for(let s=1;s<this.passes;s++)e+=t*t,t*=.5;return this.strength/Math.sqrt(e)}get blur(){return this.strength}set blur(e){this.padding=1+Math.abs(e)*2,this.strength=e}get quality(){return this._quality}set quality(e){this._quality=e,this.passes=e}};_h.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};let ei=_h;class tg extends Bs{constructor(...e){let t=e[0]??{};typeof t=="number"&&(F(Z,"BlurFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }"),t={strength:t},e[1]!==void 0&&(t.quality=e[1]),e[2]!==void 0&&(t.resolution=e[2]||"inherit"),e[3]!==void 0&&(t.kernelSize=e[3])),t={...ei.defaultOptions,...t};const{strength:s,strengthX:i,strengthY:n,quality:o,...a}=t;super({...a,compatibleRenderers:Me.BOTH,resources:{}}),this._repeatEdgePixels=!1,this.blurXFilter=new ei({horizontal:!0,...t}),this.blurYFilter=new ei({horizontal:!1,...t}),this.quality=o,this.strengthX=i??s,this.strengthY=n??s,this.repeatEdgePixels=!1}apply(e,t,s,i){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=ue.getSameSizeTexture(t);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(e,t,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(e,a,s,i),ue.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(e,t,s,i)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(e,t,s,i))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(e){this.blurXFilter.blur=this.blurYFilter.blur=e,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(e){this.blurXFilter.quality=this.blurYFilter.quality=e}get strengthX(){return this.blurXFilter.blur}set strengthX(e){this.blurXFilter.blur=e,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(e){this.blurYFilter.blur=e,this.updatePadding()}get blur(){return F("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength}set blur(e){F("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength=e}get blurX(){return F("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX}set blurX(e){F("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX=e}get blurY(){return F("8.3.0","BlurFilter.blurY is deprecated, please use BlurFilter.strengthY instead."),this.strengthY}set blurY(e){F("8.3.0","BlurFilter.blurY is deprecated, please use BlurFilter.strengthY instead."),this.strengthY=e}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(e){this._repeatEdgePixels=e,this.updatePadding()}}tg.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var sg=`
449
+ in vec2 vTextureCoord;
450
+ in vec4 vColor;
451
+
452
+ out vec4 finalColor;
453
+
454
+ uniform float uNoise;
455
+ uniform float uSeed;
456
+ uniform sampler2D uTexture;
457
+
458
+ float rand(vec2 co)
459
+ {
460
+ return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
461
+ }
462
+
463
+ void main()
464
+ {
465
+ vec4 color = texture(uTexture, vTextureCoord);
466
+ float randomValue = rand(gl_FragCoord.xy * uSeed);
467
+ float diff = (randomValue - 0.5) * uNoise;
468
+
469
+ // Un-premultiply alpha before applying the color matrix. See issue #3539.
470
+ if (color.a > 0.0) {
471
+ color.rgb /= color.a;
472
+ }
473
+
474
+ color.r += diff;
475
+ color.g += diff;
476
+ color.b += diff;
477
+
478
+ // Premultiply alpha again.
479
+ color.rgb *= color.a;
480
+
481
+ finalColor = color;
482
+ }
483
+ `,ma=`
484
+
485
+ struct GlobalFilterUniforms {
486
+ uInputSize:vec4<f32>,
487
+ uInputPixel:vec4<f32>,
488
+ uInputClamp:vec4<f32>,
489
+ uOutputFrame:vec4<f32>,
490
+ uGlobalFrame:vec4<f32>,
491
+ uOutputTexture:vec4<f32>,
492
+ };
493
+
494
+ struct NoiseUniforms {
495
+ uNoise:f32,
496
+ uSeed:f32,
497
+ };
498
+
499
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
500
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
501
+ @group(0) @binding(2) var uSampler : sampler;
502
+
503
+ @group(1) @binding(0) var<uniform> noiseUniforms : NoiseUniforms;
504
+
505
+ struct VSOutput {
506
+ @builtin(position) position: vec4<f32>,
507
+ @location(0) uv : vec2<f32>
508
+ };
509
+
510
+ fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
511
+ {
512
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
513
+
514
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
515
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
516
+
517
+ return vec4(position, 0.0, 1.0);
518
+ }
519
+
520
+ fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
521
+ {
522
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
523
+ }
524
+
525
+ fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
526
+ {
527
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
528
+ }
529
+
530
+ fn getSize() -> vec2<f32>
531
+ {
532
+ return gfu.uGlobalFrame.zw;
533
+ }
534
+
535
+ @vertex
536
+ fn mainVertex(
537
+ @location(0) aPosition : vec2<f32>,
538
+ ) -> VSOutput {
539
+ return VSOutput(
540
+ filterVertexPosition(aPosition),
541
+ filterTextureCoord(aPosition)
542
+ );
543
+ }
544
+
545
+ fn rand(co:vec2<f32>) -> f32
546
+ {
547
+ return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
548
+ }
549
+
550
+
551
+
552
+ @fragment
553
+ fn mainFragment(
554
+ @location(0) uv: vec2<f32>,
555
+ @builtin(position) position: vec4<f32>
556
+ ) -> @location(0) vec4<f32> {
557
+
558
+ var pixelPosition = globalTextureCoord(position.xy);// / (getSize());//- gfu.uOutputFrame.xy);
559
+
560
+
561
+ var sample = textureSample(uTexture, uSampler, uv);
562
+ var randomValue = rand(pixelPosition.xy * noiseUniforms.uSeed);
563
+ var diff = (randomValue - 0.5) * noiseUniforms.uNoise;
564
+
565
+ // Un-premultiply alpha before applying the color matrix. See issue #3539.
566
+ if (sample.a > 0.0) {
567
+ sample.r /= sample.a;
568
+ sample.g /= sample.a;
569
+ sample.b /= sample.a;
570
+ }
571
+
572
+ sample.r += diff;
573
+ sample.g += diff;
574
+ sample.b += diff;
575
+
576
+ // Premultiply alpha again.
577
+ sample.r *= sample.a;
578
+ sample.g *= sample.a;
579
+ sample.b *= sample.a;
580
+
581
+ return sample;
582
+ }`;const yh=class bh extends Bs{constructor(e={}){e={...bh.defaultOptions,...e};const t=st.from({vertex:{source:ma,entryPoint:"mainVertex"},fragment:{source:ma,entryPoint:"mainFragment"}}),s=dt.from({vertex:mh,fragment:sg,name:"noise-filter"}),{noise:i,seed:n,...o}=e;super({...o,gpuProgram:t,glProgram:s,resources:{noiseUniforms:new We({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}}),this.noise=i,this.seed=n??Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(e){this.resources.noiseUniforms.uniforms.uNoise=e}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(e){this.resources.noiseUniforms.uniforms.uSeed=e}};yh.defaultOptions={noise:.5};let fy=yh;var rg=`in vec2 vTextureCoord;
583
+ out vec4 finalColor;
584
+ uniform sampler2D uTexture;
585
+ void main() {
586
+ finalColor = texture(uTexture, vTextureCoord);
587
+ }
588
+ `,ga=`struct GlobalFilterUniforms {
589
+ uInputSize: vec4<f32>,
590
+ uInputPixel: vec4<f32>,
591
+ uInputClamp: vec4<f32>,
592
+ uOutputFrame: vec4<f32>,
593
+ uGlobalFrame: vec4<f32>,
594
+ uOutputTexture: vec4<f32>,
595
+ };
596
+
597
+ @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
598
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
599
+ @group(0) @binding(2) var uSampler: sampler;
600
+
601
+ struct VSOutput {
602
+ @builtin(position) position: vec4<f32>,
603
+ @location(0) uv: vec2<f32>
604
+ };
605
+
606
+ fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
607
+ {
608
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
609
+
610
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
611
+ position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
612
+
613
+ return vec4(position, 0.0, 1.0);
614
+ }
615
+
616
+ fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
617
+ {
618
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
619
+ }
620
+
621
+ @vertex
622
+ fn mainVertex(
623
+ @location(0) aPosition: vec2<f32>,
624
+ ) -> VSOutput {
625
+ return VSOutput(
626
+ filterVertexPosition(aPosition),
627
+ filterTextureCoord(aPosition)
628
+ );
629
+ }
630
+
631
+ @fragment
632
+ fn mainFragment(
633
+ @location(0) uv: vec2<f32>,
634
+ ) -> @location(0) vec4<f32> {
635
+ return textureSample(uTexture, uSampler, uv);
636
+ }
637
+ `;class ig extends Bs{constructor(){const e=st.from({vertex:{source:ga,entryPoint:"mainVertex"},fragment:{source:ga,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=dt.from({vertex:mh,fragment:rg,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}class vh{constructor(e){this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}vh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"};const ng=new Xi({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 og{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new ye,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 Th{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new We({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 lt({}),this.renderer=e}get activeBackTexture(){var e;return(e=this._activeFilterData)==null?void 0:e.backTexture}push(e){const t=this.renderer,s=e.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=s,i.container=e.container,i.outputRenderSurface=t.renderTarget.renderSurface;const n=t.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(s.every(f=>!f.enabled)){i.skip=!0;return}const l=i.bounds;if(this._calculateFilterArea(e,l),this._calculateFilterBounds(i,t.renderTarget.rootViewPort,a,o,1),i.skip)return;const h=this._getPreviousFilterData(),c=this._findFilterResolution(o);let u=0,d=0;h&&(u=h.bounds.minX,d=h.bounds.minY),this._calculateGlobalFrame(i,u,d,c,n.width,n.height),this._setupFilterTextures(i,l,t,h)}generateFilteredTexture({texture:e,filters:t}){const s=this._pushFilterData();this._activeFilterData=s,s.skip=!1,s.filters=t;const i=e.source,n=i.resolution,o=i.antialias;if(t.every(f=>!f.enabled))return s.skip=!0,e;const a=s.bounds;if(a.addRect(e.frame),this._calculateFilterBounds(s,a.rectangle,o,n,0),s.skip)return e;const l=n;this._calculateGlobalFrame(s,0,0,l,i.width,i.height),s.outputRenderSurface=ue.getOptimalTexture(a.width,a.height,s.resolution,s.antialias),s.backTexture=O.EMPTY,s.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(s,!0);const d=s.outputRenderSurface;return d.source.alphaMode="premultiplied-alpha",d}pop(){const e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&ue.returnTexture(t.backTexture),ue.returnTexture(t.inputTexture))}getBackTexture(e,t,s){const i=e.colorTexture.source._resolution,n=ue.getOptimalTexture(t.width,t.height,i,!1);let o=t.minX,a=t.minY;s&&(o-=s.minX,a-=s.minY),o=Math.floor(o*i),a=Math.floor(a*i);const l=Math.ceil(t.width*i),h=Math.ceil(t.height*i);return this.renderer.renderTarget.copyToTexture(e,n,{x:o,y:a},{width:l,height:h},{x:0,y:0}),n}applyFilter(e,t,s,i){const n=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===s,h=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(h);let u=0,d=0;if(l){const p=this._findPreviousFilterOffset();u=p.x,d=p.y}this._updateFilterUniforms(t,s,o,u,d,c,l,i);const f=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,t,n)}calculateSpriteMatrix(e,t){const s=this._activeFilterData,i=e.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),n=t.worldTransform.copyTo(G.shared),o=t.renderGroup||t.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/t.texture.orig.width,1/t.texture.orig.height),i.translate(t.anchor.x,t.anchor.y),i}destroy(){var e;(e=this._passthroughFilter)==null||e.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new ig),this._passthroughFilter}_setupBindGroupsAndRender(e,t,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(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,s.encoder.draw({geometry:ng,shader:e,state:e._state,topology:"triangle-list"}),s.type===Me.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,s,i){if(e.backTexture=O.EMPTY,e.inputTexture=ue.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){s.renderTarget.finishRenderPass();const n=s.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(n,t,i==null?void 0:i.bounds)}s.renderTarget.bind(e.inputTexture,!0),s.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,s,i,n,o){const a=e.globalFrame;a.x=t*i,a.y=s*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(e,t,s,i,n,o,a,l){const h=this._filterGlobalUniforms.uniforms,c=h.uOutputFrame,u=h.uInputSize,d=h.uInputPixel,f=h.uInputClamp,p=h.uGlobalFrame,g=h.uOutputTexture;a?(c[0]=s.bounds.minX-i,c[1]=s.bounds.minY-n):(c[0]=0,c[1]=0),c[2]=e.frame.width,c[3]=e.frame.height,u[0]=e.source.width,u[1]=e.source.height,u[2]=1/u[0],u[3]=1/u[1],d[0]=e.source.pixelWidth,d[1]=e.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],f[0]=.5*d[2],f[1]=.5*d[3],f[2]=e.frame.width*u[2]-.5*d[2],f[3]=e.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,t instanceof O&&(t.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!l),t instanceof O?(g[0]=t.frame.width,g[1]=t.frame.height):(g[0]=_.width,g[1]=_.height),g[2]=_.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(e){let t=this._filterStackIndex-1;for(;t>0&&this._filterStack[t].skip;)--t;return t>0&&this._filterStack[t].inputTexture?this._filterStack[t].inputTexture.source._resolution:e}_findPreviousFilterOffset(){let e=0,t=0,s=this._filterStackIndex;for(;s>0;){s--;const i=this._filterStack[s];if(!i.skip){e=i.bounds.minX,t=i.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?dh(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const i=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;i&&t.applyMatrix(i)}}_applyFiltersToTexture(e,t){const s=e.inputTexture,i=e.bounds,n=e.filters,o=e.firstEnabledIndex,a=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),o===a)n[o].apply(this,s,e.outputRenderSurface,t);else{let l=e.inputTexture;const h=ue.getOptimalTexture(i.width,i.height,l.source._resolution,!1);let c=h;for(let u=o;u<a;u++){const d=n[u];if(!d.enabled)continue;d.apply(this,l,c,!0);const f=l;l=c,c=f}n[a].apply(this,l,e.outputRenderSurface,t),ue.returnTexture(h)}}_calculateFilterBounds(e,t,s,i,n){var _;const o=this.renderer,a=e.bounds,l=e.filters;let h=1/0,c=0,u=!0,d=!1,f=!1,p=!0,g=-1,m=-1;for(let x=0;x<l.length;x++){const y=l[x];if(!y.enabled)continue;if(g===-1&&(g=x),m=x,h=Math.min(h,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)){W("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){e.skip=!0;return}if(p&&a.fitBounds(0,t.width/i,0,t.height/i),a.scale(h).ceil().scale(1/h).pad((c|0)*n),!a.isPositive){e.skip=!0;return}e.antialias=u,e.resolution=h,e.blendRequired=d,e.firstEnabledIndex=g,e.lastEnabledIndex=m}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let e,t=this._filterStackIndex-1;for(;t>0&&(t--,e=this._filterStack[t],!!e.skip););return e}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new og),this._filterStackIndex++,e}}Th.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"};var ag=`in vec2 vMaskCoord;
638
+ in vec2 vTextureCoord;
639
+
640
+ uniform sampler2D uTexture;
641
+ uniform sampler2D uMaskTexture;
642
+
643
+ uniform float uAlpha;
644
+ uniform vec4 uMaskClamp;
645
+ uniform float uInverse;
646
+ uniform float uChannel;
647
+
648
+ out vec4 finalColor;
649
+
650
+ void main(void)
651
+ {
652
+ float clip = step(3.5,
653
+ step(uMaskClamp.x, vMaskCoord.x) +
654
+ step(uMaskClamp.y, vMaskCoord.y) +
655
+ step(vMaskCoord.x, uMaskClamp.z) +
656
+ step(vMaskCoord.y, uMaskClamp.w));
657
+
658
+ // TODO look into why this is needed
659
+ float npmAlpha = uAlpha;
660
+ vec4 original = texture(uTexture, vTextureCoord);
661
+ vec4 masky = texture(uMaskTexture, vMaskCoord);
662
+
663
+ float a;
664
+ if (uChannel == 1.0) {
665
+ a = masky.a * npmAlpha * clip;
666
+ } else {
667
+ float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
668
+ a = alphaMul * masky.r * npmAlpha * clip;
669
+ }
670
+
671
+ if (uInverse == 1.0) {
672
+ a = 1.0 - a;
673
+ }
674
+
675
+ finalColor = original * a;
676
+ }
677
+ `,lg=`in vec2 aPosition;
678
+
679
+ out vec2 vTextureCoord;
680
+ out vec2 vMaskCoord;
681
+
682
+
683
+ uniform vec4 uInputSize;
684
+ uniform vec4 uOutputFrame;
685
+ uniform vec4 uOutputTexture;
686
+ uniform mat3 uFilterMatrix;
687
+
688
+ vec4 filterVertexPosition( vec2 aPosition )
689
+ {
690
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
691
+
692
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
693
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
694
+
695
+ return vec4(position, 0.0, 1.0);
696
+ }
697
+
698
+ vec2 filterTextureCoord( vec2 aPosition )
699
+ {
700
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
701
+ }
702
+
703
+ vec2 getFilterCoord( vec2 aPosition )
704
+ {
705
+ return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
706
+ }
707
+
708
+ void main(void)
709
+ {
710
+ gl_Position = filterVertexPosition(aPosition);
711
+ vTextureCoord = filterTextureCoord(aPosition);
712
+ vMaskCoord = getFilterCoord(aPosition);
713
+ }
714
+ `,_a=`struct GlobalFilterUniforms {
715
+ uInputSize:vec4<f32>,
716
+ uInputPixel:vec4<f32>,
717
+ uInputClamp:vec4<f32>,
718
+ uOutputFrame:vec4<f32>,
719
+ uGlobalFrame:vec4<f32>,
720
+ uOutputTexture:vec4<f32>,
721
+ };
722
+
723
+ struct MaskUniforms {
724
+ uFilterMatrix:mat3x3<f32>,
725
+ uMaskClamp:vec4<f32>,
726
+ uAlpha:f32,
727
+ uInverse:f32,
728
+ uChannel:f32,
729
+ };
730
+
731
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
732
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
733
+ @group(0) @binding(2) var uSampler : sampler;
734
+
735
+ @group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
736
+ @group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
737
+
738
+ struct VSOutput {
739
+ @builtin(position) position: vec4<f32>,
740
+ @location(0) uv : vec2<f32>,
741
+ @location(1) filterUv : vec2<f32>,
742
+ };
743
+
744
+ fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
745
+ {
746
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
747
+
748
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
749
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
750
+
751
+ return vec4(position, 0.0, 1.0);
752
+ }
753
+
754
+ fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
755
+ {
756
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
757
+ }
758
+
759
+ fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
760
+ {
761
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
762
+ }
763
+
764
+ fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
765
+ {
766
+ return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
767
+ }
768
+
769
+ fn getSize() -> vec2<f32>
770
+ {
771
+ return gfu.uGlobalFrame.zw;
772
+ }
773
+
774
+ @vertex
775
+ fn mainVertex(
776
+ @location(0) aPosition : vec2<f32>,
777
+ ) -> VSOutput {
778
+ return VSOutput(
779
+ filterVertexPosition(aPosition),
780
+ filterTextureCoord(aPosition),
781
+ getFilterCoord(aPosition)
782
+ );
783
+ }
784
+
785
+ @fragment
786
+ fn mainFragment(
787
+ @location(0) uv: vec2<f32>,
788
+ @location(1) filterUv: vec2<f32>,
789
+ @builtin(position) position: vec4<f32>
790
+ ) -> @location(0) vec4<f32> {
791
+
792
+ var maskClamp = filterUniforms.uMaskClamp;
793
+ var uAlpha = filterUniforms.uAlpha;
794
+
795
+ var clip = step(3.5,
796
+ step(maskClamp.x, filterUv.x) +
797
+ step(maskClamp.y, filterUv.y) +
798
+ step(filterUv.x, maskClamp.z) +
799
+ step(filterUv.y, maskClamp.w));
800
+
801
+ var mask = textureSample(uMaskTexture, uSampler, filterUv);
802
+ var source = textureSample(uTexture, uSampler, uv);
803
+
804
+ var a: f32;
805
+ if (filterUniforms.uChannel == 1.0) {
806
+ a = mask.a * uAlpha * clip;
807
+ } else {
808
+ var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
809
+ a = alphaMul * mask.r * uAlpha * clip;
810
+ }
811
+
812
+ if (filterUniforms.uInverse == 1.0) {
813
+ a = 1.0 - a;
814
+ }
815
+
816
+ return source * a;
817
+ }
818
+ `;class hg extends Bs{constructor(e){const{sprite:t,...s}=e,i=new $a(t.texture),n=new We({uFilterMatrix:{value:new G,type:"mat3x3<f32>"},uMaskClamp:{value:i.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"},uChannel:{value:e.channel==="alpha"?1:0,type:"f32"}}),o=st.from({vertex:{source:_a,entryPoint:"mainVertex"},fragment:{source:_a,entryPoint:"mainFragment"}}),a=dt.from({vertex:lg,fragment:ag,name:"mask-filter"});super({...s,gpuProgram:o,glProgram:a,clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=i}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(e){this.resources.filterUniforms.uniforms.uChannel=e==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(e,t,s,i){this._textureMatrix.texture=this.sprite.texture,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,e.applyFilter(this,t,s,i)}}class cg{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class ug{constructor(){this.instructions=new Oi}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const an=class Ei{constructor(e){this._renderer=e,this._managedContexts=new je({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Ei.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Ei.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=e._gpuData,s=!!t[this._renderer.uid],i=t[this._renderer.uid]||this._initContext(e);return(e.dirty||!s)&&(s&&i.reset(),i.isBatchable=!1,e.dirty=!1),i}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=new ug,s=this.getGpuContext(e);return s.graphicsData=t,t.init(),t}_initContext(e){const t=new cg;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};an.extension={type:[b.CanvasSystem],name:"graphicsContext"};an.defaultOptions={bezierSmoothness:.5};let dg=an;class Sh{constructor(e,t){this.state=it.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new je({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,t){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){e.isRenderable&&this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Sh.extension={type:[b.CanvasPipes],name:"graphics"};function wh(r,e,t){const s=(r>>24&255)/255;e[t++]=(r&255)/255*s,e[t++]=(r>>8&255)/255*s,e[t++]=(r>>16&255)/255*s,e[t++]=s}class fg{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{_e.return(e)}),this.batches.length=0}}class Ch{constructor(e,t){this.state=it.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new je({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){const t=e.context,s=!!e._gpuData,n=this.renderer.graphicsContext.updateGpuContext(t);return!!(n.isBatchable||s!==n.isBatchable)}addRenderable(e,t){const i=this.renderer.graphicsContext.updateGpuContext(e.context);e.didViewUpdate&&this._rebuild(e),i.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){const s=this._getGpuDataForRenderable(e).batches;for(let i=0;i<s.length;i++){const n=s[i];n._batcher.updateElement(n)}}execute(e){if(!e.isRenderable)return;const t=this.renderer,s=e.context;if(!t.graphicsContext.getGpuContext(s).batches.length)return;const n=s.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;const o=n.resources.localUniforms.uniforms;o.uTransformMatrix=e.groupTransform,o.uRound=t._roundPixels|e._roundPixels,wh(e.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){const t=this._getGpuDataForRenderable(e),i=this.renderer.graphicsContext.updateGpuContext(e.context);t.destroy(),i.isBatchable&&this._updateBatchesForRenderable(e,t)}_addToBatcher(e,t){const s=this.renderer.renderPipes.batch,i=this._getGpuDataForRenderable(e).batches;for(let n=0;n<i.length;n++){const o=i[n];s.addToBatch(o,t)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){const t=new fg;return e._gpuData[this.renderer.uid]=t,this._managedGraphics.add(e),t}_updateBatchesForRenderable(e,t){const s=e.context,n=this.renderer.graphicsContext.getGpuContext(s),o=this.renderer._roundPixels|e._roundPixels;t.batches=n.batches.map(a=>{const l=_e.get(Zi);return a.copyTo(l),l.renderable=e,l.roundPixels=o,l})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Ch.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"graphics"};V.add(Sh);V.add(Ch);V.add(dg);V.add(tn);class mr extends Li{constructor(e){e instanceof Fe&&(e={context:e});const{context:t,roundPixels:s,...i}=e||{};super({label:"Graphics",...i}),this.renderPipeId="graphics",t?this.context=t:(this.context=this._ownedContext=new Fe,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s??!1}set context(e){e!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=e,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(e){return this._context.containsPoint(e)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||(e==null?void 0:e.context)===!0)&&this._context.destroy(e),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){return e?new mr(this._context.clone()):(this._ownedContext=null,new mr(this._context))}lineStyle(e,t,s){F(Z,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const i={};return e&&(i.width=e),t&&(i.color=t),s&&(i.alpha=s),this.context.strokeStyle=i,this}beginFill(e,t){F(Z,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return e!==void 0&&(s.color=e),t!==void 0&&(s.alpha=t),this.context.fillStyle=s,this}endFill(){F(Z,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const e=this.context.strokeStyle;return(e.width!==Fe.defaultStrokeStyle.width||e.color!==Fe.defaultStrokeStyle.color||e.alpha!==Fe.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return F(Z,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return F(Z,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return F(Z,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return F(Z,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return F(Z,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return F(Z,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}const sr={name:"local-uniform-bit",vertex:{header:`
819
+
820
+ struct LocalUniforms {
821
+ uTransformMatrix:mat3x3<f32>,
822
+ uColor:vec4<f32>,
823
+ uRound:f32,
824
+ }
825
+
826
+ @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
827
+ `,main:`
828
+ vColor *= localUniforms.uColor;
829
+ modelMatrix *= localUniforms.uTransformMatrix;
830
+ `,end:`
831
+ if(localUniforms.uRound == 1)
832
+ {
833
+ vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
834
+ }
835
+ `}},pg={...sr,vertex:{...sr.vertex,header:sr.vertex.header.replace("group(1)","group(2)")}},Ah={name:"local-uniform-bit",vertex:{header:`
836
+
837
+ uniform mat3 uTransformMatrix;
838
+ uniform vec4 uColor;
839
+ uniform float uRound;
840
+ `,main:`
841
+ vColor *= uColor;
842
+ modelMatrix = uTransformMatrix;
843
+ `,end:`
844
+ if(uRound == 1.)
845
+ {
846
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
847
+ }
848
+ `}};class mg extends Li{constructor(e,t){const{text:s,resolution:i,style:n,anchor:o,width:a,height:l,roundPixels:h,...c}=e;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=s??"",this.style=n,this.resolution=i??null,this.allowChildren=!1,this._anchor=new xe({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=h??!1,a!==void 0&&(this.width=a),l!==void 0&&(this.height=l)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){var t;e||(e={}),(t=this._style)==null||t.off("update",this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}containsPoint(e){const t=this.bounds.width,s=this.bounds.height,i=-t*this.anchor.x;let n=0;return e.x>=i&&e.x<=i+t&&(n=-s*this.anchor.y,e.y>=n&&e.y<=n+s)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(e=!1){super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e=="boolean"?e:e!=null&&e.style)&&this._style.destroy(e),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function gg(r,e){let t=r[0]??{};return(typeof t=="string"||r[1])&&(F(Z,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:r[1]}),t}let mt=null,Qe=null;function _g(r,e){mt||(mt=z.get().createCanvas(256,128),Qe=mt.getContext("2d",{willReadFrequently:!0}),Qe.globalCompositeOperation="copy",Qe.globalAlpha=1),(mt.width<r||mt.height<e)&&(mt.width=Yt(r),mt.height=Yt(e))}function xa(r,e,t){for(let s=0,i=4*t*e;s<e;++s,i+=4)if(r[i+3]!==0)return!1;return!0}function ya(r,e,t,s,i){const n=4*e;for(let o=s,a=s*n+4*t;o<=i;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function xg(...r){let e=r[0];e.canvas||(e={canvas:r[0],resolution:r[1]});const{canvas:t}=e,s=Math.min(e.resolution??1,1),i=e.width??t.width,n=e.height??t.height;let o=e.output;if(_g(i,n),!Qe)throw new TypeError("Failed to get canvas 2D context");Qe.drawImage(t,0,0,i,n,0,0,i*s,n*s);const l=Qe.getImageData(0,0,i,n).data;let h=0,c=0,u=i-1,d=n-1;for(;c<n&&xa(l,i,c);)++c;if(c===n)return Q.EMPTY;for(;xa(l,i,d);)--d;for(;ya(l,i,h,c,d);)++h;for(;ya(l,i,u,c,d);)--u;return++u,++d,Qe.globalCompositeOperation="source-over",Qe.strokeRect(h,c,u-h,d-c),Qe.globalCompositeOperation="copy",o??(o=new Q),o.set(h/s,c/s,(u-h)/s,(d-c)/s),o}/**
849
+ * tiny-lru
850
+ *
851
+ * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
852
+ * @license BSD-3-Clause
853
+ * @version 11.4.7
854
+ */class yg{constructor(e=0,t=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=s,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){const t=new Array(e.length);for(let s=0;s<e.length;s++){const i=e[s];t[s]=[i,this.get(i)]}return t}evict(e=!1){if(e||this.size>0){const t=this.first;delete this.items[t.key],--this.size===0?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){const t=this.items[e];if(t!==void 0){if(this.ttl>0&&t.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(t),t.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){const e=new Array(this.size);let t=this.first,s=0;for(;t!==null;)e[s++]=t.key,t=t.next;return e}setWithEvicted(e,t,s=this.resetTtl){let i=null;if(this.has(e))this.set(e,t,!0,s);else{this.max>0&&this.size===this.max&&(i={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t};++this.size===1?this.first=n:this.last.next=n,this.last=n}return i}set(e,t,s=!1,i=this.resetTtl){let n=this.items[e];return s||n!==void 0?(n.value=t,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[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(e=this.keys()){const t=new Array(e.length);for(let s=0;s<e.length;s++)t[s]=this.get(e[s]);return t}}function Eh(r=1e3,e=0,t=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if(typeof t!="boolean")throw new TypeError("Invalid resetTtl value");return new yg(r,e,t)}function Ph(r){return!!r.tagStyles&&Object.keys(r.tagStyles).length>0}function Mh(r){return r.includes("<")}function bg(r,e){return r.clone().assign(e)}function vg(r,e){const t=[],s=e.tagStyles;if(!Ph(e)||!Mh(r))return t.push({text:r,style:e}),t;const i=[e],n=[];let o="",a=0;for(;a<r.length;){const l=r[a];if(l==="<"){const h=r.indexOf(">",a);if(h===-1){o+=l,a++;continue}const c=r.indexOf("<",a+1);if(c!==-1&&c<h){o+=l,a++;continue}const u=r.slice(a+1,h);if(u.startsWith("/")){const d=u.slice(1).trim();if(n.length>0&&n[n.length-1]===d){o.length>0&&(t.push({text:o,style:i[i.length-1]}),o=""),i.pop(),n.pop(),a=h+1;continue}else{o+=r.slice(a,h+1),a=h+1;continue}}else{const d=u.trim();if(s[d]){o.length>0&&(t.push({text:o,style:i[i.length-1]}),o="");const f=i[i.length-1],p=bg(f,s[d]);i.push(p),n.push(d),a=h+1;continue}else{o+=r.slice(a,h+1),a=h+1;continue}}}else o+=l,a++}return o.length>0&&t.push({text:o,style:i[i.length-1]}),t}const Tg=[10,13],Sg=new Set(Tg),wg=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Cg=new Set(wg),Ag=[9,32],Eg=new Set(Ag),Pg=[45,8208,8211,8212,173],Mg=new Set(Pg),Rg=/(\r\n|\r|\n)/,Bg=/(?:\r\n|\r|\n)/;function gr(r){return typeof r!="string"?!1:Sg.has(r.charCodeAt(0))}function Ee(r,e){return typeof r!="string"?!1:Cg.has(r.charCodeAt(0))}function ba(r){return typeof r!="string"?!1:Eg.has(r.charCodeAt(0))}function Rh(r){return typeof r!="string"?!1:Mg.has(r.charCodeAt(0))}function ln(r){return r==="normal"||r==="pre-line"}function hn(r){return r==="normal"}function Ke(r){if(typeof r!="string")return"";let e=r.length-1;for(;e>=0&&Ee(r[e]);)e--;return e<r.length-1?r.slice(0,e+1):r}function Bh(r){const e=[],t=[];if(typeof r!="string")return e;for(let s=0;s<r.length;s++){const i=r[s],n=r[s+1];if(Ee(i)||gr(i)){t.length>0&&(e.push(t.join("")),t.length=0),i==="\r"&&n===`
855
+ `?(e.push(`\r
856
+ `),s++):e.push(i);continue}t.push(i),Rh(i)&&n&&!Ee(n)&&!gr(n)&&(e.push(t.join("")),t.length=0)}return t.length>0&&e.push(t.join("")),e}function kh(r,e,t,s){const i=t(r),n=[];for(let o=0;o<i.length;o++){let a=i[o],l=a,h=1;for(;i[o+h];){const c=i[o+h];if(!s(l,c,r,o,e))a+=c,l=c,h++;else break}o+=h-1,n.push(a)}return n}const kg=/\r\n|\r|\n/g;function Ig(r,e,t,s,i,n,o,a,l){var U,he;const h=vg(r,e);if(hn(e.whiteSpace))for(let M=0;M<h.length;M++){const I=h[M];h[M]={text:I.text.replace(kg," "),style:I.style}}const u=[];let d=[];for(const M of h){const I=M.text.split(Rg);for(let L=0;L<I.length;L++){const B=I[L];B===`\r
857
+ `||B==="\r"||B===`
858
+ `?(u.push(d),d=[]):B.length>0&&d.push({text:B,style:M.style})}}(d.length>0||u.length===0)&&u.push(d);const f=t?Fg(u,e,s,n,a,l):u,p=[],g=[],m=[],_=[],x=[];let y=0;const T=e._fontString,S=o(T);S.fontSize===0&&(S.fontSize=e.fontSize,S.ascent=e.fontSize);let v="",w=!!e.dropShadow,A=((U=e._stroke)==null?void 0:U.width)||0;for(const M of f){let I=0,L=S.ascent,B=S.descent,N="";for(const D of M){const q=D.style._fontString,ne=o(q);q!==v&&(s.font=q,v=q);const ae=i(D.text,D.style.letterSpacing,s);I+=ae,L=Math.max(L,ne.ascent),B=Math.max(B,ne.descent),N+=D.text;const J=((he=D.style._stroke)==null?void 0:he.width)||0;J>A&&(A=J),!w&&D.style.dropShadow&&(w=!0)}M.length===0&&(L=S.ascent,B=S.descent),p.push(I),g.push(L),m.push(B),x.push(N);const Y=e.lineHeight||L+B;_.push(Y+e.leading),y=Math.max(y,I)}const R=A,C=y+R+(e.dropShadow?e.dropShadow.distance:0);let E=0;for(let M=0;M<_.length;M++)E+=_[M];E=Math.max(E,_[0]+R);const P=E+(e.dropShadow?e.dropShadow.distance:0),k=e.lineHeight||S.fontSize;return{width:C,height:P,lines:x,lineWidths:p,lineHeight:k+e.leading,maxLineWidth:y,fontProperties:S,runsByLine:f,lineAscents:g,lineDescents:m,lineHeights:_,hasDropShadow:w}}function Fg(r,e,t,s,i,n){var m;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:l,breakWords:h}=e,c=ln(a),u=l+o,d={};let f="";const p=(_,x)=>{const y=`${_}|${x.styleKey}`;let T=d[y];if(T===void 0){const S=x._fontString;S!==f&&(t.font=S,f=S),T=s(_,x.letterSpacing,t)+x.letterSpacing,d[y]=T}return T},g=[];for(const _ of r){const x=Gg(_),y=g.length,T=P=>{let k=0,U=P;do{const{token:he,style:M}=x[U];k+=p(he,M),U++}while(U<x.length&&x[U].continuesFromPrevious);return k},S=P=>{const k=[];let U=P;do k.push({token:x[U].token,style:x[U].style}),U++;while(U<x.length&&x[U].continuesFromPrevious);return k};let v=[],w=0,A=!c,R=null;const C=()=>{R&&R.text.length>0&&v.push(R),R=null},E=()=>{if(C(),v.length>0){const P=v[v.length-1];P.text=Ke(P.text),P.text.length===0&&v.pop()}g.push(v),v=[],w=0,A=!1};for(let P=0;P<x.length;P++){const{token:k,style:U,continuesFromPrevious:he}=x[P],M=p(k,U);if(c){const B=Ee(k),N=(R==null?void 0:R.text[R.text.length-1])??((m=v[v.length-1])==null?void 0:m.text.slice(-1))??"",Y=N?Ee(N):!1;if(B&&Y)continue}const I=!he,L=I?T(P):M;if(L>u&&I)if(w>0&&E(),h){const B=S(P);for(let N=0;N<B.length;N++){const Y=B[N].token,D=B[N].style,q=kh(Y,h,n,i);for(const ne of q){const ae=p(ne,D);ae+w>u&&E(),!R||R.style!==D?(C(),R={text:ne,style:D}):R.text+=ne,w+=ae}}P+=B.length-1}else{const B=S(P);C(),g.push(B.map(N=>({text:N.token,style:N.style}))),A=!1,P+=B.length-1}else if(L+w>u&&I){if(Ee(k)){A=!1;continue}E(),R={text:k,style:U},w=M}else if(he&&!h)!R||R.style!==U?(C(),R={text:k,style:U}):R.text+=k,w+=M;else{const B=Ee(k);if(w===0&&B&&!A)continue;!R||R.style!==U?(C(),R={text:k,style:U}):R.text+=k,w+=M}}if(C(),v.length>0){const P=v[v.length-1];P.text=Ke(P.text),P.text.length===0&&v.pop()}(v.length>0||g.length===y)&&g.push(v)}return g}function Gg(r){const e=[];let t=!1;for(const s of r){const i=Bh(s.text);let n=!0;for(const o of i){const a=Ee(o)||gr(o),l=n&&t&&!a;e.push({token:o,style:s.style,continuesFromPrevious:l}),t=!a,n=!1}}return e}const Ug={willReadFrequently:!0};function va(r,e,t,s,i){let n=t[r];return typeof n!="number"&&(n=i(r,e,s)+e,t[r]=n),n}function Og(r,e,t,s,i,n,o){const a=t.getContext("2d",Ug);a.font=e._fontString;let l=0,h="";const c=[],u=Object.create(null),{letterSpacing:d,whiteSpace:f}=e,p=ln(f),g=hn(f);let m=!p;const _=e.wordWrapWidth+d,x=Bh(r);for(let T=0;T<x.length;T++){let S=x[T];if(gr(S)){if(!g){c.push(Ke(h)),m=!p,h="",l=0;continue}S=" "}if(p){const w=Ee(S),A=Ee(h[h.length-1]);if(w&&A)continue}const v=va(S,d,u,a,s);if(v>_)if(h!==""&&(c.push(Ke(h)),h="",l=0),i(S,e.breakWords)){const w=kh(S,e.breakWords,o,n);for(const A of w){const R=va(A,d,u,a,s);R+l>_&&(c.push(Ke(h)),m=!1,h="",l=0),h+=A,l+=R}}else h.length>0&&(c.push(Ke(h)),h="",l=0),c.push(Ke(S)),m=!1,h="",l=0;else v+l>_&&(m=!1,c.push(Ke(h)),h="",l=0),(h.length>0||!Ee(S)||m)&&(h+=S,l+=v)}const y=Ke(h);return y.length>0&&c.push(y),c.join(`
859
+ `)}const Ta={willReadFrequently:!0},nt=class H{static get experimentalLetterSpacingSupported(){let e=H._experimentalLetterSpacingSupported;if(e===void 0){const t=z.get().getCanvasRenderingContext2D().prototype;e=H._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,s,i,n,o,a,l,h,c){this.text=e,this.style=t,this.width=s,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(e=" ",t,s=H._canvas,i=t.wordWrap){var T;const n=`${e}-${t.styleKey}-wordWrap-${i}`;if(H._measurementCache.has(n))return H._measurementCache.get(n);if(Ph(t)&&Mh(e)){const S=Ig(e,t,i,H._context,H._measureText,H._measureTextAdvance,H.measureFont,H.canBreakChars,H.wordWrapSplit),v=new H(e,t,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 H._measurementCache.set(n,v),v}const a=t._fontString,l=H.measureFont(a);l.fontSize===0&&(l.fontSize=t.fontSize,l.ascent=t.fontSize,l.descent=0);const h=H._context;h.font=a;const u=(i?H._wordWrap(e,t,s):e).split(Bg),d=new Array(u.length);let f=0;for(let S=0;S<u.length;S++){const v=H._measureText(u[S],t.letterSpacing,h);d[S]=v,f=Math.max(f,v)}const p=((T=t._stroke)==null?void 0:T.width)??0,g=t.lineHeight||l.fontSize,m=H._adjustWidthForStyle(f,t),_=Math.max(g,l.fontSize+p)+(u.length-1)*(g+t.leading),x=H._adjustHeightForStyle(_,t),y=new H(e,t,m,x,u,d,g+t.leading,f,l);return H._measurementCache.set(n,y),y}static _adjustWidthForStyle(e,t){var n;const s=((n=t._stroke)==null?void 0:n.width)||0;let i=e+s;return t.dropShadow&&(i+=t.dropShadow.distance),i}static _adjustHeightForStyle(e,t){let s=e;return t.dropShadow&&(s+=t.dropShadow.distance),s}static _measureText(e,t,s){const{metricWidth:i,metrics:n,letterSpacingVal:o}=H._measureTextCore(e,t,s),a=-(n.actualBoundingBoxLeft??0);let h=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(h+=o),Math.max(i,h)}static _measureTextAdvance(e,t,s){return H._measureTextCore(e,t,s).metricWidth}static _measureTextCore(e,t,s){let i=!1;H.experimentalLetterSpacingSupported&&(H.experimentalLetterSpacing?(s.letterSpacing=`${t}px`,s.textLetterSpacing=`${t}px`,i=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const n=s.measureText(e);let o=n.width,a=0;return o>0&&(i?a=-t:a=(H.graphemeSegmenter(e).length-1)*t,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(e,t,s=H._canvas){return Og(e,t,s,H._measureTextAdvance,H.canBreakWords,H.canBreakChars,H.wordWrapSplit)}static isBreakingSpace(e,t){return Ee(e)}static canBreakWords(e,t){return t}static canBreakChars(e,t,s,i,n){return!0}static wordWrapSplit(e){return H.graphemeSegmenter(e)}static measureFont(e){if(H._fonts[e])return H._fonts[e];const t=H._context;t.font=e;const s=t.measureText(H.METRICS_STRING+H.BASELINE_SYMBOL),i=s.actualBoundingBoxAscent??0,n=s.actualBoundingBoxDescent??0,o={ascent:i,descent:n,fontSize:i+n};return H._fonts[e]=o,o}static clearMetrics(e=""){e?delete H._fonts[e]:H._fonts={}}static get _canvas(){if(!H.__canvas){let e;try{const t=new OffscreenCanvas(0,0),s=t.getContext("2d",Ta);if(s!=null&&s.measureText)return H.__canvas=t,t;e=z.get().createCanvas()}catch{e=z.get().createCanvas()}e.width=e.height=10,H.__canvas=e}return H.__canvas}static get _context(){return H.__context||(H.__context=H._canvas.getContext("2d",Ta)),H.__context}};nt.METRICS_STRING="|ÉqÅ";nt.BASELINE_SYMBOL="M";nt.BASELINE_MULTIPLIER=1.4;nt.HEIGHT_MULTIPLIER=2;nt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return e=>{const t=r.segment(e),s=[];let i=0;for(const n of t)s[i++]=n.segment;return s}}return r=>[...r]})();nt.experimentalLetterSpacing=!1;nt._fonts={};nt._measurementCache=Eh(1e3);let Ie=nt;const Dg=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Ms(r){const e=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let t=r.fontFamily;Array.isArray(r.fontFamily)||(t=r.fontFamily.split(","));for(let s=t.length-1;s>=0;s--){let i=t[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!Dg.includes(i)&&(i=`"${i}"`),t[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${e} ${t.join(",")}`}const Sa=1e5;function Wt(r,e,t,s=0,i=0,n=0){if(r.texture===O.WHITE&&!r.fill)return ee.shared.setValue(r.color).setAlpha(r.alpha??1).toHexa();if(r.fill){if(r.fill instanceof Is){const o=r.fill,a=e.createPattern(o.texture.source.resource,"repeat"),l=o.transform.copyTo(G.shared);return l.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(l),a}else if(r.fill instanceof $e){const o=r.fill,a=o.type==="linear",l=o.textureSpace==="local";let h=1,c=1;l&&t&&(h=t.width+s,c=t.height+s);let u,d=!1;if(a){const{start:f,end:p}=o;u=e.createLinearGradient(f.x*h+i,f.y*c+n,p.x*h+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=e.createRadialGradient(f.x*h+i,f.y*c+n,p*h,g.x*h+i,g.y*c+n,m*h)}if(d&&l&&t){const f=t.lineHeight/c;for(let p=0;p<t.lines.length;p++){const g=(p*t.lineHeight+s/2)/c;o.colorStops.forEach(m=>{let _=g+m.offset*f;_=Math.max(0,Math.min(1,_)),u.addColorStop(Math.floor(_*Sa)/Sa,ee.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(f=>{u.addColorStop(f.offset,ee.shared.setValue(f.color).toHex())});return u}}else{const o=e.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 W("FillStyle not recognised",r),"red"}const wa=new Q;function Ot(r){let e=0;for(let t=0;t<r.length;t++)r.charCodeAt(t)===32&&e++;return e}class Lg{getCanvasAndContext(e){const{text:t,style:s,resolution:i=1}=e,n=s._getFinalPadding(),o=Ie.measureText(t||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*i),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*i),h=ct.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(s,n,i,h,o);const c=s.trim?xg({canvas:h.canvas,width:a,height:l,resolution:1,output:wa}):wa.set(0,0,a,l);return{canvasAndContext:h,frame:c}}returnCanvasAndContext(e){ct.returnCanvasAndContext(e)}_renderTextToCanvas(e,t,s,i,n){var S,v,w;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,t,s,i);return}const{canvas:o,context:a}=i,l=Ms(e),h=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=e.textBaseline,(S=e._stroke)!=null&&S.width){const A=e._stroke;a.lineWidth=A.width,a.miterLimit=A.miterLimit,a.lineJoin=A.join,a.lineCap=A.cap}a.font=l;let g,m;const _=e.dropShadow?2:1,y=(((v=e._stroke)==null?void 0:v.width)??0)/2;let T=(c-f.fontSize)/2;c-f.fontSize<0&&(T=0);for(let A=0;A<_;++A){const R=e.dropShadow&&A===0,C=R?Math.ceil(Math.max(1,p)+t*2):0,E=C*s;if(R)this._setupDropShadow(a,e,s,E);else{const P=e._gradientBounds,k=e._gradientOffset;if(P){const U={width:P.width,height:P.height,lineHeight:P.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,U,t,y,(k==null?void 0:k.x)??0,(k==null?void 0:k.y)??0)}else k?this._setFillAndStrokeStyles(a,e,n,t,y,k.x,k.y):this._setFillAndStrokeStyles(a,e,n,t,y);a.shadowColor="rgba(0,0,0,0)"}for(let P=0;P<h.length;P++){g=y,m=y+P*c+f.ascent+T,g+=this._getAlignmentOffset(u[P],d,e.align);let k=0;if(e.align==="justify"&&e.wordWrap&&P<h.length-1){const U=Ot(h[P]);U>0&&(k=(d-u[P])/U)}(w=e._stroke)!=null&&w.width&&this._drawLetterSpacing(h[P],e,i,g+t,m+t-C,!0,k),e._fill!==void 0&&this._drawLetterSpacing(h[P],e,i,g+t,m+t-C,!1,k)}}}_renderTaggedTextToCanvas(e,t,s,i,n){var y,T,S;const{canvas:o,context:a}=n,{runsByLine:l,lineWidths:h,maxLineWidth:c,lineAscents:u,lineHeights:d,hasDropShadow:f}=e,p=o.height;a.resetTransform(),a.scale(i,i),a.textBaseline=t.textBaseline;const g=f?2:1;let m=((y=t._stroke)==null?void 0:y.width)??0;for(const v of l)for(const w of v){const A=((T=w.style._stroke)==null?void 0:T.width)??0;A>m&&(m=A)}const _=m/2,x=[];for(let v=0;v<l.length;v++){const w=l[v],A=[];for(const R of w){const C=Ms(R.style);a.font=C,A.push({width:Ie._measureText(R.text,R.style.letterSpacing,a),font:C})}x.push(A)}for(let v=0;v<g;++v){const w=f&&v===0,A=w?Math.ceil(Math.max(1,p)+s*2):0,R=A*i;w||(a.shadowColor="rgba(0,0,0,0)");let C=_;for(let E=0;E<l.length;E++){const P=l[E],k=h[E],U=u[E],he=d[E],M=x[E];let I=_;I+=this._getAlignmentOffset(k,c,t.align);let L=0;if(t.align==="justify"&&t.wordWrap&&E<l.length-1){let Y=0;for(const D of P)Y+=Ot(D.text);Y>0&&(L=(c-k)/Y)}const B=C+U;let N=I+s;for(let Y=0;Y<P.length;Y++){const D=P[Y],{width:q,font:ne}=M[Y];if(a.font=ne,a.textBaseline=D.style.textBaseline,(S=D.style._stroke)!=null&&S.width){const J=D.style._stroke;if(a.lineWidth=J.width,a.miterLimit=J.miterLimit,a.lineJoin=J.join,a.lineCap=J.cap,w)if(D.style.dropShadow)this._setupDropShadow(a,D.style,i,R);else{const pe=Ot(D.text);N+=q+pe*L;continue}else{const pe=Ie.measureFont(ne),be=D.style.lineHeight||pe.fontSize,X={width:q,height:be,lineHeight:be,lines:[D.text]};a.strokeStyle=Wt(J,a,X,s*2,N-s,C)}this._drawLetterSpacing(D.text,D.style,n,N,B+s-A,!0,L)}const ae=Ot(D.text);N+=q+ae*L}N=I+s;for(let Y=0;Y<P.length;Y++){const D=P[Y],{width:q,font:ne}=M[Y];if(a.font=ne,a.textBaseline=D.style.textBaseline,D.style._fill!==void 0){if(w)if(D.style.dropShadow)this._setupDropShadow(a,D.style,i,R);else{const J=Ot(D.text);N+=q+J*L;continue}else{const J=Ie.measureFont(ne),pe=D.style.lineHeight||J.fontSize,be={width:q,height:pe,lineHeight:pe,lines:[D.text]};a.fillStyle=Wt(D.style._fill,a,be,s*2,N-s,C)}this._drawLetterSpacing(D.text,D.style,n,N,B+s-A,!1,L)}const ae=Ot(D.text);N+=q+ae*L}C+=he}}}_setFillAndStrokeStyles(e,t,s,i,n,o=0,a=0){var l;if(e.fillStyle=t._fill?Wt(t._fill,e,s,i*2,o,a):null,(l=t._stroke)!=null&&l.width){const h=n+i*2;e.strokeStyle=Wt(t._stroke,e,s,h,o,a)}}_setupDropShadow(e,t,s,i){e.fillStyle="black",e.strokeStyle="black";const n=t.dropShadow,o=n.color,a=n.alpha;e.shadowColor=ee.shared.setValue(o).setAlpha(a).toRgbaString();const l=n.blur*s,h=n.distance*s;e.shadowBlur=l,e.shadowOffsetX=Math.cos(n.angle)*h,e.shadowOffsetY=Math.sin(n.angle)*h+i}_getAlignmentOffset(e,t,s){return s==="right"?t-e:s==="center"?(t-e)/2:0}_drawLetterSpacing(e,t,s,i,n,o=!1,a=0){const{context:l}=s,h=t.letterSpacing;let c=!1;if(Ie.experimentalLetterSpacingSupported&&(Ie.experimentalLetterSpacing?(l.letterSpacing=`${h}px`,l.textLetterSpacing=`${h}px`,c=!0):(l.letterSpacing="0px",l.textLetterSpacing="0px")),(h===0||c)&&a===0){o?l.strokeText(e,i,n):l.fillText(e,i,n);return}if(a!==0&&(h===0||c)){const g=e.split(" ");let m=i;const _=l.measureText(" ").width;for(let x=0;x<g.length;x++)o?l.strokeText(g[x],m,n):l.fillText(g[x],m,n),m+=l.measureText(g[x]).width+_+a;return}let u=i;const d=Ie.graphemeSegmenter(e);let f=l.measureText(e).width,p=0;for(let g=0;g<d.length;++g){const m=d[g];o?l.strokeText(m,u,n):l.fillText(m,u,n);let _="";for(let x=g+1;x<d.length;++x)_+=d[x];p=l.measureText(_).width,u+=f-p+h,m===" "&&(u+=a),f=p}}}const Ht=new Lg,cn=class vt extends Re{constructor(e={}){super(),this.uid=re("textStyle"),this._tick=0,this._cachedFontString=null,Ng(e),e instanceof vt&&(e=e._toObject());const i={...vt.defaultTextStyle,...e};for(const n in i){const o=n;this[o]=i[n]}this._tagStyles=e.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...vt.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...vt.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Fe.defaultFillStyle,...e},()=>{this._fill=St({...this._originalFill},Fe.defaultFillStyle)})),this._fill=St(e===0?"black":e,Fe.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Fe.defaultStrokeStyle,...e},()=>{this._stroke=fr({...this._originalStroke},Fe.defaultStrokeStyle)})),this._stroke=fr(e,Fe.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const e=vt.defaultTextStyle;for(const t in e)this[t]=e[t]}assign(e){for(const t in e){const s=t;this[s]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Ms(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 vt(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){var s,i,n,o;if(this.removeAllListeners(),typeof e=="boolean"?e:e==null?void 0:e.texture){const a=typeof e=="boolean"?e:e==null?void 0:e.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(e,t){return new Proxy(e,{set:(s,i,n)=>(s[i]===n||(s[i]=n,t==null||t(i,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(ee.isColorLike(e)||e instanceof $e||e instanceof Is)}};cn.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};cn.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 Et=cn;function Ng(r){const e=r;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=Et.defaultDropShadow;r.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){F(Z,"strokeThickness is now a part of stroke");const t=e.stroke;let s={};if(ee.isColorLike(t))s.color=t;else if(t instanceof $e||t instanceof Is)s.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))s=t;else throw new Error("Invalid stroke value.");r.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(F(Z,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||e.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&W("The number of fill colors must match the number of fill gradient stops.");const t=new $e({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),i=e.fill.map(n=>ee.shared.setValue(n).toNumber());s.forEach((n,o)=>{t.addColorStop(n,i[o])}),r.fill={fill:t}}}function Wg(r,e){const{texture:t,bounds:s}=r,i=e._style._getFinalPadding();ja(s,e._anchor,t);const n=e._anchor._x*i*2,o=e._anchor._y*i*2;s.minX-=i-n,s.minY-=i-o,s.maxX-=i-n,s.maxY-=i-o}class un{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 Hg extends un{}class Ih{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),this._managedTexts=new je({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const e in this._managedTexts.items){const t=this._managedTexts.items[e];t!=null&&t._autoResolution&&t.onViewUpdate()}}validateRenderable(e){const t=this._getGpuText(e),s=e.styleKey;return t.currentKey!==s?!0:e._didTextUpdate}addRenderable(e,t){const s=this._getGpuText(e);if(e._didTextUpdate){const i=e._autoResolution?this._renderer.resolution:e.resolution;(s.currentKey!==e.styleKey||e._resolution!==i)&&this._updateGpuText(e),e._didTextUpdate=!1,Wg(s,e)}this._renderer.renderPipes.batch.addToBatch(s,t)}updateRenderable(e){const t=this._getGpuText(e);t._batcher.updateElement(t)}_updateGpuText(e){const t=this._getGpuText(e);t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){const t=new Hg;return t.currentKey="--",t.renderable=e,t.transform=e.groupTransform,t.bounds={minX:0,maxX:1,minY:0,maxY:0},t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,this._managedTexts.add(e),t}onTextUnload(e){const t=e._gpuData[this._renderer.uid];if(!t)return;const{canvasText:s}=this._renderer;s.getReferenceCount(t.currentKey)>0?s.decreaseReferenceCount(t.currentKey):t.texture&&s.returnTexture(t.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Ih.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};class Fh{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,s,i){typeof e=="string"&&(F("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:s,resolution:t}),e.style instanceof Et||(e.style=new Et(e.style)),e.textureStyle instanceof tt||(e.textureStyle=new tt(e.textureStyle)),typeof e.text!="string"&&(e.text=e.text.toString());const{text:n,style:o,textureStyle:a,autoGenerateMipmaps:l}=e,h=e.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=Ht.getCanvasAndContext({text:n,style:o,resolution:h}),d=fh(u.canvas,c.width,c.height,h,l);if(a&&(d.source.style=a),o.trim&&(c.pad(o.padding),d.frame.copyFrom(c),d.frame.scale(1/h),d.updateUvs()),o.filters){const f=this._applyFilters(d,o.filters);return this.returnTexture(d),Ht.returnCanvasAndContext(u),f}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Ht.returnCanvasAndContext(u),d}returnTexture(e){const t=e.source,s=t.resource;if(this._retainCanvasContext&&(s!=null&&s.getContext)){const i=s.getContext("2d");i&&Ht.returnCanvasAndContext({canvas:s,context:i})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",ue.returnTexture(e,!0)}renderTextToCanvas(){F("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;const t=e.styleKey;if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;const s=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle,autoGenerateMipmaps:e.autoGenerateMipmaps});return this._activeTextures[t]={texture:s,usageCount:1},s}decreaseReferenceCount(e){const t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(this.returnTexture(t.texture),this._activeTextures[e]=null))}getReferenceCount(e){var t;return((t=this._activeTextures[e])==null?void 0:t.usageCount)??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,t){const s=this._renderer.renderTarget.renderTarget,i=this._renderer.filter.generateFilteredTexture({texture:e,filters:t});return this._renderer.renderTarget.bind(s,!1),i}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}class Gh extends Fh{constructor(e){super(e,!0)}}Gh.extension={type:[b.CanvasSystem],name:"canvasText"};class Uh extends Fh{constructor(e){super(e,!1)}}Uh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"canvasText"};V.add(Gh);V.add(Uh);V.add(Ih);class py extends mg{constructor(...e){const t=gg(e,"Text");super(t,Et),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof tt?t.textureStyle:new tt(t.textureStyle)),this.autoGenerateMipmaps=t.autoGenerateMipmaps??me.defaultOptions.autoGenerateMipmaps}updateBounds(){const e=this._bounds,t=this._anchor;let s=0,i=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Ht.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ht.returnCanvasAndContext(o),s=n.width,i=n.height}else{const n=Ie.measureText(this._text,this._style);s=n.width,i=n.height}e.minX=-t._x*s,e.maxX=e.minX+s,e.minY=-t._y*i,e.maxY=e.minY+i}}class Oh extends Re{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return F(Z,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return F(Z,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return F(Z,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return F(Z,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return F(Z,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(e=!1){var t;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(t=this.chars[s].texture)==null||t.destroy();this.chars=null,e&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const Dh=class Lh extends Oh{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const t={...Lh.defaultOptions,...e};this._textureSize=t.textureSize,this._mipmap=t.mipmap;const s=t.style.clone();t.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=O.WHITE,s._fill.fill=null),this.applyFillAsTint=t.overrideFill;const i=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const n=Ms(s);t.overrideSize?(s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/i),s.dropShadow&&(s.dropShadow.blur*=this.baseRenderedFontSize/i,s.dropShadow.distance*=this.baseRenderedFontSize/i)):s.fontSize=this.baseRenderedFontSize=i,this._style=s,this._skipKerning=t.skipKerning??!1,this.resolution=t.resolution??1,this._padding=t.padding??4,t.textureStyle&&(this._textureStyle=t.textureStyle instanceof tt?t.textureStyle:new tt(t.textureStyle)),this.fontMetrics=Ie.measureFont(n),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(e){var _,x;const t=Ie.graphemeSegmenter(e).filter(y=>!this._currentChars.includes(y)).filter((y,T,S)=>S.indexOf(y)===T);if(!t.length)return;this._currentChars=[...this._currentChars,...t];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:i,context:n}=s.canvasAndContext,o=s.texture.source;const a=this._style;let l=this._currentX,h=this._currentY,c=this._currentMaxCharHeight;const u=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=(((_=a.dropShadow)==null?void 0:_.distance)??0)+(((x=a._stroke)==null?void 0:x.width)??0),f=this._padding+d;let p=!1;const g=i.width/this.resolution,m=i.height/this.resolution;for(let y=0;y<t.length;y++){const T=t[y],S=Ie.measureText(T,a,i,!1);S.lineHeight=S.height;const v=S.width*u,w=Math.ceil((a.fontStyle==="italic"?2:1)*v),A=S.height*u,R=w+f*2,C=A+f*2;if(p=!1,T!==`
860
+ `&&T!=="\r"&&T!==" "&&T!==" "&&(p=!0,c=Math.ceil(Math.max(C,c))),l+R>g&&(h+=c,c=C,l=0,h+c>m)){o.update();const P=this._nextPage();i=P.canvasAndContext.canvas,n=P.canvasAndContext.context,o=P.texture.source,l=0,h=0,c=0}const E=n.measureText(T).width/u;if(this.chars[T]={id:T.codePointAt(0),xOffset:-(f/u),yOffset:-(f/u),xAdvance:E,kerning:{}},p){this._drawGlyph(n,S,l+f,h+f,u,a);const P=o.width*u,k=o.height*u,U=new Q(l/P*o.width,h/k*o.height,R/P*o.width,C/k*o.height);this.chars[T].texture=new O({source:o,frame:U}),l+=Math.ceil(R)}}o.update(),this._currentX=l,this._currentY=h,this._currentMaxCharHeight=c,this._skipKerning||this._applyKerning(t,n,u)}get pageTextures(){return F(Z,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(e,t,s){const i=this._measureCache;for(let n=0;n<e.length;n++){const o=e[n];for(let a=0;a<this._currentChars.length;a++){const l=this._currentChars[a];let h=i[o];h||(h=i[o]=t.measureText(o).width);let c=i[l];c||(c=i[l]=t.measureText(l).width);let u=t.measureText(o+l).width,d=u-(h+c);d&&this.chars[o]&&(this.chars[o].kerning[l]=d/s),u=t.measureText(o+l).width,d=u-(h+c),d&&this.chars[l]&&(this.chars[l].kerning[o]=d/s)}}}_nextPage(){this._currentPageIndex++;const e=this.resolution,t=ct.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(t.context,this._style,e);const s=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),i=new O({source:new Ct({resource:t.canvas,resolution:s,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(i.source.style=this._textureStyle);const n={canvasAndContext:t,texture:i};return this.pages[this._currentPageIndex]=n,n}_setupContext(e,t,s){t.fontSize=this.baseRenderedFontSize,e.scale(s,s),e.font=Ms(t),t.fontSize=this.baseMeasurementFontSize,e.textBaseline=t.textBaseline;const i=t._stroke,n=(i==null?void 0:i.width)??0;if(i&&(e.lineWidth=n,e.lineJoin=i.join,e.miterLimit=i.miterLimit,e.strokeStyle=Wt(i,e)),t._fill&&(e.fillStyle=Wt(t._fill,e)),t.dropShadow){const o=t.dropShadow,a=ee.shared.setValue(o.color).toArray(),l=o.blur*s,h=o.distance*s;e.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,e.shadowBlur=l,e.shadowOffsetX=Math.cos(o.angle)*h,e.shadowOffsetY=Math.sin(o.angle)*h}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,t,s,i,n,o){const a=t.text,l=t.fontProperties,h=o._stroke,c=((h==null?void 0:h.width)??0)*n,u=s+c/2,d=i-c/2,f=l.descent*n,p=t.lineHeight*n;let g=!1;o.stroke&&c&&(g=!0,e.strokeText(a,u,d+p-f));const{shadowBlur:m,shadowOffsetX:_,shadowOffsetY:x}=e;o._fill&&(g&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.fillText(a,u,d+p-f)),g&&(e.shadowBlur=m,e.shadowOffsetX=_,e.shadowOffsetY=x)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){const{canvasAndContext:t,texture:s}=this.pages[e];ct.returnCanvasAndContext(t),s.destroy(!0)}this.pages=null}};Dh.defaultOptions={textureSize:512,style:new Et,mipmap:!0};let Ca=Dh;function zg(r,e,t,s){var y,T;const i={width:0,height:0,offsetY:0,scale:e.fontSize/t.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};i.offsetY=t.baseLineOffset;let n=i.lines[0],o=null,a=!0;const l={width:0,start:0,index:0,positions:[],chars:[]},h=t.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*h,u=e.wordWrapWidth*h,d=e.lineHeight?e.lineHeight*h:t.lineHeight,f=e.wordWrap&&e.breakWords,p=ln(e.whiteSpace),g=hn(e.whiteSpace);if(p||g){const S=[];let v=p;for(let w=0;w<r.length;w++){let A=r[w];if(A==="\r"||A===`
861
+ `)if(g)A==="\r"&&r[w+1]===`
862
+ `&&w++,A=" ";else{p&&(v=!0),S.push(A);continue}if(Ee(A))if(p&&ba(A)){if(v)continue;v=!0,S.push(" ")}else v=!1,S.push(A);else v=!1,S.push(A)}r=S}const m=S=>{const v=n.width;for(let w=0;w<l.index;w++){const A=S.positions[w];n.chars.push(S.chars[w]),n.charPositions.push(A+v)}n.width+=S.width,(l.index>0||!p)&&(a=!1),l.width=0,l.index=0,l.chars.length=0},_=()=>{let S=n.chars.length-1;if(s){let v=n.chars[S];for(;ba(v);)n.width-=t.chars[v].xAdvance,n.spacesIndex.pop(),v=n.chars[--S]}i.width=Math.max(i.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(n),i.height+=d},x=S=>S-c>u;for(let S=0;S<r.length+1;S++){let v;const w=S===r.length;w||(v=r[S]);const A=t.chars[v];if(/(?:\s)/.test(v)||v==="\r"||v===`
863
+ `||w){if(!a&&e.wordWrap&&x(n.width+l.width)?(_(),m(l),w||n.charPositions.push(0)):(l.start=n.width,m(l),w||n.charPositions.push(0)),v==="\r"||v===`
864
+ `)_();else if(!w&&A){const P=A.xAdvance+(((y=A.kerning)==null?void 0:y[o])||0)+c;n.width+=P,n.spaceWidth=P,n.spacesIndex.push(n.charPositions.length),n.chars.push(v)}}else if(A){const E=((T=A.kerning)==null?void 0:T[o])||0,P=A.xAdvance+E+c;f&&x(l.width+P)&&(a||_(),m(l),_()),l.positions[l.index++]=l.width+E,l.chars.push(v),l.width+=P,Rh(v)&&(!a&&e.wordWrap&&x(n.width+l.width)&&_(),m(l))}o=v}return _(),e.align==="center"?Vg(i):e.align==="right"?Xg(i):e.align==="justify"&&$g(i),i}function Vg(r){for(let e=0;e<r.lines.length;e++){const t=r.lines[e],s=r.width/2-t.width/2;for(let i=0;i<t.charPositions.length;i++)t.charPositions[i]+=s}}function Xg(r){for(let e=0;e<r.lines.length;e++){const t=r.lines[e],s=r.width-t.width;for(let i=0;i<t.charPositions.length;i++)t.charPositions[i]+=s}}function $g(r){const e=r.width;for(let t=0;t<r.lines.length-2;t++){const s=r.lines[t];let i=0,n=s.spacesIndex[i++],o=0;const a=s.spacesIndex.length,h=(e-s.width)/a;for(let c=0;c<s.charPositions.length;c++)c===n&&(n=s.spacesIndex[i++],o+=h),s.charPositions[c]+=o}}function jg(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const e=[];for(let t=0,s=r.length;t<s;t++){const i=r[t];if(Array.isArray(i)){if(i.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${i.length}.`);if(i[0].length===0||i[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=i[0].charCodeAt(0),o=i[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)e.push(String.fromCharCode(a))}else e.push(...Array.from(i))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}let Ks=0;class Yg{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=Eh(1e3)}getFont(e,t){var o,a;let s=`${t.fontFamily}-bitmap`,i=!0;if(se.has(s)){const l=se.get(s);return(o=l.ensureCharacters)==null||o.call(l,e),l}if(t._fill.fill&&!t._stroke?(s+=t._fill.fill.styleKey,i=!1):(t._stroke||t.dropShadow)&&(s=`${t.styleKey}-bitmap`,i=!1),s+=`-${t.fontStyle}`,s+=`-${t.fontVariant}`,s+=`-${t.fontWeight}`,!se.has(s)){const l=Object.create(t);l._lineHeight=0;const h=new Ca({style:l,overrideFill:i,overrideSize:!0,...this.defaultOptions});Ks++,Ks>50&&W("BitmapText",`You have dynamically created ${Ks} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),h.once("destroy",()=>{Ks--,se.remove(s)}),se.set(s,h)}const n=se.get(s);return(a=n.ensureCharacters)==null||a.call(n,e),n}getLayout(e,t,s=!0){const i=this.getFont(e,t),n=`${e}-${t.styleKey}-${s}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=Ie.graphemeSegmenter(e),a=zg(o,t,i,s);return this.measureCache.set(n,a),a}measureText(e,t,s=!0){return this.getLayout(e,t,s)}install(...e){var h,c,u,d;let t=e[0];typeof t=="string"&&(t={name:t,style:e[1],chars:(h=e[2])==null?void 0:h.chars,resolution:(c=e[2])==null?void 0:c.resolution,padding:(u=e[2])==null?void 0:u.padding,skipKerning:(d=e[2])==null?void 0:d.skipKerning},F(Z,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=t==null?void 0:t.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};const i=t.style,n=i instanceof Et?i:new Et(i),o=t.dynamicFill??this._canUseTintForStyle(n),a=new Ca({style:n,overrideFill:o,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1,textureStyle:t.textureStyle}),l=jg(t.chars);return a.ensureCharacters(l.join("")),se.set(`${s}-bitmap`,a),a.once("destroy",()=>se.remove(`${s}-bitmap`)),a}uninstall(e){const t=`${e}-bitmap`,s=se.get(t);s&&s.destroy()}_canUseTintForStyle(e){return!e._stroke&&(!e.dropShadow||e.dropShadow.color===0)&&!e._fill.fill&&e._fill.color===16777215}}const Aa=new Yg;function qg(){const{userAgent:r}=z.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const dn=class Tt{static _getPatternRepeat(e,t){const s=e&&e!=="clamp-to-edge",i=t&&t!=="clamp-to-edge";return s&&i?"repeat":s?"repeat-x":i?"repeat-y":"no-repeat"}start(e,t,s){}execute(e,t){var a,l,h,c;const s=t.elements;if(!s||!s.length)return;const i=e.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?j.getCanvasSource(p):null;if(!g)continue;const m=p.source.style,_=n.smoothProperty,x=m.scaleMode!=="nearest";o[_]!==x&&(o[_]=x),n.setBlendMode(t.blendMode);const y=((a=i.globalUniforms.globalUniformData)==null?void 0:a.worldColor)??4294967295,T=f.color,S=(y>>>24&255)/255,v=(T>>>24&255)/255,w=((l=i.filter)==null?void 0:l.alphaMultiplier)??1,A=S*v*w;if(A<=0)continue;o.globalAlpha=A;const R=y&16777215,C=T&16777215,E=Xt(Vt(C,R)),P=p.frame,k=m.addressModeU??m.addressMode,U=m.addressModeV??m.addressMode,he=Tt._getPatternRepeat(k,U),M=p.source._resolution??p.source.resolution??1,I=(c=(h=f.renderable)==null?void 0:h.renderGroup)==null?void 0:c.isCachedAsTexture,L=P.x*M,B=P.y*M,N=P.width*M,Y=P.height*M,D=f.bounds,q=i.renderTarget.renderTarget.isRoot,ne=D.minX,ae=D.minY,J=D.maxX-D.minX,pe=D.maxY-D.minY,be=p.rotate,X=p.uvs,we=Math.min(X.x0,X.x1,X.x2,X.x3,X.y0,X.y1,X.y2,X.y3),Be=Math.max(X.x0,X.x1,X.x2,X.x3,X.y0,X.y1,X.y2,X.y3),de=he!=="no-repeat"&&(we<0||Be>1),Oe=be&&!(!de&&(E!==16777215||be));Oe?(Tt._tempPatternMatrix.copyFrom(f.transform),$.matrixAppendRotationInv(Tt._tempPatternMatrix,be,ne,ae,J,pe),n.setContextTransform(Tt._tempPatternMatrix,f.roundPixels===1,void 0,I&&q)):n.setContextTransform(f.transform,f.roundPixels===1,void 0,I&&q);const ke=Oe?0:ne,Pt=Oe?0:ae,Mt=J,ns=pe;if(de){let Fs=g;const Rt=E!==16777215&&!be,Bt=P.width<=p.source.width&&P.height<=p.source.height;Rt&&Bt&&(Fs=j.getTintedCanvas({texture:p},E));const yr=o.createPattern(Fs,he);if(!yr)continue;const Gn=Mt,Un=ns;if(Gn===0||Un===0)continue;const On=1/Gn,Dn=1/Un,Ln=(X.x1-X.x0)*On,Nn=(X.y1-X.y0)*On,Wn=(X.x3-X.x0)*Dn,Hn=(X.y3-X.y0)*Dn,cu=X.x0-Ln*ke-Wn*Pt,uu=X.y0-Nn*ke-Hn*Pt,br=p.source.pixelWidth,vr=p.source.pixelHeight;Tt._tempPatternMatrix.set(Ln*br,Nn*vr,Wn*br,Hn*vr,cu*br,uu*vr),j.applyPatternTransform(yr,Tt._tempPatternMatrix),o.fillStyle=yr,o.fillRect(ke,Pt,Mt,ns)}else{const Rt=E!==16777215||be?j.getTintedCanvas({texture:p},E):g,Bt=Rt!==g;o.drawImage(Rt,Bt?0:L,Bt?0:B,Bt?Rt.width:N,Bt?Rt.height:Y,ke,Pt,Mt,ns)}}}};dn._tempPatternMatrix=new G;dn.extension={type:[b.CanvasPipesAdaptor],name:"batch"};let Kg=dn;class Nh{constructor(){this._tempState=it.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,s){const i=e.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(t,s.glProgram)}execute(e,t){const s=e.renderer;this._tempState.blendMode=t.blendMode,s.state.set(this._tempState);const i=t.textures.textures;for(let n=0;n<t.textures.count;n++)s.texture.bind(i[n],n);s.geometry.draw(t.topology,t.size,t.start)}}Nh.extension={type:[b.WebGLPipesAdaptor],name:"batch"};const Zs=it.for2d();class Wh{start(e,t,s){const i=e.renderer,n=i.encoder,o=s.gpuProgram;this._shader=s,this._geometry=t,n.setGeometry(t,o),Zs.blendMode="normal",i.pipeline.getPipeline(t,o,Zs);const a=i.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(e,t){const s=this._shader.gpuProgram,i=e.renderer,n=i.encoder;if(!t.bindGroup){const l=t.textures;t.bindGroup=Vi(l.textures,l.count,i.limits.maxBatchableTextures)}Zs.blendMode=t.blendMode;const o=i.bindGroup.getBindGroup(t.bindGroup,s,1),a=i.pipeline.getPipeline(this._geometry,s,Zs,t.topology);t.bindGroup._touch(i.gc.now,i.tick),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(t.size,1,t.start)}}Wh.extension={type:[b.WebGPUPipesAdaptor],name:"batch"};const fn=class Hh{constructor(e,t){var s,i;this.state=it.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,(i=(s=this._adaptor).init)==null||i.call(s,this)}static getBatcher(e){return new this._availableBatchers[e]}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new Ki({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const s in this._activeBatches)this._activeBatches[s].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let s=this._activeBatches[e.batcherName];s||(s=this._activeBatches[e.batcherName]=Hh.getBatcher(e.batcherName),s.begin()),this._activeBatch=s}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const s in t){const i=t[s],n=i.geometry;n.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),n.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(e){const t=this._batchersByInstructionSet[e.uid];for(const s in t){const i=t[s],n=i.geometry;i.dirty&&(i.dirty=!1,n.buffers[0].update(i.attributeSize*4))}}execute(e){if(e.action==="startBatch"){const t=e.batcher,s=t.geometry,i=t.shader;this._adaptor.start(this,s,i)}this._adaptor.execute(this,e)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};fn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"batch"};fn._availableBatchers=Object.create(null);let pn=fn;V.handleByMap(b.Batcher,pn._availableBatchers);V.add(Ki);const Zg={name:"texture-bit",vertex:{header:`
865
+
866
+ struct TextureUniforms {
867
+ uTextureMatrix:mat3x3<f32>,
868
+ }
869
+
870
+ @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
871
+ `,main:`
872
+ uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
873
+ `},fragment:{header:`
874
+ @group(2) @binding(0) var uTexture: texture_2d<f32>;
875
+ @group(2) @binding(1) var uSampler: sampler;
876
+
877
+
878
+ `,main:`
879
+ outColor = textureSample(uTexture, uSampler, vUV);
880
+ `}},Qg={name:"texture-bit",vertex:{header:`
881
+ uniform mat3 uTextureMatrix;
882
+ `,main:`
883
+ uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
884
+ `},fragment:{header:`
885
+ uniform sampler2D uTexture;
886
+
887
+
888
+ `,main:`
889
+ outColor = texture(uTexture, vUV);
890
+ `}},Jg=new ye;class e_ extends ar{constructor(){super(),this.filters=[new hg({sprite:new Kt(O.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}}class mn{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,s){const i=this._renderer;if(i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??"red",e.renderMaskToTexture){const n=e.mask;n.includeInBuild=!0,n.collectRenderables(s,i,null),n.includeInBuild=!1}i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,s=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){const i=_e.get(e_);if(i.inverse=e.inverse,i.channel=e.mask.channel,s){e.mask.mask.measurable=!0;const n=Fi(e.mask.mask,!0,Jg);e.mask.mask.measurable=!1,n.ceil();const o=t.renderTarget.renderTarget.colorTexture.source,a=ue.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);t.renderTarget.push(a,!0),t.globalUniforms.push({offset:n,worldColor:4294967295});const l=i.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:e.maskedContainer,filterTexture:a})}else i.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){const i=this._activeMaskStage[this._activeMaskStage.length-1];s&&(t.type===Me.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();const i=this._activeMaskStage.pop();s&&ue.returnTexture(i.filterTexture),_e.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}mn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"alphaMask"};class zh{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&e.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(e,t,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(e){}destroy(){this._renderer=null,this._colorStack=null}}zh.extension={type:[b.CanvasPipes],name:"colorMask"};class Vh{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,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(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}Vh.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"colorMask"};function t_(r,e,t,s,i,n){n=Math.max(0,Math.min(n,Math.min(s,i)/2)),r.moveTo(e+n,t),r.lineTo(e+s-n,t),r.quadraticCurveTo(e+s,t,e+s,t+n),r.lineTo(e+s,t+i-n),r.quadraticCurveTo(e+s,t+i,e+s-n,t+i),r.lineTo(e+n,t+i),r.quadraticCurveTo(e,t+i,e,t+i-n),r.lineTo(e,t+n),r.quadraticCurveTo(e,t,e+n,t)}function Xh(r,e){switch(e.type){case"rectangle":{const t=e;r.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;t_(r,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;r.moveTo(t.x+t.radius,t.y),r.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;r.ellipse?(r.moveTo(t.x+t.halfWidth,t.y),r.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(r.save(),r.translate(t.x,t.y),r.scale(t.halfWidth,t.halfHeight),r.moveTo(1,0),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const t=e;r.moveTo(t.x,t.y),r.lineTo(t.x2,t.y2),r.lineTo(t.x3,t.y3),r.closePath();break}case"polygon":default:{const t=e,s=t.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]);t.closePath&&r.closePath();break}}}function s_(r,e,t){const s=[],i=[],n=[],o=is[e.type];if(!(o!=null&&o.build(e,s)))return!1;const a=e.closePath??!0;Qi(s,t,!1,a,i,n);for(let l=0;l<n.length;l+=3){const h=n[l]*2,c=n[l+1]*2,u=n[l+2]*2;r.moveTo(i[h],i[h+1]),r.lineTo(i[c],i[c+1]),r.lineTo(i[u],i[u+1]),r.closePath()}return!0}function r_(r,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];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)),Xh(r,s.shape),n&&r.restore()}return!0}class $h{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var c,u,d;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,s=t.canvasContext,i=s==null?void 0:s.activeContext;if(!i)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&i.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const n=e.mask.mask;if(!(n instanceof mr)){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,(t._roundPixels|o._roundPixels)===1),i.beginPath();let l=!1,h=!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 T=0;T<y.length;T++){const S=y[T];if(!(S!=null&&S.shape))continue;const v=S.transform,w=v&&!v.isIdentity();w&&(i.save(),i.transform(v.a,v.b,v.c,v.d,v.tx,v.ty)),x&&m.style?l=s_(i,S.shape,m.style)||l:(Xh(i,S.shape),h=r_(i,S.holes)||h,l=!0),w&&i.restore()}}if(!l){i.restore(),this._canvasMaskStack.push(!1);return}h?i.clip("evenodd"):i.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),W(t))}}$h.extension={type:[b.CanvasPipes],name:"stencilMask"};class jh{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,s){var i;const n=e,o=this._renderer;o.renderPipes.batch.break(s),o.renderPipes.blendMode.setBlendMode(n.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const a=n.mask;a.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const l=this._maskHash.get(n);l.instructionsStart=s.instructionSize,a.collectRenderables(s,o,null),a.includeInBuild=!1,o.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const h=s.instructionSize-l.instructionsStart-1;l.instructionsLength=h;const c=o.renderTarget.renderTarget.uid;(i=this._maskStackHash)[c]??(i[c]=0)}pop(e,t,s){const i=e,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(i.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(e);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(e){var t;const s=this._renderer,i=s,n=s.renderTarget.renderTarget.uid;let o=(t=this._maskStackHash)[n]??(t[n]=0);e.action==="pushMaskBegin"?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(fe.RENDERING_MASK_ADD,o),o++,i.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?i.stencil.setStencilMode(fe.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(fe.MASK_ACTIVE,o),i.colorMask.setMask(15)):e.action==="popMaskBegin"?(i.colorMask.setMask(0),o!==0?i.stencil.setStencilMode(fe.RENDERING_MASK_REMOVE,o):(i.renderTarget.clear(null,Ae.STENCIL),i.stencil.setStencilMode(fe.DISABLED,o)),o--):e.action==="popMaskEnd"&&(e.inverse?i.stencil.setStencilMode(fe.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(fe.MASK_ACTIVE,o),i.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}jh.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"stencilMask"};const te="source-over";function i_(){const r=uh(),e=Object.create(null);return e.inherit=te,e.none=te,e.normal="source-over",e.add="lighter",e.multiply=r?"multiply":te,e.screen=r?"screen":te,e.overlay=r?"overlay":te,e.darken=r?"darken":te,e.lighten=r?"lighten":te,e["color-dodge"]=r?"color-dodge":te,e["color-burn"]=r?"color-burn":te,e["hard-light"]=r?"hard-light":te,e["soft-light"]=r?"soft-light":te,e.difference=r?"difference":te,e.exclusion=r?"exclusion":te,e.saturation=r?"saturation":te,e.color=r?"color":te,e.luminosity=r?"luminosity":te,e["linear-burn"]=r?"color-burn":te,e["linear-dodge"]=r?"color-dodge":te,e["linear-light"]=r?"hard-light":te,e["pin-light"]=r?"hard-light":te,e["vivid-light"]=r?"hard-light":te,e["hard-mix"]=te,e.negation=r?"difference":te,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=te,e.divide=te,e.min=te,e.max=te,e}const n_=new G;class Yh{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=i_(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,s,i){var h;const n=i?G.IDENTITY:((h=this._renderer.globalUniforms.globalUniformData)==null?void 0:h.worldTransformMatrix)||G.IDENTITY;let o=n_;o.copyFrom(n),o.append(e);const a=this._projTransform,l=this.activeResolution;if(s=s||l,a){const c=G.shared;c.copyFrom(o),c.prepend(a),o=c}t?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*l|0,o.ty*l|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*l,o.ty*l)}clear(e,t){const s=this.activeContext,i=this._renderer;if(s.clearRect(0,0,i.width,i.height),e){const n=ee.shared.setValue(e);s.globalAlpha=t??n.alpha,s.fillStyle=n.toHex(),s.fillRect(0,0,i.width,i.height),s.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Yh.extension={type:[b.CanvasSystem],name:"canvasContext"};class qh{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}qh.extension={type:[b.CanvasSystem],name:"limits"};class gn{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}gn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"customRender"};function Pi(r,e){const t=r.instructionSet,s=t.instructions;for(let i=0;i<t.instructionSize;i++){const n=s[i];e[n.renderPipeId].execute(n)}}class _n{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(_e.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const s=e._batchableRenderGroup??(e._batchableRenderGroup=_e.get(un));s.renderable=e.root,s.transform=e.root.relativeGroupTransform,s.texture=e.texture,s.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(s,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=new G().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push(e.texture,!0,null,e.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),Pi(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),Pi(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}_n.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"renderGroup"};const o_="#808080",Qs=new G,a_=new G,l_=new G,ti=new G;function h_(r,e,t){r.beginPath();for(let s=0;s<t.length;s+=3){const i=t[s]*2,n=t[s+1]*2,o=t[s+2]*2;r.moveTo(e[i],e[i+1]),r.lineTo(e[n],e[n+1]),r.lineTo(e[o],e[o+1]),r.closePath()}r.fill()}function c_(r){return`#${(r&16777215).toString(16).padStart(6,"0")}`}function u_(r,e,t,s,i,n){n=Math.max(0,Math.min(n,Math.min(s,i)/2)),r.moveTo(e+n,t),r.lineTo(e+s-n,t),r.quadraticCurveTo(e+s,t,e+s,t+n),r.lineTo(e+s,t+i-n),r.quadraticCurveTo(e+s,t+i,e+s-n,t+i),r.lineTo(e+n,t+i),r.quadraticCurveTo(e,t+i,e,t+i-n),r.lineTo(e,t+n),r.quadraticCurveTo(e,t,e+n,t)}function rr(r,e){switch(e.type){case"rectangle":{const t=e;r.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;u_(r,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;r.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;r.ellipse?r.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(r.save(),r.translate(t.x,t.y),r.scale(t.halfWidth,t.halfHeight),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const t=e;r.moveTo(t.x,t.y),r.lineTo(t.x2,t.y2),r.lineTo(t.x3,t.y3),r.closePath();break}case"polygon":default:{const t=e,s=t.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]);t.closePath&&r.closePath();break}}}function d_(r,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];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)),rr(r,s.shape),n&&r.restore()}return!0}function f_(r,e,t,s){const i=r.fill;if(i instanceof $e){i.buildGradient();const o=i.texture;if(o){const a=j.getTintedPattern(o,e),l=t?ti.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):ti.copyFrom(i.transform);return s&&!r.textureSpace&&l.append(s),j.applyPatternTransform(a,l),a}}if(i instanceof Is){const o=j.getTintedPattern(i.texture,e);return j.applyPatternTransform(o,i.transform),o}const n=r.texture;if(n&&n!==O.WHITE){if(!n.source.resource)return o_;const o=j.getTintedPattern(n,e),a=t?ti.copyFrom(t).scale(n.source.pixelWidth,n.source.pixelHeight):r.matrix;return j.applyPatternTransform(o,a),o}return c_(e)}class Kh{constructor(){this.shader=null}contextChange(e){}execute(e,t){var x,y,T,S,v,w,A;const s=e.renderer,i=s.canvasContext,n=i.activeContext,o=t.groupTransform,a=((x=s.globalUniforms.globalUniformData)==null?void 0:x.worldColor)??4294967295,l=t.groupColorAlpha,h=(a>>>24&255)/255,c=(l>>>24&255)/255,u=((y=s.filter)==null?void 0:y.alphaMultiplier)??1,d=h*c*u;if(d<=0)return;const f=a&16777215,p=l&16777215,g=Xt(Vt(p,f)),m=s._roundPixels|t._roundPixels;n.save(),i.setContextTransform(o,m===1),i.setBlendMode(t.groupBlendMode);const _=t.context.instructions;for(let R=0;R<_.length;R++){const C=_[R];if(C.action==="texture"){const L=C.data,B=L.image,N=B?j.getCanvasSource(B):null;if(!N)continue;const Y=L.alpha*d;if(Y<=0)continue;const D=Vt(L.style,g);n.globalAlpha=Y;let q=N;D!==16777215&&(q=j.getTintedCanvas({texture:B},D));const ne=B.frame,ae=B.source._resolution??B.source.resolution??1;let J=ne.x*ae,pe=ne.y*ae;const be=ne.width*ae,X=ne.height*ae;q!==N&&(J=0,pe=0);const we=L.transform,Be=we&&!we.isIdentity(),de=B.rotate;Be||de?(Qs.copyFrom(o),Be&&Qs.append(we),de&&$.matrixAppendRotationInv(Qs,de,L.dx,L.dy,L.dw,L.dh),i.setContextTransform(Qs,m===1)):i.setContextTransform(o,m===1),n.drawImage(q,J,pe,q===N?be:q.width,q===N?X:q.height,de?0:L.dx,de?0:L.dy,L.dw,L.dh),(Be||de)&&i.setContextTransform(o,m===1);continue}const E=C.data,P=(T=E==null?void 0:E.path)==null?void 0:T.shapePath;if(!((S=P==null?void 0:P.shapePrimitives)!=null&&S.length))continue;const k=E.style,U=Vt(k.color,g),he=k.alpha*d;if(he<=0)continue;const M=C.action==="stroke";if(n.globalAlpha=he,M){const L=k;n.lineWidth=L.width,n.lineCap=L.cap,n.lineJoin=L.join,n.miterLimit=L.miterLimit}const I=P.shapePrimitives;if(!M&&((A=(w=(v=E.hole)==null?void 0:v.shapePath)==null?void 0:w.shapePrimitives)!=null&&A.length)){const L=I[I.length-1];L.holes=E.hole.shapePath.shapePrimitives}for(let L=0;L<I.length;L++){const B=I[L];if(!(B!=null&&B.shape))continue;const N=B.transform,Y=N&&!N.isIdentity(),D=k.texture&&k.texture!==O.WHITE,q=k.textureSpace==="global"?N:null,ne=D?th(a_,k,B.shape,q):null,ae=Y?l_.copyFrom(o).append(N):o,J=f_(k,U,ne,ae);if(Y&&(n.save(),n.transform(N.a,N.b,N.c,N.d,N.tx,N.ty)),M){const pe=k;if(pe.alignment!==.5&&!pe.pixelLine){const X=[],we=[],Be=[],de=is[B.shape.type];if(de!=null&&de.build(B.shape,X)){const He=B.shape.closePath??!0;Qi(X,pe,!1,He,we,Be),n.fillStyle=J,h_(n,we,Be)}else n.strokeStyle=J,n.beginPath(),rr(n,B.shape),n.stroke()}else n.strokeStyle=J,n.beginPath(),rr(n,B.shape),n.stroke()}else n.fillStyle=J,n.beginPath(),rr(n,B.shape),d_(n,B.holes)?n.fill("evenodd"):n.fill();Y&&n.restore()}}n.restore()}destroy(){this.shader=null}}Kh.extension={type:[b.CanvasPipesAdaptor],name:"graphics"};class xn{constructor(e){this._renderer=e}addRenderable(e,t){const s=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,s),this._renderer.renderPipes.batch.addToBatch(s,t)}updateRenderable(e){const t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new un;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}xn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"sprite"};const Ts={};V.handle(b.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Ts[r.name]=r.ref},r=>{delete Ts[r.name]});class yn{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,s){this._blendModeStack.push(t),this.setBlendMode(e,t,s)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,s){var n;const i=e instanceof ci;if(this._activeBlendMode===t){this._isAdvanced&&e&&!i&&((n=this._renderableList)==null||n.push(e));return}this._isAdvanced&&this._endAdvancedBlendMode(s),this._activeBlendMode=t,e&&(this._isAdvanced=!!Ts[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,s))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const s=this._activeBlendMode;if(!Ts[s]){W(`Unable to assign BlendMode: '${s}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const i=this._ensureFilterEffect(s),n=e instanceof ci,o={renderPipeId:"filter",action:"pushFilter",filterEffect:i,renderables:n?null:[e],container:n?e.root:null,canBundle:!1};this._renderableList=o.renderables,t.add(o)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new ar,t.filters=[new Ts[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(const e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}yn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"blendMode"};function Mi(r,e){e||(e=0);for(let t=e;t<r.length&&r[t];t++)r[t]=null}const p_=new Te,Ea=_s|hr|Di;function Zh(r,e=!1){m_(r);const t=r.childrenToUpdate,s=r.updateTick++;for(const i in t){const n=Number(i),o=t[i],a=o.list,l=o.index;for(let h=0;h<l;h++){const c=a[h];c.parentRenderGroup===r&&c.relativeRenderGroupDepth===n&&Qh(c,s,0)}Mi(a,l),o.index=0}if(e)for(let i=0;i<r.renderGroupChildren.length;i++)Zh(r.renderGroupChildren[i],e)}function m_(r){const e=r.root;let t;if(r.renderGroupParent){const s=r.renderGroupParent;r.worldTransform.appendFrom(e.relativeGroupTransform,s.worldTransform),r.worldColor=lr(e.groupColor,s.worldColor),t=e.groupAlpha*s.worldAlpha}else r.worldTransform.copyFrom(e.localTransform),r.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,r.worldAlpha=t,r.worldColorAlpha=r.worldColor+((t*255|0)<<24)}function Qh(r,e,t){if(e===r.updateTick)return;r.updateTick=e,r.didChange=!1;const s=r.localTransform;r.updateLocalTransform();const i=r.parent;if(i&&!i.renderGroup?(t|=r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),t&Ea&&Pa(r,i,t)):(t=r._updateFlags,r.relativeGroupTransform.copyFrom(s),t&Ea&&Pa(r,p_,t)),!r.renderGroup){const n=r.children,o=n.length;for(let h=0;h<o;h++)Qh(n[h],e,t);const a=r.parentRenderGroup,l=r;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function Pa(r,e,t){if(t&hr){r.groupColor=lr(r.localColor,e.groupColor);let s=r.localAlpha*e.groupAlpha;s=s<0?0:s>1?1:s,r.groupAlpha=s,r.groupColorAlpha=r.groupColor+((s*255|0)<<24)}t&Di&&(r.groupBlendMode=r.localBlendMode==="inherit"?e.groupBlendMode:r.localBlendMode),t&_s&&(r.globalDisplayStatus=r.localDisplayStatus&e.globalDisplayStatus),r._updateFlags=0}function g_(r,e){const{list:t}=r.childrenRenderablesToUpdate;let s=!1;for(let i=0;i<r.childrenRenderablesToUpdate.index;i++){const n=t[i];if(s=e[n.renderPipeId].validateRenderable(n),s)break}return r.structureDidChange=s,s}const __=new G;class Jh{constructor(e){this._renderer=e}render({container:e,transform:t}){const s=e.parent,i=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const n=this._renderer,o=__;t&&(o.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));const a=n.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),n.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),Pi(e.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=s,e.renderGroup.renderGroupParent=i}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let s=e.renderGroupChildren.length-1;s>=0;s--)this._updateCachedRenderGroups(e.renderGroupChildren[s],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const s=e.root.getLocalBounds(),i=this._renderer,n=e.textureOptions.resolution||i.view.resolution,o=e.textureOptions.antialias??i.view.antialias,a=e.textureOptions.scaleMode??"linear",l=e.texture;s.ceil(),e.texture&&ue.returnTexture(e.texture,!0);const h=ue.getOptimalTexture(s.width,s.height,n,o);h._source.style=new tt({scaleMode:a}),e.texture=h,e._textureBounds||(e._textureBounds=new ye),e._textureBounds.copyFrom(s),l!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(ue.returnTexture(e.texture,!0),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,s=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=s,e.structureDidChange?Mi(e.childrenRenderablesToUpdate.list,0):g_(e,s),Zh(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!(e.isCachedAsTexture&&!e.textureNeedsUpdate))for(let i=0;i<e.renderGroupChildren.length;i++)this._updateRenderGroups(e.renderGroupChildren[i])}_updateRenderables(e){const{list:t,index:s}=e.childrenRenderablesToUpdate;for(let i=0;i<s;i++){const n=t[i];n.didViewUpdate&&e.updateRenderable(n)}Mi(t,s)}_buildInstructions(e,t){const s=e.root,i=e.instructionSet;i.reset();const n=t.renderPipes?t:t.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)}}Jh.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderGroup"};const bn=class ec{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ee(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...ec.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){ee.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&W("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};bn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"background",priority:0};bn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let x_=bn;const si={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},vn=class tc{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof Te||e instanceof O?{target:e,...t}:{...t,...e}}async image(e){const t=z.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,tc.defaultImageOptions);const{format:t,quality:s}=e,i=this.canvas(e);if(i.toBlob!==void 0)return new Promise((n,o)=>{i.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},si[t],s)});if(i.toDataURL!==void 0)return i.toDataURL(si[t],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:si[t],quality:s});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){e=this._normalizeOptions(e);const t=e.target,s=this._renderer;if(t instanceof O)return s.texture.generateCanvas(t);const i=s.textureGenerator.generateTexture(e),n=s.texture.generateCanvas(i);return i.destroy(!0),n}pixels(e){e=this._normalizeOptions(e);const t=e.target,s=this._renderer,i=t instanceof O?t:s.textureGenerator.generateTexture(e),n=s.texture.getPixels(i);return t instanceof Te&&i.destroy(!0),n}texture(e){return e=this._normalizeOptions(e),e.target instanceof O?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const t=this.canvas(e),s=document.createElement("a");s.download=e.filename??"image.png",s.href=t.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(e){const t=e.width??200;e=this._normalizeOptions(e);const s=this.canvas(e),i=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const n=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};vn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"extract"};vn.defaultImageOptions={format:"png",quality:1};let y_=vn;class Tn extends O{static create(e){const{dynamic:t,textureOptions:s,...i}=e;return new Tn({...s,source:new me(i),dynamic:t??!1})}resize(e,t,s){return this.source.resize(e,t,s),this}}const b_=new Q,v_=new ye,T_=[0,0,0,0];class sc{constructor(e){this._renderer=e}generateTexture(e){var c;e instanceof Te&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,s=e.antialias||this._renderer.view.antialias,i=e.target;let n=e.clearColor;n?n=Array.isArray(n)&&n.length===4?n:ee.shared.setValue(n).toArray():n=T_;const o=((c=e.frame)==null?void 0:c.copyTo(b_))||Ui(i,v_).rectangle,a=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};o.width=Math.max(o.width,1/t)|0,o.height=Math.max(o.height,1/t)|0;const l=Tn.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:s,textureOptions:a}),h=G.shared.translate(-o.x,-o.y);return this._renderer.render({container:i,transform:h,target:l,clearColor:n}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}sc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"textureGenerator"};function S_(r){let e=!1;for(const s in r)if(r[s]==null){e=!0;break}if(!e)return r;const t=Object.create(null);for(const s in r){const i=r[s];i&&(t[s]=i)}return t}function w_(r){let e=0;for(let t=0;t<r.length;t++)r[t]==null?e++:r[t-e]=r[t];return r.length-=e,r}const Sn=class rc{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(e){e={...rc.defaultOptions,...e},this.maxUnusedTime=e.gcMaxUnusedTime,this._frequency=e.gcFrequency,this.enabled=e.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedCollections){const{context:s,collection:i,type:n}=t;n==="hash"?s[i]=S_(s[i]):s[i]=w_(s[i])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(const s of e.renderGroupChildren)this._updateInstructionGCTick(s,t)}addCollection(e,t,s){this._managedCollections.push({context:e,collection:t,type:s})}addResource(e,t){var i,n;if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,(i=e._onTouch)==null||i.call(e,this.now);return}const s=this._managedResources.length;e._gcData={index:s,type:t},e._gcLastUsed=this.now,(n=e._onTouch)==null||n.call(e,this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){const t=e._gcData;if(!t)return;const s=t.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--,e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,s,i=0){this._managedResourceHashes.push({context:e,hash:t,type:s,priority:i}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){const e=performance.now(),t=this._managedResourceHashes;for(const i of t)this.runOnHash(i,e);let s=0;for(let i=0;i<this._managedResources.length;i++){const n=this._managedResources[i];s=this.runOnResource(n,e,s)}this._managedResources.length=s}updateRenderableGCTick(e,t){var n,o;const s=e.renderGroup??e.parentRenderGroup,i=((n=s==null?void 0:s.instructionSet)==null?void 0:n.gcTick)??-1;((s==null?void 0:s.gcTick)??0)===i&&(e._gcLastUsed=t,(o=e._onTouch)==null||o.call(e,t))}runOnResource(e,t,s){const i=e._gcData;return i.type==="renderable"&&this.updateRenderableGCTick(e,t),t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect?(this._managedResources[s]=e,i.index=s,s++):(e.unload(),e._gcData=null,e._gcLastUsed=-1,e.off("unload",this.removeResource,this)),s}_createHashClone(e,t){const s=Object.create(null);for(const i in e){if(i===t)break;e[i]!==null&&(s[i]=e[i])}return s}runOnHash(e,t){var h;const{context:s,hash:i,type:n}=e,o=s[i];let a=null,l=0;for(const c in o){const u=o[c];if(u===null){l++,l===1e4&&!a&&(a=this._createHashClone(o,c));continue}if(u._gcLastUsed===-1){u._gcLastUsed=t,(h=u._onTouch)==null||h.call(u,t),a&&(a[c]=u);continue}if(n==="renderable"&&this.updateRenderableGCTick(u,t),!(t-u._gcLastUsed<this.maxUnusedTime)&&u.autoGarbageCollect){if(a||(l+1!==1e4?(o[c]=null,l++):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(e=>{e.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Sn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"gc",priority:0};Sn.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let C_=Sn;class ic{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,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 ie},l={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||o.size,worldTransformMatrix:s||a.worldTransformMatrix,worldColor:i||a.worldColor,offset:n||a.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const c=h.uniforms;c.uProjectionMatrix=l.projectionMatrix,c.uResolution=l.resolution,c.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),c.uWorldTransformMatrix.tx-=l.offset.x,c.uWorldTransformMatrix.ty-=l.offset.y,wh(l.worldColor,c.uWorldColorAlpha,0),h.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(u=this._bindGroupPool.pop()||new lt,this._activeBindGroups.push(u),u.setResource(h,0)),l.bindGroup=u,this._currentGlobalUniformData=l}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Me.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 We({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}}ic.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"globalUniforms"};let A_=1;class nc{constructor(){this._tasks=[],this._offset=0}init(){Ue.system.add(this._update,this)}repeat(e,t,s=!0){const i=A_++;let n=0;return s&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:i}),i}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){const e=performance.now();for(let t=0;t<this._tasks.length;t++){const s=this._tasks[t];if(e-s.offset-s.last>=s.duration){const i=e-s.start;s.func(i),s.last=e}}}destroy(){Ue.system.remove(this._update,this),this._tasks.length=0}}nc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"scheduler",priority:0};let Ma=!1;function E_(r){if(!Ma){if(z.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${ur} (${r}) http://www.pixijs.com/
891
+
892
+ `,"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(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${ur} - ${r} - http://www.pixijs.com/`);Ma=!0}}class wn{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===Me.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),E_(t)}}}wn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"hello",priority:-2};wn.defaultOptions={hello:!1};const Cn=class oc{constructor(e){this._renderer=e}init(e){e={...oc.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return F("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){F("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){F("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){F("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){F("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){F("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Cn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderableGC",priority:0};Cn.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let P_=Cn;const An=class ir{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){F("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){F("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){F("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){F("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(e){e.textureGCActive!==ir.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==ir.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==ir.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){F("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};An.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGC"};An.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let M_=An;const ac=class lc{constructor(e={}){if(this.uid=re("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e={...lc.defaultOptions,...e},this.stencil=e.stencil,this.depth=e.depth,this.isRoot=e.isRoot,typeof e.colorTextures=="number"){this._managedColorTextures=!0;for(let t=0;t<e.colorTextures;t++)this.colorTextures.push(new me({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(s=>s.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(e.depthStencilTexture||this.stencil)&&(e.depthStencilTexture instanceof O||e.depthStencilTexture instanceof me?this.depthStencilTexture=e.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}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(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new me({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(e,t,s=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(e,t,s)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(e,t,s)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(e=>{e.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};ac.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Ri=ac;const Lt=new Map;es.register(Lt);function hc(r,e){if(!Lt.has(r)){const t=new O({source:new Xe({resource:r,...e})}),s=()=>{Lt.get(r)===t&&Lt.delete(r)};t.once("destroy",s),t.source.once("destroy",s),Lt.set(r,t)}return Lt.get(r)}const En=class cc{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(e){e={...cc.defaultOptions,...e},e.view&&(F(Z,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new Q(0,0,e.width,e.height),this.canvas=e.canvas||z.get().createCanvas(),this.antialias=!!e.antialias,this.texture=hc(this.canvas,e),this.renderTarget=new Ri({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(e,t,s){this.texture.source.resize(e,t,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e=="boolean"?e:!!(e!=null&&e.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};En.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"view",priority:0};En.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let R_=En;const Pn=[x_,ic,wn,R_,Jh,C_,M_,sc,y_,kl,P_,nc],uc=[yn,pn,xn,_n,mn,jh,Vh,gn];function B_(r,e,t,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-e*r.a,r.ty=-o-t*r.d,r}function k_(r){const e=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}class Mn{constructor(e){this.rootViewPort=new Q,this.viewport=new Q,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Pl("onRenderTargetChange"),this.projectionMatrix=new G,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:s,frame:i,mipLevel:n,layer:o}){var a,l;this._renderTargetStack.length=0,this.push(e,t,s,i,n??0,o??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=k_(this.rootRenderTarget),(l=(a=this.adaptor).prerender)==null||l.call(a,this.rootRenderTarget)}postrender(){var e,t;(t=(e=this.adaptor).postrender)==null||t.call(e,this.rootRenderTarget)}bind(e,t=!0,s,i,n=0,o=0){const a=this.getRenderTarget(e),l=this.renderTarget!==a;this.renderTarget=a,this.renderSurface=e;const h=this.getGpuRenderTarget(a);(a.pixelWidth!==h.width||a.pixelHeight!==h.height)&&(this.adaptor.resizeGpuRenderTarget(a),h.width=a.pixelWidth,h.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&&e instanceof O&&(i=e.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,T=i.height*g+.5|0;let S=Math.floor(_/m),v=Math.floor(x/m),w=Math.ceil(y/m),A=Math.ceil(T/m);S=Math.min(Math.max(S,0),f-1),v=Math.min(Math.max(v,0),p-1),w=Math.min(Math.max(w,1),f-S),A=Math.min(Math.max(A,1),p-v),u.x=S,u.y=v,u.width=w,u.height=A}else u.x=0,u.y=0,u.width=f,u.height=p;return B_(this.projectionMatrix,0,0,u.width/c.resolution,u.height/c.resolution,!a.isRoot),this.adaptor.startRenderPass(a,t,s,u,n,o),l&&this.onRenderTargetChange.emit(a),a}clear(e,t=Ae.ALL,s,i=this.mipLevel,n=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,s,this.viewport,i,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=Ae.ALL,s,i,n=0,o=0){const a=this.bind(e,t,s,i,n,o);return this._renderTargetStack.push({renderTarget:a,frame:i,mipLevel:n,layer:o}),a}pop(){this._renderTargetStack.pop();const e=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(e.renderTarget,!1,null,e.frame,e.mipLevel,e.layer)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,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}=e;return i.width=Math.min(i.width,o-s.x),i.height=Math.min(i.height,a-s.y),this.adaptor.copyToTexture(e,t,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((e,t)=>{e!==t&&e.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;return Xe.test(e)&&(e=hc(e).source),e instanceof Ri?t=e:e instanceof me&&(t=new Ri({colorTextures:[e]}),e.source instanceof Xe&&(t.isRoot=!0),e.once("destroy",()=>{t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);const s=this._gpuRenderTargetHash[t.uid];s&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(s))})),this._renderSurfaceToRenderTargetHash.set(e,t),t}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this.renderSurface=null}}class I_{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:s,context:i}=this._ensureCanvas(t);return{canvas:s,context:i,width:s.width,height:s.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:s}=this._ensureCanvas(t);s.width=e.pixelWidth,s.height=e.pixelHeight}startRenderPass(e,t,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,s,i)}clear(e,t,s,i){const o=this._renderTargetSystem.getGpuRenderTarget(e).context,a=i||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(a.x,a.y,a.width,a.height),s){const l=ee.shared.setValue(s);l.alpha>0&&(o.globalAlpha=l.alpha,o.fillStyle=l.toHex(),o.fillRect(a.x,a.y,a.width,a.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,s,i,n){const a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,l=t.source,{context:h}=this._ensureCanvas(l),c=(n==null?void 0:n.x)??0,u=(n==null?void 0:n.y)??0;return h.drawImage(a,s.x,s.y,i.width,i.height,c,u,i.width,i.height),l.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Xe.test(t))&&(t=z.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const s=t.getContext("2d");return{canvas:t,context:s}}}class dc extends Mn{constructor(e){super(e),this.adaptor=new I_,this.adaptor.init(e,this)}}dc.extension={type:[b.CanvasSystem],name:"renderTarget"};class fc{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=z.get().createCanvas(),s=t.getContext("2d"),i=j.getCanvasSource(e);if(!i)return t;const n=e.frame,o=e.source._resolution??e.source.resolution??1,a=n.x*o,l=n.y*o,h=n.width*o,c=n.height*o;return t.width=Math.ceil(h),t.height=Math.ceil(c),s.drawImage(i,a,l,h,c,0,0,h,c),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}fc.extension={type:[b.CanvasSystem],name:"texture"};const F_=[...Pn,Yh,qh,fc,dc],G_=[yn,pn,xn,_n,mn,$h,zh,gn],U_=[Kg,Kh],pc=[],mc=[],gc=[];V.handleByNamedList(b.CanvasSystem,pc);V.handleByNamedList(b.CanvasPipes,mc);V.handleByNamedList(b.CanvasPipesAdaptor,gc);V.add(...F_,...G_,...U_);class O_ extends ks{constructor(){const e={name:"canvas",type:Me.CANVAS,systems:pc,renderPipes:mc,renderPipeAdaptors:gc};super(e)}}const D_=Object.freeze(Object.defineProperty({__proto__:null,CanvasRenderer:O_},Symbol.toStringTag,{value:"Module"}));var nr=(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))(nr||{});class L_{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class _c{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new je({renderer:e,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(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:t}=this,s=this.getGlBuffer(e);t.bindBuffer(s.type,s.buffer)}bindBufferBase(e,t){const{_gl:s}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,s.bindBufferBase(s.UNIFORM_BUFFER,t,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;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 t=i,this._nextBindBaseIndex=i+1,s>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){const t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,s,i){const{_gl:n}=this;s||(s=0),t||(t=0),this._boundBufferBases[t]=null,n.bindBufferRange(n.UNIFORM_BUFFER,t||0,e.buffer,s*256,i||256)}updateBuffer(e){const{_gl:t}=this,s=this.getGlBuffer(e);if(e._updateID===s.updateID)return s;s.updateID=e._updateID,t.bindBuffer(s.type,s.buffer);const i=e.data,n=e.descriptor.usage&oe.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return i?s.byteLength>=i.byteLength?t.bufferSubData(s.type,0,i,0,e._updateSize/i.BYTES_PER_ELEMENT):(s.byteLength=i.byteLength,t.bufferData(s.type,i,n)):(s.byteLength=e.descriptor.size,t.bufferData(s.type,s.byteLength,n)),s}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const s=e._gpuData[this._renderer.uid];s&&(t||this._gl.deleteBuffer(s.buffer))}createGLBuffer(e){const{_gl:t}=this;let s=nr.ARRAY_BUFFER;e.descriptor.usage&oe.INDEX?s=nr.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&oe.UNIFORM&&(s=nr.UNIFORM_BUFFER);const i=new L_(t.createBuffer(),s);return e._gpuData[this._renderer.uid]=i,this._managedBuffers.add(e),i}resetState(){this._boundBufferBases=Object.create(null)}}_c.extension={type:[b.WebGLSystem],name:"buffer"};const Rn=class xc{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,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(e){this.gl=e,this._renderer.gl=e}init(e){e={...xc.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(W("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=z.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const s=this._renderer.background.alpha<1,i=e.premultipliedAlpha??!0,n=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:s,premultipliedAlpha:i,antialias:n,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&W("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof z.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const t=this._renderer.view.canvas;t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,t){let s;const i=this.canvas;if(e===2&&(s=i.getContext("webgl2",t)),!s&&(s=i.getContext("webgl",t),!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:e}=this,t={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...t,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...t,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const s=e.getExtension("WEBGL_provoking_vertex");s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var t;this.gl.isContextLost()&&((t=this.extensions.loseContext)==null||t.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const t=e.getContextAttributes();t&&!t.stencil&&W("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||W("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};Rn.extension={type:[b.WebGLSystem],name:"context"};Rn.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let N_=Rn;function yc(r,e){for(const t in r.attributes){const s=r.attributes[t],i=e[t];i?(s.format??(s.format=i.format),s.offset??(s.offset=i.offset),s.instance??(s.instance=i.instance)):W(`Attribute ${t} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}W_(r)}function W_(r){const{buffers:e,attributes:t}=r,s={},i={};for(const n in e){const o=e[n];s[o.uid]=0,i[o.uid]=0}for(const n in t){const o=t[n];s[o.buffer.uid]+=ws(o.format).stride}for(const n in t){const o=t[n];o.stride??(o.stride=s[o.buffer.uid]),o.start??(o.start=i[o.buffer.uid]),i[o.buffer.uid]+=ws(o.format).stride}}var Bi=(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))(Bi||{}),Bn=(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))(Bn||{}),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 Ra={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 H_(r){return Ra[r]??Ra.float32}const z_={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class V_{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class bc{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new je({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=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 t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=i=>t.bindVertexArrayOES(i),e.deleteVertexArray=i=>t.deleteVertexArrayOES(i));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(e.drawArraysInstanced=(i,n,o,a)=>{s.drawArraysInstancedANGLE(i,n,o,a)},e.drawElementsInstanced=(i,n,o,a,l)=>{s.drawElementsInstancedANGLE(i,n,o,a,l)},e.vertexAttribDivisor=(i,n)=>s.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const s=this.gl;this._activeGeometry=e;const i=this.getVao(e,t);this._activeVao!==i&&(this._activeVao=i,s.bindVertexArray(i)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let s=0;s<e.buffers.length;s++){const i=e.buffers[s];t.updateBuffer(i)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const s=e.attributes,i=t._attributeData;for(const n in i)if(!s[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(e,t){const s=e.attributes,i=t._attributeData,n=["g",e.uid];for(const o in s)i[o]&&n.push(o,i[o].location);return n.join("-")}getVao(e,t){var s;return((s=e._gpuData[this._renderer.uid])==null?void 0:s.vaoCache[t._key])||this.initGeometryVao(e,t)}initGeometryVao(e,t,s=!0){const i=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);const o=this.getSignature(e,t);let a=e._gpuData[this._renderer.uid];a||(a=new V_,e._gpuData[this._renderer.uid]=a,this._managedGeometries.add(e));const l=a.vaoCache;let h=l[o];if(h)return l[t._key]=h,h;yc(e,t._attributeData);const c=e.buffers;h=i.createVertexArray(),i.bindVertexArray(h);for(let u=0;u<c.length;u++){const d=c[u];n.bind(d)}return this.activateVao(e,t),l[t._key]=h,l[o]=h,i.bindVertexArray(null),h}onGeometryUnload(e,t=!1){const s=e._gpuData[this._renderer.uid];if(!s)return;const i=s.vaoCache;if(!t)for(const n in i)this._activeVao!==i[n]&&this.resetState(),this.gl.deleteVertexArray(i[n])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){var a;const s=this._renderer.gl,i=this._renderer.buffer,n=e.attributes;e.indexBuffer&&i.bind(e.indexBuffer);let o=null;for(const l in n){const h=n[l],c=h.buffer,u=i.getGlBuffer(c),d=t._attributeData[l];if(d){o!==u&&(i.bind(c),o=u);const f=d.location;s.enableVertexAttribArray(f);const p=ws(h.format),g=H_(h.format);if(((a=d.format)==null?void 0:a.substring(1,4))==="int"?s.vertexAttribIPointer(f,p.size,g,h.stride,h.offset):s.vertexAttribPointer(f,p.size,g,p.normalised,h.stride,h.offset),h.instance)if(this.hasInstance){const m=h.divisor??1;s.vertexAttribDivisor(f,m)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,s,i){const{gl:n}=this._renderer,o=this._activeGeometry,a=z_[e||o.topology];if(i??(i=o.instanceCount),o.indexBuffer){const l=o.indexBuffer.data.BYTES_PER_ELEMENT,h=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;i!==1?n.drawElementsInstanced(a,t||o.indexBuffer.data.length,h,(s||0)*l,i):n.drawElements(a,t||o.indexBuffer.data.length,h,(s||0)*l)}else i!==1?n.drawArraysInstanced(a,s||0,t||o.getSize(),i):n.drawArrays(a,s||0,t||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}}bc.extension={type:[b.WebGLSystem],name:"geometry"};const X_=new Xi({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),kn=class vc{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:s}={...vc.defaultOptions,...e};this.useBackBuffer=t,this._antialias=s,this._renderer.context.supports.msaa||(W("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=it.for2d();const i=new dt({vertex:`
893
+ attribute vec2 aPosition;
894
+ out vec2 vUv;
895
+
896
+ void main() {
897
+ gl_Position = vec4(aPosition, 0.0, 1.0);
898
+
899
+ vUv = (aPosition + 1.0) / 2.0;
900
+
901
+ // flip dem UVs
902
+ vUv.y = 1.0 - vUv.y;
903
+ }`,fragment:`
904
+ in vec2 vUv;
905
+ out vec4 finalColor;
906
+
907
+ uniform sampler2D uTexture;
908
+
909
+ void main() {
910
+ finalColor = texture(uTexture, vUv);
911
+ }`,name:"big-triangle"});this._bigTriangleShader=new rt({glProgram:i,resources:{uTexture:O.WHITE.source}})}renderStart(e){const t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){const s=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=s.colorTexture,e.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:X_,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new O({source:new me({width:e.width,height:e.height,resolution:e._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(e.width,e.height,e._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};kn.extension={type:[b.WebGLSystem],name:"backBuffer",priority:1};kn.defaultOptions={useBackBuffer:!1};let $_=kn;class Tc{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1)))}}Tc.extension={type:[b.WebGLSystem],name:"colorMask"};class Sc{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){const t=this._renderer,{geometry:s,shader:i,state:n,skipSync:o,topology:a,size:l,start:h,instanceCount:c}=e;t.shader.bind(i,o),t.geometry.bind(s,t.shader._activeProgram),n&&t.state.set(n),t.geometry.draw(a,l,h,c??s.instanceCount)}destroy(){this._renderer=null}}Sc.extension={type:[b.WebGLSystem],name:"encoder"};class wc{constructor(e){this._renderer=e}contextChange(){const e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Ll(this.maxTextures,e);const t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}wc.extension={type:[b.WebGLSystem],name:"limits"};class j_{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const ft=[];ft[fe.NONE]=void 0;ft[fe.DISABLED]={stencilWriteMask:0,stencilReadMask:0};ft[fe.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};ft[fe.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};ft[fe.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};ft[fe.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Cc{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:fe.NONE},this._renderTargetStencilState=Object.create(null),e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this.resetState()}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:fe.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=fe.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=ft[e],o=this._stencilCache;if(s.stencilMode=e,s.stencilReference=t,e===fe.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)),(e!==o.stencilMode||o.stencilReference!==t)&&(o.stencilMode=e,o.stencilReference=t,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],t,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}Cc.extension={type:[b.WebGLSystem],name:"stencil"};class Ac{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!Sl())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(e){const t=this.getUniformGroupData(e);e.buffer||(e.buffer=new ht({data:new Float32Array(t.layout.size/4),usage:oe.UNIFORM|oe.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){const t=e._signature;let s=this._syncFunctionHash[t];if(!s){const i=Object.keys(e.uniformStructures).map(a=>e.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[t]={layout:n,syncFunction:o}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,s){const i=this.getUniformGroupData(e);e.buffer||(e.buffer=new ht({data:new Float32Array(i.layout.size/4),usage:oe.UNIFORM|oe.COPY_DST}));let n=null;return t||(t=e.buffer.data,n=e.buffer.dataInt32),s||(s=0),i.syncFunction(e.uniforms,t,n,s),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;const t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}const Ec={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 Y_(r){const e=r.map(n=>({data:n,offset:0,size:0})),t=16;let s=0,i=0;for(let n=0;n<e.length;n++){const o=e[n];if(s=Ec[o.data.type],!s)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(s=Math.max(s,t)*o.data.size);const a=s===12?16:s;o.size=s;const l=i%t;l>0&&t-l<a?i+=(t-l)%16:i+=(s-l%s)%s,o.offset=i,i+=s}return i=Math.ceil(i/16)*16,{uboElements:e,size:i}}const wt=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
912
+ var matrix = uv[name].toArray(true);
913
+ data[offset] = matrix[0];
914
+ data[offset + 1] = matrix[1];
915
+ data[offset + 2] = matrix[2];
916
+ data[offset + 4] = matrix[3];
917
+ data[offset + 5] = matrix[4];
918
+ data[offset + 6] = matrix[5];
919
+ data[offset + 8] = matrix[6];
920
+ data[offset + 9] = matrix[7];
921
+ data[offset + 10] = matrix[8];
922
+ `,uniform:`
923
+ gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
924
+ `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
925
+ v = uv[name];
926
+ data[offset] = v.x;
927
+ data[offset + 1] = v.y;
928
+ data[offset + 2] = v.width;
929
+ data[offset + 3] = v.height;
930
+ `,uniform:`
931
+ cv = ud[name].value;
932
+ v = uv[name];
933
+ if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
934
+ cv[0] = v.x;
935
+ cv[1] = v.y;
936
+ cv[2] = v.width;
937
+ cv[3] = v.height;
938
+ gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
939
+ }
940
+ `},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
941
+ v = uv[name];
942
+ data[offset] = v.x;
943
+ data[offset + 1] = v.y;
944
+ `,uniform:`
945
+ cv = ud[name].value;
946
+ v = uv[name];
947
+ if (cv[0] !== v.x || cv[1] !== v.y) {
948
+ cv[0] = v.x;
949
+ cv[1] = v.y;
950
+ gl.uniform2f(ud[name].location, v.x, v.y);
951
+ }
952
+ `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
953
+ v = uv[name];
954
+ data[offset] = v.red;
955
+ data[offset + 1] = v.green;
956
+ data[offset + 2] = v.blue;
957
+ data[offset + 3] = v.alpha;
958
+ `,uniform:`
959
+ cv = ud[name].value;
960
+ v = uv[name];
961
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
962
+ cv[0] = v.red;
963
+ cv[1] = v.green;
964
+ cv[2] = v.blue;
965
+ cv[3] = v.alpha;
966
+ gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
967
+ }
968
+ `},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
969
+ v = uv[name];
970
+ data[offset] = v.red;
971
+ data[offset + 1] = v.green;
972
+ data[offset + 2] = v.blue;
973
+ `,uniform:`
974
+ cv = ud[name].value;
975
+ v = uv[name];
976
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
977
+ cv[0] = v.red;
978
+ cv[1] = v.green;
979
+ cv[2] = v.blue;
980
+ gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
981
+ }
982
+ `}];function Pc(r,e,t,s){const i=[`
983
+ var v = null;
984
+ var v2 = null;
985
+ var t = 0;
986
+ var index = 0;
987
+ var name = null;
988
+ var arrayOffset = null;
989
+ `];let n=0;for(let a=0;a<r.length;a++){const l=r[a],h=l.data.name;let c=!1,u=0;for(let d=0;d<wt.length;d++)if(wt[d].test(l.data)){u=l.offset/4,i.push(`name = "${h}";`,`offset += ${u-n};`,wt[d][e]||wt[d].ubo),c=!0;break}if(!c)if(l.data.size>1)u=l.offset/4,i.push(t(l,u-n));else{const d=s[l.data.type];u=l.offset/4,i.push(`
990
+ v = uv.${h};
991
+ offset += ${u-n};
992
+ ${d};
993
+ `)}n=u}const o=i.join(`
994
+ `);return new Function("uv","data","dataInt32","offset",o)}function Dt(r,e){return`
995
+ for (let i = 0; i < ${r*e}; i++) {
996
+ data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
997
+ }
998
+ `}const Mc={f32:`
999
+ data[offset] = v;`,i32:`
1000
+ dataInt32[offset] = v;`,"vec2<f32>":`
1001
+ data[offset] = v[0];
1002
+ data[offset + 1] = v[1];`,"vec3<f32>":`
1003
+ data[offset] = v[0];
1004
+ data[offset + 1] = v[1];
1005
+ data[offset + 2] = v[2];`,"vec4<f32>":`
1006
+ data[offset] = v[0];
1007
+ data[offset + 1] = v[1];
1008
+ data[offset + 2] = v[2];
1009
+ data[offset + 3] = v[3];`,"vec2<i32>":`
1010
+ dataInt32[offset] = v[0];
1011
+ dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
1012
+ dataInt32[offset] = v[0];
1013
+ dataInt32[offset + 1] = v[1];
1014
+ dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
1015
+ dataInt32[offset] = v[0];
1016
+ dataInt32[offset + 1] = v[1];
1017
+ dataInt32[offset + 2] = v[2];
1018
+ dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
1019
+ data[offset] = v[0];
1020
+ data[offset + 1] = v[1];
1021
+ data[offset + 4] = v[2];
1022
+ data[offset + 5] = v[3];`,"mat3x3<f32>":`
1023
+ data[offset] = v[0];
1024
+ data[offset + 1] = v[1];
1025
+ data[offset + 2] = v[2];
1026
+ data[offset + 4] = v[3];
1027
+ data[offset + 5] = v[4];
1028
+ data[offset + 6] = v[5];
1029
+ data[offset + 8] = v[6];
1030
+ data[offset + 9] = v[7];
1031
+ data[offset + 10] = v[8];`,"mat4x4<f32>":`
1032
+ for (let i = 0; i < 16; i++) {
1033
+ data[offset + i] = v[i];
1034
+ }`,"mat3x2<f32>":Dt(3,2),"mat4x2<f32>":Dt(4,2),"mat2x3<f32>":Dt(2,3),"mat4x3<f32>":Dt(4,3),"mat2x4<f32>":Dt(2,4),"mat3x4<f32>":Dt(3,4)},q_={...Mc,"mat2x2<f32>":`
1035
+ data[offset] = v[0];
1036
+ data[offset + 1] = v[1];
1037
+ data[offset + 2] = v[2];
1038
+ data[offset + 3] = v[3];
1039
+ `};function K_(r,e){const t=Math.max(Ec[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`
1040
+ v = uv.${r.data.name};
1041
+ offset += ${e};
1042
+
1043
+ arrayOffset = offset;
1044
+
1045
+ t = 0;
1046
+
1047
+ for(var i=0; i < ${r.data.size*t}; i++)
1048
+ {
1049
+ for(var j = 0; j < ${s}; j++)
1050
+ {
1051
+ ${n}[arrayOffset++] = v[t++];
1052
+ }
1053
+ ${i!==0?`arrayOffset += ${i};`:""}
1054
+ }
1055
+ `}function Z_(r){return Pc(r,"uboStd40",K_,Mc)}class Rc extends Ac{constructor(){super({createUboElements:Y_,generateUboSync:Z_})}}Rc.extension={type:[b.WebGLSystem],name:"ubo"};class Q_{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Q}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Q;const e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},(s,i)=>e.COLOR_ATTACHMENT0+i)}copyToTexture(e,t,s,i,n){const o=this._renderTargetSystem,a=this._renderer,l=o.getGpuRenderTarget(e),h=a.gl;return this.finishRenderPass(e),h.bindFramebuffer(h.FRAMEBUFFER,l.resolveTargetFramebuffer),a.texture.bind(t,0),h.copyTexSubImage2D(h.TEXTURE_2D,0,n.x,n.y,s.x,s.y,i.width,i.height),t}startRenderPass(e,t=!0,s,i,n=0,o=0){const a=this._renderTargetSystem,l=e.colorTexture,h=a.getGpuRenderTarget(e);if(o!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(n>0){if(h.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;e.isRoot&&(c=l.pixelHeight-i.height-i.y),e.colorTextures.forEach(f=>{this._renderer.texture.unbind(f)});const u=this._renderer.gl;u.bindFramebuffer(u.FRAMEBUFFER,h.framebuffer),!e.isRoot&&(h._attachedMipLevel!==n||h._attachedLayer!==o)&&(e.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.")}),h._attachedMipLevel=n,h._attachedLayer=o),e.colorTextures.length>1&&this._setDrawBuffers(e,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)),!h.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(h),this.clear(e,t,s)}finishRenderPass(e){const s=this._renderTargetSystem.getGpuRenderTarget(e);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(e){const s=this._renderer.gl,i=new j_;return i._attachedMipLevel=0,i._attachedLayer=0,e.colorTexture instanceof Xe?(this._renderer.context.ensureCanvasSize(e.colorTexture.resource),i.framebuffer=null,i):(this._initColor(e,i),s.bindFramebuffer(s.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(e){const t=this._renderer.gl;e.framebuffer&&(t.deleteFramebuffer(e.framebuffer),e.framebuffer=null),e.resolveTargetFramebuffer&&(t.deleteFramebuffer(e.resolveTargetFramebuffer),e.resolveTargetFramebuffer=null),e.depthStencilRenderBuffer&&(t.deleteRenderbuffer(e.depthStencilRenderBuffer),e.depthStencilRenderBuffer=null),e.msaaRenderBuffer.forEach(s=>{t.deleteRenderbuffer(s)}),e.msaaRenderBuffer=null}clear(e,t,s,i,n=0,o=0){if(!t)return;if(o!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const a=this._renderTargetSystem;typeof t=="boolean"&&(t=t?Ae.ALL:Ae.NONE);const l=this._renderer.gl;if(t&Ae.COLOR){s??(s=a.defaultClearColor);const h=this._clearColorCache,c=s;(h[0]!==c[0]||h[1]!==c[1]||h[2]!==c[2]||h[3]!==c[3])&&(h[0]=c[0],h[1]=c[1],h[2]=c[2],h[3]=c[3],l.clearColor(c[0],c[1],c[2],c[3]))}l.clear(t)}resizeGpuRenderTarget(e){if(e.isRoot)return;const s=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,s),(e.stencil||e.depth)&&this._resizeStencil(s)}_initColor(e,t){const s=this._renderer,i=s.gl,n=i.createFramebuffer();if(t.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),t.width=e.colorTexture.source.pixelWidth,t.height=e.colorTexture.source.pixelHeight,e.colorTextures.forEach((a,l)=>{const h=a.source;h.antialias&&(s.context.supports.msaa?t.msaa=!0:W("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(h,0);const c=s.texture.getGlSource(h),u=c.texture;if(c.target===i.TEXTURE_2D)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,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+l,u,0,0)}else if(c.target===i.TEXTURE_CUBE_MAP)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,i.TEXTURE_CUBE_MAP_POSITIVE_X,u,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),t.msaa){const a=i.createFramebuffer();t.framebuffer=a,i.bindFramebuffer(i.FRAMEBUFFER,a),e.colorTextures.forEach((l,h)=>{const c=i.createRenderbuffer();t.msaaRenderBuffer[h]=c})}else t.framebuffer=n;this._resizeColor(e,t)}_resizeColor(e,t){const s=e.colorTexture.source;if(t.width=s.pixelWidth,t.height=s.pixelHeight,t._attachedMipLevel=0,t._attachedLayer=0,e.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(s.width,s.height,s._resolution)}),t.msaa){const i=this._renderer,n=i.gl,o=t.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),e.colorTextures.forEach((a,l)=>{const h=a.source;i.texture.bindSource(h,0);const u=i.texture.getGlSource(h).internalFormat,d=t.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,d),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,u,h.pixelWidth,h.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,d)})}}_initStencil(e){if(e.framebuffer===null)return;const t=this._renderer.gl,s=t.createRenderbuffer();e.depthStencilRenderBuffer=s,t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,s),this._resizeStencil(e)}_resizeStencil(e){const t=this._renderer.gl;t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa?t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}prerender(e){const t=e.colorTexture.resource;this._renderer.context.multiView&&Xe.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(this._renderer.context.multiView&&Xe.test(e.colorTexture.resource)){const t=this._renderer.context.canvas,s=e.colorTexture;s.context2D.drawImage(t,0,s.pixelHeight-t.height)}}_setDrawBuffers(e,t){const s=e.colorTextures.length,i=this._drawBuffersCache[s];if(this._renderer.context.webGLVersion===1){const n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(i):W("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else t.drawBuffers(i)}}class Bc extends Mn{constructor(e){super(e),this.adaptor=new Q_,this.adaptor.init(e,this)}}Bc.extension={type:[b.WebGLSystem],name:"renderTarget"};class In extends Re{constructor({buffer:e,offset:t,size:s}){super(),this.uid=re("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=re("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=re("resource"),this.emit("change",this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function J_(r,e){const t=[],s=[`
1056
+ var g = s.groups;
1057
+ var sS = r.shader;
1058
+ var p = s.glProgram;
1059
+ var ugS = r.uniformGroup;
1060
+ var resources;
1061
+ `];let i=!1,n=0;const o=e._getProgramData(r.glProgram);for(const l in r.groups){const h=r.groups[l];t.push(`
1062
+ resources = g[${l}].resources;
1063
+ `);for(const c in h.resources){const u=h.resources[c];if(u instanceof We)if(u.ubo){const d=r._uniformBindMap[l][Number(c)];t.push(`
1064
+ sS.bindUniformBlock(
1065
+ resources[${c}],
1066
+ '${d}',
1067
+ ${r.glProgram._uniformBlockData[d].index}
1068
+ );
1069
+ `)}else t.push(`
1070
+ ugS.updateUniformGroup(resources[${c}], p, sD);
1071
+ `);else if(u instanceof In){const d=r._uniformBindMap[l][Number(c)];t.push(`
1072
+ sS.bindUniformBlock(
1073
+ resources[${c}],
1074
+ '${d}',
1075
+ ${r.glProgram._uniformBlockData[d].index}
1076
+ );
1077
+ `)}else if(u instanceof me){const d=r._uniformBindMap[l][c],f=o.uniformData[d];f&&(i||(i=!0,s.push(`
1078
+ var tS = r.texture;
1079
+ `)),e._gl.uniform1i(f.location,n),t.push(`
1080
+ tS.bind(resources[${c}], ${n});
1081
+ `),n++)}}}const a=[...s,...t].join(`
1082
+ `);return new Function("r","s","sD",a)}class ex{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function Ba(r,e,t){const s=r.createShader(e);return r.shaderSource(s,t),r.compileShader(s),s}function ri(r){const e=new Array(r);for(let t=0;t<e.length;t++)e[t]=!1;return e}function kc(r,e){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return ri(2*e);case"bvec3":return ri(3*e);case"bvec4":return ri(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Js=null;const ka={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"},tx={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 Ic(r,e){if(!Js){const t=Object.keys(ka);Js={};for(let s=0;s<t.length;++s){const i=t[s];Js[r[i]]=ka[i]}}return Js[e]}function sx(r,e){const t=Ic(r,e);return tx[t]||"float32"}function rx(r,e,t=!1){const s={},i=e.getProgramParameter(r,e.ACTIVE_ATTRIBUTES);for(let o=0;o<i;o++){const a=e.getActiveAttrib(r,o);if(a.name.startsWith("gl_"))continue;const l=sx(e,a.type);s[a.name]={location:0,format:l,stride:ws(l).stride,offset:0,instance:!1,start:0}}const n=Object.keys(s);if(t){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)s[n[o]].location=o,e.bindAttribLocation(r,o,n[o]);e.linkProgram(r)}else for(let o=0;o<n.length;o++)s[n[o]].location=e.getAttribLocation(r,n[o]);return s}function ix(r,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const t={},s=e.getProgramParameter(r,e.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<s;i++){const n=e.getActiveUniformBlockName(r,i),o=e.getUniformBlockIndex(r,n),a=e.getActiveUniformBlockParameter(r,i,e.UNIFORM_BLOCK_DATA_SIZE);t[n]={name:n,index:o,size:a}}return t}function nx(r,e){const t={},s=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let i=0;i<s;i++){const n=e.getActiveUniform(r,i),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Ic(e,n.type);t[o]={name:o,index:i,type:l,size:n.size,isArray:a,value:kc(l,n.size)}}return t}function Ia(r,e){const t=r.getShaderSource(e).split(`
1083
+ `).map((h,c)=>`${c}: ${h}`),s=r.getShaderInfoLog(e),i=s.split(`
1084
+ `),n={},o=i.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),a=[""];o.forEach(h=>{t[h-1]=`%c${t[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=t.join(`
1085
+ `);a[0]=l,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function ox(r,e,t,s){r.getProgramParameter(e,r.LINK_STATUS)||(r.getShaderParameter(t,r.COMPILE_STATUS)||Ia(r,t),r.getShaderParameter(s,r.COMPILE_STATUS)||Ia(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(e)))}function ax(r,e){const t=Ba(r,r.VERTEX_SHADER,e.vertex),s=Ba(r,r.FRAGMENT_SHADER,e.fragment),i=r.createProgram();r.attachShader(i,t),r.attachShader(i,s);const n=e.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"?W("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)||ox(r,i,t,s),e._attributeData=rx(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=nx(i,r),e._uniformBlockData=ix(i,r),r.deleteShader(t),r.deleteShader(s);const o={};for(const l in e._uniformData){const h=e._uniformData[l];o[l]={location:r.getUniformLocation(i,l),value:kc(h.type,h.size)}}return new ex(i,o)}const er={textureCount:0,blockIndex:0};class Fc{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(e,t){if(this._setProgram(e.glProgram),t)return;er.textureCount=0,er.blockIndex=0;let s=this._shaderSyncFunctions[e.glProgram._key];s||(s=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this)),this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),s(this._renderer,e,er)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,er)}bindUniformBlock(e,t,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=e._bufferResource;o||this._renderer.ubo.updateUniformGroup(e);const a=e.buffer,l=i.updateBuffer(a),h=i.freeLocationForBufferBase(l);if(o){const{offset:u,size:d}=e;u===0&&d===a.data.byteLength?i.bindBufferBase(l,h):i.bindBufferRange(l,h,u)}else i.getLastBindBaseLocation(l)!==h&&i.bindBufferBase(l,h);const c=this._activeProgram._uniformBlockData[t].index;n.uniformBlockBindings[s]!==h&&(n.uniformBlockBindings[s]=h,this._renderer.gl.uniformBlockBinding(n.program,c,h))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;const t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){const t=e._key;return this._programDataHash[t]=ax(this._gl,e),this._programDataHash[t]}destroy(){for(const e of Object.keys(this._programDataHash))this._programDataHash[e].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(e,t){return J_(e,t)}resetState(){this._activeProgram=null}}Fc.extension={type:[b.WebGLSystem],name:"shader"};const lx={f32:`if (cv !== v) {
1086
+ cu.value = v;
1087
+ gl.uniform1f(location, v);
1088
+ }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
1089
+ cv[0] = v[0];
1090
+ cv[1] = v[1];
1091
+ gl.uniform2f(location, v[0], v[1]);
1092
+ }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1093
+ cv[0] = v[0];
1094
+ cv[1] = v[1];
1095
+ cv[2] = v[2];
1096
+ gl.uniform3f(location, v[0], v[1], v[2]);
1097
+ }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1098
+ cv[0] = v[0];
1099
+ cv[1] = v[1];
1100
+ cv[2] = v[2];
1101
+ cv[3] = v[3];
1102
+ gl.uniform4f(location, v[0], v[1], v[2], v[3]);
1103
+ }`,i32:`if (cv !== v) {
1104
+ cu.value = v;
1105
+ gl.uniform1i(location, v);
1106
+ }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
1107
+ cv[0] = v[0];
1108
+ cv[1] = v[1];
1109
+ gl.uniform2i(location, v[0], v[1]);
1110
+ }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1111
+ cv[0] = v[0];
1112
+ cv[1] = v[1];
1113
+ cv[2] = v[2];
1114
+ gl.uniform3i(location, v[0], v[1], v[2]);
1115
+ }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1116
+ cv[0] = v[0];
1117
+ cv[1] = v[1];
1118
+ cv[2] = v[2];
1119
+ cv[3] = v[3];
1120
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
1121
+ }`,u32:`if (cv !== v) {
1122
+ cu.value = v;
1123
+ gl.uniform1ui(location, v);
1124
+ }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
1125
+ cv[0] = v[0];
1126
+ cv[1] = v[1];
1127
+ gl.uniform2ui(location, v[0], v[1]);
1128
+ }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1129
+ cv[0] = v[0];
1130
+ cv[1] = v[1];
1131
+ cv[2] = v[2];
1132
+ gl.uniform3ui(location, v[0], v[1], v[2]);
1133
+ }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1134
+ cv[0] = v[0];
1135
+ cv[1] = v[1];
1136
+ cv[2] = v[2];
1137
+ cv[3] = v[3];
1138
+ gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
1139
+ }`,bool:`if (cv !== v) {
1140
+ cu.value = v;
1141
+ gl.uniform1i(location, v);
1142
+ }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
1143
+ cv[0] = v[0];
1144
+ cv[1] = v[1];
1145
+ gl.uniform2i(location, v[0], v[1]);
1146
+ }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1147
+ cv[0] = v[0];
1148
+ cv[1] = v[1];
1149
+ cv[2] = v[2];
1150
+ gl.uniform3i(location, v[0], v[1], v[2]);
1151
+ }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1152
+ cv[0] = v[0];
1153
+ cv[1] = v[1];
1154
+ cv[2] = v[2];
1155
+ cv[3] = v[3];
1156
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
1157
+ }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},hx={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 cx(r,e){const t=[`
1158
+ var v = null;
1159
+ var cv = null;
1160
+ var cu = null;
1161
+ var t = 0;
1162
+ var gl = renderer.gl;
1163
+ var name = null;
1164
+ `];for(const s in r.uniforms){if(!e[s]){r.uniforms[s]instanceof We?r.uniforms[s].ubo?t.push(`
1165
+ renderer.shader.bindUniformBlock(uv.${s}, "${s}");
1166
+ `):t.push(`
1167
+ renderer.shader.updateUniformGroup(uv.${s});
1168
+ `):r.uniforms[s]instanceof In&&t.push(`
1169
+ renderer.shader.bindBufferResource(uv.${s}, "${s}");
1170
+ `);continue}const i=r.uniformStructures[s];let n=!1;for(let o=0;o<wt.length;o++){const a=wt[o];if(i.type===a.type&&a.test(i)){t.push(`name = "${s}";`,wt[o].uniform),n=!0;break}}if(!n){const a=(i.size===1?lx:hx)[i.type].replace("location",`ud["${s}"].location`);t.push(`
1171
+ cu = ud["${s}"];
1172
+ cv = cu.value;
1173
+ v = uv["${s}"];
1174
+ ${a};`)}}return new Function("ud","uv","renderer","syncData",t.join(`
1175
+ `))}class Gc{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,s){const i=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==i.uniformDirtyGroups[e.uid])&&(i.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(i.uniformData,e.uniforms,this._renderer,s))}_getUniformSyncFunction(e,t){var s;return((s=this._uniformGroupSyncHash[e._signature])==null?void 0:s[t._key])||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){const s=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),i=this._getSignature(e,t._uniformData,"u");return this._cache[i]||(this._cache[i]=this._generateUniformsSync(e,t._uniformData)),s[t._key]=this._cache[i],s[t._key]}_generateUniformsSync(e,t){return cx(e,t)}_getSignature(e,t,s){const i=e.uniforms,n=[`${s}-`];for(const o in i)n.push(o),t[o]&&n.push(t[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}Gc.extension={type:[b.WebGLSystem],name:"uniformGroup"};function ux(r){const e={};if(e.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e.add=[r.ONE,r.ONE],e.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],e["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof z.get().getWebGLRenderingContext()))e.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],e.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const s=r.getExtension("EXT_blend_minmax");s&&(e.min=[r.ONE,r.ONE,r.ONE,r.ONE,s.MIN_EXT,s.MIN_EXT],e.max=[r.ONE,r.ONE,r.ONE,r.ONE,s.MAX_EXT,s.MAX_EXT])}return e}const dx=0,fx=1,px=2,mx=3,gx=4,_x=5,Uc=class ki{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[dx]=this.setBlend,this.map[fx]=this.setOffset,this.map[px]=this.setCullFace,this.map[mx]=this.setDepthTest,this.map[gx]=this.setFrontFace,this.map[_x]=this.setDepthMask,this.checks=[],this.defaultState=it.for2d(),e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){this._invertFrontFace=!e.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(e){this.gl=e,this.blendModesMap=ux(e),this.resetState()}set(e){if(e||(e=this.defaultState),this.stateId!==e.data){let t=this.stateId^e.data,s=0;for(;t;)t&1&&this.map[s].call(this,!!(e.data&1<<s)),t>>=1,s++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e||(e=this.defaultState);for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(e){this._updateCheck(ki._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(ki._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this._cullFace=e,this.gl[e?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(e){this._frontFace=e,this._frontFaceDirty=!1;const t=this._invertFrontFace?!e:e;this._glFrontFace!==t&&(this._glFrontFace=t,this.gl.frontFace(this.gl[t?"CW":"CCW"]))}setBlendMode(e){if(this.blendModesMap[e]||(e="normal"),e===this.blendMode)return;this.blendMode=e;const t=this.blendModesMap[e],s=this.gl;t.length===2?s.blendFunc(t[0],t[1]):s.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,s.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,s.blendEquationSeparate(s.FUNC_ADD,s.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}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(e,t){const s=this.checks.indexOf(e);t&&s===-1?this.checks.push(e):!t&&s!==-1&&this.checks.splice(s,1)}static _checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static _checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Uc.extension={type:[b.WebGLSystem],name:"state"};let xx=Uc;class yx{constructor(e){this.target=Bn.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=K.UNSIGNED_BYTE,this.internalFormat=Bi.RGBA,this.format=Bi.RGBA,this.samplerType=0}destroy(){}}const bx={id:"buffer",upload(r,e,t,s,i,n=!1){const o=i||e.target;!n&&e.width===r.width&&e.height===r.height?t.texSubImage2D(o,0,0,0,r.width,r.height,e.format,e.type,r.resource):t.texImage2D(o,0,e.internalFormat,r.width,r.height,0,e.format,e.type,r.resource),e.width=r.width,e.height=r.height}},vx={"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},Tx={id:"compressed",upload(r,e,t,s,i,n){const o=i??e.target;t.pixelStorei(t.UNPACK_ALIGNMENT,4);let a=r.pixelWidth,l=r.pixelHeight;const h=!!vx[r.format];for(let c=0;c<r.resource.length;c++){const u=r.resource[c];h?t.compressedTexImage2D(o,c,e.internalFormat,a,l,0,u):t.texImage2D(o,c,e.internalFormat,a,l,0,e.format,e.type,u),a=Math.max(a>>1,1),l=Math.max(l>>1,1)}}},Fa=["right","left","top","bottom","front","back"];function Sx(r){return{id:"cube",upload(e,t,s,i){const n=e.faces;for(let o=0;o<Fa.length;o++){const a=Fa[o],l=n[a];(r[l.uploadMethodId]||r.image).upload(l,t,s,i,Bn.TEXTURE_CUBE_MAP_POSITIVE_X+o,(t._layerInitMask&1<<o)===0),t._layerInitMask|=1<<o}t.width=e.pixelWidth,t.height=e.pixelHeight}}}const Oc={id:"image",upload(r,e,t,s,i,n=!1){const o=i||e.target,a=r.pixelWidth,l=r.pixelHeight,h=r.resourceWidth,c=r.resourceHeight,u=s===2,d=n||e.width!==a||e.height!==l,f=h>=a&&c>=l,p=r.resource;(u?wx:Cx)(t,o,e,a,l,h,c,p,d,f),e.width=a,e.height=l}};function wx(r,e,t,s,i,n,o,a,l,h){if(!h){l&&r.texImage2D(e,0,t.internalFormat,s,i,0,t.format,t.type,null),r.texSubImage2D(e,0,0,0,n,o,t.format,t.type,a);return}if(!l){r.texSubImage2D(e,0,0,0,t.format,t.type,a);return}r.texImage2D(e,0,t.internalFormat,s,i,0,t.format,t.type,a)}function Cx(r,e,t,s,i,n,o,a,l,h){if(!h){l&&r.texImage2D(e,0,t.internalFormat,s,i,0,t.format,t.type,null),r.texSubImage2D(e,0,0,0,t.format,t.type,a);return}if(!l){r.texSubImage2D(e,0,0,0,t.format,t.type,a);return}r.texImage2D(e,0,t.internalFormat,t.format,t.type,a)}const Ax=qg(),Ex={id:"video",upload(r,e,t,s,i,n=Ax){if(!r.isValid){const o=i??e.target;t.texImage2D(o,0,e.internalFormat,1,1,0,e.format,e.type,null);return}Oc.upload(r,e,t,s,i,n)}},Ga={linear:9729,nearest:9728},Px={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},ii={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Mx={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Ua(r,e,t,s,i,n,o,a){const l=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const h=ii[o?"clamp-to-edge":r.addressModeU],c=ii[o?"clamp-to-edge":r.addressModeV],u=ii[o?"clamp-to-edge":r.addressModeW];e[i](l,e.TEXTURE_WRAP_S,h),e[i](l,e.TEXTURE_WRAP_T,c),e.TEXTURE_WRAP_R&&e[i](l,e.TEXTURE_WRAP_R,u)}if((!a||r.magFilter!=="linear")&&e[i](l,e.TEXTURE_MAG_FILTER,Ga[r.magFilter]),t){if(!a||r.mipmapFilter!=="linear"){const h=Px[r.minFilter][r.mipmapFilter];e[i](l,e.TEXTURE_MIN_FILTER,h)}}else e[i](l,e.TEXTURE_MIN_FILTER,Ga[r.minFilter]);if(s&&r.maxAnisotropy>1){const h=Math.min(r.maxAnisotropy,e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[i](l,s.TEXTURE_MAX_ANISOTROPY_EXT,h)}r.compare&&e[i](l,e.TEXTURE_COMPARE_FUNC,Mx[r.compare])}function Rx(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 Bx(r,e){let t={},s=r.RGBA;return r instanceof z.get().getWebGLRenderingContext()?e.srgb&&(t={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(t={"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,...t,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,...e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function kx(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 Ix(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 Fx=4;class Dc{constructor(e){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=e,this._managedTextures=new je({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const t={image:Oc,buffer:bx,video:Ex,compressed:Tx};this._uploads={...t,cube:Sx(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Bx(e,this._renderer.context.extensions),this._mapFormatToType=kx(e),this._mapFormatToFormat=Rx(e),this._mapViewDimensionToGlTarget=Ix(e)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let t=0;t<16;t++)this.bind(O.EMPTY,t)}initSource(e){this.bind(e)}bind(e,t=0){const s=e.source;e?(this.bindSource(s,t),this._useSeparateSamplers&&this._bindSampler(s.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){const s=this._gl;if(e._gcLastUsed=this._renderer.gc.now,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||(e=O.EMPTY.source);const i=this.getGlSource(e);s.bindTexture(i.target,i.texture)}}_bindSampler(e,t=0){const s=this._gl;if(!e){this._boundSamplers[t]=null,s.bindSampler(t,null);return}const i=this._getGlSampler(e);this._boundSamplers[t]!==i&&(this._boundSamplers[t]=i,s.bindSampler(t,i))}unbind(e){const t=e.source,s=this._boundTextures,i=this._gl;for(let n=0;n<s.length;n++)if(s[n]===t){this._activateLocation(n);const o=this.getGlSource(t);i.bindTexture(o.target,null),s[n]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){const t=this._gl,s=new yx(t.createTexture());if(s.type=this._mapFormatToType[e.format],s.internalFormat=this._mapFormatToInternalFormat[e.format],s.format=this._mapFormatToFormat[e.format],s.target=this._mapViewDimensionToGlTarget[e.viewDimension],s.target===null)throw new Error(`Unsupported view dimension: ${e.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(e.uploadMethodId==="cube"&&(s.target=t.TEXTURE_CUBE_MAP),e.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||e.isPowerOfTwo)){const n=Math.max(e.width,e.height);e.mipLevelCount=Math.floor(Math.log2(n))+1}return e._gpuData[this._renderer.uid]=s,this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceUpdate,this),e.on("styleChange",this.onStyleChange,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),this.updateStyle(e,!1),s}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){const s=this._gl,i=this.getGlSource(e);s.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=e,Ua(e.style,s,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.target,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e,t=!1){const s=e._gpuData[this._renderer.uid];s&&(t||(this.unbind(e),this._gl.deleteTexture(s.texture)),e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceUpdate,this),e.off("styleChange",this.onStyleChange,this),e.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(e){const t=this._gl,s=this.getGlSource(e);t.bindTexture(s.target,s.texture),this._boundTextures[this._activeTextureLocation]=e;const i=e.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==i&&(this._premultiplyAlpha=i,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i)),this._uploads[e.uploadMethodId])this._uploads[e.uploadMethodId].upload(e,s,t,this._renderer.context.webGLVersion);else if(s.target===t.TEXTURE_2D)this._initEmptyTexture2D(s,e);else if(s.target===t.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(s,e);else if(s.target===t.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(s,e);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(s,e),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);const s=this.getGlSource(e);this._gl.generateMipmap(s.target)}_initEmptyTexture2D(e,t){const s=this._gl;s.texImage2D(s.TEXTURE_2D,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let i=Math.max(t.pixelWidth>>1,1),n=Math.max(t.pixelHeight>>1,1);for(let o=1;o<t.mipLevelCount;o++)s.texImage2D(s.TEXTURE_2D,o,e.internalFormat,i,n,0,e.format,e.type,null),i=Math.max(i>>1,1),n=Math.max(n>>1,1)}_initEmptyTexture2DArray(e,t){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const s=this._gl,i=Math.max(t.arrayLayerCount|0,1);s.texImage3D(s.TEXTURE_2D_ARRAY,0,e.internalFormat,t.pixelWidth,t.pixelHeight,i,0,e.format,e.type,null);let n=Math.max(t.pixelWidth>>1,1),o=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++)s.texImage3D(s.TEXTURE_2D_ARRAY,a,e.internalFormat,n,o,i,0,e.format,e.type,null),n=Math.max(n>>1,1),o=Math.max(o>>1,1)}_initEmptyTextureCube(e,t){const s=this._gl,i=6;for(let a=0;a<i;a++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let n=Math.max(t.pixelWidth>>1,1),o=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++){for(let l=0;l<i;l++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+l,a,e.internalFormat,n,o,0,e.format,e.type,null);n=Math.max(n>>1,1),o=Math.max(o>>1,1)}}_applyMipRange(e,t){if(this._renderer.context.webGLVersion!==2||t.mipLevelCount<=1)return;const s=this._gl,i=Math.max((t.mipLevelCount|0)-1,0);s.texParameteri(e.target,s.TEXTURE_BASE_LEVEL,0),s.texParameteri(e.target,s.TEXTURE_MAX_LEVEL,i)}_initSampler(e){const t=this._gl,s=this._gl.createSampler();return this._glSamplers[e._resourceId]=s,Ua(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[e._resourceId]}_getGlSampler(e){return this._glSamplers[e._resourceId]||this._initSampler(e)}getGlSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this._initSource(e)}generateCanvas(e){const{pixels:t,width:s,height:i}=this.getPixels(e),n=z.get().createCanvas();n.width=s,n.height=i;const o=n.getContext("2d");if(o){const a=o.createImageData(s,i);a.data.set(t),o.putImageData(a,0,0)}return n}getPixels(e){const t=e.source.resolution,s=e.frame,i=Math.max(Math.round(s.width*t),1),n=Math.max(Math.round(s.height*t),1),o=new Uint8Array(Fx*i*n),a=this._renderer,l=a.renderTarget.getRenderTarget(e),h=a.renderTarget.getGpuRenderTarget(l),c=a.gl;return c.bindFramebuffer(c.FRAMEBUFFER,h.resolveTargetFramebuffer),c.readPixels(Math.round(s.x*t),Math.round(s.y*t),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(O.EMPTY.source),this._boundSamplers=Object.create(null);const e=this._gl;this._premultiplyAlpha=!1,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Dc.extension={type:[b.WebGLSystem],name:"texture"};class Lc{contextChange(e){const t=new We({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),s=e.limits.maxBatchableTextures,i=ji({name:"graphics",bits:[$l,Yl(s),Ah,qi]});this.shader=new rt({glProgram:i,resources:{localUniforms:t,batchSamplers:ql(s)}})}execute(e,t){const s=t.context,i=s.customShader||this.shader,n=e.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(s);i.groups[0]=n.globalUniforms.bindGroup,n.state.set(e.state),n.shader.bind(i),n.geometry.bind(a.geometry,i.glProgram);const h=l.instructions;for(let c=0;c<l.instructionSize;c++){const u=h[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}}Lc.extension={type:[b.WebGLPipesAdaptor],name:"graphics"};class Nc{init(){const e=ji({name:"mesh",bits:[Ah,Qg,qi]});this._shader=new rt({glProgram:e,resources:{uTexture:O.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new G}}}})}execute(e,t){const s=e.renderer;let i=t._shader;if(i){if(!i.glProgram){W("Mesh shader has no glProgram",t.shader);return}}else{i=this._shader;const n=t.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]=e.localUniformsBindGroup,s.encoder.draw({geometry:t._geometry,shader:i,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Nc.extension={type:[b.WebGLPipesAdaptor],name:"mesh"};const Gx=[...Pn,Rc,$_,N_,wc,_c,Dc,Bc,bc,Gc,Fc,Sc,xx,Cc,Tc],Ux=[...uc],Ox=[Nh,Nc,Lc],Wc=[],Hc=[],zc=[];V.handleByNamedList(b.WebGLSystem,Wc);V.handleByNamedList(b.WebGLPipes,Hc);V.handleByNamedList(b.WebGLPipesAdaptor,zc);V.add(...Gx,...Ux,...Ox);class Dx extends ks{constructor(){const e={name:"webgl",type:Me.WEBGL,systems:Wc,renderPipes:Hc,renderPipeAdaptors:zc};super(e)}}const Lx=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:Dx},Symbol.toStringTag,{value:"Module"}));class Vc{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,s){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,s)}_createBindGroup(e,t,s){const i=this._gpu.device,n=t.layout[s],o=[],a=this._renderer;for(const c in n){const u=e.resources[c]??e.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 l=a.shader.getProgramData(t).bindGroups[s],h=i.createBindGroup({layout:l,entries:o});return this._hash[e._key]=h,h}destroy(){this._hash=null,this._renderer=null}}Vc.extension={type:[b.WebGPUSystem],name:"bindGroup"};class Nx{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Xc{constructor(e){this._renderer=e,this._managedBuffers=new je({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuBuffer)||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),s=e.data;return e._updateID&&s&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,s.buffer,0,(e._updateSize||s.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=re("resource"),e.data&&(bi(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Nx(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}Xc.extension={type:[b.WebGPUSystem],name:"buffer"};class Wx{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let s=t+e*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,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let s=0;s<e.length;s++)this.data[t/4+s]=e[s];return t}destroy(){this.data=null}}class $c{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}$c.extension={type:[b.WebGPUSystem],name:"colorMask"};class Fn{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await z.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>t.features.has(n)),i=await t.requestDevice({requiredFeatures:s});return{adapter:t,device:i}}destroy(){this.gpu=null,this._renderer=null}}Fn.extension={type:[b.WebGPUSystem],name:"device"};Fn.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class jc{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,s,i){const n=this._renderer.pipeline.getPipeline(e,t,s,i);this.setPipeline(n)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,s){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const i=this._renderer.bindGroup.getBindGroup(t,s,e);this.renderPassEncoder.setBindGroup(e,i)}setGeometry(e,t){const s=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const i in s)this._setVertexBuffer(parseInt(i,10),e.attributes[s[i]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const s in e.groups){const i=e.groups[s];t||this._syncBindGroup(i),this.setBindGroup(s,i,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const s=e.resources[t];s.isUniformGroup&&this._renderer.ubo.updateUniformGroup(s)}}draw(e){const{geometry:t,shader:s,state:i,topology:n,size:o,start:a,instanceCount:l,skipSync:h}=e;this.setPipelineFromGeometryProgramAndState(t,s.gpuProgram,i,n),this.setGeometry(t,s.gpuProgram),this._setShaderBindGroups(s,h),t.indexBuffer?this.renderPassEncoder.drawIndexed(o||t.indexBuffer.data.length,l??t.instanceCount,a||0):this.renderPassEncoder.draw(o||t.getSize(),l??t.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 e=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(e);const t=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(t);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 e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=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(e){this._gpu=e}}jc.extension={type:[b.WebGPUSystem],name:"encoder",priority:1};class Yc{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}Yc.extension={type:[b.WebGPUSystem],name:"limits"};class qc{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:fe.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const s=this._renderTargetStencilState[this._activeRenderTarget.uid];s.stencilMode=e,s.stencilReference=t;const i=this._renderer;i.pipeline.setStencilMode(e),i.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}qc.extension={type:[b.WebGPUSystem],name:"stencil"};const or={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 Hx(r){const e=r.map(s=>({data:s,offset:0,size:0}));let t=0;for(let s=0;s<e.length;s++){const i=e[s];let n=or[i.data.type].size;const o=or[i.data.type].align;if(!or[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),t=Math.ceil(t/o)*o,i.size=n,i.offset=t,t+=n}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function zx(r,e){const{size:t,align:s}=or[r.data.type],i=(s-t)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
1176
+ v = uv.${r.data.name};
1177
+ ${e!==0?`offset += ${e};`:""}
1178
+
1179
+ arrayOffset = offset;
1180
+
1181
+ t = 0;
1182
+
1183
+ for(var i=0; i < ${r.data.size*(t/4)}; i++)
1184
+ {
1185
+ for(var j = 0; j < ${t/4}; j++)
1186
+ {
1187
+ ${n}[arrayOffset++] = v[t++];
1188
+ }
1189
+ ${i!==0?`arrayOffset += ${i};`:""}
1190
+ }
1191
+ `}function Vx(r){return Pc(r,"uboWgsl",zx,q_)}class Kc extends Ac{constructor(){super({createUboElements:Hx,generateUboSync:Vx})}}Kc.extension={type:[b.WebGPUSystem],name:"ubo"};const ot=128;class Zc{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new Wx({minUniformOffsetAlignment:ot});const t=256/ot;for(let s=0;s<t;s++){let i=oe.UNIFORM|oe.COPY_DST;s===0&&(i|=oe.COPY_SRC),this._buffers.push(new ht({data:this._batchBuffer.data,usage:i}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);const s=e.buffer.data,i=this._batchBuffer.addEmptyGroup(s.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,i/4),this._bindGroupHash[e.uid]=this._getBindGroup(i/ot),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);const t=e.buffer.data,s=this._batchBuffer.addGroup(t);return this._getBufferResource(s/ot)}getArrayBindGroup(e){const t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/ot)}getArrayBufferResource(e){const s=this._batchBuffer.addGroup(e)/ot;return this._getBufferResource(s)}_getBufferResource(e){if(!this._bufferResources[e]){const t=this._buffers[e%2];this._bufferResources[e]=new In({buffer:t,offset:(e/2|0)*256,size:ot})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){const t=new lt({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){const e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);const s=this._renderer.gpu.device.createCommandEncoder();for(let i=1;i<this._buffers.length;i++){const n=this._buffers[i];s.copyBufferToBuffer(e.getGPUBuffer(t),ot,e.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([s.finish()])}destroy(){var e;for(let t=0;t<this._bindGroups.length;t++)(e=this._bindGroups[t])==null||e.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}}Zc.extension={type:[b.WebGPUPipes],name:"uniformBatch"};const Xx={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function $x(r,e,t,s,i){return r<<24|e<<16|t<<10|s<<5|i}function jx(r,e,t,s,i){return t<<8|r<<5|s<<3|i<<1|e}class Qc{constructor(e){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=e}contextChange(e){this._gpu=e,this.setStencilMode(fe.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=e.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=e.colorTargetCount,this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=ft[e],this._updatePipeHash())}setPipeline(e,t,s,i){const n=this.getPipeline(e,t,s);i.setPipeline(n)}getPipeline(e,t,s,i){e._layoutKey||(yc(e,t.attributeData),this._generateBufferKey(e)),i||(i=e.topology);const n=$x(e._layoutKey,t._layoutKey,s.data,s._blendModeId,Xx[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(e,t,s,i),this._pipeCache[n])}_createPipeline(e,t,s,i){const n=this._gpu.device,o=this._createVertexBufferLayouts(e,t),a=this._renderer.state.getColorTargets(s,this._colorTargetCount),l=this._stencilMode===fe.RENDERING_MASK_ADD?0:this._colorMask;for(let d=0;d<a.length;d++)a[d].writeMask=l;const h=this._renderer.shader.getProgramData(t).pipeline,c={vertex:{module:this._getModule(t.vertex.source),entryPoint:t.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(t.fragment.source),entryPoint:t.fragment.entryPoint,targets:a},primitive:{topology:i,cullMode:s.cullMode},layout:h,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(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){const t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){const t=[];let s=0;const i=Object.keys(e.attributes).sort();for(let o=0;o<i.length;o++){const a=e.attributes[i[o]];t[s++]=a.offset,t[s++]=a.format,t[s++]=a.stride,t[s++]=a.instance}const n=t.join("|");return e._layoutKey=Ss(n,"geometry"),e._layoutKey}_generateAttributeLocationsKey(e){const t=[];let s=0;const i=Object.keys(e.attributeData).sort();for(let o=0;o<i.length;o++){const a=e.attributeData[i[o]];t[s++]=a.location}const n=t.join("|");return e._attributeLocationsKey=Ss(n,"programAttributes"),e._attributeLocationsKey}getBufferNamesToBind(e,t){const s=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[s])return this._bindingNamesCache[s];const i=this._createVertexBufferLayouts(e,t),n=Object.create(null),o=t.attributeData;for(let a=0;a<i.length;a++){const h=Object.values(i[a].attributes)[0].shaderLocation;for(const c in o)if(o[c].location===h){n[a]=c;break}}return this._bindingNamesCache[s]=n,n}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);const s=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[s])return this._bufferLayoutsCache[s];const i=[];return e.buffers.forEach(n=>{const o={arrayStride:0,stepMode:"vertex",attributes:[]},a=o.attributes;for(const l in t.attributeData){const h=e.attributes[l];(h.divisor??1)!==1&&W(`Attribute ${l} has an invalid divisor value of '${h.divisor}'. WebGPU only supports a divisor value of 1`),h.buffer===n&&(o.arrayStride=h.stride,o.stepMode=h.instance?"instance":"vertex",a.push({shaderLocation:t.attributeData[l].location,offset:h.offset,format:h.format}))}a.length&&i.push(o)}),this._bufferLayoutsCache[s]=i,i}_updatePipeHash(){const e=jx(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[e]||(this._pipeStateCaches[e]=Object.create(null)),this._pipeCache=this._pipeStateCaches[e]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Qc.extension={type:[b.WebGPUSystem],name:"pipeline"};class Yx{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class qx{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,s,i,n){const o=this._renderer,a=this._getGpuColorTexture(e),l=o.texture.getGpuSource(t.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:l,origin:n},i),t}startRenderPass(e,t=!0,s,i,n=0,o=0){var c,u;const l=this._renderTargetSystem.getGpuRenderTarget(e);if(o!==0&&((c=l.msaaTextures)!=null&&c.length))throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(n>0&&((u=l.msaaTextures)!=null&&u.length))throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const h=this.getDescriptor(e,t,s,n,o);l.descriptor=h,this._renderer.pipeline.setRenderTarget(l),this._renderer.encoder.beginRenderPass(l),this._renderer.encoder.setViewport(i)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);return t.contexts[0]?t.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(e.colorTextures[0].source)}getDescriptor(e,t,s,i=0,n=0){typeof t=="boolean"&&(t=t?Ae.ALL:Ae.NONE);const o=this._renderTargetSystem,a=o.getGpuRenderTarget(e),l=e.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=t&Ae.COLOR?"clear":"load";return s??(s=o.defaultClearColor),{view:p,resolveTarget:g,clearValue:s,storeOp:"store",loadOp:m}});let h;if((e.stencil||e.depth)&&!e.depthStencilTexture&&(e.ensureDepthStencilTexture(),e.depthStencilTexture.source.sampleCount=a.msaa?4:1),e.depthStencilTexture){const u=t&Ae.STENCIL?"clear":"load",d=t&Ae.DEPTH?"clear":"load";h={view:this._renderer.texture.getGpuSource(e.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:l,depthStencilAttachment:h}}clear(e,t=!0,s,i,n=0,o=0){if(!t)return;const{gpu:a,encoder:l}=this._renderer,h=a.device;if(l.commandEncoder===null){const u=h.createCommandEncoder(),d=this.getDescriptor(e,t,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();h.queue.submit([p])}else this.startRenderPass(e,t,s,i,n,o)}initGpuRenderTarget(e){e.isRoot=!0;const t=new Yx;return t.colorTargetCount=e.colorTextures.length,e.colorTextures.forEach((s,i)=>{if(s instanceof Xe){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)}t.contexts[i]=n}if(t.msaa=s.source.antialias,s.source.antialias){const n=new me({width:0,height:0,sampleCount:4,arrayLayerCount:s.source.arrayLayerCount});t.msaaTextures[i]=n}}),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4)),t}destroyGpuRenderTarget(e){e.contexts.forEach(t=>{t.unconfigure()}),e.msaaTextures.forEach(t=>{t.destroy()}),e.msaaTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);e.depthStencilTexture&&t.msaa&&(e.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorTextures.forEach((s,i)=>{const n=t.msaaTextures[i];n==null||n.resize(s.source.width,s.source.height,s.source._resolution)})}}class Jc extends Mn{constructor(e){super(e),this.adaptor=new qx,this.adaptor.init(e,this)}}Jc.extension={type:[b.WebGPUSystem],name:"renderTarget"};class eu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){const t=this._gpu.device,s=e.gpuLayout.map(n=>t.createBindGroupLayout({entries:n})),i={bindGroupLayouts:s};return this._gpuProgramData[e._layoutKey]={bindGroups:s,pipeline:t.createPipelineLayout(i)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}eu.extension={type:[b.WebGPUSystem],name:"shader"};const Se={};Se.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};Se.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}};Se.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}};Se.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};Se.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};Se.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}};Se["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}};Se["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}};Se["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}};Se.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};Se.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}};Se.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class tu{constructor(){this.defaultState=new it,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e,t){const s=Se[e.blendMode]||Se.normal,i=[],n={format:"bgra8unorm",writeMask:0,blend:s};for(let o=0;o<t;o++)i[o]=n;return i}destroy(){this.gpu=null}}tu.extension={type:[b.WebGPUSystem],name:"state"};const Kx={type:"image",upload(r,e,t,s=0){const i=r.resource,n=(r.pixelWidth|0)*(r.pixelHeight|0),o=i.byteLength/n;t.device.queue.writeTexture({texture:e,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})}},su={"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}},Zx={blockBytes:4,blockWidth:1,blockHeight:1},Qx={type:"compressed",upload(r,e,t,s=0){let i=r.pixelWidth,n=r.pixelHeight;const o=su[r.format]||Zx;for(let a=0;a<r.resource.length;a++){const l=r.resource[a],h=Math.ceil(i/o.blockWidth)*o.blockBytes;t.device.queue.writeTexture({texture:e,mipLevel:a,origin:{x:0,y:0,z:s}},l,{offset:0,bytesPerRow:h},{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)}}},Oa=["right","left","top","bottom","front","back"];function Jx(r){return{type:"cube",upload(e,t,s){const i=e.faces;for(let n=0;n<Oa.length;n++){const o=Oa[n],a=i[o];(r[a.uploadMethodId]||r.image).upload(a,t,s,n)}}}}const ru={type:"image",upload(r,e,t,s=0){const i=r.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const l=z.get().createCanvas(i.width,i.height);l.getContext("2d").drawImage(i,0,0,i.width,i.height),r.resource=l,W("ImageSource: Image element passed, converting to canvas and replacing resource.")}const n=Math.min(e.width,r.resourceWidth||r.pixelWidth),o=Math.min(e.height,r.resourceHeight||r.pixelHeight),a=r.alphaMode==="premultiply-alpha-on-upload";t.device.queue.copyExternalImageToTexture({source:i},{texture:e,origin:{x:0,y:0,z:s},premultipliedAlpha:a},{width:n,height:o})}},ey={type:"video",upload(r,e,t,s){ru.upload(r,e,t,s)}};class ty{constructor(e){this.device=e,this.sampler=e.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(e){let t=this.pipelines[e];return t||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
1192
+ var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
1193
+ vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
1194
+
1195
+ struct VertexOutput {
1196
+ @builtin(position) position : vec4<f32>,
1197
+ @location(0) texCoord : vec2<f32>,
1198
+ };
1199
+
1200
+ @vertex
1201
+ fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
1202
+ var output : VertexOutput;
1203
+ output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
1204
+ output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
1205
+ return output;
1206
+ }
1207
+
1208
+ @group(0) @binding(0) var imgSampler : sampler;
1209
+ @group(0) @binding(1) var img : texture_2d<f32>;
1210
+
1211
+ @fragment
1212
+ fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
1213
+ return textureSample(img, imgSampler, texCoord);
1214
+ }
1215
+ `})),t=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){const t=this._getMipmapPipeline(e.format);if(e.dimension==="3d"||e.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let s=e;const i=e.depthOrArrayLayers||1,n=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const l={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:i},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};s=this.device.createTexture(l)}const o=this.device.createCommandEncoder({}),a=t.getBindGroupLayout(0);for(let l=0;l<i;++l){let h=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),c=n?1:0;for(let u=1;u<e.mipLevelCount;++u){const d=s.createView({baseMipLevel:c++,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,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:h}]});f.setPipeline(t),f.setBindGroup(0,p),f.draw(3,1,0,0),f.end(),h=d}}if(!n){const l={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:i};for(let h=1;h<e.mipLevelCount;++h)o.copyTextureToTexture({texture:s,mipLevel:h-1},{texture:e,mipLevel:h},l),l.width=Math.ceil(l.width/2),l.height=Math.ceil(l.height/2)}return this.device.queue.submit([o.finish()]),n||s.destroy(),e}}class sy{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class iu{constructor(e){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=e,e.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new je({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const t={image:ru,buffer:Kx,video:ey,compressed:Qx};this._uploads={...t,cube:Jx(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gpu=e}initSource(e){var t;return((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuTexture)||this._initSource(e)}_initSource(e){if(e.autoGenerateMipmaps){const h=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(h))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;e.uploadMethodId!=="compressed"&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);const s=su[e.format]||{blockWidth:1,blockHeight:1},i=Math.ceil(e.pixelWidth/s.blockWidth)*s.blockWidth,n=Math.ceil(e.pixelHeight/s.blockHeight)*s.blockHeight,o={label:e.label,size:{width:i,height:n,depthOrArrayLayers:e.arrayLayerCount},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},a=this._gpu.device.createTexture(o);return e._gpuData[this._renderer.uid]=new sy(a),this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceResize,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),a}onSourceUpdate(e){const t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onUpdateMipmaps(e){this._mipmapGenerator||(this._mipmapGenerator=new ty(this._gpu.device));const t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceUnload(e){e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceResize,this),e.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(e){e._gcLastUsed=this._renderer.gc.now;const t=e._gpuData[this._renderer.uid],s=t==null?void 0:t.gpuTexture;s?(s.width!==e.pixelWidth||s.height!==e.pixelHeight)&&(t.destroy(),this._bindGroupHash[e.uid]=null,e._gpuData[this._renderer.uid]=null,this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuTexture)||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){const t=e.source;return this._bindGroupHash[e.uid]=new lt({0:t,1:t.style,2:new We({uTextureMatrix:{type:"mat3x3<f32>",value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){const t=e.source;t._gcLastUsed=this._renderer.gc.now;let s=t._gpuData[this._renderer.uid];return s||(this.initSource(t),s=t._gpuData[this._renderer.uid]),s.textureView||(s.textureView=s.gpuTexture.createView({dimension:t.viewDimension})),s.textureView}generateCanvas(e){const t=this._renderer,s=t.gpu.device.createCommandEncoder(),i=z.get().createCanvas();i.width=e.source.pixelWidth,i.height=e.source.pixelHeight;const n=i.getContext("webgpu");return n.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:z.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),s.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:i.width,height:i.height}),t.gpu.device.queue.submit([s.finish()]),i}getPixels(e){const t=this.generateCanvas(e),s=ct.getOptimalCanvasAndContext(t.width,t.height),i=s.context;i.drawImage(t,0,0);const{width:n,height:o}=t,a=i.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return ct.returnCanvasAndContext(s),{pixels:l,width:n,height:o}}destroy(){this._managedTextures.destroy();for(const e of Object.keys(this._bindGroupHash)){const t=Number(e),s=this._bindGroupHash[t];s==null||s.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}iu.extension={type:[b.WebGPUSystem],name:"texture"};class nu{constructor(){this._maxTextures=0}contextChange(e){const t=new We({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=e.limits.maxBatchableTextures;const s=$i({name:"graphics",bits:[Xl,jl(this._maxTextures),pg,Yi]});this.shader=new rt({gpuProgram:s,resources:{localUniforms:t}})}execute(e,t){const s=t.context,i=s.customShader||this.shader,n=e.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(s),h=n.encoder;h.setGeometry(a.geometry,i.gpuProgram);const c=n.globalUniforms.bindGroup;h.setBindGroup(0,c,i.gpuProgram);const u=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);h.setBindGroup(2,u,i.gpuProgram);const d=l.instructions;let f=null;for(let p=0;p<l.instructionSize;p++){const g=d[p];if(g.topology!==f&&(f=g.topology,h.setPipelineFromGeometryProgramAndState(a.geometry,i.gpuProgram,e.state,g.topology)),i.groups[1]=g.bindGroup,!g.gpuBindGroup){const m=g.textures;g.bindGroup=Vi(m.textures,m.count,this._maxTextures),g.gpuBindGroup=n.bindGroup.getBindGroup(g.bindGroup,i.gpuProgram,1)}h.setBindGroup(1,g.bindGroup,i.gpuProgram),h.renderPassEncoder.drawIndexed(g.size,1,g.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}nu.extension={type:[b.WebGPUPipesAdaptor],name:"graphics"};class ou{init(){const e=$i({name:"mesh",bits:[sr,Zg,Yi]});this._shader=new rt({gpuProgram:e,resources:{uTexture:O.EMPTY._source,uSampler:O.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new G}}}})}execute(e,t){const s=e.renderer;let i=t._shader;if(!i)i=this._shader,i.groups[2]=s.texture.getTextureBindGroup(t.texture);else if(!i.gpuProgram){W("Mesh shader has no gpuProgram",t.shader);return}const n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=s.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=e.localUniforms;i.groups[1]=s.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}s.encoder.draw({geometry:t._geometry,shader:i,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}ou.extension={type:[b.WebGPUPipesAdaptor],name:"mesh"};const ry=[...Pn,Kc,jc,Fn,Yc,Xc,iu,Jc,eu,tu,Qc,$c,qc,Vc],iy=[...uc,Zc],ny=[Wh,ou,nu],au=[],lu=[],hu=[];V.handleByNamedList(b.WebGPUSystem,au);V.handleByNamedList(b.WebGPUPipes,lu);V.handleByNamedList(b.WebGPUPipesAdaptor,hu);V.add(...ry,...iy,...ny);class oy extends ks{constructor(){const e={name:"webgpu",type:Me.WEBGPU,systems:au,renderPipes:lu,renderPipeAdaptors:hu};super(e)}}const ay=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:oy},Symbol.toStringTag,{value:"Module"}));class ly extends Oh{constructor(e,t){super();const{textures:s,data:i}=e;Object.keys(i.pages).forEach(n=>{const o=i.pages[parseInt(n,10)],a=s[o.id];this.pages.push({texture:a})}),Object.keys(i.chars).forEach(n=>{const o=i.chars[n],{frame:a,source:l,rotate:h}=s[o.page],c=$.transformRectCoords(o,a,h,new Q),u=new O({frame:c,orig:new Q(0,0,o.width,o.height),source:l,rotate:h});this.chars[n]={id:n.codePointAt(0),xOffset:o.xOffset,yOffset:o.yOffset,xAdvance:o.xAdvance,kerning:o.kerning??{},texture:u}}),this.baseRenderedFontSize=i.fontSize,this.baseMeasurementFontSize=i.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:i.fontSize},this.baseLineOffset=i.baseLineOffset,this.lineHeight=i.lineHeight,this.fontFamily=i.fontFamily,this.distanceField=i.distanceField??{type:"none",range:0},this.url=t}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){const{texture:t}=this.pages[e];t.destroy(!0)}this.pages=null}static install(e){Aa.install(e)}static uninstall(e){Aa.uninstall(e)}}const hy=Object.freeze(Object.defineProperty({__proto__:null,BitmapFont:ly},Symbol.toStringTag,{value:"Module"}));V.add(pu,mu);V.add(Sd);V.mixin(Te,wd);V.add(hh);V.add(ch);V.mixin(Te,Vm);V.add(Th,ph);V.add(vh);const cy=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),uy=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{uf as A,tg as B,Ie as C,mr as G,fy as N,ie as P,Q as R,Kt as S,py as T,zt as _,qs as a,Te as b,Et as c,O as d};